import byucc.jhdl.base.*; import byucc.jhdl.Logic.*; //new Logic class including methods to permute a wire, rotate a wire right, //and rotate a wire left public class DESLogic extends Logic{ //constructor for the class public DESLogic(Node parent){ super(parent); } //method to create DES round hardware public void desRound(int round_num,Wire encode,Wire data_in,Wire key_in, Wire data_out,Wire key_out){ new DESRoundC(this,round_num,encode,data_in,key_in,data_out,key_out); } //method to create sBoxes public void sBoxes(Wire in,Wire out){ new SBoxes(this,in,out); } //permutation method. public Wire permute(int[] order,Wire in,String name){ WireList outList = new WireList(); for (int i = 0; i< order.length;i++) outList.insert(in.gw(in.getWidth()-order[i])); return concat(outList,name); } //rotate left method public Wire rotl(int rot_amt, Wire in,String name){ if (rot_amt >0){ int width = in.getWidth(); Wire rot_bits = in.range(width-1,width-rot_amt); Wire shifted_wire = range(shiftl(in,rot_amt),width-1,rot_amt); return concat(shifted_wire,rot_bits,name); } else return in; } //rotate right method public Wire rotr(int rot_amt,Wire in,String name){ if (rot_amt >0){ int width = in.getWidth(); Wire rot_bits = in.range(rot_amt-1,0); Wire shifted_wire = range(shiftr(in,rot_amt),width-1-rot_amt,0); return concat(rot_bits,shifted_wire,name); } else return in; } }