uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

mux4to1_tb.v (596B)


      1 module mux4to1_tb;
      2 	reg [3:0] tb_a;
      3 	reg [1:0] tb_s;
      4 	wire tb_y;
      5 
      6 	mux4to1 mux4to1_tb (
      7 		.a (tb_a),
      8 		.s (tb_s),
      9 		.y (tb_y)
     10 	);
     11 
     12 	initial begin
     13 		/* used by gtkwave to display the testbench in waveforms */
     14 		$dumpfile("mux4to1.vcd");
     15 		$dumpvars(0, mux4to1_tb);
     16 
     17 		/* print the results to the command line */
     18 		$monitor("time=%3d, tb_a=%b, tb_s=%b, tb_y=%b\n",
     19 		    $time, tb_a, tb_s, tb_y);
     20 
     21 		/* set a random 4bit value */
     22 		tb_a <= 4'b1101;
     23 
     24 		/* wait for 20 time units after each assignment */
     25 		tb_s <= 2'b00;
     26 		#20 tb_s <= 2'b01;
     27 		#20 tb_s <= 2'b10;
     28 		#20 tb_s <= 2'b11;
     29 	end
     30 endmodule