Include your Verilog le for the eight-bit wide 2-to-1 multiplexer in your projec
ID: 1932492 • Letter: I
Question
Include your Verilog le for the eight-bit wide 2-to-1 multiplexer in your project. Use switch SW17 on the DE2 board as the s input, switches SW7??0 as the X input and SW15??8 as the Y input. Connect the SW switches to the red lights LEDR and connect the output M to the green lights LEDG7??0.
Figure 1a shows a sum-of-products circuit that implements a 2-to-1 multiplexer with a
select input s. If s = 0 the multiplexers output m is equal to the input x, and if s = 1 the
output is equal to y. Part b of the gure gives a truth table for this multiplexer, and part
c shows its circuit symbol.
The multiplexer can be described by the following Verilog statement:
as s ign m = (~ s & x ) j ( s & y ) ; }
You are to write a Verilog module that includes eight assignment statements like the
one shown above to describe the circuit given in Figure 2a. This circuit has two eight-bit
inputs, X and Y , and produces the eight-bit output M. If s = 0 then M = X, while if
s = 1 then M = Y . We refer to this circuit as an eight-bit wide 2-to-1 multiplexer. It has
the circuit symbol shown in Figure 2b, in which X, Y , and M are depicted as eight-bit
wires. Perform the steps shown below.
Explanation / Answer
//----------------------------------------
module part2(SW,LEDR,LEDG);
input [17:0]SW;
output [17:0]LEDR;
output [7:0]LEDG;
assign LEDR = SW;
assign LEDG[7:0] = (SW[17] == 0 )?SW[7:0]:SW[15:8] ;
// x = SW[7:0]
// y = Sw[15:0];
//m = LEDG[7:0];
//m = (~s & x) | (s & y)
endmodule
//----------------------------------------