Branching Statements

Stimulus for the 4 to 1 Multiplexor

        module muxstimulus;
          reg in1, in2, in3, in4;
          reg cntrl1, cntrl2;
          wire out;

        multiplexor4_1 mux4_1(out, in1, in2, in3, in4, cntrl1, cntrl2);

        initial begin
          in1 = 1; in2 = 0; in3 = 1; in4 = 0;
          $display("Initial arbirtary values");
          #0 $display($time, " input1=%b, input2=%b, input3=%b, input4=%b",
                                in1, in2, in3, in4);

         {cntrl1, cntrl2} = 2'b00;
         #1 $display($time, " cntrl1=%b, cntrl2=%b, output is %b",
                                                 cntrl1, cntrl2, out);

         {cntrl1, cntrl2} = 2'b01;
         #1 $display($time, " cntrl1=%b, cntrl2=%b, output is %b",
                                                 cntrl1, cntrl2, out);
         {cntrl1, cntrl2} = 2'b10;
         #1 $display($time, " cntrl1=%b, cntrl2=%b, output is %b",
                                                 cntrl1, cntrl2, out);

         {cntrl1, cntrl2} = 2'b11;
         #1 $display($time, " cntrl1=%b, cntrl2=%b, output is %b",
                                                cntrl1, cntrl2, out);
        end

        endmodule