SlideShare a Scribd company logo
Ex. No: 2 DESIGN AND SIMULATION OF SEQUENTIAL CIRCUITS
USING VERILOG HDL
AIM:
To design the following sequential circuits and simulate them by creating the test benches
•Counter
•PRBS Generator
•Accumulator
SOFTWARE REQUIRED:
•Xilinx 13.4 ISE– A project navigator software tool
PROCEDURE:
•Double click Xilinx ISE Design Suite 13.4 on the desktop or Go to Start–> All programs
–>Xilinx ISE Design Suite 13.4->ISE Design tools.
•Click on File –> New project. A new project wizard will open. Type the name of the project
and select the location. The top-level source type should be selected as HDL. Click next.
•A new project wizard opens.
Product category :All
Family :Spartan 6
Device :XC6SLX45
Package :CSG324
Speed :-2
Top-level source type :HDL
Synthesis tool :XST(VHDL/Verilog)
Simulator :Isim(VHDL/Verilog)
Preferred language :Verilog
•Click next–>finish–>Right click on the project name shown in hierarchy and select new
source.
•New source wizard open. Select Verilog module and give program name as the file name
and click next and finish.
•Write the program and save it.
•In the process tab click on ‘+’ sign of synthesis and double click on check syntax.
•In the hierarchy tab right click on the program and select new source.
•In the opened new source wizard select Verilog test fixture and then give file name and click
next and select the associate source and click next and then finish.
•Write the test bench code save it and select the simulation in design tab.
•Select the test bench file in hierarchy tab and in process tab click on ‘+’ sign of Isim
simulator and double click on simulate behavioral model .The waveform displays.
•Save the waveform.
VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
CODING:
Date: a) COUNTER
Verilog Code:
module counter(clk,reset,count);
input clk,reset;
output [3:0] count;
wire clk,reset;
reg [3:0] count;
always @ (posedge clk)
begin
if(!reset)
count=4'b0000;
else
count=count+4'b1;
end
endmodule
Testbench:
module countertb;
// Inputs
reg clk;
reg reset;
// Outputs
wire [3:0] count;
// Instantiate the Unit Under Test (UUT)
counter uut (
.clk(clk),
.reset(reset),
.count(count)
);
initial begin
$display("timet clk reset count");
$display("%gt %b %b %b %b",$time,clk,reset,count);
// Initialize Inputs
clk=1;
#50 reset=1;
#70 reset=0;
#50 reset=1;
#50 $finish;
end
always
VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
begin
#10 clk=~clk;
end
endmodule
Waveform:
Date: b) PRBS GENERATOR
Verilog Code:
module prbs(rand,clk,reset);
input clk,reset;
output rand;
reg [3:0] temp;
always @ (posedge reset)
begin
temp=4'hF;
end
always @(posedge clk)
begin
if(~reset)
begin
temp<={temp[0]^temp[1],temp[2],temp[3]};
end
end
assign rand=temp[0];
endmodule
VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
Testbench:
module prbstb;
// Inputs
reg clk;
reg reset;
// Outputs
wire rand;
// Instantiate the Unit Under Test (UUT)
prbs uut (
.rand(rand),
.clk(clk),
.reset(reset)
);
initial
forever
begin
// Initialize Inputs
clk = 0;
#20 clk=1;
#20 clk=0;
end
initial
forever
begin
// Initialize Inputs
reset = 0;
#80 reset=1;
#50 reset=0;
end
endmodule
Waveform:
VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
Date: c) ACCUMULATOR
Verilog Code:
module accu (in, acc, clk, reset);
input [7:0] in;
input clk, reset;
output [7:0] acc;
reg [7:0] acc;
always@(posedge clk)
begin
if(reset) acc<= 0;
else acc<=acc+in;
end
endmodule
Testbench:
module accu_tb;
reg clk, reset;
reg [7:0] in;
wire [7:0] out;
accu accu1(in, out, clk, reset);
initial
begin
clk =1'b0;
forever
begin
#5 clk = ~clk;
end
end
initial
begin
#50 $finish;
end
initial
begin
#10 reset<=1;
in<=1;
#10 reset<=0;
#10 reset<=1;
in<=4;
#10 reset<=1;
in<=3;
#10 reset<=0;
#10 reset<=1;
end
VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
endmodule
Waveform:
RESULT:
The Verilog code for sequential circuits were designed, simulated and waveforms were
generated using test bench.
VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE

More Related Content

What's hot

Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
Rkrishna Mishra
 
Vlsi lab
Vlsi labVlsi lab
Vlsi lab
Hendrick Rick
 
ECAD lab manual
ECAD lab manualECAD lab manual
ECAD lab manual
Dr. Swaminathan Kathirvel
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
Mukul Mohal
 
VLSI lab manual Part B, VTU 7the sem KIT-tiptur
VLSI lab manual Part B, VTU 7the sem KIT-tipturVLSI lab manual Part B, VTU 7the sem KIT-tiptur
VLSI lab manual Part B, VTU 7the sem KIT-tiptur
Pramod Kumar S
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
Archita Misra
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
Amairullah Khan Lodhi
 
Vhdl programming
Vhdl programmingVhdl programming
Vhdl programming
Yogesh Mashalkar
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
Ricardo Castro
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteProcessor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
DVClub
 
VHDL Programs
VHDL ProgramsVHDL Programs
VHDL Programs
A B Shinde
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
Soumya Behera
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
Jinesh Kb
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
Ramesh Naik Bhukya
 
VHDL CODES
VHDL CODES VHDL CODES
VHDL CODES
OmkarDarekar6
 
VTU ECE 7th sem VLSI lab manual
VTU ECE 7th sem VLSI lab manualVTU ECE 7th sem VLSI lab manual
VTU ECE 7th sem VLSI lab manual
Maharaja Institute of Technology Mysore
 
Virtual platform
Virtual platformVirtual platform
Virtual platform
sean chen
 
Verilator: Fast, Free, But for Me?
Verilator: Fast, Free, But for Me? Verilator: Fast, Free, But for Me?
Verilator: Fast, Free, But for Me?
DVClub
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
Santhosh Poralu
 

What's hot (20)

Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
Vlsi lab
Vlsi labVlsi lab
Vlsi lab
 
ECAD lab manual
ECAD lab manualECAD lab manual
ECAD lab manual
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
 
VLSI lab manual Part B, VTU 7the sem KIT-tiptur
VLSI lab manual Part B, VTU 7the sem KIT-tipturVLSI lab manual Part B, VTU 7the sem KIT-tiptur
VLSI lab manual Part B, VTU 7the sem KIT-tiptur
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
Vhdl programming
Vhdl programmingVhdl programming
Vhdl programming
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteProcessor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
 
VHDL Programs
VHDL ProgramsVHDL Programs
VHDL Programs
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
 
VHDL CODES
VHDL CODES VHDL CODES
VHDL CODES
 
VTU ECE 7th sem VLSI lab manual
VTU ECE 7th sem VLSI lab manualVTU ECE 7th sem VLSI lab manual
VTU ECE 7th sem VLSI lab manual
 
Virtual platform
Virtual platformVirtual platform
Virtual platform
 
Verilator: Fast, Free, But for Me?
Verilator: Fast, Free, But for Me? Verilator: Fast, Free, But for Me?
Verilator: Fast, Free, But for Me?
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
 

Similar to Vlsi lab manual exp:2

Ecad final
Ecad finalEcad final
Ecad final
Srinivas Sri
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
gopikahari7
 
Cadence SImulation
Cadence SImulationCadence SImulation
Cadence SImulation
RajaSekar K
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
George Papaioannou
 
Vhdl design flow
Vhdl design flowVhdl design flow
Vhdl design flow
Rohit Chintu
 
Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDEIntroduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
Pantech ProLabs India Pvt Ltd
 
ASIC design verification
ASIC design verificationASIC design verification
ASIC design verification
Gireesh Kallihal
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
Roman Elizarov
 
Added value of SimWare
Added value of SimWareAdded value of SimWare
Added value of SimWare
José Ramón Martínez Salio
 
Stoop 390-instruction stream
Stoop 390-instruction streamStoop 390-instruction stream
Stoop 390-instruction stream
The World of Smalltalk
 
Mentor manual
Mentor manualMentor manual
Mentor manual
basavaraju ramaduragam
 
Advance Computer Architecture
Advance Computer ArchitectureAdvance Computer Architecture
Advance Computer Architecture
Vrushali Lanjewar
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
Kenneth Geisshirt
 
Advanced System Security and Digital Forensics
Advanced System Security and Digital ForensicsAdvanced System Security and Digital Forensics
Advanced System Security and Digital Forensics
Dr. Ramchandra Mangrulkar
 
Internet of Things exercise on IBM Bluemix
Internet of Things exercise on IBM BluemixInternet of Things exercise on IBM Bluemix
Internet of Things exercise on IBM Bluemix
LennartF
 
Verilog overview
Verilog overviewVerilog overview
Verilog overview
posdege
 
A Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLA Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQL
Databricks
 
OpenCL Programming 101
OpenCL Programming 101OpenCL Programming 101
OpenCL Programming 101
Yoss Cohen
 
Week1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin
敬倫 林
 
Testing: ¿what, how, why?
Testing: ¿what, how, why?Testing: ¿what, how, why?
Testing: ¿what, how, why?
David Rodenas
 

Similar to Vlsi lab manual exp:2 (20)

Ecad final
Ecad finalEcad final
Ecad final
 
MattsonTutorialSC14.pptx
MattsonTutorialSC14.pptxMattsonTutorialSC14.pptx
MattsonTutorialSC14.pptx
 
Cadence SImulation
Cadence SImulationCadence SImulation
Cadence SImulation
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
Vhdl design flow
Vhdl design flowVhdl design flow
Vhdl design flow
 
Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDEIntroduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
Introduction to Microchip-SIMULINK Blocksets and MATLAB Plug-in for MPLAB® IDE
 
ASIC design verification
ASIC design verificationASIC design verification
ASIC design verification
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Added value of SimWare
Added value of SimWareAdded value of SimWare
Added value of SimWare
 
Stoop 390-instruction stream
Stoop 390-instruction streamStoop 390-instruction stream
Stoop 390-instruction stream
 
Mentor manual
Mentor manualMentor manual
Mentor manual
 
Advance Computer Architecture
Advance Computer ArchitectureAdvance Computer Architecture
Advance Computer Architecture
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
Advanced System Security and Digital Forensics
Advanced System Security and Digital ForensicsAdvanced System Security and Digital Forensics
Advanced System Security and Digital Forensics
 
Internet of Things exercise on IBM Bluemix
Internet of Things exercise on IBM BluemixInternet of Things exercise on IBM Bluemix
Internet of Things exercise on IBM Bluemix
 
Verilog overview
Verilog overviewVerilog overview
Verilog overview
 
A Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLA Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQL
 
OpenCL Programming 101
OpenCL Programming 101OpenCL Programming 101
OpenCL Programming 101
 
Week1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin
 
Testing: ¿what, how, why?
Testing: ¿what, how, why?Testing: ¿what, how, why?
Testing: ¿what, how, why?
 

Vlsi lab manual exp:2

  • 1. Ex. No: 2 DESIGN AND SIMULATION OF SEQUENTIAL CIRCUITS USING VERILOG HDL AIM: To design the following sequential circuits and simulate them by creating the test benches •Counter •PRBS Generator •Accumulator SOFTWARE REQUIRED: •Xilinx 13.4 ISE– A project navigator software tool PROCEDURE: •Double click Xilinx ISE Design Suite 13.4 on the desktop or Go to Start–> All programs –>Xilinx ISE Design Suite 13.4->ISE Design tools. •Click on File –> New project. A new project wizard will open. Type the name of the project and select the location. The top-level source type should be selected as HDL. Click next. •A new project wizard opens. Product category :All Family :Spartan 6 Device :XC6SLX45 Package :CSG324 Speed :-2 Top-level source type :HDL Synthesis tool :XST(VHDL/Verilog) Simulator :Isim(VHDL/Verilog) Preferred language :Verilog •Click next–>finish–>Right click on the project name shown in hierarchy and select new source. •New source wizard open. Select Verilog module and give program name as the file name and click next and finish. •Write the program and save it. •In the process tab click on ‘+’ sign of synthesis and double click on check syntax. •In the hierarchy tab right click on the program and select new source. •In the opened new source wizard select Verilog test fixture and then give file name and click next and select the associate source and click next and then finish. •Write the test bench code save it and select the simulation in design tab. •Select the test bench file in hierarchy tab and in process tab click on ‘+’ sign of Isim simulator and double click on simulate behavioral model .The waveform displays. •Save the waveform. VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
  • 2. CODING: Date: a) COUNTER Verilog Code: module counter(clk,reset,count); input clk,reset; output [3:0] count; wire clk,reset; reg [3:0] count; always @ (posedge clk) begin if(!reset) count=4'b0000; else count=count+4'b1; end endmodule Testbench: module countertb; // Inputs reg clk; reg reset; // Outputs wire [3:0] count; // Instantiate the Unit Under Test (UUT) counter uut ( .clk(clk), .reset(reset), .count(count) ); initial begin $display("timet clk reset count"); $display("%gt %b %b %b %b",$time,clk,reset,count); // Initialize Inputs clk=1; #50 reset=1; #70 reset=0; #50 reset=1; #50 $finish; end always VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
  • 3. begin #10 clk=~clk; end endmodule Waveform: Date: b) PRBS GENERATOR Verilog Code: module prbs(rand,clk,reset); input clk,reset; output rand; reg [3:0] temp; always @ (posedge reset) begin temp=4'hF; end always @(posedge clk) begin if(~reset) begin temp<={temp[0]^temp[1],temp[2],temp[3]}; end end assign rand=temp[0]; endmodule VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
  • 4. Testbench: module prbstb; // Inputs reg clk; reg reset; // Outputs wire rand; // Instantiate the Unit Under Test (UUT) prbs uut ( .rand(rand), .clk(clk), .reset(reset) ); initial forever begin // Initialize Inputs clk = 0; #20 clk=1; #20 clk=0; end initial forever begin // Initialize Inputs reset = 0; #80 reset=1; #50 reset=0; end endmodule Waveform: VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
  • 5. Date: c) ACCUMULATOR Verilog Code: module accu (in, acc, clk, reset); input [7:0] in; input clk, reset; output [7:0] acc; reg [7:0] acc; always@(posedge clk) begin if(reset) acc<= 0; else acc<=acc+in; end endmodule Testbench: module accu_tb; reg clk, reset; reg [7:0] in; wire [7:0] out; accu accu1(in, out, clk, reset); initial begin clk =1'b0; forever begin #5 clk = ~clk; end end initial begin #50 $finish; end initial begin #10 reset<=1; in<=1; #10 reset<=0; #10 reset<=1; in<=4; #10 reset<=1; in<=3; #10 reset<=0; #10 reset<=1; end VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE
  • 6. endmodule Waveform: RESULT: The Verilog code for sequential circuits were designed, simulated and waveforms were generated using test bench. VLSI Lab Manual, Prepared by Komala Vani Challa, AP/ECE, VVCOE