Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Verilog</strong> <strong>for</strong><br />
<strong>Digital</strong> <strong>Design</strong><br />
Chapter 1:<br />
Introduction<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
1
<strong>Digital</strong> Systems<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
2
<strong>Digital</strong> Systems<br />
• <strong>Digital</strong> systems surround us<br />
– Electronic system operating on 0s and 1s<br />
– Typically implemented on an Integrated t Circuit it (IC) –<br />
"chip"<br />
• Desktop/laptop computers ("PCs") are the most<br />
popular examples<br />
• Other increasingly common examples<br />
– Consumer electronics: Cell phones, portable music<br />
players, cameras, video game consoles, electronic<br />
music instruments, ...<br />
– Medical equipment: Hearing aids, pacemakers, life<br />
support systems, ...<br />
– Automotive electronics: Engine control, brakes, ...<br />
– Military equipment<br />
– Networking components: Routers, switches, ...<br />
– Many, many more...<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
3
Hardware Description Languages (HDLs)<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
4
<strong>Digital</strong> Systems and HDLs<br />
• Typical digital components per IC<br />
– 1960s/1970s: 10-1,000<br />
– 1980s: 1,000-100,000<br />
100 – 1990s: Millions<br />
– 2000s: Billions<br />
• 1970s<br />
– IC behavior documented using<br />
combination of schematics,<br />
diagrams, and natural language<br />
(e.g., English)<br />
• 1980s<br />
– Simulating circuits becoming more<br />
important<br />
• Schematics commonplace<br />
• Simulating schematic helped<br />
ensure circuit was correct be<strong>for</strong>e<br />
costly implementation<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
natural<br />
language<br />
IC (millions)<br />
Transistors per I<br />
100,000<br />
10,000<br />
1,000<br />
100<br />
10<br />
1997<br />
2000 0<br />
2003<br />
diagrams<br />
schematics<br />
"The system has four states.<br />
When in state Off, the<br />
system outputs 0 and stays<br />
in state Off until the input<br />
becomes 1. In that case, the<br />
system enters state On1,<br />
followed by On2, and then<br />
On3, in which the system<br />
outputs 1. The system then<br />
returns to state Off."<br />
b<br />
FSM<br />
inputs<br />
clk<br />
2006<br />
b<br />
clk<br />
2009<br />
2012 2<br />
2015<br />
2018<br />
Inputs: b; Outputs: x<br />
x=0<br />
Off b’<br />
s1<br />
b<br />
x=1<br />
On1<br />
x=1<br />
On2<br />
Combinational Logic<br />
Combinational<br />
logic<br />
s1<br />
s0<br />
State register<br />
s0<br />
State register<br />
n1<br />
n0<br />
x<br />
x=1<br />
On3<br />
FSM<br />
outputs<br />
5<br />
x<br />
n1<br />
n0
HDLs <strong>for</strong> Simulation<br />
• Hardware description<br />
languages (HDLs) –<br />
Machine-readable textual<br />
languages <strong>for</strong> describing<br />
hardware<br />
– Text language could be<br />
more efficient means of<br />
circuit entry than graphical<br />
language<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
// CombLogic<br />
always @(State, B) begin<br />
case (State)<br />
FSM inputs<br />
end<br />
endcase<br />
end<br />
S_Off: begin<br />
X
<strong>Verilog</strong><br />
• <strong>Verilog</strong><br />
– Defined in 1985 at Gateway <strong>Design</strong> Automation Inc.,<br />
which was then acquired by Cadence <strong>Design</strong><br />
Systems<br />
– C-like syntax<br />
– Initially a proprietary language, but became open<br />
standard in early 1990s, then IEEE standard<br />
("1364") in 1995, revised in 2002, and again in 2005.<br />
• Other HDLs<br />
– VHDL<br />
• VHSIC Hardware Description Language / defined in<br />
1980s / U.S. Dept. of Defense project / Ada-like syntax /<br />
IEEE standard ("1076") in 1987<br />
• VHDL & <strong>Verilog</strong> very similar in capabilities, differ mostly<br />
in syntax<br />
– SystemC<br />
• Defined in 2000s by several companies / C++ libraries<br />
and macro routines / IEEE standard ("1666") in 2005<br />
• Excels <strong>for</strong> system-level; cumbersome <strong>for</strong> logic level<br />
– System<strong>Verilog</strong><br />
• System-level modeling extensions to <strong>Verilog</strong> / IEEE<br />
Standard ("1800") in 2005<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
module DoorOpener(C,H,P,F);<br />
input C, H, P;<br />
output F;<br />
reg F;<br />
always @(C,H,P)<br />
begin<br />
F
HDLs <strong>for</strong> <strong>Design</strong> and Synthesis<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
8
HDLs <strong>for</strong> <strong>Design</strong> and Synthesis<br />
• HDLs became increasingly used <strong>for</strong><br />
designing ICs using top-down design<br />
process<br />
– <strong>Design</strong>: Converting a higher-level<br />
description into a lower-level one<br />
– Describe circuit in HDL, simulate<br />
FSM inputs<br />
• Physical design tools automatically<br />
convert to low-level IC design<br />
– Describe behavior in HDL, simulate<br />
• e.g., Describe addition as A = B + C,<br />
rather than as circuit of hundreds of logic<br />
gates<br />
– Compact description, designers get<br />
function right first<br />
• <strong>Design</strong> circuit<br />
– Manually, or<br />
– Using synthesis tools, which<br />
automatically convert HDL behavior to<br />
HDL circuit<br />
– Simulate circuit, it should match<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
HDL<br />
HDL<br />
HDL behavior<br />
Synthesis<br />
HDL circuit<br />
Physical design<br />
FSM outputs<br />
Clk_s<br />
Rst_s<br />
b_s<br />
x_s<br />
Clk_s<br />
Rst_s<br />
10 20 30 4050 60 70 8090100110<br />
b_s<br />
x_s<br />
10 20 30 4050 60 70 8090100110<br />
9
HDLs <strong>for</strong> Synthesis<br />
• Use of HDLs <strong>for</strong> synthesis is growing<br />
– Circuits are more complex<br />
– Synthesis tools are maturing<br />
• But HDLs originally defined <strong>for</strong><br />
simulation<br />
– General language<br />
– Many constructs not suitable <strong>for</strong><br />
synthesis<br />
• e.g., delays<br />
– Behavior description may simulate, but<br />
not synthesize, or may synthesize to<br />
incorrect or inefficient circuit<br />
• Not necessarily synthesis tool's fault!<br />
HDL behavior<br />
Synthesis<br />
HDL circuit<br />
Clk_s<br />
Simulate Rst_s<br />
b_s<br />
x_s<br />
10 20 30 4050 60 70 8090100110<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
10
HDLs <strong>for</strong> Synthesis<br />
• Consider the English language<br />
– General and complex; many uses<br />
– But use <strong>for</strong> cooking recipes is greatly restricted<br />
• Chef understands: stir, blend, eggs, bowl, ...<br />
• Chef may not understand: bludgeon, harmonic,<br />
<strong>for</strong>thright, castigate, ..., even if English grammar<br />
is correct<br />
– If the meal turns out bad, don't blame the chef!<br />
• Likewise, consider HDL language<br />
– General and complex; many uses<br />
– But use <strong>for</strong> synthesizing circuits is greatly<br />
restricted ti t • Synthesis tool understands: sensitivity lists, if<br />
statements, ...<br />
• Synthesis tool may not understand: wait<br />
statements, while loops, ..., even if the HDL<br />
simulates correctly<br />
– If the circuit is bad, don't blame the synthesis tool!<br />
– This book emphasizes use of VHDL <strong>for</strong> design<br />
and synthesis<br />
HDL behavior<br />
Synthesis<br />
HDL circuit<br />
Clk_s<br />
Simulate Rst_s<br />
b_s<br />
x_s<br />
10 20 30 4050 60 70 8090100110<br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
11
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
• This book introduces use of <strong>Verilog</strong> <strong>for</strong> design and synthesis<br />
– In contrast to books that introduce the general language first, and then (maybe)<br />
describe synthesis subset<br />
– No need to learn entire French language if your goal is just to write recipes in<br />
French<br />
• Shows use of <strong>Verilog</strong> <strong>for</strong> increasingly complex digital systems<br />
– Combinational logic design<br />
– Sequential logic design<br />
– Datapath components<br />
– Register transfer level (RTL) design<br />
– Emphasizes a very disciplined use of the language <strong>for</strong> specific purposes<br />
• Book can be used as supplement to digital design textbook<br />
– Specifically follows structure and examples of "<strong>Digital</strong> <strong>Design</strong>" by Frank Vahid,<br />
John Wiley and Sons, 2007<br />
• But can be used with other books too<br />
– Can also be used as standalone introduction to <strong>Verilog</strong><br />
<strong>Verilog</strong> <strong>for</strong> <strong>Digital</strong> <strong>Design</strong><br />
Copyright © 2007<br />
Frank Vahid and Roman Lysecky<br />
12