Lab 2
Lab 2
Lab 2
1
Digital Systems Design
2
Modeling Digital Systems
• HDL is for writing models of a system
• Reasons for modeling
– requirements specification
– documentation
– testing using simulation
– formal verification
– synthesis
• Goal
– most reliable design process, with minimum cost and
time
– avoid design errors!
3
Generation of ICs
4
IC Design Flow
5
IC Design Flow
6
Hardware Description Languages
• HDL can be used to describe any digital
system:
• For example, a computer or a component.
• A digital system can be described at several
levels:
• Switch level: wires, resistors and transistors
• Gate level: logic gates and flip flops
• Register Transfer Level (RTL): registers and
the transfers of information between registers.
Basic Limitation of HDL
Description of digital systems only
Application Areas of HDL
System Specification
Suitable for all levels
Behavioral level
Not suitable
HW/SW
Partition
Hardware Softwre
Spec Spec
ASIC
FPGA Boards
Software
&
PLD Systems
Std Parts
Why use HDL?
• Text-based
• Allows simulation before building
circuit
• Can be compiled (synthesized)
into logic circuit
• Much easier to write test
benches
10
Why use HDL?
• More abstract models of circuits
▪Easier to write
▪Simulates faster
• More flexible
• Provides sequencing
• A major par of Verilog’s success:
▪It allowed both the model and the
testbench to be described together
11
Two Major HDLs
• VHDL
• Verilog HDL
• Virtually every chip (FPGA, ASIC,
etc.):
▪ Designed in part using one of these
two languages
• Combines structural and behavioral
modeling styles. 12
VHDL
• “V” is short for Very High Speed
Integrated Circuits.
• Designed for and sponsored by US
Department of Defense.
• Designed by a committee (1981-1985).
• Syntax based on Ada programming
language.
• Was made an IEEE Standard in 1987.
13
Verilog HDL
• Introduced in 1985 by Gateway
Design System Corporation:
▪ Now a part of Cadence Design
Systems, Inc.
• Became an IEEE Standard in 1995
• Syntax based on C programming
language.
14
Verilog Compared to VHDL
• Verilog and VHDL are comparable languages
• VHDL has a slightly wider scope
▪ System-level modeling
▪ Fewer sources of nondeterminism (e.g., no
shared variables)
• VHDL is harder to simulate quickly
• VHDL has fewer built-in facilities for
hardware modelling
• VHDL is a much more verbose language
▪ Most examples don’t fit on slides
15
Design Methodology
16
Introduction to Verilog
• Verilog is Hardware description language(HDL).
• It describes digital system like MP, FF, Registers, Memory etc.
• HDL descriptions provide technology-independent documentation of
a design and its functionality.
• Design style :
→ Bottom-up -- Each design is performed at gate level
→ Top Down -- Desired style of all designers- early testing is done.
Abstraction Levels in HDLs
Behavioral
Gate
Layout (VLSI)
Concept of Verilog “Module”
input/output declarations;
parallel statements;
endmodule
Example 1 :: simple AND gate
• Arithmetic operators
*, /, +, -, %
• Logical operators
! logical negation
&& logical AND
|| logical OR
• Relational operators
>, <, >=, <=, ==, !=
• Bitwise operators
~, &, |, ^, ~^
Description Styles in Verilog
• Examples
module generate_sum (a, b, c);
input a, b;
output c;
xor (c, a, b);
endmodule
Data-flow Modeling
• X: unknown
• Declaring a register
reg [<range>] <reg_name> [<reg_name>*];
• Declaring memory
reg [<range>] <memory_name> [<start_addr> : <end_addr>];
• Examples
reg r; // 1-bit reg variable
wire w1, w2; // 2 1-bit wire variable
reg [7:0] vreg; // 8-bit register
reg [7:0] memory [0:1023]; a 1 KB memory
1. Introduction
➢ References :
▪ Introduction to Simulation of Verilog Designs Using ModelSim
Graphical Waveform Editor (Altera).
42
2. Design Project
Simple example : f(x1, x2, x3) = x1x2 + x2x3 + x3x1
Verilog code :
assign f = (x1&x2)|(x2&x3)|(x3&x1);
endmodule;
43
2. Design Project
Open the ModelSim simulator. In the displayed
window select File > New > Project
44
2. Design Project
A Create Project pop-up box will appear…
Choose Project
Location
45
2. Design Project
Create new file…
3
46
2. Design Project
Double click
Text Editor
47
2. Design Project
Or add existing file…
48
2. Design Project
After completed coding, select Compile > Compile all
50
3. Simulate without testbench
Simulation window…
51
3. Simulate without testbench
Create waveforms for Simulation…
52
3. Simulate without testbench
Modify waveforms for Simulation…
Right click
53
3. Simulate without testbench
Waveform window…
54
3. Simulate without testbench
Waveform window…
55
3. Simulate without testbench
With output signal…
56
3. Simulate without testbench
Simulate…Select Run all
57
3. Simulate without testbench
Result…