Stimulus module for (switch-level) 1-bit 2-1multiplexer


// Stimulus module for (switch-level) 1-bit 2-1 multiplexer
module stimulus;
   
   reg	ctrl, in1, in2;                // declare register inputs
   wire	out;                           // declare output
   
   mux21_sw M1 (out, ctrl, in1, in2);  // call multiplexer
   
   initial begin
      #2 $display ("in1 in2 ctrl - out");
      forever #5 $display (" %b   %b   %b   -  %b", in1, in2, ctrl, out);
   end
   
   initial begin
      ctrl=1'b0; in1=1; in2=0;
      #5 in1=1'b0;                     // test for changing in1 values
      #5 in1=1'b1;
      #5 in1=1'b0;
      #5 in1=1'b1;
      #5 in1=1'b0;
      #5 in1=1'b1;
      #5 ctrl=1'b0;                    // test for changing ctrl values
      #5 ctrl=1'b1;
      #5 ctrl=1'b0;
      #5 ctrl=1'b1;
      #5 ctrl=1'b0;
      #5 ctrl=1'b1;
      #5 in2=1'b0;                     // test for changing in1 values
      #5 in2=1'b1;
      #5 in2=1'b0;
      #5 in2=1'b1;
      #5 in2=1'b0;
      #5 in2=1'b1;
      #5 $finish;
   end
   
endmodule

Back