Skip to content

Latest commit

 

History

History

Day-8

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

4x1 MUX

In this Verilog module, data_inputs is a 4-bit input bus representing the data inputs to the multiplexer, and select is a 2-bit input bus representing the selection lines. The mux_output is the output of the multiplexer.

The assign statement is used to create conditional assignments based on the values of the select lines. Depending on the value of the select lines, the appropriate data input is selected and assigned to the mux_output.

Remember to include this module in your Verilog design hierarchy and connect it to the desired signals and components.

4x1 MUX using 2x1 MUX

In this implementation, we first create a 2x1 multiplexer module (mux_2x1) that takes two data inputs (data0 and data1), a select signal (select), and produces an output mux_output.

Then, we create the 4x1 multiplexer module (mux_4x1_using_2x1) which uses two instances of the 2x1 multiplexer to achieve the functionality of a 4x1 multiplexer. The mux_4x1_using_2x1 module takes four data inputs (data_inputs), a 2-bit select signal (select), and produces the final mux_output.

The intermediate_select signal is used to pass the select signal from the main module to the intermediate muxes (mux0 and mux1).

Please note that you need to instantiate the mux_4x1_using_2x1 module in your Verilog design hierarchy and connect it to the desired signals and components.

8x1 MUX using 4x1 MUX

In this code, the mux_8x1 module takes an 8-bit input bus data_inputs and a 3-bit input bus select as its inputs. It uses two 4x1 multiplexers, mux1 and mux2, to implement the 8x1 multiplexer functionality.

The mux1 takes the lower 4 bits of data_inputs and the lower 2 bits of select to select one of the four inputs. Its output mux1_output is then connected to the data inputs of mux2.

The mux2 takes the upper 4 bits of data_inputs and the lower 2 bits of select to select one of the four inputs. If the most significant bit of select (select[2]) is 0, it uses the output of mux1 as its output. Otherwise, it directly selects the upper 4 bits of data_inputs.

This way, the mux_8x1 module behaves as an 8x1 multiplexer using two levels of 4x1 multiplexers.