Design & Implement 4-BIT COMPARATOR program using Verilog HDL
AIM:-To Design & Implement 4-BIT COMPARATOR program using Verilog HDL.
Objectives: The main objective of this program is to learn how to use ternary operator using 3 conditions
TOOL:-Xilinx ISE 9.2i Version
FAMILY |
SPARTAN 3 |
Device |
XC3S400 |
Package |
PQ208 |
Speed |
-4/-5 |
Synthesis |
XST(VERILOG/VHDL) |
Simulator |
ISE Simulator |
ARCHITECTURE:
Truth Table
A3 | A2 | A1 | A0 | B3 | B2 | B1 | B0 | A>B | A<B | A=B |
---|---|---|---|---|---|---|---|---|---|---|
0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |
1 |
Source code:
module comp4bit(eq,gr,ls,a,b);
input [3:0] a,b;
output eq,gr,ls;
assign eq = (a==b) ? 1 : 0;
assign gr = (a>b) ? 1 : 0;
assign ls = (a<b) ? 1 : 0;
endmodule
Test Bench:
module comp4bittb();
reg [3:0] a,b;
wire eq,gr,ls;
comp4bit c1 (eq,gr,ls,a,b);
initial begin
a=4'b0000;b=4'b0000;
end
always #80 a[3]=~a[3];
always #40 a[2]=~a[2];
always #20 a[1]=~a[1];
always #10 a[0]=~a[0];
always #80 b[0]=~b[0];
always #40 b[1]=~b[1];
always #20 b[2]=~b[2];
always #10 b[3]=~b[3];
initial #320 $stop;
endmodule
SIMULATED WAVEFORMS:-
RTL SCHEMATIC:-
SYNTHESIS REPORT:-
TIMING REPORT:-
DEVICE UTILIZATION SUMMARY:-
SYNTHESIS DIAGRAM:-
CONCLUSION:-
The 4-bit comparator was designed using Verilog HDL & implemented in FPGA Spartan 3 kit.
Viva Questions
- What is Verilog?
- What are the various modeling used in Verilog
- What is LUT.
- What are the differences between MUX and DMUX.
- What are the differences between a comparator and MUX.
- What is the top down modeling?
- What are the applications of the comparator?
- Why don’t we use just one NMOS or PMOS transistor as a transmission gate?
- Why don’t we use just one NMOS or PMOS transistor as a transmission gate?
- What are set up time & hold time constraints? What do they signify?
- Explain Clock Skew?
- What is the structural gate-level modeling?
- What is Switch-level modeling?
- What are identifiers?
- What is the structural Domain in Verilog
Outcomes: The main outcome of this program is to findout the largest/smallest/equal among two numbers using ternary operator.This statement is used generally to compare two numbers.
-
UpdatedNov 28, 2021
-
Views6,406
Design and implement the 8x1 MULTIPLEXER with 2x1 MULTIPLEXERs program using Verilog HDL
Design & Implement 8X1 MULTIPLEXER program using Verilog HDL
Design & Implement 4-BIT COMPARATOR program using Verilog HDL
Design & Implement JK-FLIP FLOP program using Verilog HDL
Design & Implement 8X3 ENCODER program using Verilog HDL
Design & Implement T-FLIPFLOP program using Verilog HDL