import java.io.*; import byucc.jhdl.base.*; import byucc.jhdl.Xilinx.*; import byucc.jhdl.Xilinx.XC4000.*; import byucc.jhdl.Logic.*; public class mod4count2 extends Logic { public static CellInterface[] cell_interface = { in( "reset", 1 ), in( "mod4", 1 ), out( "total_count", "wid" ), param( "wid", INTEGER ) }; public mod4count2(Node parent, int length, Wire reset, Wire mod4, Wire total_count) { super(parent); int i; int width = total_count.getWidth(); bind( "wid", width); connect("reset", reset); connect("mod4", mod4); connect("total_count", total_count); Wire addem = or(mod4,reset); // Count up if addem is asserted. count down otherwise. new upDownCounter(this, reset, constant(width,length), addem, vcc(), total_count); } }