VLSI Lab Manual
VLSI Lab Manual
Technologies
9 Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings
12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change
LEARNING OUTCOMES:
● Students will be able to design digital circuits/systems through a Hardware descriptive
language.
● Students will be able to use CAD tools (IDE) to design and analyze digital systems.
● Students will be familiar with the Logic synthesis, Simulation and verification of digital
circuits and implementation of FPGA Device.
● Students will be familiar Scaling of CMOS Inverter for different technologies, study of
secondary effects
● students will understand the Circuit optimization with respect to area, performance
and/or power, Layout, Extraction of parasitic and back annotation, modifications in circuit
parameters and layout consumption, DC/transient analysis, Verification of layouts (DRC, LVS)
Check the system before starting doing the programme and close the project before shutting
down the systems.
Do not touch the FPGA at any cost and don’t turn on the FPGA board before connecting to the
system with the JTAG Port.
INSTRUCTIONS TO STUDENTS:
● Students are expected to attend the lab sessions well dressed in formals.
● Write records neatly and legibly and maintain the same updated.
● Observation books should be submitted to the faculty concerned in the same lab
session for verification and signature.
● Observations should be posted in the records and the same should be brought for
correction as soon as the lab experiment is done, generally for the next lab session.
● Students should ensure that they sign the attendance register available in the lab.
● Cooperate with the teachers and the lab faculty.
SOFTWARE REQUIREMENTS:
1. Xilinx Vivado System edition IDE 2018.1 version Synthesis and Simulation Tools.
2. Mentor Graphics HEP1 (Layout Editor) Software.
HARDWARE REQUIREMENTS:
Design and implementation of the following CMOS digital/analog circuits using Cadence /
Mentor Graphics / Synopsys /Equivalent CAD tools. The design shall include Gate-level
design, Transistor- level design, Hierarchical design, Verilog HDL/VHDL design, Logic
synthesis, Simulation and verification, Scaling of CMOS Inverter for different technologies,
study of secondary effects ( temperature, power supply and process corners), Circuit
optimization with respect to area,
performance and/or power, Layout, Extraction of parasitics and back annotation, modifications
in circuit parameters and layout consumption, DC/transient analysis, Verification of layouts
(DRC, LVS
programs:
Programming can be done using any compiler. Download the programs on FPGA/CPLD
boards and performance testing may be done using pattern generator (32 channels) and logic
analyzer apart from verification by simulation with any of the front end tools.
VLSI programs:
● Introduction to layout design rules. Layout, physical verification, placement & route for
complex design, static timing analysis, IR drop analysis and crosstalk analysis of the following:
Note: Any SIX of the above experiments from each part are to be conducted (Total
12)
CONTENTS
5 Aim
.
1
5 Software & Hardware
. 5.2.1 Xilinx vivado 2018.1 version
2 5.2.2 Fpga-zynq board xc7z020clg484-1
5.2.3 Jumper cable with power supply
5 Code converter truth table
.
3
5 Logic diagram binary to gray
.
4
5 Verilog code for binary to gray code conversion
. 5.5.1 Structural Model
5 5.5.2 Dataflow Model
5.5.3 Behavioral Model
5.5.3.1 Behavioral Model-01
5.5.3.2 Behavioral Model-02
5.5.3.3 Behavioral Model-03
5 Test Bench Code
.
6
5 Simulation output Waveform window
.
7
5 Result
.
8
Lab 6: 4-BIT COMPARATOR
6 Aim
.
1
6 Software & Hardware
. 6.2.1 Xilinx vivado 2018.1 version
2 6.2.2 Fpga-zynq board xc7z020clg484-1
6.2.3 Jumper cable with power supply
6 4-bit comparator block diagram
.
3
6 4-bit comparator logic diagram
.
4
6 4-bit comparator truth table
.
5
6 Verilog source code
. 6.6.1 Structural Model
6 6.6.2 Dataflow Model
6.6.2.1 Dataflow Model-01
6.6.2.2 Dataflow Model-02
6.6.3 Behavioral Model
6 Test Bench Code
.
7
6 Simulation output Waveform window
.
8
6 Result
.
9
7 Aim
.
1
7 Software & Hardware
. 7.2.1 Xilinx vivado 2018.1 version
2 7.2.2 Fpga-zynq board xc7z020clg484-1
7.2.3 Jumper cable with power supply
7 Full Adder Block Diagram
.
3
7.4 Logic Diagram
7.5 Truth Table
7.6 Verilog Source Code
7.6.1 Structural Model
7.6.2 Dataflow Model
7.6.2.1 Dataflow Model-01
7.6.2.2 Dataflow Model-02
7.6.3 Behavioral Model
7.7 Test Bench Code
7.8 Simulation output Waveform window
7.9 Result
9.1 Aim
9.2 Software & Hardware
9.2.1 Xilinx vivado 2018.1 version
9.2.2 Fpga-zynq board xc7z020clg484-1
9.2.3 Jumper cable with power supply
9.3 bit Binary counter diagram
9.3.3 Simulation
9.4.3 Simulation
9.5 Result
10.1 Aim
10.3.3 Simulation
10.4 Result
The goal of this guide is to familiarize the reader with the Vivado tools through the hello world
of hardware, blinking an LED.
1. Starting Vivado
Linux
Open a terminal, cd into a working directory that can be cluttered with temporary Vivado files
and logs, then run the following:
source <install_path>/Vivado/<version>/settings64.sh && vivado
3.2
The text in this dialog describes the steps that will be taken to create a project. Click Next to
continue to the first step.
3.3
The first step is to set the name of the project. Vivado will use this name when generating its
folder structure.
Important
Do NOT use spaces in your project name or location path. This will cause problems with
Vivado. Instead use an underscore, a dash, or CamelCase. Click Next to continue.
3.4
Now that the project has a name and a place to save its files we need to select the type of
project we will be creating. Select RTL Project and make sure to check Do not specify sources
at this time. Source files will be added and created after the project has been created. Advanced
users may use the other options on this screen, but they will not be covered in this guide.
Click Next to continue.
3.5
Important
If your board does not appear in this list, then Digilent's board files haven't yet been installed. If
this is the case, revisit the prerequisites section of this guide, then close Vivado and start again
from the beginning
Now it is time to choose the target device. Click the Boards tab at the top of the dialog, then
select your board from the list.
● Allows for quick access to project settings, adding sources, language templates, and the IP
catalog
● IP Integrator
● Simulation
● Allows a developer to verify the output of their deisgn prior to programming their device
● RTL Analysis
● lets the developer see how the tools are interpreting their code
● Synthesis
The Project Manager consists of four panes, Sources, Properties, Results, and the Workspace.
The Sources pane contains the project hierarchy and is used for opening up files. The folder
structure is organized such that the HDL files are kept under the Design Sources folder,
constraints are kept under the Constraints folder, and simulation files are kept under the
Simulation Sources folder. Files can be opened in the Workspace by double-clicking on the
corresponding entry in the Sources pane. Sources can also be added by either right clicking the
folder to add the file to and selecting Add Sources or by clicking the Add Sources button ( ).
The Properties pane allows for viewing and editing of file properties. When a file is selected in
the Sources pane its properties are shown here. This pane can usually be ignored.
The unnamed pane at the bottom of the Project Manager window consists of several
different useful tools for debugging a project. The most important one to know is the
Messages tool. This tool parses the Tcl console for errors, warnings, and other important
information and displays it in an informative way.
These tools can be accessed by selecting the different tabs at the bottom of this pane.
The Tcl Console is a tool that allows for running commands directly without the use of the
main user interface. Some messages may link to the Tcl Console to provide more
information regarding an error.
The Reports tool is useful for quickly jumping to any one of the many reports that Vivado
generates on a design. These reports include power, timing, and utilization just to name a
few.
The Log displays the output from the latest Synthesis, Implementation, and Simulation
runs. Digging into this is usually not necessary as the reports and messages view store the
information in the log in a more readable format.
The last tool is the Design Runs. Using this tool run settings can be edited and new runs
can be created. This tool is useful when targeting multiple devices with the same design.
The most important pane in the Project Manager is the Workspace. The Workspace is
where reports are opened for viewing and HDL/constraints files are opened for editing.
Initially the Workspace displays the Project Summary which show some basic information
from some of the reports.
6. Adding a Constraint File
In order to connect HDL code with the physical pins of the FPGA, a constraint file needs to
be added or created. Digilent has produced a Xilinx Design Constraint (XDC) file for each
of our boards. Download the ZIP Archive containing each of these master XDC files, then
extract it in a location you will remember.
6.1
In the Project Manager section of the Flow Navigator, click the button. In the
wizard that pops up, select Add or create constraints then click Next.
6.2
At this stage, Vivado provides a list of all of the constraint files that will be added or
created when we click Finish. Currently this list is empty, this will change when files have
been added or created. A constraint file will not be created from scratch in this guide, so
click Add Files.
6.3
Find the directory you extracted the digilent-xdc-master.zip archive into, then click on the
file for your board. This should add the name of the file to the File Name field.
Click OK to continue.
6.4
Make sure that the selected XDC file has been added into the list of sources, then click
Finish.
6.5
In the Sources pane of the Project Manager, expand the Constraints folder, then double
click on the XDC file you just added. Each of Digilent's XDC files contains constraints for
each of the commonly used peripherals on their respective boards. For this demo,
constraining the default system clock and a single led is required.
Find and uncomment the lines that call get_ports on the names led[0] and clk by removing
the '#' symbol at the beginning of the line. On some boards the clock port will consist of
two different ports, clk_p and clk_n. The clock port is occasionally named something like
sysclk, but should appear at the top of the XDC file. Uncomment the create_clock line that
follows the clock port/s definition as well.
Tip
A board using clk_p/clk_n pins means that the input clock that uses differential logic. If
you want to know more read this article on low-voltage differential signalling.
Change the name inside of the get_ports call to 'led' from 'led[0]'. Do the same for the
clock if it is something other than 'clk' or 'clk_p' and 'clk_n'.
7. Creating a Verilog Source File
7.1
In the Project Manager section of the Flow Navigator, click the button again.
Select Add or create design sources then click Next.
7.2
As before, at this stage, we will be provided a list of all of the source files that will be added
or created when we click Finish. Instead of clicking Add Files, click Create File.
Tip
It is also possible to add existing source files in the same way as we added the constraint
file above.
7.3
You will be prompted to select a File type, File name, and File location. Make sure to pick
Verilog and
<Local to project> for the type and location. Give your file a name ending in '.v'.
Important
Do NOT use spaces in your file name. This will cause problems with Vivado. Instead use an
underscore, a dash, or CamelCase.
Click OK to continue.
7.4
Make sure that the new Verilog source file has been added into the list of sources, then click
Finish.
7.5
Unlike when the constraint file was added, at this point a Define Module dialog will pop up.
You can rename your Verilog module using the Module name field, but this is unnecessary.
The Verilog module's clock and led ports need to be defined. Clicking the Add ( ) button
will add an empty slot for a port to the I/O Port Definitions list.
There are five fields to define for each of the module's I/O ports:
● Port Name: This field defines the name of the port and needs to match one of the names
you used in your XDC file.
● Direction: This drop-down menu can be set to input, output, or inout, defining the
direction that signals propagate through this port, with respect to your module. Outputs are the
signals that your module will be controlling.
● Bus: This can be checked or not, when checked, this port consists of multiple single bit
signals,
grouped into a single bus.
● MSB: The index of the most significant bit of the port, if it is a bus. This option is grayed
out for single- bit ports.
● LSB: The index of the least significant bit of the port, if it is a bus. This option is grayed out
for single- bit ports.
Tip
If you are defining a module which will be instantiated in another module, which we will
not go into in this guide, be aware that the port names should not be declared in the XDC,
this is only done for your 'top' module.
If your board uses differential clocking, add two single-bit input ports with the same
names as the positive and negative clock ports that were uncommented in your XDC file.
Otherwise, add a single single-bit input port with the same name as the clock port that
was uncommented in your XDC file. Add a single-bit output port with the same name as
the LED port that was uncommented in your XDC file.
Once these two or three ports have been added, click OK to continue.
7.6
At this point, the new source file will be added to the Design Sources folder in the Sources
pane of the
Project Manager. Expand this folder and double click on the file to open it.
Next, some Verilog code needs to be written to define how the design will actually
behave.Between the ');' that comes after the module's port list and the 'endmodule'
statement, add the following code:
reg
[24:0]
count =
0;
assign
led =
count[2
4];
IBUFGDS clk_inst (
.O(clk),
.I(clk_p),
.IB(clk_n)
);
It should be noted that the rate at which the clock will blink will differ depending on the
board used. System clocks on different Digilent boards run at a number of different rates,
depending on the needs of the board. The system clock period in nanoseconds can be
found on the create_clock line of the XDC file.
Click Finish
A Test Fixture does not need any inputs and outputs so just click OK.
Click Yes, the text fixture file is added to the simulation sources:
Open up the nearly created comb.tf file and add the following Verilog statements to instantiate a
copy of the comb module and create a simple test fixture:
Click save and you will the Simulation Sources hierarchy is now updated:
In the Flow navigator select Simulation Settings and verify the Simulation top module name
is comb_tf:
In the Flow Navigator select Run Simulation => Run Behavioral
Simulation A simulation window will open.
Select the Zoom Fit option on the left and you will see the simulation results:
You can visually check the j and k outputs and verify they match the truth table.
RTL Analysis
Open Elaborated Design
Now click on “Open Elaborated Design” under the RTL Analysis phase of the Flow Navigator.
You may also get the information popup shown, if so simply click the “OK” button. Vivado
will do a little work and then open the Elaborated Design.
Notice that now the “RTL Analysis” phase is highlighted in the Flow Navigator and the header
next to it has changed from “Project Manager” to “Elaborated Design” to indicate you have
that stage of the design open and the windows you see pertain to it. If you click back and forth
between the “Project Manager” and “RTL Analysis” phases of the Flow Navigator you will see
the header and windows change accordingly.
View Schematic
You can click “Schematic” underneath the RTL Analysis phase in the Flow Navigator to open
a tab that displays a schematic representation of the previously written VHDL.
Device Pin Assignment
With the Elaborated Design open you can now do your actual programmable logic device pin
assignments. Select the “I/O Planning” view from the drop-down in the top bar if it isn’t
already, then make sure you are viewing the “I/O Ports” tab at the bottom and click to expand
and view all the available ports.
The port names and directions match the previously entered VERILOG HDL code. You have
to type in or select from each drop-down a “Site” for each to give it a valid physical pin
assignment of your programmable logic device. You similarly need to assign the appropriate
“I/O Std” to match your board’s supplied I/O bank power rail for each selected pin.
For those following along with the Basys 3 board, the pin “Site” assignments shown for each
port will match the silkscreen on your board for convenience, and all the “I/O Std” selections
should be “LVCMOS33”.
Once everything is properly entered, select File -> Save Constraints from the Vivado top drop-
down
menu.
If you get the “Bitstream Generation Completed” popup shown, select the “Open Hardware
Manager” radial and click the “OK” button. If not you can instead click “Open Hardware
Manager” under the Program and Debug phase of the Flow Navigator after bitstream
generation completes.
Open Targetow click “Open Target” under the Program and Debug phase of the Flow
Navigator and then “Open New Target…” from the menu that appears. You will need to have
already connected your JTAG programmer and/or development board to your computer,
powered it on, and installed any necessary drivers to continue.
The Open New Hardware Target wizard will launch, click the “Next >” button to proceed.
Select “Local server (target is on local machine)” from the drop-down if it isn’t already, and
then click the “Next >” button to proceed. Vivado will work for a moment to find any valid
target devices connected to your local machine.
If all goes well you will see something like what’s shown here matching your specific
hardware. Select your specific JTAG hardware target and programmable logic device and click
the “Next >” button. Note that you have the option to change the “JTAG Clock Frequency”, but
it’s reasonable to start with the default setting and only make adjustments later if necessary.
Click the “Finish” button and Vivado will attempt to connect to your specified hardware.
Program Device
Now click “Program Device” under the Program and Debug phase of the Flow Navigator and
then your specific device from the menu that appears.
The “Program Device” popup that appears should have the file path to the bitstream file you
generated automatically filled in. Select the “Enable end of startup check” check-box if it isn’t
already and then click the “Program” button. Vivado will work for a moment, but if successful,
when everything is finished your device should be programmed and ready for you to verify its
proper behavior.
For those following along with the Basys 3, toggle switches SW0-SW2 and verify the
previously described correct behavior of LEDs LD0-LD2.
The Bitstream File field should be automatically filled in with the bit file generated earlier. If
not, click the button at the right end of the field and navigate to
<Project Directory>/<Project Name>.runs/impl_1/ and select the bit file (Example: ).
Now click Program. This will connect to the board, clear the current configuration, and
program using the new bit file.
COMMON PROCEDURE
1. Create New project and type the project name and check the top level source type as
HDL
2. Enter the device properties and click Next
3. Click New Source And Select the Verilog Module and then give the file name
4. Give the Input and Output port names and click finish.
5. Type the Verilog program check syntax and save it
6. Double click the synthesize and generate report
7. Generate a test bench file and observe the waveform by simulation run behavioral
simulation
8. For implementation Select XDC design constraints and give input and output port pin
number
9. Click Implement design for Translate, map and place & route
10. Generate .bit file using programming file
11. Implement in FPGA through parallel-JTAG cable
12. Check the behavior of design in FPGA by giving inputs
EXP 1:HDL CODE TO REALIZE ALL THE LOGIC GATES
1.1 AIM:
To develop the source code for logic gates by using VERILOG and obtain the simulation.
NAND GATE:
LOGIC DIAGRAM: TRUTH TABLE:
A B Y=AB
0 0 1
0 1 1
1 0 1
1 1 0
OR GATE:
LOGIC DIAGRAM: TRUTH TABLE:
A B Y=AB
0 0 0
0 1 1
1 0 1
1 1 1
NOR GATE:
LOGIC DIAGRAM: TRUTH TABLE:
A B Y=AB
0 0 1
0 1 0
1 0 0
1 1 0
NOT GATE:
LOGIC DIAGRAM: TRUTH TABLE:
A ~A
0 1
1 0
XOR GATE:
LOGIC DIAGRAM: TRUTH TABLE:
A B Y=A⊕B
0 0 0
0 1 1
1 0 1
1 1 0
XNOR GATE:
LOGIC DIAGRAM: TRUTH TABLE:
A B Y=A⊙B
0 0 1
0 1 0
1 0 0
1 1 1
1.3.1 Black Box
LOGIC GATES
AND GATE :
module andgate(a,b);
input [1:0] a;
output reg b;
always@(a)
begin
case(a)
2'b11:b=1'b1;
default:b=1'b0;
endcase
end
endmodule
OR GATE :
module orgate(a,b);
output reg b;
always@(a)
begin
case(a)
2'b00:b=1'b0;
default:b=1'b1;
endcase
end
endmodule
module gates_tb;
wire [6:0]c;
reg a, b;
initial begin
a = 1'b0;
b = 1'b0;
#100;a = 1'b0;
b = 1'b1;
#100;a = 1'b1;
b = 1'b0;
#100;
a = 1'b1; b = 1'b1;
end
endmodule
1.7 Simulation output Waveform window: Displays output waveform for verification.
1.8 RESULT:
Thus the OUTPUT’s of all logic gates are verified by simulating the VERILOG code.
module Test_decoder_2to4;
reg A, B;
reg en;
A = 1'b0;
// time = 0 B = 1'b0;
en = 1'b0; #9;
en = 1'b1;
// time = 10 #10;
A = 1'b0;
B = 1'b1;
// time = 20 #10;
A = 1'b1;B = 1'b0;
// time = 30
// time = 40
#5;
en = 1'b0;
// time = 45
#5;
end
endmodule
2.6 Simulation Output Waveform window: Displays output waveform for verification.
2.7 RESULT:
Thus the OUTPUT of 2 to 4 decoders is verified by simulating the VERILOG HDL code.
EXP 3: DESIGN OF 8-TO-3 ENCODER (WITHOUT AND WITH
PRIORITY)
3.1 AIM: To develop the source code for 8-to-3 encoder (without and with priority) by using
VERILOG and obtain the simulation.
3.7 Testbench:
module prio_enco_8x3_tst; reg [7:0] d_in;
wire[2:0] d_out;
prio_enco_8x3 u1 (.d_out(d_out), .d_in(d_in) )
initial
begin
#10
d_in=8'b11001100; ;
#10
d_in=8'b01100110; ;
#10;
d_in=8'b00110011;
#10
d_in=8'b00010010;
;
#10
d_in=8'b00001001; ;
#10
d_in=8'b00000100; ;
d_in=8'b0000001 #10
1; ;
d_in=8'b00000001 #10
; ;
d_in=8'b00000000 #
; 10;
$stop;
end // initial begin
3.8 Simulation output: Waveform window: Displays output waveform for verification.
3.9 RESULT:
Thus the OUTPUT of 8 to 3 decoder (without and with priority) is verified by simulating
the VERILOG HDL code.
EXP 4: DESIGN OF 8-to-1 MULTIPLEXER AND 1X8
DEMULTIPLEXER
4.1 AIM:
To develop the source code for 8x1 multiplexer and demultiplexer by using VERILOG and
obtain the simulation.
4.2 SOFTWARE & HARDWARE:
4.2.1 XILINX VIVADO 2018.1 VERSION.
4.2.2 FPGA-ZYNQ BOARD XC7Z020CLG484-1.
4.2.3 JUMPER CABLE WITH POWER SUPPLY.
4.6 Simulation output Waveform window: Displays output waveform for verification:
4.7 DEMULTIPLEXER:
4.10 Simulation output Waveform window: Displays output waveform for verification.
4.11 RESULT:
Thus the OUTPUT’s of Multiplexers and Demultiplexers are verified by simulating
the VERILOG code.
Lab 5: DESIGN OF 4 BIT BINARY TO GRAY CODE CONVERTER
5.1 Aim
To develop the source code for binary to gray converter by using VERILOG and obtained the
simulation.
module tb();
// stimulus
always
begin
bin <= 0; #10;
bin <= 1; #10;
bin <= 2; #10;
bin <= 3; #10;
bin <= 4; #10;
bin <= 5; #10;
bin <= 6; #10;
bin <= 7; #10;
bin <= 8; #10;
bin <= 9; #10;
bin <= 10; #10;
bin <= 11; #10;
bin <= 12; #10;
bin <= 13; #10;
bin <= 14; #10;
bin <= 15; #10;
#100;
$stop;
end
endmodule
Thus the OUTPUT of binary to gray converter are verified by simulating the
VERILOG code.
Lab 6: 4-BIT COMPARATOR
6.1 Aim
To develop the source code for the 4-Bit comparator by using VERILOG and obtaining the
simulation.
module Comparator4Bit(
input [3:0] A,
input [3:0] B,
output reg A_greater_B,
output reg A_equal_B,
output reg B_greater_A
);
// Output assignment
always @(diff, is_diff_zero)
begin
A_greater_B = ~is_diff_zero & diff[3];
A_equal_B = is_diff_zero;
B_greater_A = ~is_diff_zero & diff[3];
end
endmodule
module Subtract4Bit(
input [3:0] A,
input [3:0] B,
output reg [3:0] difference );
always @(A, B)
begin
difference = A - B;
end
endmodule
module ZeroDetector(
input [3:0] input,
output reg is_zero );
always @(input)
begin
is_zero = (input == 4'b0000);
end
endmodule
6 Result
.
9
Thus the OUTPUT's 4-bit comparator is verified by simulating the VERILOG code.
Lab 7: DESIGN OF FULL ADDER USING THREE MODELING
STYLES
7.1 Aim
To develop the source code for full adder using three modeling styles by using VERILOG and
obtaining the simulation.
module fullAdder_tb;
reg In1;
eg In2;
reg Cin;
wire Sum;
wire Cout;
reg [2:0] i = 3'd0; //Temporary looping variable
fullAdder uut ( .In1(In1), .In2(In2), .Cin(Cin),.Sum(Sum), .Cout(Cout) );
initial
begin
In1 = 1'b0;
In2 = 1'b0;
Cin = 1'b0;
// Wait 100 ns for global reset to finish
#100;
for = 0; i < 8; i = i + 1'b1)
begin
{In1,In2,Cin} = {In1,In2,Cin} + 1'b1;
#20;
end
end
endmodule
7.9 Result
Thus the OUTPUT of full adder using three modeling styles is verified by simulating the
VERILOG code.
Lab 8: DESIGN OF FLIP FLOPS (SR,JK,D,T).
8.1 Aim
To develop the source code for flipflops by using VERILOG and obtained the simulation
module SRFlipFlop(input S, input R, input clk, output reg Q, output reg Q_bar);
endmodule
8.3.4.3 Behavioral Model
module SRFlipFlop(input S, input R, input clk, output reg Q, output reg Q_bar);
module srff_tb;
reg s,r,clk,rst;
wire q,qb;
rff srflipflop(.s(s),.r(r),.clk(clk),.rst(rst),.q(q),.qb(qb));
initial
begin
clk=0;
s = 0;
r = 0;
#5
rst = 1;
#30
rst = 0;
$monitor($time, "\tclk=%b\t ,rst=%b\t, s=%b\t,r=%b\t, q=%b\t, qb=
%b",clk,rst,s,r,q,qb);
#100 $finish;
end
always #5 clk = ~clk;
always #30 s = ~s;
always #40
endmodule
8.3.6 Simulation output Waveform window
module jk(q,q1,j,k,c);
output q,q1;
input j,k,c;
reg q,q1;
initial
begin
q=1'b0;
q1=1'b1;
end
always @ (posedge c)
begin
case({j,k})
{1'b0,1'b0}:
begin
q=q;
q1=q1;
end
{1'b0,1'b1}:
begin
q=1'b0;
q1=1'b1;
end
{1'b1,1'b0}:
begin
q=1'b1;
q1=1'b0;
end
{1'b1,1'b1}:
begin
q=~q;
q1=~q1;
end
endcase
end
endmodule
module JKFF_tb;
reg J,K,clk,rst;
wire Q;
JKFF JKflipflop(.J(J),.K(K),.clk(clk),.rst(rst),.Q(Q));
initial
begin
clk=0;
J = 0;
K = 0;
#5 rst = 1;
#30 rst = 0;
$monitor($time, "\tclk=%b\t ,rst=%b\t, J=%b\t,K=%b\t, Q=%b",clk,rst,J,K,Q);
#100 $finish;
end
always #5 clk = ~clk; always
#30 J = ~J;
always #40 K = ~K;
endmodule
8.5.6 Simulation output Waveform window
module dff_df(d,c,q,q1);
input d,c;
output q,q1;
assign w1=d&c;
assign w2=~d&c;
q=~(w1|q1);
q1=~(w2|q);
endmodule
module Stimulus_v;
reg Reset;
reg Clock;
reg d;
wire q;
DFF uut (.Clock(Clock),.Reset(Reset),.d(d),.q(q));
always
#1 Clock=~Clock;
initial
begin
Clock=0;
Reset=0;d=0;
#2 Reset=0;d=1;
#2 d=0;
#2 Reset=1; d=1;
#2 d=0; #2 d=1;
#2 Reset=0; d=0; #1;
#2 $stop;
end
endmodule
module t_df(q,q,1,t,c);
output q,q1;
input t,c;
wire w1,w2;
assign w1=t&c&q;
assign w2=t&c&q1;
assign q=~(w1|q1);
assign q1=~(w2|q);
endmodule
8.7.4.3 Behavioral Model
module t_beh(q,q1,t,c);
output q,q1;
input t,c;
reg q,q1;
initial
begin
q=1'b1;
q1=1'b0;
end
always @ (c)
begin
if(c)
begin
if (t==1'b0)
begin
q=q;
q1=q1;
end
else
begin
q=~q;
q1=~q1;
end
end
end
endmodule
module Stimulus_v;
reg Clock, Reset, t;
wire q;
TFF uut (.Clock(Clock),.Reset(Reset),.t(t),.q(q));
always
#1 Clock=~Clock;
initial
begin
Clock=0;
Reset=0;
t=0;
#2 Reset=0; t=1;
#2 t=0;
#2 Reset=1; t=1;
#2 t=0;
#2 t=1;
#2 Reset=0; t=0;
#1;
#2 $stop;
end endmodule
8.7.7 Result
Thus the OUTPUT of FlipFlops are verified by simulating the VERILOG code.
#100
$finish ;
end
$display("\t\ttime,\tclk,\treset,\tenable,\tout");
$monitor("%d,\t%b,\t%b,\t%b,\t%d",$time,
clk,reset,enable,out); end
endmodule
9.3.3 Simulation output Waveform window: Displays output waveform for verification:
#100
$finish ;
end
always #5
clk = !clk;
9.4.3 Simulation output Waveform window: Displays output waveform for verification:
9.5 RESULT:
Thus the OUTPUT’s of 4-bit counter and BCD COUNTER using three modeling styles are
verified by synthesizing and simulating the VERILOG code
10.1 AIM:
To develop the source code for finite state machine design by using VERILOG and
obtained the simulation
module mealy1011(clk,rst,inp,outp);
input clk,rst,inp;
output reg outp;
reg [1:0]state;
parameter S0=0, S1=1, S2=2, S3=3;
always @(posedge clk or posedge rst)
if(rst)
state<=S0;
else case(state)
S0: if(inp) state<=S1;
else state<=S0;
S1: if(inp) state<=S1;
else state<=S2;
S2: if(inp) state<=S3;
else state<=S0;
endcase
always @(state,inp)
case(state)
S0: if(inp)
outp<=0;
else outp<=0;
S1: if(inp) outp<=0;
else outp<=0;
S2: if(inp) outp<=0;
else outp<=0;
S3: if(inp) outp<=1;
else outp<=0;
endcase
endmodule
10.3.2 Verilog test bench program :
AIM: To Implement Left Shift Register using Verilog HDL and download on to the FPGA
kit.
SOFTWARE & HARDWARE:
1. XILINX VIVADO 2018.1 VERSION.
2. FPGA-ZYNQ BOARD XC7Z020CLG484-1.
3. JUMPER CABLE WITH POWER SUPPLY.
Truth Table
Shift
D C B A
Pulse
0 0 0 0 0
1 0 0 0 1
2 0 0 1 1
3 0 1 1 1
4 1 1 1 1
output so;
reg[3:0] tmp;
begin
assign so = tmp[3];
endmodule
TEST BENCH:
module stimulus;
reg clk ;
reg si;
wire so;
leftshift s1 (.clk(clk),.s_in(si),.so(so) );
initial begin
clk = 0;si = 0;
#10 si=1’b1;
#10 si=1’b0;
#10 si=1’b0;
#10 si=1’b1;
#10 si=1’b0;
#10 si=1’bx;
end
always
#5 clk = ~clk;
initial #150
$stop;
endmodule
WAVE FORMS:
RESULT:
Hence the Left shift register is implemented using VHDL & downloaded onto the FPGA kit.
AIM: To Design and implement a seven segment led display using VHDL.
DESIGN:
Logic Symbol :
Truth Table:
VHDL CODE:
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
Use ieee.std_logic_arith.all;
entity sevenseg is
port(bin : in std_logic_vector(3 downto 0);
---Input binary value from 0 to 15--- dispcom : out std_logic;
disp : out std_logic_vector(6 downto 0));
---Seven segment display for displaying the hex value---
end sevenseg;
architecture Behavioral of
sevenseg is begin
dispcom <= '0'; --for common cathode seven segment display
-------------------- SEVEN SEGMENT DISPLAY MODULE --------------------
process(bi
n) begin
case bin is
when "0000" =>disp <= "0111111"; --0--
when "0001" =>disp <= "0000110"; --1--
when "0010" =>disp <= "1011011"; --2--
when "0011" =>disp <= "1001111"; --3--
when "0100" =>disp <= "1100110"; --4--
when "0101" =>disp <= "1101101"; --5--
when "0110" =>disp <= "1111101"; --6--
when "0111" =>disp <= "0000111"; --7--
when "1000" =>disp <= "1111111"; --8--
when "1001" =>disp <= "1100111"; --9--
when "1010" =>disp <= "1110111"; --a--
when "1011" =>disp <= "1111100"; --b--
when "1100" =>disp <= "0111001"; --c--
when "1101" =>disp <= "1011110"; --d--
when "1110" =>disp <= "1111001"; --e--
when "1111" =>disp <= "1110001"; --f--
when others =>disp <= "0000000";
end case;
end process
end Behavioral
WAVE FORMS: