Digital System Design: Introduction To Basic Syntax of Verilog and Gate-Level-Modeling Using Xilinx Ise Tools Objectives
Digital System Design: Introduction To Basic Syntax of Verilog and Gate-Level-Modeling Using Xilinx Ise Tools Objectives
OBJECTIVES
REFERENCE
Chapter 4
PROCEDURE
Start >> Programs >> Xilinx ISE 7.1 >> Project Navigator
Page | 1
Digital System Design LAB 1
Page | 2
Digital System Design LAB 1
4. Click Next.
5. In the next window of ‘Select Device and Design Flow for the Project’:
Select the simulator as : ISE simulator and don’t worry about the rest of the options for the time
being. We shall look at them in greater detail afterwards.
6. Click Next.
Page | 3
Digital System Design LAB 1
Page | 4
Digital System Design LAB 1
Page | 5
Digital System Design LAB 1
Page | 6
Digital System Design LAB 1
Page | 7
Digital System Design LAB 1
14. You will see something like this:-
15. Enter the following Verilog Code in half_adder.v file and save the file:
output sum;
output carry;
input in1;
input in2;
endmodule
In the ‘Processes Window’, located 2nd from the top on the left hand side, locate the
“Synthesize-XST” process and expand it by clicking on the small box containing + sign
alongside it. Now, in the options available inside the “Synthesize-XST” process, locate
the “Check Syntax” step and click on it.
Page | 8
Digital System Design LAB 1
16. Make the Gate-level Diagram of the half and full adder. Show proper working and table.
Page | 9
Digital System Design LAB 1
17. Make sure that your Verilog Code is free of any Syntax errors and the Check Syntax process does not
give any error.( of course we are talking about half-adder you just made. )
19. In the New Source Window, select the ‘Test Bench Waveform’ out of different options available in the
left hand column and give the file name as “half_adder_tb”.
Page | 10
Digital System Design LAB 1
21. In the next window, you have to associate this testbench waveform with a particular verilog module
of your design to which you want to apply this waveform and check the results. As we have only one
module, half_adder, in our design, select half_adder and then click Next.
Page | 11
Digital System Design LAB 1
22. In the next ‘New Source Information’ window, simply click Finish.
Page | 12
Digital System Design LAB 1
24. In the right hand side portion named ‘Clock Information’, select ‘Combinational (or Internal Clock)’
option.
Page | 13
Digital System Design LAB 1
27. In this Waveform window, you can see that outputs are indicated with yellow colour and inputs are
indicated with light green colour.
28. You can click the input signal waveform area to decide what waveform you want to apply to the inputs
of your module and then in the next step, you will be able to simulate and see the results of applying
that particular input in the form of output waveforms.
29. Click the save icon in order to save this TestBenchWaveform file named
half_adder_tb.tbw.
30. In the ‘Sources in the Project’ window on the top left hand side, select the Test Bench
Waveform file named ‘half_adder_tb’. Then, click on the ‘Process View’ tab, located at
the bottom of the 2nd window from the top on the left hand side.
Page | 14
Digital System Design LAB 1
31.Clicking the ‘Process View’ for half_adder_tb file will result in the screen as shown
below:
Page | 15
Digital System Design LAB 1
32. Expand the “Xilinx ISE Simulator” options in the Processes Window and double click on
the “Simulate Behavioral Model” option.
33. This will start the simulation process and you will end up with something like this:
34. Out of the four tabs available at the bottom of the main window, select the second from
the right hand side named half_adder_tb_isim. This will show you the results of
simulating the Verilog module half_adder.v by applying it the input waveform mentioned
in the file half_adder_tb.tbw.
Page | 16
Digital System Design LAB 1
35. Exercise:
Write down the module statement and port list for the following Block diagram:
(You are not expected to write the whole programme just the first couple of statements)
36. Following the steps indicated as above simulate the full adder . ( I mean the so many
steps you just did , do them again and get used to them . They are your friends!!! )
Gate level code for the full adder module:
output sum;
Page | 17
Digital System Design LAB 1
output carry_out;
input in1;
input in2;
input carry_in;
wire c, d, e;
xor x1(c,in1,in2);
xor x2(sum, c, carry_in);
and a1(d, in1, in2);
and a2(e, c, carry_in);
or o1(carry_out, d, e);
end module
Note the difference of Verilog code for the full adder and the code of half adder
employed in the last couple of steps . Note the use of “wire c,d,e;” in order to handle
the intermediate connections between the gates.
37.Enter this code and then, simulate it using the steps described above
39. The use of the smaller blocks to design a larger block is known as “Hierarchical Design”.
This sort of hierarchical design can be implemented in Verilog as well through the
concept of “Instantiating” a smaller module in some larger module .Following is the
Verilog Code for the full adder using this hierarchical approach, by “Instantiating” the
half_adder module.
output sum;
output carry_out;
input in1;
input in2;
Page | 18
Digital System Design LAB 1
input carry_in;
wire c, d, e;
half_adder h1(s1,c1,in1,in2);
half_adder h2( x2(sum, c2, s1, carry_in);
or o1(carry_out, c1, c2);
endmodule
40. Enter this code and then, simulate it using the steps described above.
41. Previously you had been asked to write the Verilog Code of a 4 bit Ripple Carry Adder
which consisted of 4 full adders that you had previously designed. Now, you will again
write the Verilog Code for this Ripple Carry Adder but this time the inputs and outputs
will be handled differently using the concept of “Vectors” in Verilog.
42. Following is the Diagram for that Ripple Carry Adder using this new approach.
43. Following is the Verilog code for the Ripple Carry Adder defining the inputs and outputs as
Vectors.
endmodule
As it had been mentioned in the first lab that in Verilog we have different levels of
abstraction available to us like:
a. Gate level
b. Dataflow level
c. Behavioral level
Page | 19
Digital System Design LAB 1
In the first few labs, we have looked at the Gate level coding. Now, we shall take a look at
the Dataflow level Coding:
In the manual techniques of designing any digital logic circuit, we start from the truth
table, generate a separate Boolean Equation for each output column of the truth table,
then these Boolean equations are simplified using different techniques and finally, these
simplified Boolean equations are translated into gate level diagram.
In Gate level coding, we basically translate the gate level diagram of a circuit into
statements. While in Dataflow level coding, we can directly translate the Boolean
equations of a circuit into statements. So, you can easily see that Dataflow level coding
is at a higher level of abstraction as compared to Gate level coding. While describing
Boolean equations in the form of Dataflow statements, we use logical operators like
negation (~), and (&), or(|), xor(^), xnor(^~),etc. Besides describing Boolean
equations at Dataflow level, we can even move on to a higher level of abstraction and
use other type of operators as well like arithmetic operators(+,-) etc.
Page | 20
Digital System Design LAB 1
45. See the results of Designed module using ISE Simulator.
output sum;
output carry;
input X,Y,Z;
assign sum = X ^ Y ^ Z;
assign carry = (X & Y) | (Z & (X ^ Y));
endmodule
49. Write the code for a 4 bit adder using data flow modelling.
51. This was the start and end of Gate Level Modelling.
Page | 21
Observations/Comments/Explanation of Results