Onur Digitaldesign Comparch 2021 Lecture8 Timing and Verification Afterlecture
Onur Digitaldesign Comparch 2021 Lecture8 Timing and Verification Afterlecture
ETH Zürich
Spring 2021
19 March 2021
Required Readings (This Week)
Hardware Description Languages and Verilog
H&H Chapter 4 in full
2
Required Readings (Next Week)
Von Neumann Model, LC-3, and MIPS
P&P, Chapter 4, 5
H&H, Chapter 6
P&P, Appendices A and C (ISA and microarchitecture of LC-3)
H&H, Appendix B (MIPS instructions)
Programming
P&P, Chapter 6
3
Assignment: Required Lecture Video
Why study computer architecture? Why is it important?
Future Computing Platforms: Challenges & Opportunities
Required Assignment
Watch one of Prof. Mutlu’s lectures and analyze either (or both)
https://www.youtube.com/watch?v=kgiZlSOcGFM (May 2017)
https://www.youtube.com/watch?v=mskTeNnf-i0 (Feb 2021)
5
Extra Assignment 2: Moore’s Law (II)
Guidelines on how to review papers critically
6
Agenda
Wrap Up FSMs in Verilog
Circuit Verification
7
Wrap Up: FSMs in Verilog
8
Recall: Finite State Machines (FSMs)
Each FSM consists of three separate parts:
next state logic
state register
output logic
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
state register
9
Recall: Finite State Machines (FSMs)
Comprise
Sequential circuits CLK
State register(s)
Store the current state and S’ S
Next Current
Load the next state at the clock edge State State
10
FSM Example 1: Divide the Clock Frequency by 3
The output Y is HIGH for one clock cycle out of every 3. In other
words, the output divides the frequency of the clock by 3.
11
Implementing FSM Example 1: Definitions
module divideby3FSM (input clk,
input reset,
output q);
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
12
Implementing FSM Example 1: State
Register CLK
S’ S
Next Current
State State
// state register
always @ (posedge clk, posedge reset)
if (reset) state <= S0;
else state <= nextstate;
13
Implementing FSM Example 1: Next State
Logic
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
14
Implementing FSM Example 1: Output Logic
CLK
M next
next k state k output N
inputs state
state
outputs
logic
logic
// output logic
assign q = (state == S0);
16
FSM Example 2: Smiling Snail
Alyssa P. Hacker has a snail that crawls down a paper tape
with 1’s and 0’s on it
The snail smiles whenever the last four digits it has crawled
over are 1101
Design Moore and Mealy FSMs of the snail’s brain
Moore
Mealy
17
Implementing FSM Example 2:
Definitions
module SmilingSnail (input clk,
input reset,
input number,
output smile);
parameter S0 = 2'b00;
parameter S1 = 2'b01;
parameter S2 = 2'b10;
parameter S3 = 2’b11;
number/smile
18
Implementing FSM Example 2: State
Register
// state register
always @ (posedge clk, posedge reset)
if (reset) state <= S0;
else state <= nextstate;
19
Implementing FSM Example 2: Next State
Logic
// next state logic
always @ (*)
case (state)
S0: if (number) nextstate = S1;
else nextstate = S0;
S1: if (number) nextstate = S2;
else nextstate = S0;
S2: if (number) nextstate = S2;
else nextstate = S3;
S3: if (number) nextstate = S1;
else nextstate = S0;
default: nextstate = S0;
endcase
20
Implementing FSM Example 2: Output Logic
// output logic
assign smile = (number & state == S3);
21
Implementation of FSM Example 2
module SmilingSnail (input clk, always @ (*) // next state logic
input reset, case (state)
input number, S0: if (number)
output smile); nextstate = S1;
else nextstate = S0;
reg [1:0] state, nextstate; S1: if (number)
nextstate = S2;
parameter S0 = 2'b00; else nextstate = S0;
parameter S1 = 2'b01; S2: if (number)
parameter S2 = 2'b10; nextstate = S2;
parameter S3 = 2’b11; else nextstate = S3;
S3: if (number)
// state register nextstate = S1;
always @ (posedge clk, posedge else nextstate = S0;
reset) default: nextstate = S0;
if (reset) state <= S0; endcase
else state <= nextstate; // output logic
assign smile = (number & state==S3);
endmodule
22
What Did We Learn?
Basics of describing sequential circuits in Verilog
24
What Will We Learn Today?
Timing in combinational circuits
Propagation delay and contamination delay
Glitches
Circuit Verification
How to make sure a circuit works correctly
Functional verification
Timing verification
25
Tradeoffs in Circuit Design
26
Circuit Design is a Tradeoff Between:
Area
Circuit area is proportional to the cost of the device
Speed / Throughput
We want faster, more capable circuits
Power / Energy
Mobile devices need to work with a limited power supply
High performance devices dissipate more than 100W/cm2
Design Time
Designers are expensive in time and money
The competition will not wait for you
27
Requirements and Goals Depend On
Application
28
Circuit Timing
Until now, we investigated logical functionality
29
Part 1:
Combinational Circuit Timing
30
Digital Logic Abstraction
“Digital logic” is a convenient abstraction
Output changes immediately with the input
A 1 0
Y 0 1
31
Combinational Circuit Delay
In reality, outputs are delayed from inputs
Transistors take a finite amount of time to switch
A Y
delay
time
Time
32
Real Inverter Delay Example
Image source: Sandoval-Ibarra, F., and E. S. Hernández-Bernal. "Ring CMOS NOT-based oscillators:
Analysis and design." Journal of applied research and technology, 2008.
33
Circuit Delay and Its Variation
Delay is fundamentally caused by
Capacitance and resistance in a circuit
Finite speed of light (not so fast on a nanosecond scale!)
34
Delays from Input to Output Y
Contamination delay (tcd): delay until Y starts changing
Propagation delay (tpd): delay until Y finishes changing
Cross-hatching
means value is changing 35
Calculating Longest & Shortest Delay
Paths
We care about both the longest and shortest delay paths
in a circuit (we will see why later in the lecture)
Critical Path
A n1
B
n2
C
D Y
Short Path
Critical (Longest) Path: tpd = 2 tpd_AND + tpd_OR
Shortest Path: tcd = tcd_AND
36
Calculating Longest Delay Path (Critical
Path)
41
Disclaimer: Calculating Long/Short
Paths
It’s not always this easy to determine the long/short paths!
Not all input transitions affect the output
Can have multiple different paths from an input to output
42
Combinational Timing Summary
Circuit outputs change some time after the inputs change
Caused by finite speed of light (not so fast on a ns scale!)
Delay is dependent on inputs, environmental state, etc.
43
Output Glitches
44
Glitches
Glitch: one input transition causes multiple output transitions
0
0
1
45
Glitches
Glitch: one input transition causes multiple output transitions
0
1 -> 0
1 -> ?
46
Glitches
Glitch: one input transition causes multiple output transitions
1
Fast path (2 gates)
47
Glitches
Glitch: one input transition causes multiple output transitions
1
Fast path (2 gates)
48
Glitches
Glitch: one input transition causes multiple output transitions
Slow path (3 gates)
0
(B) 1 -> 0 n1
(Y) 1 -> 0 -> 1
n2
1
Fast path (2 gates)
49
Optional: Avoiding Glitches Using K-Maps
Glitches are visible in K-maps
Recall: K-maps show the results of a change in a single input
A glitch occurs when moving between prime implicants
(A) 0 AB
(B) 1 -> 0
(Y) 1 -> 0 -> 1
(C) 1
BC
50
Optional: Avoiding Glitches Using K-Maps
We can fix the issue by adding in the consensus term
Ensures no transition between different prime implicants
(A) 0 AB
(B) 1 -> 0
BC (Y) 1 -> 1
(C) 1
AC
No dependence on B
=> No glitch!
51
Avoiding Glitches
Q: Do we always care about glitches?
Fixing glitches is undesirable
More chip area
More power consumption
More design effort
The circuit is eventually guaranteed to converge to the right
value regardless of glitchiness
52
Part 2:
Sequential Circuit Timing
53
Recall: D Flip-Flop
Flip-flop samples D at the active clock edge
It outputs the sampled value to Q
It “stores” the sampled value until the next active clock edge
CLK
D Q
D
D Q
tsetup thold
ta
Setup time (tsetup): time before the clock edge that data
must be stable (i.e. not changing)
Hold time (thold): time after the clock edge that data must
be stable
Aperture time (ta): time around clock edge that data
must be stable (ta = tsetup + thold)
55
Violating Input Timing: Metastability
If D is changing when sampled, metastability can occur
Flip-flop output is stuck somewhere between ‘1’ and ‘0’
Output eventually settles non-deterministically
Example Timing Violations (NAND RS Latch)
CLK
Q Non-deterministic
Convergence
Metastability
Source: W. J. Dally, Lecture notes for EE108A, Lecture 13: Metastability and
Synchronization Failure (When Good Flip-Flops go Bad) 11/9/2005. 56
Flip-Flop Output Timing
CLK CLK
D Q
tccq
tpcq
58
Ensuring Correct Sequential Operation
Need to ensure correct input timing on R2
CLK
tsetup thold
ta
59
Ensuring Correct Sequential Operation
This means there is both a minimum and maximum
delay between two flip-flops
CL too fast -> R2 thold violation
Potential
CL too slow -> R2 tsetup violation
R2 ttSETUP
R2 HOLD
VIOLATION!
CLK CLK
Q1 CL D2
R1 R2
(a)
Tc
CLK
Q1
D2
(b) tHOLD tSETUP
60
Setup Time Constraint
Safe timing depends on the maximum delay from R1 to R2
The input to R2 must be stable at least tsetup before the clock edge.
CLK CLK
Q1 D2
CL Tc
R1 R2
Tc
CLK
Q1
D2
tpcq tpd tsetup
61
Setup Time Constraint
Safe timing depends on the maximum delay from R1 to R2
The input to R2 must be stable at least tsetup before the clock edge.
CLK CLK
Q1 D2
CL Tc > tpcq
R1 R2
Tc
CLK
Q1
D2
tpcq tpd tsetup
62
Setup Time Constraint
Safe timing depends on the maximum delay from R1 to R2
The input to R2 must be stable at least tsetup before the clock edge.
CLK CLK
Q1 D2
CL Tc > tpcq + tpd
R1 R2
Tc
CLK
Q1
D2
tpcq tpd tsetup
63
Setup Time Constraint
Safe timing depends on the maximum delay from R1 to R2
The input to R2 must be stable at least tsetup before the clock edge.
CLK CLK
Q1 D2
CL Tc > tpcq + tpd + tsetup
R1 R2
Tc
CLK
Q1
D2
tpcq tpd tsetup
64
Setup Time Constraint
Safe timing depends on the maximum delay from R1 to R2
The input to R2 must be stable at least tsetup before the clock edge.
Wasted work
CLK CLK
Q1 CL D2
Tc > tpcq + tpd + tsetup
R1 R2 Useful work
Tc
CLK
Q1 Sequencing overhead:
D2
amount of time wasted
tpcq tpd tsetup
each cycle due to sequencing
element timing requirements
65
tsetup Constraint and Design Performance
66
Hold Time Constraint
Safe timing depends on the minimum delay from R1 to R2
D2 (i.e., R2 input) must be stable for at least thold after the clock edge
Must not change until
thold after the clock
CLK CLK
Q1 CL D2 tccq
R1 R2
CLK
Q1
D2
tccq tcd
thold
67
Hold Time Constraint
Safe timing depends on the minimum delay from R1 to R2
D2 (i.e., R2 input) must be stable for at least thold after the clock edge
CLK CLK
Q1 CL D2 tccq + tcd
R1 R2
CLK
Q1
D2
tccq tcd
thold
68
Hold Time Constraint
Safe timing depends on the minimum delay from R1 to R2
D2 (i.e., R2 input) must be stable for at least thold after the clock edge
CLK CLK
Q1 CL D2 tccq + tcd > thold
R1 R2
CLK
Q1
D2
tccq tcd
thold
69
Hold Time Constraint
Safe timing depends on the minimum delay from R1 to R2
D2 (i.e., R2 input) must be stable for at least thold after the clock edge
CLK CLK
Q1 CL D2 tccq + tcd > thold
R1 R2
tcd > thold - tccq
CLK
Q1
We need to have a minimum
D2
combinational delay!
tccq tcd
thold
70
Hold Time Constraint
Safe timing depends on the minimum delay from R1 to R2
D2 (i.e., R2 input) must be stable for at least thold after the clock edge
CLK CLK
Q1 CL D2 tccq + tcd > thold
R1 R2
tcd > thold - tccq
CLK
Q1
Does NOT depend on Tc!
D2
tccq tcd
Very hard to fix thold violations after
thold
manufacturing- must modify circuits!
71
Sequential Timing Summary
tccq / tpcq clock-to-q delay (contamination/propagation)
tcd / tpd combinational logic delay (contamination/propagation)
tsetup time that FF inputs must be stable before next clock edge
thold time that FF inputs must be stable after a clock edge
Tc clock period
R1 R2 R1 R2
Tc
CLK CLK
Q1 Q1
D2 D2
tccq tcd tpcq tpd tsetup
thold
72
Example: Timing Analysis
CLK CLK
A Timing Characteristics
tccq = 30 ps
B
tpcq = 50 ps
X' X
C tsetup = 60 ps
D
Y' Y thold = 70 ps
per gate
tpd = 35 ps
tpd =
tcd = 25 ps
tcd =
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc >
fmax = 1/Tc =
73
Example: Timing Analysis
CLK CLK
A Timing Characteristics
tccq = 30 ps
B
tpcq = 50 ps
X' X
C tsetup = 60 ps
D
Y' Y thold = 70 ps
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd =
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc >
fmax = 1/Tc =
74
Example: Timing Analysis
CLK CLK
A Timing Characteristics
tccq = 30 ps
B
tpcq = 50 ps
X' X
C tsetup = 60 ps
D
Y' Y thold = 70 ps
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 25 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc >
fmax = 1/Tc =
75
Example: Timing Analysis
tpcq CLKA CLK
Timing Characteristics
tccq = 30 ps
B tpd
tpcq = 50 ps
X' X
C tsetup = 60 ps
D
Y' Y thold = 70 ps
tsetup
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 25 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc > (50 + 105 + 60) ps = 215 ps
fmax = 1/Tc = 4.65 GHz
76
Example: Timing Analysis
CLK CLK
A Timing Characteristics
tccq = 30 ps
B
tccq tpcq = 50 ps
X' X
C tsetup = 60 ps
D
tcd Y' Y thold = 70 ps
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 25 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
D
Y' Y thold = 70 ps
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 25 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
I L
Tc > (50 + 105 + 60) ps = 215 ps (30 + 25) ps > 70 ps ? FA
fmax = 1/Tc = 4.65 GHz 78
Example: Fixing Hold Time Violation
Add buffers to the short paths:
CLK CLK
Timing Characteristics
A tccq = 30 ps
B tpcq = 50 ps
X' X tsetup = 60 ps
C
thold = 70 ps
Y' Y
D
per gate
tpd = 35 ps
tpd =
tcd = 25 ps
tcd =
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc >
fc =
79
Example: Fixing Hold Time Violation
Add buffers to the short paths:
CLK CLK
Timing Characteristics
A tccq = 30 ps
B tpcq = 50 ps
X' X tsetup = 60 ps
C
thold = 70 ps
Y' Y
D
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 2 x 25 ps = 50 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc >
fc =
80
Example: Fixing Hold Time Violation
Add buffers to the short paths:
CLK CLK
Timing Characteristics
tpcq A tccq = 30 ps
B tpd tpcq = 50 ps
X' X tsetup = 60 ps
C
thold = 70 ps
Y' Y
D
tsetup
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 2 x 25 ps = 50 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc > (50 + 105 + 60) ps = 215 ps
fc = 1/Tc = 4.65 GHz
81
Example: Fixing Hold Time Violation
Add buffers to the short paths:
CLK CLK
Timing Characteristics
A tccq = 30 ps
B tpcq = 50 ps
X' X tsetup = 60 ps
C
thold = 70 ps
Y' Y
D
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 2 x 25 ps = 50 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc > (50 + 105 + 60) ps = 215 ps
Note: no change
fc = 1/Tc = 4.65 GHz to max frequency!
82
Example: Fixing Hold Time Violation
Add buffers to the short paths:
CLK CLK
Timing Characteristics
A tccq = 30 ps
B tpcq = 50 ps
tccq X' X tsetup = 60 ps
C
tcd Y' Y
thold = 70 ps
D
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 2 x 25 ps = 50 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
Tc > (50 + 105 + 60) ps = 215 ps (30 + 50) ps > 70 ps ?
fc = 1/Tc = 4.65 GHz
83
Example: Fixing Hold Time Violation
Add buffers to the short paths:
CLK CLK
Timing Characteristics
A tccq = 30 ps
B tpcq = 50 ps
X' X tsetup = 60 ps
C
thold = 70 ps
Y' Y
D
per gate
tpd = 35 ps
tpd = 3 x 35 ps = 105 ps
tcd = 25 ps
tcd = 2 x 25 ps = 50 ps
Check setup time constraints: Check hold time constraints:
Tc > tpcq + tpd + tsetup tccq + tcd > thold ?
SS
Tc > (50 + 105 + 60) ps = 215 ps (30 + 50) ps > 70 ps ? PA
fc = 1/Tc = 4.65 GHz
84
Clock Skew
To make matters worse, clocks have delay too!
The clock does not reach all parts of the chip at the same time!
Clock skew: time difference between two clock edges
CLOCK A
SOURCE
Long, slow B
clock path
Clock Source
Point A
Point B
clock skew
85
Clock Skew Example
Example of the Alpha 21264 clock skew spatial distribution
Source: Abdelhadi, Ameer, et al. "Timing-driven variation-aware nonuniform clock mesh synthesis." GLSVLSI’10.
89
Part 3:
Circuit Verification
90
How Do You Know That A Circuit Works?
You have designed a circuit
Is it functionally correct?
Even if it is logically correct, does the hardware meet all
timing constraints?
91
Testing Large Digital Designs
Testing can be the most time consuming design stage
Functional correctness of all logic paths
Timing, power, etc. of all circuit elements
Adapted from ”CMOS VLSI Design 4e”, Neil H. E. Weste and David Money Harris ©2011 Pearson 93
Part 4:
Functional Verification
94
Functional Verification
Goal: check logical correctness of the design
95
Testbench-Based Functional Testing
Testbench: a module created specifically to test a design
Tested design is called the “device under test (DUT)”
Outputs
Inputs
Test Output
Pattern Checking
Generator Logic
DUT
Testbench
97
Common Verilog Testbench Types
Input/Output
Testbench Error Checking
Generation
Simple Manual Manual
Self-Checking Manual Automatic
Automatic Automatic Automatic
98
Example DUT
We will walk through different types of testbenches to test
a module that implements the logic function:
y = (b ∙ c) + (a ∙ b)
// performs y = ~b & ~c | a & ~b
module sillyfunction(input a, b, c,
output y);
wire b_n, c_n;
wire m1, m2;
100
Simple Testbench
101
Simple Testbench
module testbench1(); // No inputs, outputs
reg a, b, c; // Manually assigned
wire y; // Manually checked
102
Simple Testbench: Output Checking
Most common method is to look at waveform diagrams
Thousands of signals over millions of clock cycles
time
Manually check that output is correct at all times
103
Simple Testbench
Pros:
Easy to design
Can easily test a few, specific inputs (e.g., corner cases)
Cons:
Not scalable to many test cases
Outputs must be checked manually outside of the simulation
E.g., inspecting dumped waveform signals
E.g., printf() style debugging
104
Self-Checking Testbench
105
Self-Checking Testbench
module testbench2();
reg a, b, c;
wire y;
initial begin
a = 0; b = 0; c = 0; #10; // apply input, wait 10ns
if (y !== 1) $display("000 failed."); // check result
c = 1; #10;
if (y !== 0) $display("001 failed.");
b = 1; c = 0; #10;
if (y !== 0) $display("010 failed.");
end
endmodule
106
Self-Checking Testbench
Pros:
Still easy to design
Still easy to test a few, specific inputs (e.g., corner cases)
Simulator will print whenever an error occurs
Cons:
Still not scalable to millions of test cases
Easy to make an error in hardcoded values
You make just as many errors writing a testbench as actual code
Hard to debug whether an issue is in the testbench or in the DUT
107
Self-Checking Testbench using Testvectors
Write testvector file
List of inputs and expected outputs
Can create vectors manually or automatically using an
already verified, simpler “golden model” (more on this later)
Example file:
$ cat testvectors.tv
000_1
001_0
010_0
011_0
100_1 Format:
101_1 input_output
110_0
111_0
…
108
Testbench with Testvectors Design
Use a “clock signal” for assigning inputs, reading outputs
Test one testvector each “clock cycle”
Clock cycle
module testbench3();
reg clk, reset; // clock and reset are internal
reg a, b, c, yexpected; // values from testvectors
wire y; // output of circuit
reg [31:0] vectornum, errors; // bookkeeping variables
reg [3:0] testvectors[10000:0];// array of testvectors
110
Testbench Example (2/5): Clock Generation
// generate clock
always // no sensitivity list, so it always executes
begin
clk = 1; #5; clk = 0; #5; // 10ns period
end
111
Testbench Example (3/5): Read Testvectors into
Array
// at start of test, load vectors and pulse reset
initial // Only executes once
begin
$readmemb("example.tv", testvectors); // Read
vectors
vectornum = 0; errors = 0; // Initialize
reset = 1; #27; reset = 0; // Apply reset wait
end
112
Testbench Example (4/5): Assign Inputs/Outputs
// apply test vectors on rising edge of clk
always @(posedge clk)
begin
{a, b, c, yexpected} = testvectors[vectornum];
end
113
Testbench Example (5/5): Check Outputs
always @(negedge clk)
begin
if (~reset) // don’t test during reset
begin
if (y !== yexpected)
begin
$display("Error: inputs = %b", {a, b, c});
$display(" outputs = %b (%b exp)",y,yexpected);
errors = errors + 1;
end
114
Self-Checking Testbench with
Testvectors
Pros:
Still easy to design
Still easy to test a few, specific inputs (e.g., corner cases)
Simulator will print whenever an error occurs
No need to change hardcoded values for different tests
Cons:
May be error-prone depending on source of testvectors
More scalable, but still limited by reading a file
Might have many more combinational paths to test than will fit in
memory
115
Automatic Testbench
116
Golden Models
A golden model represents the ideal circuit behavior
Must be developed, and might be difficult to write
Can be done in C, Perl, Python, Matlab or even in Verilog
module golden_model(input a, b, c,
output y);
assign y = ~b & ~c | a & ~b;// high-level abstraction
endmodule
117
Automatic Testbench
The DUT output is compared against the golden model
Inputs Outputs
DUT
Test
Pattern Check
Generation Equality
Golden
Model
Testbench
119
Automatic Testbench
Pros:
Output checking is fully automated
Could even compare timing using a golden timing model
Highly scalable to as much simulation time as is feasible
Leads to high coverage of the input space
Better separation of roles
Separate designers can work on the DUT and the golden model
DUT testing engineer can focus on important test cases
instead of output checking
Cons:
Creating a correct golden model may be (very) difficult
Coming up with good testing inputs may be difficult
120
However, Even with Automatic
Testing…
How long would it take to test a 32-bit adder?
In such an adder there are 64 inputs = 264 possible inputs
If you test one input in 1ns, you can test 109 inputs per
second
or 8.64 x 1014 inputs per day
or 3.15 x 1017 inputs per year
we would still need 58.5 years to test all possibilities
121
Part 5:
Timing Verification
122
Timing Verification Approaches
High-level simulation (e.g., C, Verilog)
Can model timing using “#x” statements in the DUT
Useful for hierarchical modeling
Insert delays in FF’s, basic gates, memories, etc.
High level design will have some notion of timing
Usually not as accurate as real circuit timing
123
The Good News
Tools will try to meet timing for you!
Setup times, hold times
Clock skews
…
124
The Bad News
The tool can fail to find a solution
Desired clock frequency is too aggressive
Can result in setup time violation on a particularly long path
Too much logic on clock paths
Introduces excessive clock skew
Timing issues with asynchronous logic
125
Meeting Timing Constraints
Unfortunately, this is often a manual, iterative process
Meeting strict timing constraints (e.g., high performance
designs) can be tedious
126
Meeting Timing Constraints: Principles
Let’s go back to the fundamentals
Circuit Verification
How to make sure a circuit works correctly
Functional verification
Timing verification
128
Digital Design & Computer Arch.
Lecture 8: Timing and Verification
ETH Zürich
Spring 2021
19 March 2021