DSD Lab 3
DSD Lab 3
DSD Lab 3
&
Technology, Taxila
DSD
Lab Manual# 03
GROUP NO 3
6TH SEMESTER
OMEGA SECTION
Dated;
18/07/2023
Objective:
Designing, Simulating and Implementing the HDL code for 4-bit 4x1 Mux, 2-bit 4x1 Mux, 1-bit
1x8 Demultiplexer, 3x8 Decoder, and 4x16 decoder using two 3x8 decoder and additional logic (Enable)
Procedure:
1. Writing the Source Code of module and simulating it
2. Opening Elaborated Design
3. Setting Constraints
4. Running Synthesis
5. After Successful Synthesis Running Implementation
6. After Successful Implementation Generating Bit Stream
7. Downloading Bit Stream to FPGA kit using Hardware Manager
Apparatus List:
• Verilog HDL
• FPGA Development Board
• Xilinx Vivado or any other Verilog simulation and synthesis tool
TASK 1:
Verilog Code for 4-bit 4x1 Mux and simulate it only.
Verilog Code:
Source code Testbench
Simulation
TASK 2:
Truth Table
sel out
2’b00 A
2’b01 B
2’b10 C
2’b11 D
Verilog Code:
Source code Testbench
RESULTS:
Schematic Diagram:
Simulation:
FPGA Implementation
Sel=00 Sel=01
Sel=10 Sel=11
TASK 3:
Truth Table:
S2 S1 S0 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
Verilog Code:
Source code Testbench
module module
oneto8demux(d0,s0,s1,s2,OUT); input test_bench(); reg
s2,s1,s0; output [7:0]OUT; reg s0,s1,s2; wire
[7:0]OUT; input d0; [7:0]OUT; reg d0;
always@(d0 or s0 or s1 or s2) oneto8demux
begin DUT(.d0(d0),.s0(s0),.s1(s1),.s2(s2),.OUT(O
case({s2,s1,s0}) UT)); initial begin
0:OUT=8'b00000001; #10 s2=1'b0;s1=1'b0;s0=1'b0;d0=1'b1;
#10 s2=1'b0;s1=1'b0;s0=1'b1;d0=1'b1;
1:OUT=8'b00000010;
#10 s2=1'b0;s1=1'b1;s0=1'b0;d0=1'b1;
2:OUT=8'b00000100;
#10 s2=1'b0;s1=1'b1;s0=1'b1;d0=1'b1;
3:OUT=8'b00001000;
#10 s2=1'b1;s1=1'b0;s0=1'b0;d0=1'b1;
4:OUT=8'b00010000; #10 s2=1'b1;s1=1'b0;s0=1'b1;d0=1'b1;
5:OUT=8'b00100000;
#10 s2=1'b1;s1=1'b1;s0=1'b0;d0=1'b1;
6:OUT=8'b01000000;
#10
7:OUT=8'b10000000;
s2=1'b1;s1=1'b1;s0=1'b1;d0=1'b1;
endcase
end end endmodule
endmodule
RESULTS:
Schematic Diagram:
Simulation:
FPGA Implementation:
TASK 4:
3x8 Decoder Simulation and Implementation on FPGA Kit
Truth Table
S2 S1 S0 D1 D1 D2 D3 D4 D5 D6 D7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
Verilog Code:
Source code Testbench
RESULTS:
Schematic Diagram:
Simulation:
FPGA Implementation:
TASK 5:
4x16 decoder using two 3x8 decoder and additional logic (Enable) Simulation and
Implementation on FPGA Kit.
Truth Table
Verilog Code:
Source code Testbench
3'b011:Data_out=8'b00001000;
3'b100:Data_out=8'b00010000;
3'b101:Data_out=8'b00100000;
3'b110:Data_out=8'b01000000;
3'b111:Data_out=8'b10000000;
default:Data_out=8'b10000000;
endcase else case(Data_in)
3'b000:Data_out=8'b00000001;
3'b001:Data_out=8'b00000010;
3'b010:Data_out=8'b00000100;
3'b011:Data_out=8'b00001000;
3'b100:Data_out=8'b00010000;
3'b101:Data_out=8'b00100000;
3'b110:Data_out=8'b01000000;
3'b111:Data_out=8'b10000000;
default:Data_out=8'b10000000; endcase
endmodule
RESULTS:
Schematic Diagram:
Simulation:
FPGA Implementation:
1) a0a1a2e= 1110
2) a0a1a2e= 0101
Conclusion:
We can conclude
• A 4-bit 4x1 mux will have 4 inputs, 4-bit each, and a 4- bit output with 2 bits select line. Mux will
select 1 of 4 inputs on the basis of select line.
• 2-bit 4x1 mux will have 4 inputs, 2-bit each, and a 2-bit output and with 2 bits select line. Mux
will select 1 of 4 inputs because of select line. Results are verified through implementation on
FPGA Kit.
• One common input line of 1x8 demux will be switched to one of the 8 output lines according to
select bits. Results are verified on FPGA Kit.
• 3x8 decoder works on the basis of 3 inputs which are used to select one of 8 outputs.
• When two 3 to 8 Decoder circuits are combined to make a 4x16 decoder, the enable pin acts as
the input for both the decoders. When enable pin is high at one 3 to 8 decoder circuits then it is
low at another 3 to 8 decoder circuit. Results are verified on Kit.