module counterUDTB; //Port modes reg r$clock, r$Reset, r$Enable, r$Sel; wire [3:0] w$Q; //Instantiate DUT CounterUD U1( .i$clock(r$clock), .i$Reset(r$Reset), .i$Enable(r$Enable), .i$Sel(r$Sel), .o$Q(w$Q) ); //Create an input stimulus initial begin $monitor($time, "clock=%b Reset=%b En=%b Sel=%b Q=%b", r$clock, r$Reset, r$Enable, r$Sel, w$Q); $shm_open("counterwaves.shm"); $shm_probe("AC"); //Initial values r$clock = 0; r$Reset = 0; r$Enable = 1; r$Sel = 1; //Take out of reset - counter should remain at zero #30 r$Reset = 1; //Enable the counter - counter should begin counting up #20 r$Enable = 0; /*Allow counter to count through its cycles - make sure that it counts long enough to see if it goes through all of its outputs and rolls over correctly*/ #200 //Make the counter count down r$Sel = 0; #200 //Disable counter to see if count holds its current count r$Enable = 0; #40 $finish; end always #5 r$clock = ~r$clock; endmodule