Skip to content

Latest commit

 

History

History

Bufif0 Gate

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Bufif0 Gate

This is a Verilog code that implements a 2-input BUFIF0 Gate module and a testbench to verify its functionality.

Description:

  • Let's explain the code in detail:

  • The bufif0_gate module:

                       ********************************************************************************
                       *                                                                              *
       	            *   ---> It takes two input signals, `a` and `enable`.                         *
       	            *   ---> It has one output signal, `y`.                                        *
       	            *   ---> The output signal `y` is assigned the value of `a` if `enable`        *
                       *        is true (non-zero), otherwise it is assigned 0.                       *
                       *                                                                              *
                       ********************************************************************************
    
  • The bufif0_gate_tb module (testbench):

                   **********************************************************************************************
                   *                                                                                            *
       	        *   ---> It declares two registers, `a` and `b`, as inputs to the testbench.                 *
       	        *   ---> It declares a wire, `y`, as the output of the testbench.                            *
       	        *   ---> It instantiates a `bufif0_gate` module instance called `bufif0_1` and connects      *
                   *        its input and output ports to the signals in the testbench.                         *
       	        *   ---> It includes an `initial` block to simulate the behavior and display the results.    *
       	        *   ---> The `$display` function is used to print a header for the output table.             *
       	        *   ---> The `$monitor` function is used to continuously monitor and display the values      * 
                   *        of `a`, `b`, and `y` in a formatted table.                                          *
       	        *   ---> The values of `a` and `b` are changed at different time intervals (`#1`)            *
                   *        to simulate different input combinations.                                           *
       	        *   ---> The updated values of `a`, `b`, and `y` are automatically displayed by              *
                   *        the `$monitor` function.                                                            *
                   *                                                                                            *
                   **********************************************************************************************
    
  • The testbench demonstrates the behavior of the 2-input BUFIF0 gate for all possible input combinations:

                           _____________________________________________________
                           |                                                   |
                           |       1. `a = 0`, `b = 0` (outputs `y = 0`)       |
                           |       2. `a = 0`, `b = 1` (outputs `y = 0`)       |
                           |       3. `a = 1`, `b = 0` (outputs `y = 1`)       |
                           |       4. `a = 1`, `b = 1` (outputs `y = 1`)       |
                           |___________________________________________________|
    
  • The output table displays the input values a and enable (labeled as "b" in the table), as well as the output value y, for each input combination.

Output

Bufif0 Gate

References