Ddco 00
Ddco 00
EXPERIMENT -1
Given a 4-variable logic expression, simplify it using appropriate technique and
simulate the same using basic gates.
F(W,X,Y,Z)=Sm(0,1,2,4,5,6,8,9,12,13,14)
Solution F = Y1 + W1Z1 +X1Z1
Theory:
Procedure:
1. Open ORCAD CAPTURE.
2. Select new project from file menu.
3. Select analog and mixed A/D.
4. Choose blank project.
5. Make circuit as shown in figure.
6. Place the voltage marker at appropriate node.
7. Create new simulation profile and click on run.
Analysis Type: Transient
Run to time – 10ms
Output waveform
Conclusion :
EXPERIMENT -2
Design a full adder and subtractor and simulate the same using basic gates.
a) Full adder
Sum = A xor B xor Cin
Cout = AB+BC+CA
Theory :
Procedure:
1. Open ORCAD CAPTURE.
2. Select new project from file menu.
3. Select analog and mixed A/D.
4. Choose blank project.
5. Make circuit as shown in figure.
6. Place the voltage marker at appropriate node.
7. Create new simulation profile and click on run.
Analysis Type: Transient
Run to time – 30ms
Output waveform
b) Full Subtractor
Procedure:
1. Open ORCAD CAPTURE.
2. Select new project from file menu.
3. Select analog and mixed A/D.
4. Choose blank project.
5. Make circuit as shown in figure.
6. Place the voltage marker at appropriate node.
7. Create new simulation profile and click on run.
Analysis Type: Transient
Run to time – 30ms
Output waveform
Aim : Design Verilog HDL to implement AND gate, OR gate, not gate, EX-OR gate
AND OR
NOT X-OR
Verilog Code:
initial begin
A = 0; B = 0;
#100 A = 0; B = 1;
#100 A = 1; B = 0;
#100 A = 1; B = 1;
end
endmodule
EXPERIMENT-4
Design Verilog HDL to implement simple circuits using structural, Data flow and Behavioral
model.
Circuit:
TRUTH TABLE
Input Output
a a b c f
0 0 0 0
b 0 0 1 1
0 1 0 0
f 0 1 1 0
1 0 0 0
1 0 1 1
c 1 1 0 1
1 1 1 1
Verilog Code:
i)DATA FLOW MODEL
module dataflow(a,b,c, f);
input a,b,c;
output f;
assign f=((a&b)|((~b)&c));
endmodule
SIMULATION OUTPUT
EXPERIMENT 4:
Design Verilog HDL to implement Binary adder –Subtractor – Half and Full adder,
Half and Full Subtractor.
Half-Adder
Circuit Truth table
Verilog code
assign s = a ^ b;
assign c = a & b;
endmodule
Half-Subtractor
Verilog code
module half_subtractor (a,b,diff,borrow);
input a,b;
output diff,borrow;
assign diff = a ^ b;
assign borrow = ~a & b;
endmodule
FULL ADDER
Circuit Truth table
Verilog code:
FULL SUBTRACTOR
Verilog code:
SIMULATION OUTPUT
EXPERIMENT 5:
Design Verilog HDL to implement Decimal adder.
Circuit:
module decimal_adder(a,b,carry_in,sum,carry);
input [3:0] a,b;
input carry_in;
output [3:0] sum;
output carry;
reg [4:0] sum_temp;
reg [3:0] sum;
reg carry;
always @(a,b,carry_in)
begin
sum_temp = a+b+carry_in;
if(sum_temp > 9)
begin
sum_temp = sum_temp+6;
carry = 1;
sum = sum_temp[3:0];
end
else begin
carry = 0;
sum = sum_temp[3:0];
end
end
endmodule
TRUTH TABLE
SIMULATION OUTPUT
EXPERIMENT 6:
Design Verilog HDL to implement Different types of multiplexer like 2:1, 4:1 and 8:1.
2 to 1 Multiplexerd
Block diagram
En
Truth Table
A
Input Output
2:1-
MUX Y SEL En Y
B X 1 0
0 0 A
1 0 B
SEL
Verilog code:
assign Y = B;
SIMULATION OUTPUT
4 to 1 Multiplexer
Verilog code
Verilog code
module mux81(din, sel,
module mux41(din, sel, dout); dout);
input [7:0] din;
input [3:0] din; input [2:0] sel;
input [1:0] sel; output dout;
output dout; reg dout;
always @(din or sel)
reg dout; begin
always @(din or sel) case (sel)
begin 3’b000:dout=din[0];
3’b001:dout=din[1];
case (sel) 3’b010:dout=din[2];
3’b00:dout=din[0]; 3’b011:dout=din[3];
3’b01:dout=din[1]; 3’b100:dout=din[4];
3’b101:dout=din[5];
3’b10:dout=din[2];
3’b110:dout=din[6];
3’b11:dout=din[3];
3’b111:dout=din[7]
default: dout=1’bx;
endcase ;
end default: dout=1’
endmodule bx;
endcase
end
endmodule
SIMULATION OUTPUT
8 to 1 Multiplexer
I(0)
Selector O/P
I(1)
I(2) S2 S1 S0 Y
I(3) 0 0 0 I(0)
y
I(4) 8:1 0 0 1 I(1)
MUX
I(5) 0 1 0 I(2)
I(6) 0 1 1 I(3)
I(7) 1 0 0 I(4)
1 0 1 I(5)
s(2) s(0) 1 1 0 I(6)
s(1) 1 1 1 I(7)
Verilog code
SIMULATION OUTPUT:
EXPERIMENT 7:
Design Verilog HDL to implement Different types of De-Multiplexer.
1:2 Demultiplexer
TRUTH TABLE
Verilog code:
module demux1to2(i,sel,y0,y1);
input i,sel;
output y0,y1;
assign {y0,y1} = sel?{1'b0,i}:{i,1'b0};
endmodule
SIMULATION OUTPUT
1:4 Demultiplexer
TRUTH TABLE
Verilog code:
module demux1to4(d,sel,y0,y1,y2,y3);
input d;
input[1:0] sel;
output y0,y1,y2,y3;
assign y0=(sel==2'b00)?d:1'b0;
assign y1=(sel==2'b01)?d:1'b0;
assign y2=(sel==2'b10)?d:1'b0;
assign y3=(sel==2'b11)?d:1'b0;
endmodule
SIMULATION OUTPUT
1:8 Demultiplexer
Truth Table
Selector Output
e
d S2 S1 S0 y7 y6 y5 y4 y3 y2 y1 y0
n
0 d/0 X X X Z Z Z Z Z Z Z Z
1 d/0 0 0 0 Z Z Z Z Z Z Z d/0
1 d/0 0 0 1 Z Z Z Z Z Z d/0 Z
1 d/0 0 1 0 Z Z Z Z Z d/0 Z Z
1 d/0 0 1 1 Z Z Z Z d/0 Z Z Z
1 d/0 1 0 0 Z Z Z d/0 Z Z Z Z
1 d/0 1 0 1 Z Z d/0 Z Z Z Z Z
1 d/0 1 1 0 Z d/0 Z Z Z Z Z Z
1 d/0 1 1 1 d/0 Z Z Z Z Z Z Z
Verilg code:
module demux1to8(d,sel,y0,y1,y2,y3,y4,y5,y6,y7);
input d;
input[2:0] sel;
output y0,y1,y2,y3,y4,y5,y6,y7;
assign y0=(sel==3’b000)?d:1’b0;
assign y1=(sel==3’b001)?d:1’b0;
assign y2=(sel==3’b010)?d:1’b0;
assign y3=(sel==3’b011)?d:1’b0;
assign y4=(sel==3’b100)?d:1’b0;
assign y5=(sel==3’b101)?d:1’b0;
assign y6=(sel==3’b110)?d:1’b0;
assign y7=(sel==3’b111)?d:1’b0;
endmodule
SIMULATION OUTPUT
EXPERIMENT 8:
Design Verilog program for implementing various types of Flip-Flops such as SR, JK,
and D.
A. SR Flip-flop
Circuit Truth table
rst pr Clk s r q qb
1 X X X X 0 1
0 1 X X X 1 0
0 0 1 0 0 Qb Qbprevious
0 0 1 0 1 0 1
0 0 1 1 0 1 0
0 0 1 1 1 1 1
SIMULATION OUTPUT
B. D Flip-flop:
Circuit Truth table
clk d q qb
X 1 1 0
1 1 1 0
1 0 0 1
Verilog Code
module dff(data,clk,q);
input data,clk;
output q;
reg q;
always@(posedge clk)
begin
q<=data;
end
endmodule
SIMULATION OUTPUT
C JK Flip-flop:
Rst Clk J K Q Qb
1 1 0 0 Previous state
1 1 0 1 0 1
1 1 1 0 1 0
1 1 1 1 Qb Q
0 - - - 0 1
Verilog code
SIMULATION OUTPUT