import byucc.jhdl.base.*; import byucc.jhdl.Logic.*; import byucc.jhdl.Xilinx.*; import byucc.jhdl.Xilinx.XC4000.*; import java.util.Random; public class NBitAdderTB extends Logic implements TestBench { public static void main(String argv[]) { HWSystem hw= new HWSystem(); NBitAdderTB tb = new NBitAdderTB(hw); hw.cycle(20); } private final static int width = 8; Wire a = wire(this, width); Wire b = wire(this, width); Wire sum = wire(this, width+1); Random rand; int count=0; public NBitAdderTB(Node parent) { super(parent); new NBitAdder(this, a, b, sum, width); rand = new Random(); } public void reset() { a.put(this, 0); b.put(this, 0); count=0; } public void clock() { a.put(this, rand.nextInt()); b.put(this, rand.nextInt()); System.out.println("\nCycle "+ count + ":"+ "\n\ta="+ a.get(this)+ "\tb="+ b.get(this)+ "\tsum="+ sum.get(this)); count++; } }