1digital Circuit Design Using Verilog Manual
1digital Circuit Design Using Verilog Manual
Aim: - To realize half/full adder and half/full subtractor using logic gates.
Apparatus Required: -
Procedure: -
3. Switch on VCC and apply various combinations of input according to the truth table.
4. Note down the output readings for half/full adder and half/full subtractor
sum/difference and the carry/borrow bit for different combinations of inputs.
Half Adder
Sum Carry
A B
(S) (C)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
K-map simplification:
Circuit Diagram
Department of E&C, SSIT, Tumakuru Page 1
Digital Circuit Design Using Verilog Lab manual
Full Adder
Sum Carry
A B Ci
(S) (Co)
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
K-map Simplification:
= C (AB)
Half Subtractor :
Circuit Diagram
USING BASIC AND XOR GATES
Full subtractor:
7486 DIFF(D)
A
B 7486 7404
7408
Cin
Circuit Diagram
(USING BASIC AND XOR GATES)
Result:
Develop and verify the Verilog code for the given Boolean expressions and Half /
full adder using different types of modeling
LOGIC c
GATES
d
f Logic Symbol
a b c(and) d(or e(not) f(nand ) g(nor) h(xor) i(xnor)
for Logic
) g gates
0 0 0 0 1 1 h1 0 1 TRUTH
TABLE:
0 1 0 1 1 1 i 0 1 0
1 0 0 1 0 1 0 1 0
1 1 1 1 0 0 0 0 1
Boolean Expressions:
c= ab
d= a+b
e= a̅
f= ab
g= a+b
h= aƟb
i= aƟb
a b sum(s) carry(c)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Boolean Expressions:
s= aƟb
c= ab
s=1; c=0;
end
else
if (a==1 & b==1)
begin
s=0; c=1;
end
end
endmodule
AIM: - To realize IC 7483 as parallel adder / Subtractor and realize half/full subtractor using mux
IC 74153
Apparatus Required: -
Procedure: -
4. For subtraction connect C0 to Vcc, Apply the B input through NOT gate, which gives the
complement of B.
Pin Detail: -
7483
Adder: -
12
Truth Table: -
Subtractor:-
Pin Details: -
SELECT INPUTS
SELECT INPUTS
LINES
LINES
S1 S2 Ēa Ioa I1a I2a I3a Za
S1 S2 Ēb Iob I1b I2b I3b Zb
X X 1 X X X X 0
X X 1 X X X X 0
0 0 0 0 X X X 0
0 0 0 0 X X X 0
0 0 0 1 X X X 1
0 0 0 1 X X X 1
0 1 0 X 0 X X 0
0 1 0 X 0 X X 0
0 1 0 X 1 X X 1
0 1 0 X 1 X X 1
1 0 0 X X 0 X 0
1 0 0 X X 0 X 0
1 0 0 X X 1 X 1 Truth Table:
- 1 0 0 X X 1 X 1
1 1 0 X X X 0 0
1 1 0 X X X 0 0
1 1 0 X X X 1 1
1 1 0 X X X 1 1
Develop the Verilog code for the following combinational circuits in gate level/data flow any
type of modelling. – MUX, DEMUX, encoder, decoder.
TRUTH TABLE:
TRUTH TABLE:
TRUTH TABLE:
Inputs Outputs
s(7) s(6) s(5) s(4) s(3) s(2) s(1) s(0) y(2) y(1) y(0)
0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0 0 1
0 0 0 0 0 1 0 0 0 1 0
0 0 0 0 1 0 0 0 0 1 1
0 0 0 1 0 0 0 0 1 0 0
0 0 1 0 0 0 0 0 1 0 1
0 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 1 1 1
TRUTH TABLE:
Inputs Outputs
s(1) s(0) y(3) y(2) y(1) y(0)
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
Boolean Expressions:
y[0]= s[1]s[0]
y[1]= s[1]s[0]
y[2]= s[1]s[0]
y[3]= s[1]s[0]
module decoder2_4(s,y);
input [1:0] s;
output [3:0] y;
assign y[0]=(~s[1]) & (~s[0]);
Department of E&C, SSIT, Tumakuru Page 17
Digital Circuit Design Using Verilog Lab manual
FLIP-FLOPS
Aim: Verification of truth-tables of the following types of SR flip flop and master slave JK flip-flops
using NAND gates
Apparatus Required: -
IC 7410, IC 7400, etc.
Procedure: -
1. Connections are made as per circuit diagram.
2. The truth table is verified for various combinations of inputs.
SR Flip-flop: Truth-table:
PR
J 7410 7410
7400
7400 Q
7400 Q’
7400
K 7410 7410
clr
7410
Develop and verify Verilog code using behavioural modelling for sequential circuits- flip-flops .
AIM: Write a Verilog code for D Flip Flop in Behavioral modeling, simulate it using modelsim simulator.
Clear
D FLIP-FLOP
D Q
Clk
Qb
Preset
TRUTH TABLE:-
always@(posedge clk)
begin
if(clear==0)
begin
q=0;qb=1;
end
else
if(preset==0)
begin
q=1;qb=0;
end
else
begin
case(d)
1'b0:begin q=0;qb=1; end
1'b1:begin q=1;qb=0;end
endcase
end
end
endmodule
AIM: Write a Verilog code for JK Flip Flop in Behavioral modeling, simulate it using modelsim
simulator
Clear
J K FLIP-FLOP
J Q
Clk
Qb
K Preset
TRUTH TABLE:-
JK Flip Flop
ASYNCHRONOUS COUNTERS
Procedure: -
2. Clock pulses are applied one by one at the clock I/P and the O/P is observed at QA, QB &
QC for IC 7476.
Truth-table:
Truth-table:
EXEPRIMENT 4.B
Department of E&C, SSIT, Tumakuru Page 24
Digital Circuit Design Using Verilog Lab manual
Develop and verify the Verilog code for 3 bit binary up/down counter
AIM: Write a Verilog code for Asynchronous binary 4-bit up counter in Behavioral modeling, simulate it
using modelsim simulator.
BINARY
rst q[3:0]
COUNTER
clk
TRUTH TABLE :
Inputs Outputs
rst Clk q(3) q(2) q(1) q(0)
1 X 0 0 0 0
0 Π 0 0 0 0
0 Π 0 0 0 1
0 Π 0 0 1 0
0 Π 0 0 1 1
0 Π 0 1 0 0
0 Π 0 1 0 1
0 Π 0 1 1 0
0 Π 0 1 1 1
0 Π 1 0 0 0
0 Π 1 0 0 1
0 Π 1 0 1 0
0 Π 1 0 1 1
0 Π 1 1 0 0
0 Π 1 1 0 1
0 Π 1 1 1 0
0 Π 1 1 1 1
Binary Up Counter
DECODER
AIM:-To drive the LED display using 7447 7-segment decoder/ driver.
APPARATUS REQUIRED: -
PROCEDURE: -
2. Connect the pins of IC 7447 to the respective pins of the LED display board.
3. Give different combinations of the inputs and observe the decimal numbers displayed on the board.
NC
TRUTH-TABLE:
Result:
Develop the Verilog code for comparator (n-bit), and BCD counter.
AIM: Write a Verilog code for N-bit comparator in behavioral modeling, simulate it using modelsim
simulator.
COMPARATOR y(1)
b[n:0]
y(2)
TRUTH TABLE:
INPUT OUTPUT (Y)
a>b 100
a=b 010
a<b 001
module comp_n(a,b,y);
parameter n=3;
input [n:0] a,b;
output [2:0] y;
reg [2:0] y;
always @ (a,b)
begin
if(a==b)
y=3’b010;
else
if(a<b)
y=3’b001;
else
if(a>b)
y=3’b100;
end
endmodule
AIM: Write a Verilog code for Asynchronous BCD 4-bit up counter in Behavioral modeling, simulate it
using modelsim simulator.
TRUTHTABLE :
Inputs Outputs
rst Clk q(3) q(2) q(1) q(0)
1 X 0 0 0 0
0 Π 0 0 0 0
0 Π 0 0 0 1
0 Π 0 0 1 0
0 Π 0 0 1 1
0 Π 0 1 0 0
0 Π 0 1 0 1
0 Π 0 1 1 0
0 Π 0 1 1 1
0 Π 1 0 0 0
0 Π 1 0 0 1
BCD Up Counter