Instructions
  • Please read the PROCEDURE section carefully before starting the simulation for the experiment.
  • The verilog module and testbench code are partially filled and divided into code blocks.
  • Drag and drop these code blocks to arrange them in the correct order for the code to work.
  • Complete the partially filled code blocks.
  • Once you have completed the code and rearranged the blocks as required, click on validate. This will give the output truth table as per the code and will also give a success/failure message accordingly.
  • Clicking on reset will reset the experiment and you can start your practice again.
Verilog Module
  • // Define module name, inputs and outputs

    module (

       ,

      input    ,

      input    ,

      input    ,

      output ,

      output

    );

  •  // Define the functionality of this module.

    always @(*)
      begin
         if(S0===0 && S1===0)
          begin
                  ;
                  ;
          end

         if(S1===0 && S0===1)
          begin
                  ;
          end

         if(S1===1 && S0===0)
          begin
                  ;
          end

         if(S1===1 && S0===1)
          begin
                  ;
          end
      end

  • // End of the module
    endmodule
Verilog Testbench

`timescale 1ns/1ns
  • // Define Test Bench name

    module ;

  • // Declare the input and output variables

      reg ;

      reg ;

      reg ;

      reg ;

      wire ;

      wire ;

  •   // Instantiate the ALU module

       uut (

         ,

         ,

         ,

         ,

         ,

         ) ;

  • // Initial Block

      initial begin

        // Defining the input waves A, B

        A = 0; B = 0; S0 = 0; S1 = 0;
        #1
        A = 0; B = 0; S0 = 0; S1 = 1;
        #1
        A = 0; B = 0; S0 = 1; S1 = 0;
        #1
        A = 0; B = 0; S0 = 1; S1 = 1;
        #1
        A = 0; B = 1; S0 = 0; S1 = 0;
        #1
        A = 0; B = 1; S0 = 0; S1 = 1;
        #1
        A = 0; B = 1; S0 = 1; S1 = 0;
        #1
        A = 0; B = 1; S0 = 1; S1 = 1;
        #1
        A = 1; B = 0; S0 = 0; S1 = 0;
        #1
        A = 1; B = 0; S0 = 0; S1 = 1;
        #1
        A = 1; B = 0; S0 = 1; S1 = 0;
        #1
        A = 1; B = 0; S0 = 1; S1 = 1;
        #1
        A = 1; B = 1; S0 = 0; S1 = 0;
        #1
        A = 1; B = 1; S0 = 0; S1 = 1;
        #1
        A = 1; B = 1; S0 = 1; S1 = 0;
        #1
        A = 1; B = 1; S0 = 1; S1 = 1;
        #1


        $finish;
      end

  • // End of the module
    endmodule
Observations