advanced vlsi chap8-2-verilog
TRANSCRIPT
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
1/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Topics
Verilog register-transfer modeling:
basics using traffic light controller;
synthesis.
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
2/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog
Verilog was designed as an efficient
simulation language.
Relatively simple, terse syntax.
Most popular HDL in use today.
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
3/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog formulas
a & b Boolean AND
a | b Boolean OR
~a Boolean NOTa = b Assignment
a == b Equality
#1 timea
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
4/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog constants
Bit constant:
0, 1
Bit vector constant:
4b1010
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
5/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Some useful constructs
define aconst 2b00
constant vector
$monitor($time,,a=%b, b=%b,a,b);
value monitor output#1 a=0; b=0
#2 a=1; b=0sequence of waveforms
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
6/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Four-valued OR function
0 1 X z
0 0 1 x x
1 1 1 1 1
X x 1 x x
Z x 1 x x
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
7/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Four-valued AND function
0 1 X z
0 0 0 x x
1 0 1 x x
X x x x x
Z x x x x
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
8/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog structural model
Module adder(a,b,cin,sum,cout);
input a, b, cin;
output sum, cout;xor #2 s(sum,a,b,cin); // sum
and #1 // carry out
c1(x1,a,b); c2(x2,a,cin);
c3(x3,b,cin);or #1
c4(cout,x1,x2,x3);
endmodule
Time delay for output
Output
wireInput wires
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
9/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
If statements
if (b | c) then
y = 1;
elsey
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
10/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Conditional assignments
if (b | c) then
y = 1;
elsez = a | b;
Simulation:
Condition is tested
based on current signalstates.
Only one net gets an
event.
Synthesis: Creates dont-cares for
y and z.
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
11/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Loop statement
A loop performs an operation over an array
of signals:
for (i=0; i
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
12/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
always statement
always guards execution of a block of
statements.
Block is always executed on the logicalcondition.
always @(sigval) begin ..
end
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
13/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Structure of a Verilog model
Module statement.
Declares I/O pin names.
Declarations:
inputs and outputs;
registers.
Body.
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
14/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
A synthesizable Verilog
archtiecture
Declarations of pins and registers.
Definitions of constants (similar to C
#define statement). define GREEN 2b11
Combinational and sequential portions.
Within @always statements.
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
15/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog combinational portion
always @(ctrl_state or short or long or
cars) begin
when HG: begin // state hwy-green
highway_light = GREEN;
farm_light = RED;
if (cars & long) then
begin ctrl_next = HY; start_timer =1; end
else begin ctrl_next - HG;
start_timer = 0; end
end
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
16/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog sequential portion
always @(posedge clock or negedge reset)
if (~reset)
ctrl_state
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
17/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Testbench structure
Unit under test
(UUT)
testbench
tester
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
18/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Verilog testbed organization
Module declaration.
Two components: UUT and tester.
Definition of UUT.
Definition of tester.
-
7/28/2019 ADVANCED VLSI CHAP8-2-verilog
19/19
Modern VLSI Design 4e: Chapter 8 Copyright 2008 Wayne Wolf
Testbench tester process
initial
begin
$monitor($time,,a=%b,a);
#1 a=0; b=0; cin=0;
#1 a=1; b=0; cin=0;
#2 a=1; b=1; cin=1;
endendmodule
Test inputs
Prints signal values