import byucc.jhdl.base.*; import byucc.jhdl.Logic.*; import byucc.jhdl.Xilinx.*; import byucc.jhdl.Xilinx.XC4000.*; /** * Right shifter mux. */ public class ShiftMuxR extends Logic{ public static CellInterface[] cell_interface = { param("width",INTEGER), in("a","width"), in("shift",1), out("out","width") }; public ShiftMuxR(Node parent,/* node parent */ boolean logical, /* true means logical shift false means arithmetic shift */ int shiftnum, /* */ Wire a, /* Input to be shifted */ Wire shift, /* shift enable */ Wire out){ /* Shifted to right */ super(parent); int width = a.getWidth();//get the width of the a wire /*calculate the bottom row for placement usage at the end of cell*/ int botrow = (width/2 - 1) + width%2; /* bind the param and connect the ports to the internal wires */ bind("width",width); connect("a",a); connect("shift",shift); connect("out",out); Wire shifted_wire; /* Shift wire right by 2 raised to the shiftnum power */ if (logical) shifted_wire = shiftr(a,(int)Math.pow(2,shiftnum)); else shifted_wire = ashiftr(a,(int)Math.pow(2,shiftnum)); /* select original or shifted version of the wire */ mux_o(a, shifted_wire, shift, out); /* map the mux and place it in the appropriate place using the botrow variable to find to lowest row used and then pack the lut's as tightly as possible going up */ map(a, shifted_wire, shift, out); place(out, 0, botrow, 0, -MAX_PACK); } }