Eda Lab
Eda Lab
STUDENT’S MANUAL
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
EDA LAB MANUAL ECE Department
Mission
• To attain excellence in imparting technical education from the undergraduate through
doctorate levels by adopting coherent and judiciously coordinated curricular and co-curricular
programs
• To foster partnership with industry and government agencies through collaborative research
and consultancy
• To nurture and strengthen auxiliary soft skills for overall development and improved
employability in a multi-cultural work space
• To develop scientific temper and spirit of enquiry in order to harness the latent innovative
talents
• To develop constructive attitude in students towards the task of nation building and empower
them to become future leaders
• To nourish the entrepreneurial instincts of the students and hone their business acumen.
• To involve the students and the faculty in solving local community problems through
economical and sustainable solutions.
Vision and Mission of ECE Department
Vision
To be recognized as a premier education center providing state of art education and facilitating
research and innovation in the field of Electronics and Communication.
Mission
We are dedicated to providing high quality, holistic education in Electronics and Communication
Engineering that prepares the students for successful pursuit of higher education and challenging
careers in research, R& D and Academics.
LABORATORY MANUAL
FOR
Approved by:
2) Sign : 2) Sign :
3)Designation : 3) Designation :
4) Date : 4) Date :
2) Sign : 1) Name :
3)Designation : 2) Sign :
4) Date : 3) Designation :
4) Date :
2) Sign :
3) Date :
EC 432
Part A
Write the Code using VERILOG, Simulate and synthesize the following
Note:-
1. All the codes should be implemented appropriately using Gate level, Dataflow and
Behavioral Modeling.
2. All the programs should be simulated using test benches.
3. Minimum of two experiments to be implemented on FPGA/CPLD boards.
Part B
Mini project:
i) 8 bit CPU
ii) Generation of different waveforms using DAC
iii) RTL code for Booth‟s algorithm for signed binary number multiplication
iv) Development of HDL code for MAC unit and realization of FIR Filter
v) Design of 4-bit thermometer to Binary Code Converter
.
MUFFAKHAM JAH
COLLEGE OF ENGINEERING & TECHNOLOGY
ELECTRONICS & COMMUNICATION ENGINEERING DEPARTMENT
Behavioral Modeling
7. Encoders, Decoders, Priority Encoder And Comparator
10.Flip-Flops
11.Registers/Counters
13. Appendix
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
TRUTH TABLE:
Vin1 Vin2 invert_ out and_ out or_ out nand_ out nor_ out exor_out exnor_out
0 0 1 0 0 1 1 0 1
0 1 0 0 1 1 0 1 0
1 0 1 0 1 1 0 1 0
1 1 0 1 1 0 0 0 1
LOGICAL DIAGRAM:
`resetall
`timescale 1 ns / 1 ns `timescale 1 ns / 1
ps module test;
module allgates(inverter_out, and_out, nand_out,
or_out, nor_out, exor_out, exnor_out, vin1, vin2); reg vin1, vin2;
or or1(or_out,vin1,vin2); for(i=0;i<4;i=i+1
RESULT:
AIM:
i) To verify truth table and waveforms of arithmetic units: adder and subtractor
(binary 1-bit half adder/binary 1-bit half subtractor) using gate level model.
ii) Verification of code on FPGA board.
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
LOGIC DIAGRAM:
Circuit diagram:
PROGRAM: 1-bit binary half adder TESTBENCH: 1-bit binary half adder
module ha(a,b,sum,co); `timescale 1ns/1ps
module ha_test;
input a,b; reg a,b;
wire sum,co;
output sum,co; ha hadder(a,b,sum,co); /*INSTANTIATE THE
MODULE NAME(ha)
xor (sum,a,b);
THAT NEEDS BE TESTED WITH
INSTANTIATION NAME hadder*/
and (co,a,b);
initia
l
endmodule
begin
{a,b}=2‟b00; #5
{a,b}=2‟b01; #5
{a,b}=2‟b10; #5
{a,b}=2‟b11;
#5 $finish;
end
initial
#5 {a,b}=2‟b01;
#5 {a,b}=2‟b10;
#5 {a,b}=2‟b11;
#5 $finish;
end
initial
RESULT:
REQUIREMENTS:
PROCEDURE:
S A B
S Y
0 Y 0
0 A
1 0 Y
1 B
LOGICAL DIAGRAM:
Components:
initi
al
begi
n
#5 b=1;x=1;
#5 $finish;
end
initial
input x,y;
demux1to2 dm(x,a,b,y);
output a,b; not (xbar,x); initial
and (a,y,xbar);
begin
and (b,y,x);
y=0; x=0;
endmodule
#5 y=1; x=1;
#5 y=0; x=1;
#5 y=1; x=0;
#5 $finish;
end
initial
endmodule
RESULTS:
i) Truth tables and waveforms of 2x1 multiplexer and 1x2 demultiplexer are
verified.
ii) Code is verified on FPGA board.
Exercise:
Write Verilog Module and Testbench to simulate the following using gate level Modeling
MJCET Page 16
EDA LAB MANUAL ECE Department
List Of Experiments
8 Arithmetic Units
MJCET Page 17
EDA LAB MANUAL ECE Department
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
TRUTH TABLE:
Vin1 Vin2 invert_ out and_ out or_ out nand_ out nor_ out exor_out exnor_out
0 0 1 0 0 1 1 0 1
0 1 0 0 1 1 0 1 0
1 0 1 0 1 1 0 1 0
1 1 0 1 1 0 0 0 1
MJCET Page 18
EDA LAB MANUAL ECE Department
LOGICAL DIAGRAM:
PROGRAM: TESTBENCH:
`timescale 1 ns / 1 ps
`resetall
module test;
`timescale 1 ns / 1 ns
reg vin1, vin2;
module allgates(inverter_out, and_out, nand_out, or_out,
wire inverter_out_vin2, and_out, nand_out, or_out, nor_out,
nor_out, exor_out, exnor_out, vin1, vin2); input vin1, vin2; exor_out, exnor_out;
output inverter_out, and_out, nand_out, or_out, nor_out, integer i;
exor_out, exnor_out;
allgates ag(inverter_out_vin2, and_out, nand_out, or_out,
assign inverter_out=~vin2; assign nor_out, exor_out, exnor_out, vin1, vin2); initial
and_out=vin1&vin2; assign
for(i=0;i<4;i=i+1)
nand_out=~(vin1&vin2); assign
begin
or_out=vin1|vin2;
{vin1,vin2}=i; #5 ;
assign nor_out=~(vin1|vin2);
end
assign exor_out=(vin1^vin2;
endmodule
assign exnor_out=vin1~^vin2;
endmodule
MJCET Page 19
RESULT:
i) Truth tables and waveforms of logic gates are verified.
ii) Code is verified on FPGA board.
AIM:
i) To verify truth table and waveforms of arithmetic units: adder and
subtractor(binary 1-bit half adder/binary 1-bit half subtractor) using dataflow
level model.
ii) Verification of code on FPGA board.
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
PROGRAM: 1-bit binary half adder TESTBENCH: 1-bit binary half adder
module ha(a,b,sum,co); `timescale 1ns/1ps
module ha_test;
input a,b;
reg a,b;
output sum,co;
wire sum,co;
assign sum=a^b; ha hadder(a,b,sum,co); /*INSTANTIATE THE
endmodule initial
begin
{a,b}=2‟b00; #5
{a,b}=2‟b01; #5
{a,b}=2‟b10; #5
{a,b}=2‟b11;
#5 $finish;
MJCET Page 21
EDA LAB MANUAL ECE
Department
e
$monitor($time, “a=%b, b=%b,
n
sum=%b, co=%b” , a, b, sum, co);
d
endmodule
initial
module hs(a,b,diff,barrow);
RESULTS
input a,b;
output diff,barrow;
abar=~a;
assign barrow=abar&b;
endmodule
MJCET Page 22
EDA LAB MANUAL ECE Department
#5
TESTBENCH: 1-bit binary half subtracor {a,b}=2‟b01;
#5
`timescale {a,b}=2‟b10;
1ns/1ps module #5
hs_test; reg a,b; {a,b}=2‟b11;
wire diff,barrow;
#5
hs hsub(a,b,diff,barrow); /*INSTANTIATE THE
$finish;
MODULE NAME(hs) THAT NEEDS BE TESTED end
WITH INSTANTIATION NAME hsub*/
initial
initi
$monitor($time, “a=%b, b=%b,
al
diff=%b, barrow=%b” , a, b, diff,
begi
n barrow); endmodule
{a,b}=2‟b00;
i) Truth tables and waveforms of arithmetic units- binary 1-bit half adder and half
subtractor are verified.
ii) Code is verified on FPGA board.
i) To verify truth table and waveforms of 2x1 multiplexer and 1x2 demultiplexer
using dataflow level model.
ii) Verification of code on FPGA board.
REQUIREMENTS:
MJCET Page 23
EDA LAB MANUAL ECE Department
PROCEDURE:
TRUTH TABLE:
S A B
S Y
0 Y 0
0 A
1 0 Y
1 B
MJCET Page 24
EDA LAB MANUAL ECE Department
wire xbar,y1,y2;
TESTBENCH: (MUX 2x1)
assign xbar=~x;
assign y1=a&xbar;
`timescale 1 ns / 1 ps
assign y2=b&x;
module mux_test;
assign y=y1|y2; reg x,a,b;
wire y;
(NOTE only primary inputs “a,b,x” and primary output
endmodule
“y” have been declared with reg and wire respectively;
but not the intermediary(OR intermediatory) signals
such
as “xbar,y1,y2″)
mux2to1 mux(x,a,b,y); /*INSTANTIATE
THE
MODULE NAME(mux2to1) THAT NEEDS BE
TESTED WITH INSTANTIATION NAME mux*/
initial
begin
a=0; b=0; x=0;
#5 a=1;
#5 x=1;
#5 b=1;x=1;
#5 $finish;
end
initial
$monitor($time, “a=%b, b=%b, x=%b” , a , b
, x);
endmodule
output y;
PROGRAM: (MUX 2x1)
assign y=x? b: a;
`resetall
endmodule
`timescale 1 ns / 1 ns module
MJCET Page 25
EDA LAB MANUAL ECE Department
`timescale 1 ns / 1 ps
module
mux_test; reg
x,a,b;
wire y;
(NOTE only primary inputs “a,b,x” and
primary output “y” have been declared with
reg and wire respectively; but not the
intermediary(OR intermediatory) signals
such as “xbar,y1,y2″)
mux2to1 mux(x,a,b,y); /*INSTANTIATE
THE
MODULE NAME(mux2to1) THAT NEEDS BE TESTED WITH
INSTANTIATION NAME mux*/
Initial
Begin
a=0;b=0;
x=0; #5 a=1;
#5 x=1;
#5 b=1;x=1;
#5 $finish;
End
initial
$monitor($time, “a=%b, b=%b, x=%b” , a ,b
,x);
endmodule
MJCET Page 26
PROGRAM: (DeMux 1x2) TESTBENCH: (DeMux 1x2)
`resetall
x,y;
output a,b; assign
endmodule begin
y=0;
x=0;
#5 y=1;
x=1; #5
y=0; x=1;
#5 y=1;
x=0; #5
$finish; end
initial
x); endmodule
Results:
i) Truth tables and waveforms of 2x1 multiplexe and 1x2 demultiplexer are
verified.
ii) Code is verified on FPGA board.
EDA LAB MANUAL ECE Department
Exercise:
MJCET Page 28
EDA LAB MANUAL ECE Department
BEHAVIORAL MODELING
LIST OF EXPERIMENTS
15. Flip-Flops
16. Registers/Counters
17. Sequence Detector using Mealy and Moore type state machines
MJCET Page 29
EDA LAB MANUAL ECE Department
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
1. Write the program and testbench.
2. Simulate the testbench and observe the waveform for different
combinations of input as per the truth table and verify simulation results
with expected output waveform.
3. Now synthesize the program and note down how many lookup
tables(LUTs) been consumed.
4. Also verify output on FPGA board.
MJCET Page 30
EDA LAB MANUAL ECE Department
0 1 0 0 1 0
1 0 0 0 1 1
Y0
B. DECODER 2x4 B. I0
BLOCK DIAGRAM Y1
2-to-4
I1 decoder Y2
Y3
inputs outputs
I1 I0 Y3 Y2 Y1 Y0
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
inputs outputs
I0 Y0
I3 I2 I1 I0 Y1 Y0 Status
0 0 0 0 0 0 0 I1
Priority Y1
I2 Encoder
0 0 0 1 0 0 1
4x2
0 0 1 x 0 1 1 I3 Status
0 1 x x 1 0 1
1 x x x 1 1 1
D. COMPARATOR
MJCET Page 31
EDA LAB MANUAL ECE Department
A3 A2 A1 A0 B3 B2 B1 B0 A<B
1. ENCODER 4x2
PROGRAM: TESTBENCH:
module encoder4to2(i0,i1,i2,i3,y1,y0); `timescale 1ns/1ps
input i0,i1,i2,i3; module enco_test;
output reg y1,y0; reg i0,i1,i2,i3;
always@* wire y1,y0;
case({i3,i2,i1,i0}) integer I;
4‟b0001:{y1,y0}=2‟b00; encoder4to2 encoder(i0,i1,i2,i3,y1,y0);
4‟b0010:{y1,y0}=2‟b01; /*INSTANTIATE THE MODULE NAME (encoder4to2) THAT
NEEDS BETESTED WITH INSTANTIATION NAME
4‟b0100:{y1,y0}=2‟b10; encoder*/
4‟b1000:{y1,y0}=2‟b11; initial
default:{y1,y0}=2‟bxx; begin
endcase { i0,i1,i2,i3}=0;
endmodule for(i=1; i<16; i=i+1)
#5 {i3,i2,i1,i0}=I;
#150
$finish;
end
initial
$monitor($time, “i0=%b, i1=%b,
i2=%b, i3=%b, y1=%b, y0=%b”,
i0,i1,i2,i3,y1,y0);
endmodule
MJCET Page 32
EDA LAB MANUAL ECE Department
2. DECODER 2x4
PROGRAM: TESTBENCH:
end
initial
#150 $finish;
initial
MJCET Page 33
EDA LAB MANUAL ECE Department
$monitor($finish,
“i0=%b,i1=%b,y0=%b,y1=%b,y2=%b,y3=
%b”, i0,i1,y0,y1,y2,y3);
endmodule
PROGRAM:
TESTBENCH:
module pe(i3,i2,i1,i0,y1,y0,status);
input i3,i2,i1,i0;
output y1,y0,status;
always@*
casex({i3,i2,i1,i0}) // note it is casex not case
4‟b0000:{y1,y0,status}=3‟b000;
4‟b0001:{y1,y0,status}=3‟b001 ;
4‟b001x:{y1,y0,status}=3‟b011;
4‟b01xx:{y1,y0,status}=3‟b101;
4‟b1xxx:{y1,y0,status}=3‟b111;
`timescale 1ns/1ps
endcase
module test_priority;
endmodule
reg i3,i2,i1,i0;
wire y1,y0,status;
integer i;
pe encoder(i3,i2,i1,i0,y1,y0,status);
/*INSTANTIATE THE MODULE NAME(pe) THAT NEEDS
BE TESTED WITH INSTANTIATION NAME encoder*/
initial
begin
MJCET Page 34
EDA LAB MANUAL ECE Department
{i3,i2,i1,i0}=4‟b000 endmodule
0; for(i=1;i<16;
i=i+1) #5
{i3,i2,i1,i0}=i; #150
$finish;
end
initial
PROGRAM: TESTBENCH:
TESTBENCH:
module comp(a,b,agtb,altb,aeqb);
input [2:0]a,b;
`timescale 1ns/1ps
output reg agtb, altb, aeqb; module test_comparator;
always@* reg [2:0]a,b;
begin wire agtb, altb, aeqb;
if(a>b) comp com1(a,b,agtb,altb,aeqb);
{agtb,altb,aeqb}=3‟b100; initial
else if(a<b) begin
{agtb,altb,aeqb}=3‟b010; {a,b}=0;
else #5 {a,b}=1;
{agtb,altb,aeqb}=3‟b001; #5 {a,b}=2;
end #5 {a,b}=3;
endmodule #10 $finish;
End
Initial
$monitor($time, “a=%b, b=%b, agtb=%b,
altb=%b, aeqb=%b” , a,b,agtb,altb,aeqb);
endmodule
MJCET Page 35
EDA LAB MANUAL ECE Department
RESULT:
AIM:
i) To verify truth table and waveforms of 8-bit parallel adder using 4-bit tasks and
functions using behavioural level model.
ii) Verification of code on FPGA board.
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
MJCET Page 36
EDA LAB MANUAL ECE Department
BLOCK DIAGRAM:
B7 B6 B5 B4 B3 B2 B1 B0 B7 B6 B5 B4 B3 B2 B1 B0
SUM
8-BIT PARALLEL ADDER
CO
endmodule
module adder8bit_task4bit(a,b,sum,co);
input [7:0]a,b;
output reg [7:0]sum;
output reg co;
reg cint;
task task4bit;
input [3:0]a_task, b_task;
input cin_task;
output [3:0]sum_task;
output co_task;
{co_task,sum_task}=a_task + b_task +
cin_task; `timescale 1ns/1ps
module test_adder8bit;
endtask
reg [7:0]a,b;
always@(
wire [7:0]sum;
*) begin
wire co;
task4bit(a[3:0], b[3:0], 0, sum[3:0], cint);
adder8bit_task4bit add_task(a,b,sum,co);
task4bit(a[7:4], b[7:4], cint, sum[7:4], co); /*INSTANTIATE THE MODULE NAME(adder8bit_task4bit)
end THAT NEEDS BE TESTED WITH INSTANTIATION NAME
MJCET Page 37
EDA LAB MANUAL ECE Department
add_task*/
$monitor($time, “a=%b, b=%b, sum=%b,
initial co=%b)” , a, b, sum, co);
begin endmodule
repeat(10)
begin
#5 a=$random; b=$random;
end
end
initial
#150
$finish;
initial
2.8-BIT PARALLEL ADDER USING 4-BIT FUNCTION
PROGRAM: TESTBENCH:
module `timescale 1ns/1ps
adder8bit_function4bit(a,b,sum,co); module test_adder8bit;
input [7:0]a,b;
output reg [7:0]sum; reg [7:0]a,b;
output reg co; wire [7:0]sum;
reg cint;
function [4:0]function4bit; wire co;
input [3:0]a_function, b_function; adder8bit_function4bit
input cin_function; add_function(a,b,sum,co);
function4bit=a_function + b_function + /*INSTANTIATE THE MODULE
NAME(adder8bit_function4bit) THAT NEEDS BE TESTED
cin_function; WITH INSTANTIATION NAME add_function*/
endfunction initial
always@(*) begin
begin repeat(10)
{cint,sum[3:0]}= begin
function4bit(a[3:0],b[3:0],0); #5 a=$random; b=$random;
MJCET Page 38
EDA LAB MANUAL ECE Department
{co,sum[7:4]}= end
function4bit(a[7:4],b[7:4],cint); end
end initial
endmodule #150 $finish;
initial
$monitor($time, “a=%b, b=%b, sum=%b,
co=%b)” , a, b, sum, co);
endmodule
RESULT:
i) Truth tables and waveforms of 8-bit parallel adder using 4-bit tasks and
functions are verified.
ii) Code is verified on FPGA board.
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
MJCET Page 39
EDA LAB MANUAL ECE Department
3. Now synthesize the program and note down how many lookup tables(LUTs) been
consumed.
4. Also verify output on FPGA board.
TRUTH TABLE:
Opcode Operation
0 AND
1 OR
2 NAND
3 NOR
4 ADDITION
5 SUBTRACTION
6 MULTIPLICATION
7 XOR
BLOCK DIAGRAM:
OPERAND1 OPERAND2
RESULT
MJCET Page 40
EDA LAB MANUAL ECE Department
PROGRAM:
MJCET Page 41
EDA LAB MANUAL ECE Department
i) Truth tables and waveforms of Arithmetic and Logic Unit with minimum of eight
instructions are verified.
ii) Code is verified on FPGA board.
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
MJCET Page 42
EDA LAB MANUAL ECE Department
1 0 Q
1 1 Q
0 x 0 1
MJCET Page 43
EDA LAB MANUAL ECE Department
BLOCK DIAGRAM:
TRUTH TABLE:
0 X 0 1
1 0 0 1
1 1 1 0
1. JK-FLIP FLOP
case({j,k})
2‟b00: begin q=q; qbar=~q; end 2‟b01: begin
PROGRAM: q=0; qbar=~q; end 2‟b10: begin q=1;
qbar=~q; end 2‟b11: begin q=~q; qbar=~q;
end endcase
module jkff(j,k,clk,rst,q,qbar); end endmodule
input j,k,clk,rst; output
reg q,qbar;
always@(posedge clk)
begin
if(~rst)
begin
q=0;
qbar=~q;
end
else
MJCET Page 44
EDA LAB MANUAL ECE Department
TESTBENCH: 3; end
initial // inputs rst, clk
begin
`timesca rst=1;
le
clk=0; #5
1ns/1ps
rst=0; #5
module
rst=1;
jkff_test
end
; reg
always
j,k,clk,rs
t; wire #5 clk=~clk;
q,qbar; initial
jkff jk1(j,k,clk,rst,q,qbar); $monitor($time, “j=%b, k=%b, clk=%b,
/*INSTANTIATE THE MODULE NAME(jkff) rst=%b, q=%b, qbar=%b “, j,k,clk,rst,q,qbar);
THAT NEEDS BE TESTED WITH
INSTANTIATION NAME jk1*/ initial
initial // #90 $finish;
inputs endmodule
j,k begin
{j,k}=0;
{j,k}=1;
{j,k}=2;
{
j
,
k
}
=
2. T-FLIP FLOP
PROGRAM:
else case(t)
0: begin q=q; qbar=~q; end
1: begin q=~q; qbar=~q; end endcase
MJCET Page 45
EDA LAB MANUAL ECE Department
#200
$finish;
endmodule
TESTBENCH:
3. D-FLIP FLOP
`timescale
1ns/1ps module PROGRAM:
tff_test; reg
t,clk,rst;
module dff(d,clk,rst,q,qbar); input d,clk,rst;
wire q,qbar;
output reg q,qbar; always@(posedge
tff tff1(t,clk,rst,q,qbar);
clk) begin
/*INSTANTIATE THE MODULE NAME(tff) THAT NEEDS
BE TESTED WITH INSTANTIATION NAME tff1*/ if(~rst) begin q=0;
MJCET Page 46
EDA LAB MANUAL ECE Department
TESTBENCH:
`timescale
1ns/1ps module
MJCET Page 47
EDA LAB MANUAL ECE Department
REQUIREMENTS:
Operating System: Windows
Software: Mentor Graphics: Modelsim, Precision RTL
Hardware: FPGA-Spartan 3E
Device: XC3S500E-4FG320
PROCEDURE:
BLOCK DIAGRAM:
clk
4-bit right
r_out rst shift
register
r_i
FUNCTIONAL TABLE:
MJCET Page 48
EDA LAB MANUAL ECE Department
BLOCK DIAGRAM:
clk
l_in
Rst
4-bit left
L_out shift
MJCET Page 49
EDA LAB MANUAL ECE Department
FUNCTIONAL TABLE:
TRUTH TABLE:
Clk Rst Q3 Q2 Q1 Q0
1 1 0 0 0 0
1 0 0 0 0 1
1 0 0 0 1 0
1 0 0 0 1 1
1 0 0 1 0 0
1 0 0 1 0 1
1 0 0 1 1 0
1 0 0 1 1 1
1 0 1 0 0 0
1 0 1 0 0 1
1 0 0 0 0 0
MJCET Page 50
EDA LAB MANUAL ECE Department
PROGRAM:
#25
r_in=1;
#10
r_in=0;
#10
r_in=1;
#10
r_in=0;
end
initial
#900
MJCET Page 51
EDA LAB MANUAL ECE Department
$finish;
endmodule
Always
#5 clk =~clk;
Initial begin
End
Initial
#900 $finish;
MJCET Page 52
EDA LAB MANUAL ECE Department
endmodule
PROGRAM:
module usr(clk,rst,mode,pl_data_out,pl_data_in,q,r_in,r_out,l_in,l_out);
input clk,rst,r_in,l_in;
input [3:0]pl_data_in;
input [1:0]mode;
output [3:0]pl_data_out;
output r_out, l_out;
always@(posedge clk)
begin
if(rst)
begin
pl_data_out=3‟b0000;
r_out=0;
l_out=0;
end
else
case(mode)
0:pl_data_out=pl_data_out; // hold state
1:pl_data_out={r_in,pl_data_out}; // shift right in
2:pl_data_out={pl_data_out,l_in}; // shift left in
3:pl_data_out=pl_data_in; // load new input
endcase
end
MJCET Page 53
EDA LAB MANUAL ECE Department
PROGRAM: TESTBENCH:
MJCET Page 54
EDA LAB MANUAL ECE Department
5. UP/DOWN COUNTER
PROGRAM: TESTBENCH:
MJCET Page 55
EDA LAB MANUAL ECE Department
#300 ud=0;
#100 ud=1;
end
initial
#900 $finish;
endmodule
PROGRAM:
module
pload_counter(clk,rst,pdata_in,pload,ud,q);
input clk,rst,pload,ud;
input [3:0]pdata_in;
output reg [3:0]q;
always@(posedge clk)
if(rst)
q<=0;
else
if(pload)
q<=pdat
a_in;
else
if(ud)
q<=q+1;
else q<=q-1;
endmodule
MJCET Page 56
EDA LAB MANUAL ECE Department
RESULT:
AIM:
i) To verify truth table and waveforms of sequence detector using moore and mealy
type state machines (sequence 101 non-over lapping).
ii) Verification of code on FPGA board.
REQUIREMENTS:
PROCEDURE:
MJCET Page 57
EDA LAB MANUAL ECE Department
2. Simulate the testbench and observe the waveform for different combinations of input
as per the truth table and verify simulation results with expected output waveform.
3. Now synthesize the program and note down how many lookup tables (LUTs) been
consumed.
4. Also verify output on FPGA board.
INPUT
SEQUENTIAL
NEXT NEXT OUTPUT OUTPUT
STATE STATE (NS) LOGIC
LOGIC
LOGIC
CLOCK RESET
CURRENT
STATE (CS)
STATE DIAGRAM:
MJCET Page 58
EDA LAB MANUAL ECE Department
PROGRAM:
`resetall
`timescale 1 ns / 1 ns
module moore101(clk,rst,in,out); input
clk,rst,in;
output out;
parameter s0=0,s1=1,s2=2,s3=3; reg [1:0]
cs,ns; always@(posedge clk)
begin if(rst) cs<=0;
else cs<=ns; end
always@* case(cs)
s0: if(in) ns=s1;
else ns=s0; s1:
if(in) ns=s1; else ns=s2;
s2: if(in) ns=s3;
else
ns=s0;
s3: if(in) ns=s1;
else
ns=s0;
endcase
assign out=(cs==s3)?1:0;
endmodule
MJCET Page 59
EDA LAB MANUAL ECE Department
TESTBENCH:
endmodule
SEQUENTIAL
NEXT NEXT OUTPUT OUTPUT
STATE STATE (NS) LOGIC
LOGIC
LOGIC
INPUT
CLOCK RESET
CURRENT
STATE (CS)
MJCET Page 60
EDA LAB MANUAL ECE Department
STATE DIAGRAM:
Sequence 101 non-over lapping pattern Mealy type
`resetall `timescale 1 ns / 1 ps
`timescale 1 ns / 1 ns module test;
module mealy101(clk,rst,in,out); reg clk,rst,in;
input clk,rst,in; wire out;
output reg out; mealy101 m1(clk,rst,in,out);
parameter s0=0,s1=1,s2=2,s3=3; initial
reg [1:0] cs,ns; begin
always@(posedge clk) clk=0;
begin rst=0;
if(rst) cs<=0; #5 rst=1;
else cs<=ns; #5 rst=0;
end end
always@* always #5 clk=~clk;
case(cs) initial
s0: if(in) begin ns=s1; out=0; end begin
else begin ns=s0; out=0; end #15 in=1;
s1: if(in) begin ns=s1; out=0; end #10 in=0;
MJCET Page 61
EDA LAB MANUAL ECE Department
RESULT:
i) Truth tables and waveforms of sequence detector using moore and mealy type
state machines are verified.
ii) Code is verified on FPGA board.
Exercise:
2. 8:1 MUX
3. 3:8 Decoder
4. 8: 3 Encoder
MJCET Page 62
EDA LAB MANUAL ECE Department
9. 1011 over lapping and non over lapping pattern mealy and moore
Tanner Tools
IC Flow Diagram
MJCET Page 63
EDA LAB MANUAL ECE Department
Experiments List
MJCET Page 64
EDA LAB MANUAL ECE Department
Excersise
5. Design the Schematic of CMOS Universal Gates using S-edit (Tanner tools)
6. Design the Schematic of CMOS AND using S-edit (Tanner tools)
7. Design the Schematic of CMOS OR using S-edit (Tanner tools)
8. Design the Schematic of CMOS Ex Nor gates using S-edit (Tanner tools)
9. Design the Schematic of CMOS Fulladder using S-edit (Tanner tools)
10. Design the Schematic of CMOS Half Substractor using S-edit (Tanner tools)
11. Design the Schematic of CMOS Full Substractor using S-edit (Tanner tools)
Aim:
MJCET Page 65
EDA LAB MANUAL ECE Department
Design the Schematic of CMOS Inverter using S-edit (Tanner tools), generate
the netlist and veifty the output waveform.
Software requirements:
Operating System : Xp Windows
Procedure:
1. Create Library with your name or roll no in S-edit, include the all.lib
(library)in same directory.
2. Click on Cell tab, create a New cell name (Ex: Inverter design), inside the
library you will design name as inverter.
3. Design the schmatic design of in iverter in S-edit, give the DC Voltage
source, Pulse Voltage, Print voltage input node and output node.
4. Click on T-spice ( )which generate the circuit netlist, pop up t-spice editor,
where you can include the model file and Analysis.
5. Click on run button ( ) which simulation will done and open the waveform
editor (W-edit)
Invertor schematic:
Netlist Of Inverter
MJCET Page 66
EDA LAB MANUAL ECE Department
.end
MJCET Page 67
EDA LAB MANUAL ECE Department
MJCET Page 68
EDA LAB MANUAL ECE Department
Aim:
Design the Schematic of CMOS Buffer using S-edit (Tanner tools), generate
the netlist and veifty the output waveform.
Software requirements:
Operating System : Xp Windows
Procedure:
1. Existing libraries you can design different cells, need to change the cell name
only.
2. Click on Cell tab, create a New cell name (Ex: Buffer design), inside the
library you will design name as Buffer.
3. Design the schmatic design of in iverter in S-edit, give the DC Voltage
source, Pulse Voltage, Print voltage input node and output node.
4. Click on T-spice ( )which generate the circuit netlist, pop up t-spice editor,
where you can include the model file and Analysis.
5. Click on run button ( ) which simulation will done and open the waveform
editor (W-edit)
Buffer:
MJCET Page 69
EDA LAB MANUAL ECE Department
Netlist
MJCET Page 70
EDA LAB MANUAL ECE Department
.end
MJCET Page 71
EDA LAB MANUAL ECE Department
Aim:
Design the Schematic of CMOS XOR Gate S-edit (Tanner tools), generate the
netlist and veifty the output waveform.
Software requirements:
Operating System : Xp Windows
Procedure:
1. Existing libraries you can design different cells, need to change the cell name
only.
2. Click on Cell tab, create a New cell name (Ex: Xor), inside the library you
will design name as Xor.
3. Design the schmatic design of in iverter in S-edit, give the DC Voltage
source, Pulse Voltage, Print voltage input node and output node.
4. Click on T-spice ( )which generate the circuit netlist, pop up t-spice editor,
where you can include the model file and Analysis.
MJCET Page 72
EDA LAB MANUAL ECE Department
5. Click on run button ( ) which simulation will done and open the waveform
editor (W-edit)
MJCET Page 73
EDA LAB MANUAL ECE Department
MNMOS_6 abar a Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_7 xorfinal xnor Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_1 bbar b Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_2 xnor abar N_9 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_1 bbar b N_2 N_1 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_2 N_5 abar N_4 N_3 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_3 N_4 b N_5 N_6 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_4 xnor a N_5 N_7 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_5 N_5 bbar xnor N_8 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_6 abar a N_12 N_11 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_7 xorfinal xnor N_14 N_13 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
VVoltageSource_1 N_2 Gnd DC 5
VVoltageSource_3 N_12 Gnd DC 5
VVoltageSource_4 N_4 Gnd DC 5
VVoltageSource_6 N_14 Gnd DC 5
VVoltageSource_2 b Gnd PULSE(0 5 0 5n 5n 95n 200n)
VVoltageSource_5 a Gnd PULSE(0 5 0 5n 5n 95n 200n)
.PRINT TRAN V(b)
.PRINT TRAN V(xnor)
.PRINT TRAN V(a)
.PRINT TRAN V(xorfinal)
********* Simulation Settings - Analysis section *********
.tran 1n 1000n
********* Simulation Settings - Additional SPICE commands *********
.end
Output of xor:
MJCET Page 74
EDA LAB MANUAL ECE Department
Excersie:
Assignment:
Aim:
MJCET Page 75
EDA LAB MANUAL ECE Department
Design the Schematic of CMOS Half Adder using S-edit (Tanner tools),
generate the netlist and veifty the output waveform.
Software requirements:
Procedure:
1. Existing libraries you can design different cells, need to change the cell name
only.
2. Click on Cell tab, create a New cell name (Ex: Halfadder design), inside the
library you will design name as Halfadder.
3. Design the schmatic design of in iverter in S-edit, give the DC Voltage
source, Pulse Voltage, Print voltage input node and output node.
4. Click on T-spice ( )which generate the circuit netlist, pop up t-spice editor,
where you can include the model file and Analysis.
5. Click on run button ( ) which simulation will done and open the waveform
editor (W-edit)
MJCET Page 76
EDA LAB MANUAL ECE Department
* Cell: ha
* View: view0
* Export as: top-level cell
* Export mode: hierarchical
* Exclude empty cells: yes
* Expand paths: yes
* Wrap lines: no
* Root path: C:\Documents and Settings\Admin\My Documents\Tanner EDA\Tanner Tools
v14.1\Libraries\All\invert
* Exclude global pins: no
* Control property name: SPICE
.lib "C:\Documents and Settings\Admin\My Documents\Tanner EDA\Tanner Tools
v14.1\Libraries\Models\Generic_025.lib" tt
********* Simulation Settings - Parameters and SPICE Options *********
*-------- Devices: SPICE.ORDER > 0 --------
MNMOS_3 N_7 a xnor 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_4 N_8 b Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_5 Gnd bbar N_7 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_6 abar a Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_7 sum xnor Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_8 o a N_19 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_9 Gnd b N_19 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_10 carry o Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_1 bbar b Gnd 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MNMOS_2 xnor abar N_8 0 NMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_10 carry o N_18 N_20 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_1 bbar b N_6 N_14 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_2 N_10 abar N_5 N_13 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_3 N_5 b N_10 N_12 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_4 xnor a N_10 N_11 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_5 N_10 bbar xnor N_9 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_6 abar a N_3 N_4 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_7 sum xnor N_1 N_2 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_8 o a N_16 N_15 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
MPMOS_9 N_16 b o N_17 PMOS W=2.5u L=250n AS=2.25p PS=6.8u AD=2.25p PD=6.8u
VVoltageSource_1 N_6 Gnd DC 5
VVoltageSource_3 N_3 Gnd DC 5
VVoltageSource_4 N_5 Gnd DC 5
VVoltageSource_6 N_1 Gnd DC 5
VVoltageSource_7 N_16 Gnd DC 5
MJCET Page 77
EDA LAB MANUAL ECE Department
WaveForm
MJCET Page 78
EDA LAB MANUAL ECE Department
Exercise:
1.Design the Schematic of CMOS Full Adder using S-edit (Tanner tools).
2. Design the Schematic of CMOS Full Substractor using S-edit (Tanner tools).
3. Design the Schematic of CMOS Half Substractor using S-edit (Tanner tools).
4. Design the Schematic of CMOS 4:1 Mux using S-edit (Tanner tools).
4. Design the Schematic of CMOS 2:4 Decoder using S-edit (Tanner tools).
APPENDIX
MJCET Page 79
EDA LAB MANUAL ECE Department
i. The number of experiments in each laboratory course shall be as per the curriculum in the
scheme of instructions provided by OU. Mostly the number of experiments is 10 in each
laboratory course under semester scheme and 18 under year wise scheme.
ii. The students will maintain a separate note book for observations in each laboratory
course.
iii. In each session the students will conduct the allotted experiment and enter the data in the
observation table.
iv. The students will then complete the calculations and obtain the results. The course
coordinator will certify the result in the same session.
v. The students will submit the record in the next class. The evaluation will be continuous
and not cycle-wise or at semester end.
vi. The internal marks of 25 are awarded in the following manner:
a. Laboratory record - Maximum Marks 15
b. Test and Viva Voce - Maximum Marks 10
vii. Laboratory Record: Each experimental record is evaluated for a score of 50. The rubric
parameters are as follows:
a. Write up format - Maximum Score 15
b. Experimentation Observations & Calculations - Maximum Score 20
c. Results and Graphs - Maximum Score 10
d. Discussion of results - Maximum Score 5
While (a), (c) and (d) are assessed at the time of record submission, (b) is assessed during the
session based on the observations and calculations. Hence if a student is absent for an experiment
but completes it in another session and subsequently submits the record, it shall be evaluated for
a score of 30 and not 50.
viii. The experiment evaluation rubric is therefore as follows:
MJCET Page 81
EDA LAB MANUAL ECE Department
ix. The first page of the record will contain the following title sheet:
10
11
12
x. The 15 marks of laboratory record will be scaled down from the TOTAL of the
assessment sheet.
xi. The test and viva voce will be scored for 10 marks as follows:
Internal Test - 6 marks
Viva Voce / Quiz - 4 marks
MJCET Page 82
EDA LAB MANUAL ECE Department
On successful completion of the course, the student will acquire the ability to:
1. Conduct experiments, take measurements and analyze the data through hands-on
experience in order to demonstrate understanding of the theoretical concepts of
_______________________, while working in small groups.
3. Employ graphics packages for drawing of graphs and use computational software for
statistical analysis of data.
4. Compare the experimental results with those introduced in lecture, draw relevant
conclusions and substantiate them satisfactorily.
xiii. The Course coordinators would prepare the assessment matrix in accordance with the
guidelines provided above for the five course outcomes. The scores to be entered against
each of the course outcome would be the sum of the following as obtained from the
assessment sheet in the record:
xiv. Soft copy of the assessment matrix would be provided to the course coordinators.
MJCET Page 83
EDA LAB MANUAL ECE Department
PO2: Problem analysis: Identify, formulate, research literature, and analyse complex engineering problems reaching
substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences
PO3: Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health and
safety, and the cultural, societal, and environmental considerations.
PO4: Conduct investigations of complex problems: Use research-based knowledge and research methods including
design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid
conclusions.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and
IT tools including prediction and modeling to complex engineering activities with an understanding of the
limitations.
PO6: The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health,
safety, legal, and cultural issues and the consequent responsibilities relevant to the professional engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional engineering solutions in societal
and environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
PO9: Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams,
and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one‟s own work, as a member and leader in a team, to manage projects
and in multidisciplinary environments.
PO 12: Life-long learning: Recognise the need for, and have the preparation and ability to engage in independent
and life-long learning in the broadest context of technological change.
MJCET Page 84
EDA LAB MANUAL ECE Department
PSO2: The ECE Graduates will develop preliminary skills and capabilities necessary for embedded system design
and demonstrate understanding of its societal impact.
PSO3: The ECE Graduates will obtain the knowledge of the working principles of modern communication systems
and be able to develop simulation models of components of a communication system.
PSO4: The ECE Graduates will develop soft skills, aptitude and programming skills to be employable in IT sector.
MJCET Page 85