Professional Documents
Culture Documents
Thiet Ke Vi Mach So Nang Cao Truong Quang Vinh Asic&Ip Ch4 p1 (Cuuduongthancong - Com)
Thiet Ke Vi Mach So Nang Cao Truong Quang Vinh Asic&Ip Ch4 p1 (Cuuduongthancong - Com)
Thiet Ke Vi Mach So Nang Cao Truong Quang Vinh Asic&Ip Ch4 p1 (Cuuduongthancong - Com)
HỒ CHÍ MINH
TRƯỜNG ĐẠI HỌC BÁCH KHOA
KHOA ĐIỆN-ĐIỆN TỬ
BỘ MÔN KỸ THUẬT ĐIỆN TỬ
om
.c
ng
ASIC CHIP AND IP CORE DESIGN
co
an
th
ng
Chapter 4: Verification Process (Part 1)
o
du
1 CuuDuongThanCong.com https://fb.com/tailieudientucntt
4.1 Test Environment
om
Testbench
Clock
.c
Generation
ng
Input Response Verification
co
Initialization Stimuli Assessment Utility & Synch’n
an
th
ng
Testbench to Design Interface
o
du
u
cu
Design Under
Verification
om
– Input vector % (10000111)
.c
Clock
ng
Input
Q0 D
co
Q1 D
Q7 D Q6 D Q5 D Q4 D Q3 D Q2 D FF
FF
FF FF FF FF FF FF
an
th
ng
Instantialtion:
o
du
u
om
• Need to apply a bit stream:
.c
• Store bits in an array and apply the array.
ng
initial i = size_of_input;
co
always @(posedge clk) begin
an
if (i != 0) begin
th
ng in <= input_array[i];
i <= i – 1;
end
o
du
end
Response assessment:
u
cu
om
initial begin
.c
DUV.Q0 = 1’b0;
ng
DUV.Q1 = 1’b0;
co
…
DUV.Q7 = 1’b0;
an
Clock generation: th
o ng
du
om
– Matlab
.c
– ModelSim
ng
co
– VCS
an
• Languages
th
ng
– VHDL, Verilog, SystemC
o
– Vera, Specman
du
u
– OVM, VMM
cu
– C/C++
om
– Initialization
.c
– Input stimulus generation
ng
– Responses assessment
co
• Approach
an
th
a) Initialize all inputs ng
b) Generate the clock signals
o
om
– TC1:
.c
• Verify integers add/subtract
• Input vectors chosen to cause corner cases (e.g. overflow)
ng
– TC2:
co
• Verify Boolean operations:
an
• Input vectors: certain bit patterns (e.g. 101010101, 11111111)
• Reusability: th
ng
– Use the same testbench for multiple test cases
o
du
om
– Assign values to state elements (FFs, memories)
.c
– Although the task of circuitry (at power-on), often done in
ng
testbench.
co
– Reasons:
an
• Initialization circuit has not designed at the time.
th
• Simulation is to run starting from a long time after power-on,
ng
– (e.g. simulating through initialization stage takes too long)
o
du
om
(uninitialized) to initial value and some others don’t.
.c
Inconsistent results from simulator to simulator.
ng
– Initialize at a positive time.
co
– Even safer:
an
• Initialize to X (or ‘U’) at time zero.
th
• Then initialize to init value at a positive time.
ng
task init_later;
input [N:0] value;
o
du
begin
design.usb.xmit.Q = 1’bx;
u
…
cu
#1;
design.usb.xmit.Q = value[0];
…
end
end task
om
.c
initial clock = 1’b0; initial clock = 1’b0;
always begin always begin
ng
#1 clock = 1’b1; #1 clock = ~clock; // rising
co
#1 clock = 1’b0; #1 clock = ~clock; // falling
#2 clock = 1’b1; #2 clock = ~clock; // rising
an
#2 clock = 1’b0; #2 clock = ~clock; // falling
end end
th
ng
period
o
du
u
cu
clock
om
– Difficult to see the value of clock at a given time
.c
• Comments: falling/rising.
ng
– If left uninitialized, doesn’t toggle (starts at x)
co
• A potential bug.
an
th
– Easy to change the phase or initial value.
ng
• Other statements kept intact.
o
du
om
– Clock divider:
.c
initial i = 0;
ng
always @(base_clock)
co
begin
an
i = i % N;
if (i = 0) derived_clock = ~derived_clock;
th
i = i +1; ng
end
o
du
Clock multiplier:
u
om
.c
initial begin
derived_clock = 1’b0; //assume starting 0
ng
@(posedge base_clock) T1 = $realtime;
@(posedge base_clock) T2 = $realtime;
co
period = T2 – T1;
T1 = T2;
an
->start; // start generating derived_clock
end
th
// continuously measure base block’s period
ng
always @(start)
forever
o
@(posedge base_clock) begin
du
T2 = $realtime;
period = T2 – T1;
u
T1 = T2;
cu
end
om
from the other.
.c
ng
initial clock1 = 1’b0; initial clock1 = 1’b0;
co
always clock1 = #1 always clock1 = #1 ~clock1;
~clock1;
an
initial clock2 = 1’b0;
initial clock2 = 1’b0;
th
always @(negedge clock1) clock2 = #2
always clock2 = #2 ~clock; ng ~clock;
o
Right Wrong
du
u
cu
om
different:
− Adding jitter to clock1 must not affect clock2
.c
ng
initial clock1 = 1’b0;
co
always clock1 = #1 ~clock1;
an
jitter = $random(seed) % RANGE;
th
assign clock1_jittered = (jitter) clock1;
ng
o
du
u
cu
om
may be produced:
• intermittent behavior.
.c
– Independent waveforms should be synchronized before propagation
ng
co
an
th Synch’er
ng
w1
o
w3
du
Synchronized
signal
Synchronizing
u
w2
cu
Signal
om
– A latch.
.c
– Uses a signal (synchronizing) to trigger sampling of
ng
another to create a dependency between them.
co
an
• Removes uncertainty in their relative phase.
th
ng
always @(fast_clock)
o
clock_synchronized <= clock;
du
u
cu
om
– Applying vectors to primary inputs synchronously.
.c
Stimuli Memory
ng
input vector
10111011 I/O
co
10111100 memory
an
00001110 I D
Control Data
th
00101101
00001111
ng
11011011
o
00110010
du
10101010
u
cu
Stimulus Design
Clock
Testbench
om
– triggered by a stimulus clock, memory is read one vector at
.c
a time.
ng
– Stimulus clock must be synchronized with design clock.
co
– Encapsulate the code for applying data in a task (procedure)
an
• Stimulus application is separated from particular memory or
th
design ng
• Asynchronous Method:
o
du
• e.g. Handshaking.
cu
om
1. Monitoring the design nodes during simulation
2. Comparing the node values with expected values.
.c
ng
• Absence of discrepancy could have many meanings:
co
– Erroneous nodes were not monitored,
an
– Bugs were not exercised by the input stimuli,
th
– There are bugs in the “expected” values that masks the
ng
real problem,
o
du
om
1. Offline (post processing)
.c
Node values are dumped out to a file during simulation
ng
Then the file is processed after the simulation is finished.
co
2. On the fly
an
Node values are gathered during simulation and are compared with
th
expected values. ng
o
du
u
cu
om
– In text or VCD (Value change Dump)
.c
• To be viewed by a waveform viewer.
ng
– With dumping simulation speed: 2x-20x decreased.
co
• If simulation performance needed, avoid dumping out all nodes.
an
• Must use measures to locate bugs efficiently.
th
o ng
du
u
cu
om
– Scope:
.c
• Restrict dumping to certain areas where bugs are more likely to
ng
occur.
co
– Interval:
• Turn on dumping only within a time window.
an
th
– Depth: ng
• Dump out only at a specified depth (from the top module).
o
– Sampling:
du
om
– Dumping routines should have parameters to turn
.c
on/off dumping.
ng
co
an
$dump_nodes(top.A, depth, dump_flag)
th
o ng
du
Scope: Module A
u
om
– Visual inspection of signal traces is suitable only
.c
• for a small number of signals.
ng
• when the user knows where to look for clues (i.e. scope
co
is narrow).
an
– For large designs, the entire set of dumped traces needs to
examined. th
o ng
• Manual inspection is not feasible.
du
• Common Method:
u
cu
om
– Can be generated directly.
.c
– Or by a different model of the design
ng
• e.g. non-synthesizable higher level model or a C/C++ model.
co
– If different responses
an
• bugs in design,
th
• bugs in golden response.
o ng
du
u
cu
om
clk = 0;
rst = 0;
.c
end
• Stimulus generation:
ng
co
#T1 rst = 1;
#T2 rst = 0;
an
th
• Clock generation
ng
always #T clk = ~clk;
o
du
• Response assessment
u
if (expected != product)
cu
om
• $display(“..”, arg2, arg3, ..); → much like printf(), displays
.c
formatted string in std output when encountered
ng
• $monitor(“..”, arg2, arg3, ..); → like $display(), but .. displays
co
string each time any of arg2, arg3, .. Changes
an
• $stop; → suspends sim when encountered
th
• $finish; → finishes sim when encountered
ng
• $fopen(“filename”); → returns file descriptor (integer); then,
o
du
you can use $fdisplay(fd, “..”, arg2, arg3, ..); or $fmonitor(fd, “..”,
arg2, arg3, ..); to write to file
u
cu
om
.c
ng
co
an
th
o ng
du
u
cu
om
a) Multiplexer 8 to 1
.c
b) Signed 8-bit Multiplier
ng
co
c) 8-bit FIFO
an
Requirements:
th
ng
– Generate stimulus inputs
o
–
u