Documente Academic
Documente Profesional
Documente Cultură
TECHNOLOGY
VELAMMAL NAGAR, VIRAGANOOR
MADURAI-625009
Prepared By:
P.Karthikeyan
Assistant Professor/ECE
&Head/ECE
Approved By:
Dr.S.Vasuki
Professor
CONTENTS
1. Study of Simulation using tools.
2. Study of Synthesis tools.
3. Place and Root and Back annotation for FPGAs.
4. Basic logic gates
5. Half adder and full adder
6. Half Subtractor and full Subtractor
7. Encoder and decoder
8. Multiplexer and demultiplexer
9. Flip-Flops
10. Counters
11. Registers
12. Traffic light controller
13. Realtime Clock
14. Serial adder
15. Parallel Pipelined adder/Subtractor
16. Parallel Pipeline adder
Expt.No:
Date
:
AIM:
RESULT:
10
11
Expt.No:
Date
:
AIM:
To study the Synthesis tools.
THEORY:
Now that you have created the source files, verified the designs behavior
with simulation,and added constraints, you are ready to synthesize and
implement the design.
Implementing the Design:
1. Select the counter source file in the Sources in Project window.
2. In the Processes for Source window, click the + sign next to
Implement Design. The Translate, Map, and Place & Route processes
are displayed. Expand those processes as well by clicking on the +
sign. You can see that there are many sub-processes and options that can
be run during design implementation.
3. Double-click the top level Implement Design process.ISE determines
the current state of your design and runs the processes needed to pull your
design through implementation. In this case, ISE runs the Translate, Map
and PAR processes. Your design is now pulled through to a placed-androuted state. This feature is called the pull through model.
4. After the processes have finished running, notice the status markers in
the Processes for Source window. You should see green checkmarks next
to several of the processes, indicating that they ran successfully. If there
are any yellow exclamation points, check the warnings in the Console tab
or the Warnings tab within the Transcript window. If a red X appears next
to a process, you must locate and fix the error before you can continue.
Verification of Synthesis:
Your synthesized design can be viewed as a schematic in the Register
Transfer Level (RTL) Viewer. The schematic view shows gates and
elements independent of the targeted Xilinx device.
1. In the Processes for Source window, double-click View RTL
Schematic found in the Synthesize - XST process group. The top
level schematic representation of your synthesized design opens in
the workspace.
12
2. Right-click on the symbol and select Push Into the Selected Instance
to view the schematic in detail.
The Design tab appears in the Sources in Project window, enabling you to
view the design hierarchy. In the schematic, you can see the design
components you created in the HDL source, and you can push into
symbols to view increasing levels of detail.
3. Close the schematic window.
13
RESULT:
14
Expt.No:
Date
:
AIM:
To study the Place and Root and Back annotation for FPGAs.
THEORY:
After implementation is complete, you can verify your design before
downloading it to a device.
Viewing Placement:
In this section, you will use the Floor planner to verify your pin outs and
placement. Floor planner is also very useful for creating area groups for
designs.
1. Select the counter source file in the Sources in Project window.
2. Click the + sign to expand the Place & Route group of processes.
3. Double-click the View/Edit Placed Design (Floorplanner) process.
The Floorplanner view opens.
4. Select View _ Zoom _ ToBox and then use the mouse to draw a box
around the counter instance, shown in green on the right side of the chip.
5. This Fig 1 shows where the entire design was placed. Click on any of
the components listed in the Design Hierarchy window to see where each
component is placed.
6. Zoom in to the right side of the chip even more, and place your mouse
over the K13pad. You can see that your pinout constraint was applied the DIRECTION pin is placed at K13.
7. Close the Floorplanner without saving.
Viewing Resource Utilization in Reports:
Many ISE processes produce summary reports which enable you to check
information about your design after each process is run. Detailed reports
are available from the Processes for Source window. You can also view
summary information and access most often-utilized reports in the Design
Summary.
1. Click on the Design Summary tab at the bottom of the window. If you
closed the summary during this tutorial, you can reopen it by doubleclicking the View Design Summary process.
15
16
17
18
19
20
RESULT:
21
Expt.No:
Date
:
AIM:
To write Verilog HDL program for Basic Logic gates and verify the output using
Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
22
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
23
AND Gate:
Output:
#
#
#
#
#
#
#
#
#
AND Gate
-----------------------------------------------Input1
Input2
Output
-----------------------------------------------0
0
0
0
1
0
1
0
0
1
1
1
-------------------------------------------------
PROGRAM:
AND Gate:
// Module Name: Andgate
module Andgate(i1, i2, out);
input i1;
input i2;
output out;
and (out,i1,i2);
endmodule
24
module Stimulus_v;
// Inputs
reg i1;
reg i2;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
Andgate uut (
.i1(i1),
.i2(i2),
.out(out)
);
initial
begin
$display("\t\t\t\tAND Gate");
$display("\t\t--------------------------------------");
$display("\t\tInput1\t\t Input2\t\t Output");
$display("\t\t--------------------------------------");
$monitor("\t\t\t%b\t\t%b\t\t%b ",i1,i2,out);
#4 $display("\t\t--------------------------------------");
end
initial
begin
i1=1'b0; i2=1'b0;
#1 i2=1'b1;
#1 i1=1'b1; i2=1'b0;
#1 i1=1'b1; i2=1'b1;
#1 $stop;
end
endmodule
OR Gate:
25
Output:
#
#
#
#
#
#
#
#
#
OR Gate
-----------------------------------------------Input1
Input2
-----------------------------------------------0
0
0
0
1
1
1
0
1
1
1
1
------------------------------------------------
Output
OR Gate:
// Module Name: Orgate
module Orgate(i1, i2, out);
input i1;
input i2;
output out;
or(out,i1,i2);
endmodule
// Module Name: Simulus.v
module Simulus_v;
// Inputs
reg i1;
reg i2;
// Outputs
wire out;
26
Output:
#
#
#
#
#
#
#
#
#
NAND Gate
-----------------------------------------------Input1
Input2
Output
-----------------------------------------------0
0
1
0
1
1
1
0
1
1
1
0
------------------------------------------------
27
NAND Gate:
// Module Name: Nandgate
module Nandgate(i1, i2, out);
input i1;
input i2;
output out;
nand(out,i1,i2);
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg i1;
reg i2;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
Nandgate uut (
.i1(i1),
.i2(i2),
.out(out)
);
initial
begin
$display("\t\t\t\tNAND Gate");
$display("\t\t--------------------------------------");
$display("\t\tInput1\t\t Input2\t\t Output");
$display("\t\t--------------------------------------");
$monitor("\t\t\t%b\t\t%b\t\t%b ",i1,i2,out);
#4 $display("\t\t--------------------------------------");
end
initial
begin
i1=1'b0; i2=1'b0;
#1 i2=1'b1;
#1 i1=1'b1; i2=1'b0;
28
#1 i1=1'b1; i2=1'b1;
#1 $stop;
end
endmodule
NOR Gate:
Output:
#
#
#
#
#
#
#
#
#
NOR Gate
-----------------------------------------------Input1
Input2
-----------------------------------------------0
0
1
0
1
0
1
0
0
1
1
0
------------------------------------------------
Output
NOR Gate:
// Module Name: Norgate
module Norgate(i1, i2, out);
input i1;
input i2;
output out;
nor(out,i1,i2);
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg i1;
reg i2;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
29
Norgate uut (
.i1(i1),
.i2(i2),
.out(out)
);
initial
begin
$display("\t\t\t\tNOR Gate");
$display("\t\t--------------------------------------");
$display("\t\tInput1\t\t Input2\t\t Output");
$display("\t\t--------------------------------------");
$monitor("\t\t\t%b\t\t%b\t\t%b ",i1,i2,out);
#4 $display("\t\t--------------------------------------");
end
initial
begin
i1=1'b0; i2=1'b0;
#1 i2=1'b1;
#1 i1=1'b1; i2=1'b0;
#1 i1=1'b1; i2=1'b1;
#1 $stop;
end
endmodule
XOR Gate:
Output:
#
#
#
#
#
#
#
#
#
XOR Gate
-----------------------------------------------Input1
Input2
Output
-----------------------------------------------0
0
0
0
1
1
1
0
1
1
1
0
-------------------------------------------------
30
XOR Gate:
// Module Name: Xorgate
module Xorgate(i1, i2, out);
input i1;
input i2;
output out;
xor(out,i1,i2);
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg i1;
reg i2;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
Xorgate uut (
.i1(i1),
.i2(i2),
.out(out)
);
initial
begin
$display("\t\t\t\tXOR Gate");
$display("\t\t--------------------------------------");
$display("\t\tInput1\t\t Input2\t\t Output");
$display("\t\t--------------------------------------");
$monitor("\t\t\t%b\t\t%b\t\t%b ",i1,i2,out);
#4 $display("\t\t--------------------------------------");
end
initial
begin
i1=1'b0; i2=1'b0;
#1 i2=1'b1;
31
#1 i1=1'b1; i2=1'b0;
#1 i1=1'b1; i2=1'b1;
#1 $stop;
end
endmodule
XNOR Gate:
Output:
#
#
#
#
#
#
#
#
#
XNOR Gate
-----------------------------------------------Input1
Input2
-----------------------------------------------0
0
1
0
1
0
1
0
0
1
1
1
------------------------------------------------
Output
XNOR Gate:
// Module Name: Xnorgate
module Xnorgate(i1, i2, out);
32
input i1;
input i2;
output out;
xnor(out,i1,i2);
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg i1;
reg i2;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
Xnorgate uut (
.i1(i1),
.i2(i2),
.out(out)
);
initial
begin
$display("\t\t\t\tXNOR Gate");
$display("\t\t--------------------------------------");
$display("\t\tInput1\t\t Input2\t\t Output");
$display("\t\t--------------------------------------");
$monitor("\t\t\t%b\t\t%b\t\t%b ",i1,i2,out);
#4 $display("\t\t--------------------------------------");
end
initial
begin
i1=1'b0; i2=1'b0;
#1 i2=1'b1;
#1 i1=1'b1; i2=1'b0;
#1 i1=1'b1; i2=1'b1;
#1 $stop;
end
endmodule
Not Gate:
33
Output:
#
#
#
#
#
#
#
NOT Gate
--------------------------Input
Output
--------------------------0
1
1
0
---------------------------
NOT Gate:
34
$display("\t\t------------------------");
$monitor("\t\t %b\t\t %b",in,out);
#2 $display("\t\t------------------------");
end
initial
begin
in=0;
#1 in=1;
#1 $stop;
end
endmodule
Buffer:
Output:
#
#
#
#
#
#
#
BUFFER
--------------------------Input
Output
--------------------------0
0
1
1
---------------------------
RESULT:
Expt. No:
Date
:
35
AIM:
To write Verilog HDL program for Half Adder and Full Adder and verify the output
using Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
36
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Half Adder:
Output:
#
#
#
Sum
#
#
#
#
#
#
Half Adder
-----------------------------------------------------------------Input1
Input2
Carry
-----------------------------------------------------------------0
0
0
0
0
1
0
1
1
0
0
1
1
1
1
0
------------------------------------------------------------------
PROGRAM:
Half Adder:
// Module Name:
HalfAddr
37
38
Output:
Full Adder
#
----------------------------------------------------------------------------------------------#
i1
i2
C_in
C_out
Sum
#
----------------------------------------------------------------------------------------------#
0
0
0
0
0
#
0
0
1
0
1
#
0
1
0
0
1
#
0
1
1
1
0
#
1
0
0
0
1
#
1
0
1
1
0
#
1
1
0
1
0
#
1
1
1
1
1
#
------------------------------------------------------------------------------------------------
39
Full Adder:
// Module Name: FullAddr
module FullAddr(i1, i2, c_in, c_out, sum);
input i1;
input i2;
input c_in;
output c_out;
output sum;
wire s1,c1,c2;
xor n1(s1,i1,i2);
and n2(c1,i1,i2);
xor n3(sum,s1,c_in);
and n4(c2,s1,c_in);
or n5(c_out,c1,c2);
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg i1;
reg i2;
reg c_in;
// Outputs
wire c_out;
wire sum;
// Instantiate the Unit Under Test (UUT)
FullAddr uut (
.i1(i1),
.i2(i2),
.c_in(c_in),
.c_out(c_out),
.sum(sum)
);
initial
begin
$display("\t\t\t\t\t\tFull Adder");
40
$display("\t\t----------------------------------------------------------------");
$display("\t\ti1\t\ti2\t\tC_in\t\t\tC_out\t\tSum");
$display("\t\t----------------------------------------------------------------");
$monitor("\t\t%b\t\t%b\t\t%b\t\t\t%b\t\t
%b",i1,i2,c_in,c_out,sum);
#9
$display("\t\t-------------------------------------------------------------------");
end
initial begin
i1 = 0;i2 = 0;c_in = 0;
#1 i1 = 0;i2 = 0;c_in = 0;
#1 i1 = 0;i2 = 0;c_in = 1;
#1 i1 = 0;i2 = 1;c_in = 0;
#1 i1 = 0;i2 = 1;c_in = 1;
#1 i1 = 1;i2 = 0;c_in = 0;
#1 i1 = 1;i2 = 0;c_in = 1;
#1 i1 = 1;i2 = 1;c_in = 0;
#1 i1 = 1;i2 = 1;c_in = 1;
#2 $stop;
end
endmodule
EXERCISE:
(i) Design a combinational circuit in verilog coding which performs three bits addition in
behavioral model
(ii) Design a combinational circuit in verilog coding which performs three bits addition in
structural model
(iii) Design a combinational circuit in verilog coding which performs two bits addition in
behavioral model and also using this circuit as a component to design the three bit adder in
structural model.
RESULT:
41
Expt. No:
Date
:
AIM:
To write Verilog HDL program for Half Subtractor & Full Subtractor and verify the
output using Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the
output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
42
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Half Subtractor:
Output:
#
#
#
Difference
#
#
#
#
#
#
Half Subtractor
-----------------------------------------------------------------------Input1
Input2
Borrow
------------------------------------------------------------------------0
0
0
0
0
1
1
1
1
0
0
1
1
1
0
0
------------------------------------------------------------------------
43
PROGRAM:
Half Subtractor:
44
$display("\t\t\t\t\tHalf Subtractor");
$display("\t\t----------------------------------------------------------");
$display("\t\tInput1\t\t Input2\t\t Borrow\t\t Difference");
$display("\t\t----------------------------------------------------------");
$monitor("\t\t\t%b\t\t%b\t\t%b\t\t%b",i0,i1,bor,dif);
#4
$display("\t\t-----------------------------------------------------------");
end
initial
begin
i0=1'b0; i1=1'b0;
#1 i1=1'b1;
#1 i0=1'b1; i1=1'b0;
Full Subtractor:
Output:
#
#
Full Subtractor
----------------------------------------------------------------------------------------------#
B_in
I1
i0
B_out
Difference
#
----------------------------------------------------------------------------------------------#
0
0
0
0
0
#
0
0
1
0
1
#
0
1
0
1
1
#
0
1
1
0
0
#
1
0
0
1
1
#
1
0
1
0
0
#
1
1
0
1
0
#
1
1
1
1
1
45
#
------------------------------------------------------------------------------------------------
#1 i0=1'b1; i1=1'b1;
#1 $stop;
end
endmodule
Full Subtractor:
46
.i1(i1),
.i0(i0),
.b_out(b_out),
.dif(dif)
);
initial
begin
$display("\t\t\t\t\t\tFull Subtractor");
$display("\t\t-------------------------------------------------------------------------");
$display("\t\tB_in\t\tI1\t\ti0\t\t\tB_out\t\tDifference");
$display("\t\t-------------------------------------------------------------------------");
$monitor("\t\t%b\t\t%b\t\t%b\t\t\t %b\t\t\t
%b",b_in,i1,i0,b_out,dif);
#9
$display("\t\t-------------------------------------------------------------------------");
end
initial begin
// Initialize Inputs
b_in = 0;i1 = 0;i0 = 0;
#1 b_in = 0;i1 = 0;i0 =
#1 b_in = 0;i1 = 0;i0 =
#1 b_in = 0;i1 = 1;i0 =
#1 b_in = 0;i1 = 1;i0 =
#1 b_in = 1;i1 = 0;i0 =
#1 b_in = 1;i1 = 0;i0 =
#1 b_in = 1;i1 = 1;i0 =
#1 b_in = 1;i1 = 1;i0 =
#2 $stop;
end
endmodule
0;
1;
0;
1;
0;
1;
0;
1;
EXERCISE:
(i) Design a combinational circuit in verilog coding which performs three bits
Subtraction in behavioral model
(ii) Design a combinational circuit in verilog coding which performs three bits subtraction
in structural model
(iii) Design a combinational circuit in verilog coding which performs two bits
subtraction in behavioral model and also using this circuit as a component to design
the three bit subtractor in structural model
47
RESULT:
Expt No:
Date:
AIM:
To write Verilog HDL program for 2x4 Decoder & 4x2 Encoder and verify the
output using Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the
output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
48
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Encoder:
49
Output:
#
#
#
#
#
#
#
#
#
4to2 Encoder
------------------------------------Input
Output
------------------------------------1000
00
0100
01
0010
10
0001
11
------------------------------------
PROGRAM:
Encoder:
50
$display("\t\tInput\t\t\tOutput");
$display("\t\t------------------------------");
$monitor("\t\t%B%B%B%B\t\t\t %B
%B",i0,i1,i2,i3,out0,out1);
#4 $display("\t\t-------------------------------");
end
initial
begin
i0=1; i1=0; i2=0; i3=0;
51
#1
#1
#1
#1
end
endmodule
Decoder:
// Module Name: Decd2to4
module Decd2to4(i0, i1, out0, out1, out2, out3);
input i0;
input i1;
output out0;
output out1;
output out2;
output out3;
reg out0,out1,out2,out3;
always@(i0,i1)
case({i0,i1})
2'b00: {out0,out1,out2,out3}=4'b1000;
2'b01: {out0,out1,out2,out3}=4'b0100;
2'b10: {out0,out1,out2,out3}=4'b0010;
2'b11: {out0,out1,out2,out3}=4'b0001;
default: $display("Invalid");
endcase
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg i0;
reg i1;
// Outputs
wire out0;
wire out1;
wire out2;
wire out3;
Output:
#
#
#
#
#
#
#
2to4 Decoder
------------------------------------Input
Output
------------------------------------00
1000
01
0100
10
0010
52
#
#
11
0001
------------------------------------
53
EXERCISE:
(i)Design a Data flow model combinational circuit (8 inputs 3 outputs) in verilog
coding.
(ii) Design a Data flow model combinational circuit (3 inputs 8 outputs) in verilog
coding.
(iii) Design a Structural model combinational circuit (8 inputs 3 outputs) in verilog
coding.
RESULT:
Expt. No:
Date
:
AIM:
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
54
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Multiplexer:
55
Output:
#
#
#
#
#
#
#
#
#
#
#
4to1 Multiplexer
----------------------------------------------Input=1011
----------------------------------------------Selector
Output
----------------------------------------------{0,0}
1
{1,0}
0
{0,1}
1
{1,1}
1
-----------------------------------------------
PROGRAM:
Multiplexer:
// Module Name:
Mux4to1
56
Demultiplexer:
57
initial
begin
$display("\t\t\t 4to1 Multiplexer");
$display("\t\t------------------------------------");
#1 $display("\t\t\t Input=%b%b%b%b",i0,i1,i2,i3);
$display("\t\t------------------------------------");
$display("\t\tSelector\t\t\t\tOutput");
$display("\t\t------------------------------------");
$monitor("\t\t{%b,%b}\t\t\t\t\t%b",s0,s1,out);
#4 $display("\t\t------------------------------------");
end
initial
begin
i0=1; i1=0; i2=1; i3=1;
#1 s0=0; s1=0;
#1 s0=1; s1=0;
#1 s0=0; s1=1;
#1 s0=1; s1=1;
#1 $stop;
end
endmodule
Demultiplexer:
58
Output:
#
#
#
#
#
#
#
#
#
#
1to4 Demultiplexer
----------------------------------------------Input=1
----------------------------------------------Status
Output
----------------------------------------------{0,0}
1000
{0,1}
0100
{1,0}
0010
{1,1}
0001
---------------------------------------------
59
reg in;
reg s0;
reg s1;
// Outputs
wire out0;
wire out1;
wire out2;
wire out3;
// Instantiate the Unit Under Test (UUT)
Dux1to4 uut (
.in(in),
.s0(s0),
.s1(s1),
.out0(out0),
.out1(out1),
.out2(out2),
.out3(out3)
);
initial
begin
$display("\t\t 1to4 Demultiplexer");
$display("\t\t------------------------------------");
#1 $display("\t\t\t\tInput=%b",in);
$display("\t\t------------------------------------");
$display("\t\tStatus\t\t\t\tOutput");
$display("\t\t------------------------------------");
$monitor("\t\t{%b,%b}\t\t\t\t%b%b%b
%b",s1,s0,out0,out1,out2,out3);
#4 $display("\t\t------------------------------------");
end
initial
begin
in=1;
#1 s1=0;s0=0;
#1 s1=0;s0=1;
#1 s1=1;s0=0;
#1 s1=1;s0=1;
#1 $stop;
end
endmodule
60
EXERCISE:
(i) Design a serial to parallel converter (2 select lines) in verilog coding using case
statement.
(ii)Design a parallel to serial converter (2 select lines) in verilog coding using case
statement.
(iii)Design a serial to parallel converter (2 select lines) in verilog coding using if
statement.
(iv)Design a parallel to serial converter (2 select lines) in verilog coding using if
statement.
(v)Design a 8 to 1 MUX and 1to 8 DEMUX in verilog coding using dataflow model
RESULT:
Expt.No:
Date
:
FLIP-FLOPS
AIM:
To write Verilog HDL program for JK- FilpFlop,D-FlipFlop and T-FlipFlop and
verify the output using Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and
verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
61
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Flip-Flop:
D Flip-Flop:
62
Output:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
D FipFlop
-------------------------------------------------------------------------Clock
Reset
Input (d)
Output q(~q)
--------------------------------------------------------------------------0
0
0
0(1)
1
0
0
0(1)
0
0
1
0(1)
1
0
1
0(1)
0
0
0
0(1)
1
0
0
0(1)
0
1
1
0(1)
1
1
1
1(0)
0
1
0
1(0)
1
1
0
0(1)
0
1
1
0(1)
1
1
1
1(0)
0
0
0
0(1)
1
0
0
0(1)
0
0
0
0(1)
--------------------------------------------------------------------------
PROGRAM:
D Flip-Flop:
63
input d;
output q;
reg q;
always@(posedge Clock or negedge Reset)
if (~Reset) q=1'b0;
else q=d;
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg Reset;
reg Clock;
reg d;
// Outputs
wire q;
// Instantiate the Unit Under Test (UUT)
DFF uut (
.Clock(Clock),
.Reset(Reset),
.d(d),
.q(q)
);
initial
begin
$display("\t\t\t\t\tD FipFlop");
$display("\t\t------------------------------------------------------------");
$display("\t\tClock\t\tReset\t\tInput (d)\t\tOutput q(~q)");
$display("\t\t------------------------------------------------------------");
$monitor("\t\t %d \t\t %d \t\t %d
\t\t
%d(%d)",Clock,Reset,d,q,~q);
#15
$display("\t\t------------------------------------------------------------");
end
always
#1 Clock=~Clock;
initial
begin
Clock=0; Reset=0;d=0;
#2 Reset=0; d=1;
T Flip-Flop:
64
Output:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
T FipFlop
--------------------------------------------------------------------------Clock
Reset
Input (t)
Output q(~q)
--------------------------------------------------------------------------0
0
0
0(1)
1
0
0
0(1)
0
0
1
0(1)
1
0
1
0(1)
0
0
0
0(1)
1
0
0
0(1)
0
1
1
0(1)
1
1
1
1(0)
0
1
0
1(0)
1
1
0
1(0)
0
1
1
1(0)
1
1
1
0(1)
0
0
0
0(1)
1
0
0
0(1)
0
0
0
0(1)
--------------------------------------------------------------------------
#2 d=0;
#2 Reset=1; d=1;
#2
d=0;
65
#2 d=1;
#2 Reset=0; d=0;
#1; // Gap for display.
#2 $stop;
end
endmodule
T Flip-Flop:
// Module Name: TFF
module TFF(Clock, Reset, t, q);
input Clock;
input Reset;
input t;
output q;
reg q;
always@(posedge Clock , negedge Reset)
if(~Reset) q=0;
else if (t) q=~q;
else q=q;
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg Clock;
reg Reset;
reg t;
// Outputs
wire q;
// Instantiate the Unit Under Test (UUT)
TFF uut (
.Clock(Clock),
.Reset(Reset),
.t(t),
.q(q)
);
initial
begin
$display("\t\t\t\t\tT FipFlop");
JK Flip-Flop:
66
$display("\t\t------------------------------------------------------------");
$display("\t\tClock\t\tReset\t\tInput (t)\t\tOutput q(~q)");
$display("\t\t------------------------------------------------------------");
$monitor("\t\t %d \t\t %d \t\t %d
\t\t
%d(%d)",Clock,Reset,t,q,~q);
#15
$display("\t\t------------------------------------------------------------");
end
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; // Gap for display.
#2 $stop;
end
endmodule
JK Flip-Flop:
Program:
67
Output:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
JK FipFlop
-------------------------------------------------------------------------Clock
Reset
Input (j,k)
Output q(~q)
-------------------------------------------------------------------------0
0
(0,0)
0(1)
1
0
(0,0)
0(1)
0
0
(0,1)
0(1)
1
0
(0,1)
0(1)
0
0
(1,0)
0(1)
1
0
(1,0)
0(1)
0
0
(1,1)
0(1)
1
0
(1,1)
0(1)
0
1
(0,0)
0(1)
1
1
(0,0)
0(1)
0
1
(0,1)
0(1)
1
1
(0,1)
0(1)
0
1
(1,0)
0(1)
1
1
(1,0)
1(0)
0
1
(1,1)
1(0)
1
1
(1,1)
0(1)
0
0
(0,0)
0(1)
1
0
(0,0)
0(1)
0
0
(0,0)
0(1)
-------------------------------------------------------------------------
68
69
#2 j=0; k=1;
#2
j=1; k=0;
#2
j=1; k=1;
#2 Reset=1;
j=0; k=0;
#2
j=0; k=1;
#2 j=1; k=0;
#2 j=1; k=1;
#2 Reset=0; j=0; k=0;
#1; // Gap for display.
#2 $stop;
end
endmodule
EXERCISE:
(i)Design a synchronous reset flip-flop in behavioral model (Realize a flip-flop by
using SR flip-flop as S&R in single input).
(ii) Design a synchronous reset flip-flop which having capability of divide by 2 in
behavioral model.
(iii)Design a synchronous reset flip-flop in behavioral model (Realize a flip-flop by
using JK flip-flop with J=K=1).
RESULT:
Expt No:
Date:
IMPLEMENTATION OF COUNTERS
70
AIM:
To write Verilog HDL program for Counters and verify the output using Xilinx ISE
10.1 version. To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
71
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Counter:
PROGRAM:
2- Bit Counter:
// Module Name: Count2Bit
module Count2Bit(Clock, Clear, out);
input Clock;
input Clear;
output [1:0] out;
reg [1:0]out;
always@(posedge Clock, negedge Clear)
if((~Clear) || (out>=4))out=2'b00;
else out=out+1;
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg Clock;
reg Clear;
// Outputs
wire [1:0] out;
// Instantiate the Unit Under Test (UUT)
Count2Bit uut (
.Clock(Clock),
.Clear(Clear),
.out(out)
72
);
initial
begin
$display("\t\t\t 2 Bit Counter");
$display("\t\t----------------------------------------");
$display("\t\tClock\t\tClear\t\tOutput[2]");
$display("\t\t----------------------------------------");
$monitor("\t\t %b\t\t %b \t\t
%b ",Clock,Clear,out);
#28 $display("\t\t----------------------------------------");
end
always
#1 Clock=~Clock;
initial
begin
Clock=0;Clear=0;
#10 Clear=1;
#16Clear=0;
#2 $stop;
end
endmodule
Output:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
2 Bit Counter
--------------------------------------------------Clock
Clear
Output[2]
--------------------------------------------------0
0
00
1
0
00
0
0
00
1
0
00
0
0
00
1
0
00
0
0
00
1
0
00
0
0
00
1
0
00
0
1
00
1
1
01
0
1
01
1
1
10
0
1
10
1
1
11
0
1
11
1
1
00
0
1
00
1
1
01
0
1
01
1
1
10
73
#
#
#
#
#
#
#
0
1
10
1
1
11
0
1
11
1
1
00
0
0
00
1
0
00
------------------------------------------------
EXCERCISE
(i) Design a frequency divider in verilog coding which having capability of frequency
dividing in both the directions
(ii) Design a counter in Verilog coding for given counting sequence.
0000,0001,0010,0011,0100,0101,0110,0111,0110,0101,0100,0011,0001,0000
RESULT:
Expt No:
Date:
IMPLEMENTATION OF REGISTERS
74
AIM: To write Verilog HDL program for Registers and verify the output using Xilinx
ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
75
OutPut:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
2 Bit Register
----------------------------------------------------------------------Clock
Clear
Input[2]
Output[2]
----------------------------------------------------------------------0
0
00
00
1
0
00
00
0
0
01
00
1
0
01
00
0
0
10
00
1
0
10
00
0
0
11
00
1
0
11
00
0
1
00
00
1
1
00
00
0
1
01
00
1
1
01
01
0
1
10
01
1
1
10
10
0
1
11
10
1
1
11
11
0
0
11
00
1
0
11
00
0
0
11
00
--------------------------------------------------------------------
76
PROGRAM:
2 Bit Register:
// Module Name: Reg2Bit
module Reg2Bit(Clock, Clear, in, out);
input Clock;
input Clear;
input [0:1] in;
output [0:1] out;
reg [0:1] out;
always@(posedge Clock, negedge Clear)
if(~Clear) out=2'b00;
else out=in;
endmodule
// Module Name: Stimulus.v
module Stimulus_v;
// Inputs
reg Clock;
reg Clear;
reg [0:1] in;
// Outputs
wire [0:1] out;
// Instantiate the Unit Under Test (UUT)
Reg2Bit uut (
.Clock(Clock),
.Clear(Clear),
.in(in),
.out(out)
);
initial
begin
$display("\t\t\t\t 2 Bit Register");
$display("\t\t------------------------------------------------------");
$display("\t\tClock\t\tClear\t\tInput[2]\t\tOutput[2]");
77
$display("\t\t------------------------------------------------------");
$monitor("\t\t %b\t\t %b \t\t %b \t\t
%b
",Clock,Clear,in,out);
#19
$display("\t\t------------------------------------------------------");
end
always
#1 Clock=~Clock;
initial
begin
Clock=0;Clear=0;
in=2'b00;
#2 in=2'b01;
#2 in=2'b10;
#2 in=2'b11;
#2 Clear=1;
in=2'b00;
#2 in=2'b01;
#2 in=2'b10;
#2 in=2'b11;
#2 Clear=0;
#1; //Gap for display.
#2 $stop;
end
endmodule
EXCERCISE
(i)Design a counter in Verilog coding for given counting sequence.
00000001, 00000010, 000000100,00001000,00010000,00100000,01000000,1000000
(ii) Design a counter in Verilog coding for given counting sequence
0000, 1000, 1100,1110,1111,0111,0011,0001,0000.
(iii)Design a ring counter in verilog coding
(iv)Design a twisted ring counter in verilog coding
RESULT:
78
Expt. No:
Date:
AIM:
To write Verilog HDL program for Traffic Light Controller and verify the output
using Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
79
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Logic Diagram:
PROGRAM :
80
81
p3<=5'b100;//Amber
p4<=5'b001;//red
end
6'b001000:
begin
p1<=5'b100;//green
p2<=5'b001;//red
p3<=5'b010;//red
p4<=5'b100;//green
end
6'b001100:
begin
p1<=5'b001;//Amber
p2<=5'b001;//red
p3<=5'b010;//red
p4<=5'b010;//Amber
end
6'b010000:
begin
p1<=5'b010;//Red
p2<=5'b100;//Green
p3<=5'b001;//Green
p4<=5'b001;//red
end
6'b010100:
begin
p1<=5'b010;//red
p2<=5'b010;//amber
p3<=5'b100;//amber
p4<=5'b001;//red
end
6'b011000:
begin
p1<=5'b100;//green
p2<=5'b001;//red
p3<=5'b010;//red
p4<=5'b100;//green
end
6'b011100:
begin
p1<=5'b001;//amber
p2<=5'b001;//red
82
p3<=5'b010;//red
p4<=5'b010;//amber
end
6'b100000:
begin
p1<=5'b010;//red
p2<=5'b100;//green
p3<=5'b001;//green
p4<=5'b001;//red
end
6'b100100:sig<=8'h0;
default:begin
end
endcase
end
end
endmodule
RESULT:
Expt. No:
83
Date:
AIM:
To write Verilog HDL program for Real Time Clock and verify the output using
Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
84
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Block Diagram:
PROGRAM:
Real Time Clock:
module realtimelock(clk,rst,sl,atoh);
input clk; // System Clock
input rst; // Reset(micro switch)
output[5:0] sl; // Segment Selection
output[7:0] atoh; // Segment Display Control Data
reg[5:0] sl;
reg[7:0] atoh;
reg[26:0] sig2;
reg[19:1] sig3;
reg[7:0] ssdigit1;
reg[7:0] ssdigit2;
reg[7:0] ssdigit3;
reg[7:0] ssdigit4;
reg[7:0] ssdigit5;
reg[7:0] ssdigit6;
85
integer
integer
integer
integer
integer
integer
digit1;
digit2;
digit3;
digit4;
digit5;
digit6;
86
3'b000 : begin
sl = 6'b111110;
case (digit1)
0 : ssdigit1 = 8'b00111111;
1 : ssdigit1 = 8'b00000110;
2 : ssdigit1 = 8'b01011011;
default : ssdigit1 = 8'b00000000;
endcase
atoh = ssdigit1;
end
3'b001 : begin
sl = 6'b111101;
case (digit2)
0 : ssdigit2 = 8'b00111111;
1 : ssdigit2 = 8'b00000110;
2 : ssdigit2 = 8'b01011011;
3 : ssdigit2 = 8'b01001111;
4 : ssdigit2 = 8'b01100110;
5 : ssdigit2 = 8'b01101101;
6 : ssdigit2 = 8'b01111101;
7 : ssdigit2 = 8'b00000111;
8 : ssdigit2 = 8'b01111111;
9 : ssdigit2 = 8'b01101111;
default : ssdigit2 = 8'b00000000;
ndcase
atoh = ssdigit2;
end
3'b011 : begin
sl = 6'b111011;
case (digit3)
0 : ssdigit3 = 8'b00111111;
1 : ssdigit3 = 8'b00000110;
2 : ssdigit3 = 8'b01011011;
3 : ssdigit3 = 8'b01001111;
4 : ssdigit3 = 8'b01100110;
5 : ssdigit3 = 8'b01101101;
default : ssdigit3 = 8'b00000000;
endcase
atoh = ssdigit3;
end
3'b100 : begin
sl = 6'b110111;
case (digit4)
0 : ssdigit4 = 8'b00111111;
1 : ssdigit4 = 8'b00000110;
2 : ssdigit4 = 8'b01011011;
3 : ssdigit4 = 8'b01001111;
4 : ssdigit4 = 8'b01100110;
5 : ssdigit4 = 8'b01101101;
6 : ssdigit4 = 8'b01111101;
7 : ssdigit4 = 8'b00000111;
8 : ssdigit4 = 8'b01111111;
9 : ssdigit4 = 8'b01101111;
default : ssdigit4 = 8'b00000000;
endcase
atoh = ssdigit4;
end
3'b110 : begin
sl = 6'b101111;
case (digit5)
0 : ssdigit5 = 8'b00111111;
87
1 : ssdigit5 = 8'b00000110;
2 : ssdigit5 = 8'b01011011;
3 : ssdigit5 = 8'b01001111;
4 : ssdigit5 = 8'b01100110;
5 : ssdigit5 = 8'b01101101;
default : ssdigit5 = 8'b00000000;
endcase
atoh = ssdigit5;
end
3'b111 : begin
sl = 6'b011111;
case (digit6)
0 : ssdigit6 = 8'b00111111;
1 : ssdigit6 = 8'b00000110;
2 : ssdigit6 = 8'b01011011;
3 : ssdigit6 = 8'b01001111;
4 : ssdigit6 = 8'b01100110;
5 : ssdigit6 = 8'b01101101;
6 : ssdigit6 = 8'b01111101;
7 : ssdigit6 = 8'b00000111;
8 : ssdigit6 = 8'b01111111; 9 : ssdigit6 = 8'b01101111;
default : ssdigit6 = 8'b00000000;
endcase
atoh = ssdigit6;
end
endcase
end
end
endmodule
Output:
RESULT:
Expt No:
Date
:
88
AIM:
To write Verilog HDL program for Serial Adder and verify the output using Xilinx
ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
89
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
Serial adder
PROGRAM:
Serial Adder:
90
module
SERIALADDER_TOP( RST,LOAD,A3,A2,A0,A1,A5,A4,A6,A7,B7,B6,B4,B
5,B1,B0,
B2,B3,clk1,S3,S4,S0,Cout,S2,S1,S7,S6,S5,Done);
input RST,LOAD,A3,A2,A0,A1,A5,A4;
input A6,A7,B7,B6,B4,B5,B1,B0;
input B2,B3,clk1;
output S3,S4,S0,Cout,S2,S1,S7,S6;
output S5,Done;
wire w50,w51,w52,w53,w54,w55,w56,w57;
wire w58,w59,w60,w61,w62,w63,w64,w65;
wire w66,w67,w68,w69,w70,w71,w72,w73;
wire w74,w75,w76,w77,w78,w79,w80,w81;
wire w82,w83,w84,w85,w86,w87,w88,w89;
wire w90,w91,w92,w93,w94,w95,w96,w97;
wire w98,w99,w100,w101,w102,w103,w104,w105;
wire w106,w107,w108,w109,w110,w111,w112,w113;
wire w114,w115,w116,w117,w118,w119,w120,w121;
wire w122,w123,w124,w125,w126,w127,w128,w129;
wire w130,w131,w132,w133,w134,w135,w136,w137;
dreg #(12) dreg6(w32,w36,w34,w35,clk1);
mux #(10) mux(w34,w32,LOAD,LOAD);
or #(16) or2(w35,RST,Done);
dreg #(12) dreg7(w38,w39,w37,w31,clk1);
dreg #(12) dreg8(Cout,w49,w38,RST,Done);
or #(86) or21(w31,RST,LOAD);
mux #(12) mux_Sh1(w51,w50,A5,LOAD);
mux #(12) mux_Sh2(w53,w52,A6,LOAD);
dreg #(6) dreg2_Sh3(w54,w55,w51,RST,clk1);
dreg #(6) dreg1_Sh4(w52,w57,w56,RST,clk1);
mux #(12) mux_Sh5(w58,w54,A4,LOAD);
dreg #(6) dreg3_Sh6(w60,w61,w59,RST,clk1);
mux #(12) mux_Sh7(w56,RST,A7,LOAD);
dreg #(6) dreg1_Sh8(w50,w62,w53,RST,clk1);
mux #(12) mux_Sh9(w59,w63,A2,LOAD);
dreg #(6) dreg3_Sh10(w63,w65,w64,RST,clk1);
mux #(12) mux_Sh11(w64,w66,A3,LOAD);
mux #(12) mux_Sh12(w68,w67,A0,LOAD);
dreg #(6) dreg3_Sh13(w14,w69,w68,RST,clk1);
mux #(12) mux_Sh14(w70,w60,A1,LOAD);
dreg #(6) dreg3_Sh15(w67,w71,w70,RST,clk1);
dreg #(6) dreg3_Sh16(w66,w72,w58,RST,clk1);
mux #(12) mux_Sh17(w74,w73,B5,LOAD);
mux #(12) mux_Sh18(w76,w75,B6,LOAD);
dreg #(6) dreg2_Sh19(w77,w78,w74,RST,clk1);
dreg #(6) dreg1_Sh20(w75,w80,w79,RST,clk1);
91
92
Simulation parameters
RST CLK 10 10
LOAD CLK 20 20
A3 CLK 40 40
A2 CLK 80 80
A0 CLK 160 160
A1 CLK 320 320
A5 CLK 640 640
A4 CLK 1280 1280
A6 CLK 2560 2560
A7 CLK 5120 5120
B7 CLK 10240 10240
B6 CLK 20480 20480
B4 CLK 40960 40960
B5 CLK 81920 81920
B1 CLK 163840 163840
B0 CLK 327680 327680
B2 CLK 655360 655360
B3 CLK 1310720 1310720
clk1 CLK 10.00 10.00
93
Output:
RESULT:
Expt No:
Date
:
94
AIM:
To write Verilog HDL program for Parallel Pipeline Adder and Subtractor and
verify the output using Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and
verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
95
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
BLOCK DIAGRAM:
PROGRAM:
module Adder_Subtractor_Top( B5,addbsub,clk1,RST,A7,A6,A5,A4,
A3,A2,A1,B7,B6,B4,B3,B2,
B1,B0,A0,Q7,COUT,Q0,Q1,Q2,
Q3,Q4,Q5,Q6);
input B5,addbsub,clk1,RST,A7,A6,A5,A4;
input A3,A2,A1,B7,B6,B4,B3,B2;
input B1,B0,A0;
output Q7,COUT,Q0,Q1,Q2,Q3,Q4,Q5;
output Q6;
wire w68,w69,w70,w71,w72,w73,w74,w75;
wire w76,w77,w78,w79,w80,w81,w82,w83;
wire w84,w85,w86,w87,w88,w89,w90,w91;
wire w92,w93,w94,w95,w96,w97,w98,w99;
wire w100,w101,w102,w103,w104,w105,w106,w107;
wire w108,w109,w110,w111,w112,w113,w114,w115;
wire w116,w117,w118,w119,w120,w121,w122,w123;
wire w124,w125,w126,w127,w128,w129,w130;
96
97
98
#16000 A6=~A6;
#32000 A5=~A5;
#64000 A4=~A4;
#128000 A3=~A3;
#256000 A2=~A2;
#512000 A1=~A1;
#1024000 B7=~B7;
#2048000 B6=~B6;
#4096000 B4=~B4;
#8192000 B3=~B3;
#16384000 B2=~B2;
#32768000 B1=~B1;
#65536000 B0=~B0;
#131072000 A0=~A0;
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
Simulation parameters
B5 CLK 10 10
add/sub CLK 20 20
clk1 CLK 5.000 5.000
RST CLK 40 40
A7 CLK 80 80
A6 CLK 160 160
A5 CLK 320 320
A4 CLK 640 640
A3 CLK 1280 1280
A2 CLK 2560 2560
A1 CLK 5120 5120
B7 CLK 10240 10240
B6 CLK 20480 20480
B4 CLK 40960 40960
B3 CLK 81920 81920
B2 CLK 163840 163840
Output:
99
RESULT:
100
To write Verilog HDL program for 8bit Parallel Adder and verify the output using
Xilinx ISE 10.1 version.To download the bit file in FPGA Kit and verify the output.
APPARATUS REQUIRED:
1.Xilinx Spartan-3 Trainer Kit(XC3S400-PQ208)
2.PC with Windows XP OS
3.Xilinx ISE 10.1
PROCEDURE:
1. Start the Xilinx Project Navigator by using the desktop shortcut or by using the
Start
Programs
Xilinx ISE (10.1)
2. Create a new project. In window go to FILE
NEW PROJECT.
Specify the project name and location and say NEXT.
3. Select the family as Spartan 3, the device as XC3S400, package as PQ208 and
speed as -4.
4. Creating a verilog file. Click on the symbol of FPGA device and then right
Click
Click on new source
Verilog module and give the file
name and say next.
5. Define input and output ports.
6. Write the verilog code in verilog editor.
7. Check syntax. Run the Check syntax
Process window
Synthesize
check syntax, and debug errors if present.
8. Creating a test bench file. Click the symbol of FPGA device and then right click
Click on new source
Test Bench Waveform and give the name
Select Entity
Finish.
9. Select the desired parameters for simulating your design.
10. Simulate the code. Click on test bench file. Test bench file will open in main
window. Assign all the signals and save file. From the source of process window.
Click on simulate Behavioral model in process window.
11. Verify your design in wave window by seeing truth table of output signal with
respect to input signal. Close ISE simulator window.
12. Synthesize the design using ISE.For synthesizing your design, from the source
window select, synthesis/Implementation from the drop-down menu. Highlight
file in the sources in Project window. To run synthesis, right-click on synthesize,
and the run option or double-click on synthesize in the processes for current
source window.
13. Check the synthesis report. If there is any error correct it and rerun synthesis.
14. Create constraints file (UCF).Click on the symbol of FPGA device and then right
click
Click on new source
Implementation Constraints file and
give the name
Select entity
Finish. Click on user constraint and in
that double click on assign package pins option in process window. Xilinx PACE
window opens. Enter all the pins assignments in PACE, depending upon target
device and number of inputs and outputs used in your design.
101
15. Implementing a design, once synthesis is complete, use the Xilinx constraints
editor to add timing and location constraints for the implementation of your
design. This procedure runs you through the basic flow for implementation.
16. Generating programming file
Right click on generate programming file, choose the run option, or double left
click on generate programming file. This will generate the bit stream.
17. Downloading in boundary scan mode
Note; Xilinx provides 2-tools for downloading purpose
IMPACT-is a command line and GUI based tool PROM file formatter.
BLOCK DIAGRAM:
102
PROGRAM:
module Adder_Par_Top( Cin,RST,B7,clk1,A7,A6,A5,A4,
A3,A2,A1,A0,B6,B5,B4,B3,
B2,B1,B0,R0,R7,R6,R5,R4,
R3,R2,R1,Cout);
input Cin,RST,B7,clk1,A7,A6,A5,A4;
input A3,A2,A1,A0,B6,B5,B4,B3;
input B2,B1,B0;
output R0,R7,R6,R5,R4,R3,R2,R1;
output Cout;
wire w58,w59,w60,w61,w62,w63,w64,w65;
wire w66,w67,w68,w69,w70,w71,w72,w73;
wire w74,w75,w76,w77,w78,w79,w80,w81;
wire w82,w83,w84,w85,w86,w87,w88,w89;
wire w90,w91,w92,w93,w94,w95,w96,w97;
wire w98,w99,w100,w101,w102,w103,w104,w105;
wire w106,w107,w108,w109,w110,w111,w112;
dreg dreg1(w3,w47,Cin,RST,clk1);
dreg dreg2(Cout,w57,w18,w56,clk1);
or or2_fa1_pa1(w60,w58,w59);
xor xor2_fa2_pa2(w61,w1,w3);
and and2_fa3_pa3(w59,w1,w3);
and and2_fa4_pa4(w58,w61,w2);
xor xor2_fa5_pa5(w19,w61,w2);
or or2_fa6_pa6(w64,w62,w63);
xor xor2_fa7_pa7(w65,w4,w60);
and and2_fa8_pa8(w63,w4,w60);
and and2_fa9_pa9(w62,w65,w5);
xor xor2_fa10_pa10(w20,w65,w5);
or or2_fa11_pa11(w68,w66,w67);
xor xor2_fa12_pa12(w69,w6,w64);
and and2_fa13_pa13(w67,w6,w64);
and and2_fa14_pa14(w66,w69,w7);
xor xor2_fa15_pa15(w21,w69,w7);
or or2_fa16_pa16(w72,w70,w71);
xor xor2_fa17_pa17(w73,w8,w68);
and and2_fa18_pa18(w71,w8,w68);
and and2_fa19_pa19(w70,w73,w9);
xor xor2_fa20_pa20(w22,w73,w9);
or or2_fa21_pa21(w76,w74,w75);
xor xor2_fa22_pa22(w77,w10,w72);
and and2_fa23_pa23(w75,w10,w72);
and and2_fa24_pa24(w74,w77,w11);
xor xor2_fa25_pa25(w23,w77,w11);
or or2_fa26_pa26(w80,w78,w79);
103
xor xor2_fa27_pa27(w81,w12,w76);
and and2_fa28_pa28(w79,w12,w76);
and and2_fa29_pa29(w78,w81,w13);
xor xor2_fa30_pa30(w24,w81,w13);
or or2_fa31_pa31(w84,w82,w83);
xor xor2_fa32_pa32(w85,w14,w80);
and and2_fa33_pa33(w83,w14,w80);
and and2_fa34_pa34(w82,w85,w17);
xor xor2_fa35_pa35(w25,w85,w17);
or or2_fa36_pa36(w18,w86,w87);
xor xor2_fa37_pa37(w88,w16,w84);
and and2_fa38_pa38(w87,w16,w84);
and and2_fa39_pa39(w86,w88,w15);
xor xor2_fa40_pa40(w26,w88,w15);
dreg dreg16_re41(w11,w89,A4,RST,clk1);
dreg dreg17_re42(w9,w90,A3,RST,clk1);
dreg dreg18_re43(w2,w91,A0,RST,clk1);
dreg dreg19_re44(w5,w92,A1,RST,clk1);
dreg dreg20_re45(w7,w93,A2,RST,clk1);
dreg dreg21_re46(w17,w94,A6,RST,clk1);
dreg dreg22_re47(w15,w95,A7,RST,clk1);
dreg dreg23_re48(w13,w96,A5,RST,clk1);
dreg dreg16_re49(w10,w97,B4,RST,clk1);
dreg dreg17_re50(w8,w98,B3,RST,clk1);
dreg dreg18_re51(w1,w99,B0,RST,clk1);
dreg dreg19_re52(w4,w100,B1,RST,clk1);
dreg dreg20_re53(w6,w101,B2,RST,clk1);
dreg dreg21_re54(w14,w102,B6,RST,clk1);
dreg dreg22_re55(w16,w103,B7,RST,clk1);
dreg dreg23_re56(w12,w104,B5,RST,clk1);
dreg dreg16_re57(R4,w105,w23,RST,clk1);
dreg dreg17_re58(R3,w106,w22,RST,clk1);
dreg dreg18_re59(R0,w107,w19,RST,clk1);
dreg dreg19_re60(R1,w108,w20,RST,clk1);
dreg dreg20_re61(R2,w109,w21,RST,clk1);
dreg dreg21_re62(R6,w110,w25,RST,clk1);
dreg dreg22_re63(R7,w111,w26,RST,clk1);
dreg dreg23_re64(R5,w112,w24,RST,clk1);
endmodule
104
Output:
RESULT:
105