Documente Academic
Documente Profesional
Documente Cultură
Intel Confidential
1
<presentor name>
Chapter 3: Agenda
Intel Confidential
2
Validation Requirement for testing a RTL in
simulated environment
Requirement for testing a RTL in simulated environment:
1. Ability to drive stimuli to the device
2. Ability to read/sample the device output signals
3. Multiple threads, one per input or output channel
4. Synchronization: Ability to wait for events (notation of time)
sample
drive
Stimuli output
Stimuli DUT output
Stimuli output
Intel Confidential
3
RTL simulator signal access
Intel Confidential
4
Accessing DUT Signals in Specman
Intel Confidential
5
Computed Signal Names
All or part of a signal name can be computed at runtime using
the current value of an expression inside parentheses.
Example:
<'
struct msg_s {
run() is also {
for id from 0 to 1 {
'~.top.reset_port_(id)' = 0;
}; Replaced to
};
};
'> '~.top.reset_port_0' = 0;
'~.top.reset_port_1' = 0;
6
Access Signals using Ports
Intel Confidential
7
Port definition: syntax
Syntax:
port-name: [list of] [direction] simple_port of element-type is instance
Example:
<'
unit msg_u {
data: simple_port of uint(bits:12) is instance;
data1: in simple_port of byte is instance;
};
'>
Direction is in type
Intel Confidential
8
Access Signals using Ports - Example
<‘
unit encoder {
data: out simple_port of int(bits:64) is instance;
keep bind(data, external);
keep data.hdl_path() == “~.x.data";
hdl_path() is the
drive(v: int(bits:64))@sys.any is { signal path
data$ = v;
wait cycle;
};
}; .. end of encoder
‘>
Intel Confidential
9
More about ports
• You can use ports to communicate between e units
• More modular (they don’t know the counterpart)
• You can bind one e-ports using the bind() method
• Ports can be left un-bounded (bind to empty)
• Port can be connected to HDL signals (bind to external)
• There are many kind of ports in e:
10
Intel MMG - Signal_sig package
Intel Confidential
11
Declaring A New Signal Type Of signal_sig
Intel Confidential
12
Declaring signals using signal_sig: example
Notice signal is in a
container
13
signals: methods of *_sig_u (partial list)
name Description
get() : <signal type> Sample the signal value
set(<signal type>) Drive signal
set_span(<signal type>, Used for setting signal for
<how long>, specific amount of time. then
PHASE|CYC) return to unset value
Intel Confidential
14
Signal multi-value
Intel Confidential
15
All the port’s MVL related methods
put_mvl() put_mvl_to_bit_slice()
get_mvl() force_mvl()
put_mvl_list() force_mvl_list()
get_mvl_list() force_mvl_string()
put_mvl_string() force_mvl_to_bit_slice()
get_mvl_string() has_x()
get_mvl4() has_z()
get_mvl4_list() has_unknown()
get_mvl4_string()
Note: For detailed description of these methods, see the e reference manual
Intel Confidential
16
Driving signal – special notes
Intel Confidential
17
Verilog variable declaration
Syntax:
Verilog variable 'HDL-pathname'[using option, …]
Intel Confidential
18
Verilog variable declaration - Example
Example:
<'
unit port_u {
When to sample
verilog variable 'data_bus[31:0]' using
strobe = "@( posedge clk_ b) ", When to drive
drive = "@( posedge clk_ b) #3",
drive_hold = "@( negedge clk_ b) #10", How long to hold
wire,
forcible; To drive a Verilog wire
};
'> Enables ability to “force” signal from Specman
19
Use Existing Verilog Code
Intel Confidential
20
Agenda
Intel Confidential
21
Events
Event name
Choices are rise, fall, or change
Any HDL signal here
22
Events (cont’)
Example:
Define an event Sample at simulator tick
<‘
Define new event Already defined clock
struct monitor {
event clock_e is rise('~.top.clk')@sim;
event valid_e is true('~.top.valid‘ == 1)@clock_e;
event addr_e is change(‘~.top.addr’) @valid_e;
};
‘> Another event Previously defined
Intel Confidential
23
Agenda
Intel Confidential
24
Specman interface to simulator
ticks
Time
legend
Simulator
Calling
Specman
Call back
requests
Specman
Intel Confidential
25
Specman <-> Simulator interface
Intel Confidential
26
Test phases - reminder
Intel Confidential
27
Test phases associated methods
Intel Confidential
28
Specman interface to simulator – cont’
Switch to Specman
Simulator
Specman
Event Description
sys.any Emitted on every Specman tick
Is also the or-ing of all events
sys.tick_start Emitted at the start of every Specman tick
sys.new_time Emitted every tick and the time has changed since
last tick
30
Agenda
Intel Confidential
31
Time consuming methods - Example
struct monitor_s {
event clock_e is rise('~.top.clk')@sim;
Default sampling
event
see_request() @clock_e is {
wait [3]; // wait 3 cycles
out("Request seen");
}; Time consuming action
};
Intel Confidential
32
Time-Consuming Methods (TCMs)
• TCMs are methods that have the notion of time
• TCMs can be executed over several simulation cycles
• TCMs can be executed in parallel
• TCMs are distinguished from methods by their default sampling event
};
Intel Confidential
33
Calling and Starting TCMs
Action 1 Action 1
TCM
Action 2
Action 2
Intel Confidential
34
Call and Start action Syntax
Syntax:
• Call TCM or method
[struct-exp.]method-name([parameter-list]);
• Start TCM
start [struct-exp.]TCM-name([parameter-list]);
Intel Confidential
35
Time consuming actions
• e has the following time consuming actions:
– Wait, sync
– All of, first of
action description
36
Wait and Sync Actions
Syntax:
wait temporal-expression [@sampling-event];
sync temporal-expression [@sampling-event];
37
Difference between wait and sync actions
Enable is 1 at t0 t0 t1 t2
clock_e
'top.enable'
Time
t0 print a; print a;
t0 wait true('~.top.enable' == 1)@clock_e;
t1 print b ; print b;
t0 print a; print a;
t0 sync true('~.top.enable' == 1)@clock_e;
t0 print b ; print b;
Intel Confidential
38
All of and first off action blocks
Syntax:
all of { {block_a}; {block_b};…};
first of { {block_a}; {block_b};…};
Intel Confidential
39
All of action block - example
<'
extend sys { Can have any number of
event aclk is rise(~.aclk) @sim; time consuming action
event a; or non time-consuming
event b; action here,
detect_all() @aclk is { including TCM call
all of {
{ wait @a; };
{ wait @b; };
};
out("Both a and b occurred"); Exit to here when all
}; blocks of action ends
}; their execution
'>
Intel Confidential
40
First of action block - example
<'
extend sys { Can have any number of
event aclk is rise(~.aclk) @sim; time consuming action
event a; or non time-consuming
event b; action here,
detect_first() @aclk is { including TCM call
first of {
{ wait @a; };
{ wait @b; };
};
out(“a or b occurred"); Exit to here when either
}; blocks of action ends
}; their execution
'>
Intel Confidential
41
TCMs– Sampling Event
Intel Confidential
42
TCMs– Sampling Event (Continued)
Intel Confidential
43
More about Events
Intel Confidential
44
Event Definition and Emission
45
Basic Event Syntax – Using event port and
tick notation
@clk
'~.top.enable'
Example:
@enablef_e
<'
unit ports_u {
clk: in event_port is instance;
Using event port
keep bind(clk, external);
keep clk.hdl_path() == "clk";
keep clk.edge() == fall;
event enablef_e is fall('~.top.enable') @clk$;
};
'> Using tick notation
Intel Confidential
46
Temporal expression
Basic Temporal Expressions
Note: The sampling event indicates when the TE should be evaluated by Specman
Intel Confidential
47
Wait Examples using Basic TEs
<'
struct monitor_s {
event clock_e is rise('~.top.clk')@sim;
event clock2_e is change('~.top.clk2')@sim;
Default sampling event is clock_e
notify() @clock_e is {
wait true(reset == 1); wait until reset == 1 on clock_e
out("reset is 1");
wait [2] * cycle @clock2_e;
out("two clock2_e events after reset");
}; wait 2 cycles of clock2_e
run() is also {
start notify();
};
};
Intel Confidential
'>
48
Wait Examples using Basic TE's – cont’
<'
struct monitor_s {
event clock_e is rise('~.top.clk')@sim;
event clock2_e is change('~.top.clk2')@sim;
Intel Confidential
49
Prints: ’two
Print: ‘reset events
clock2_e is 1” after reset’
Temporal Sequence
@clk_e
@req_e
@grant_e
Intel Confidential
50
Debugging Events
Intel Confidential
51
Agenda
Intel Confidential
52
Abstract Conversion
Elements to pack
Packing ordering options
Intel Confidential
53
Abstract Conversion – pack example
Intel Confidential
54
Packing High Example
packet.addr = 2'b11 11
packet.data[0] = 8’haa 1 01 01 0 10
packet.data[1] = 8’hee 1 1 1 0 1 1 1 0
Intel Confidential
55
Packing Low Example
packet.addr = 2'b11 11
packet.data[0] = 8’haa 1 01 01 0 10
packet.data[1] = 8’hee 1 1 1 0 1 1 1 0
data = 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1
17 . . . . . . . . . . . . . . . . . . . . . . . . 0
Intel Confidential
56
Physical Fields
Intel Confidential
57
Physical Fields
• Physical Fields
• Are typically extracted from the specification
• Should be injected into the DUT
• Virtual Fields
• Are not physical, no preceding “%”
• Use for improving the controllability of generation
• Define variations of data item (sub typing)
• Are required for checking, debugging, etc
Intel Confidential
58
Packing a Struct’s Physical Fields
Virtual field–
controls generation
<'
type pkt_type_t: [good, bad]; Packs physical fields
struct packet_s { of cur_packet
kind : pkt_type_t; <‘
%addr : byte;
%data : list of byte; struct port_s {
}; cur_packet: packet_s;
'> send() is {
var packed_data : list of bit;
packed_data = pack(packing.high,
cur_packet);
Physical fields start driver_tcm(packed_data);
};
driver_tcm(data: list of
bit) @clock_e is {
//...
};
};
Intel Confidential '>
59
Unpacking – from signal to structs
Intel Confidential
60
Agenda
Intel Confidential
61
Specify Behavior Upon DUT Errors
Intel Confidential
62
Data-Checking Constructs
Intel Confidential
63
Check Failure Effects
Intel Confidential
64
Check Failure Effects (Continued)
1. Reports a WARNING.
WARNING
2. Continues the run.
Intel Confidential
65
Setting the Check Failure Effect
The check effect can be controlled with the set check command.
Syntax:
Specman command > set ch[eck[s]] [@module-name] [in
struct-name[.method-name]] ["match-string"] check-effect
Examples:
66
WARNING:
Does not stop the run.
ERROR:
Stops the run.
Intel Confidential
67
Error and warning messages
Intel Confidential
68
Counting errors and warnings
Data-checking constructs:
• Automatically updates global error counters
(reported at end of test):
num_of_dut_errors
num_of_dut_warnings
• Enables control of check effect on simulation
Intel Confidential
69
Messages
Intel Confidential
70
Messaging - syntax
71
Messaging - syntax
Intel Confidential
72
Messaging - creating new logger
You can create a new logger by instantiating a new
message_logger unit instance in your module
Instance of new logger
Setting a tag to capture,
my_logger : message_logger is instance; by default NORMAL
keep soft my_logger.tags == {MY_TAG;}; Can be extended
keep soft my_logger.verbosity == MEDIUM; can be more then one
keep soft my_logger.to_screen == FALSE;
Verbosity of the logger
keep my_logger.to_file == “agent_log.elog“;
Print to screen ?
Generally false
Intel Confidential
73
Agenda
Intel Confidential
74
Writing modular code
Intel Confidential
75
Test environment’s major functional blocks
Test 3
Test 2
Checker
Test 1
Stimuli
BFM DUT
generator Input Output
Intel Confidential
76
Test environment’s major functional blocks
(cont’)
Intel Confidential
77
Connection between functional blocks
Intel Confidential
78
Defining and using method ports
79
Defining and using method ports – example
Intel Confidential
81
What is coverage?
Coverage can also be used to check the correct behavior of the test
environment:
• All checkers are activated
• Effectiveness of every test
• More statistics related to the TE behavior
Intel Confidential
82
Specman Coverage features
Intel Confidential
83
Process of collecting coverage
Coverage
files
DUT Specman
Intel Confidential
Simulation report
84
Defining coverage group
Syntax:
cover event-type [using coverage-group-option, ...] is {
item item-name[:type=exp] [using coverage-item-option, ...]
...
};
Example:
Sampling event
struct instruction_s
event inst_driven;
cover inst_driven is { Item (field)
item op1;
item op2;
Item full notation
item op2_big: bool = (op2 >= 64);
item hdl_sig: int = 'top.sig_1';
};
}; Item is a DUT signal
Note: Coverage groups are struct members
Intel Confidential
85
Type of coverage items
Intel Confidential
86
Transition Coverage Item (Continued)
Syntax:
transition item-name [using coverage-item-option, ...];
Example:
<'
type fsm_state_t: [ADDR, DATA, HOLD];
extend port_u {
event clk_rise_e is rise('clk') @sim;
cover clk_rise_e is {
item state: fsm_state_t = '~/top/stts';
transition state using
illegal = (prev_state == HOLD and
state == ADDR);
};
};
'> prev_ is the keyword to reference
a previous value of the item state
Intel Confidential
87
Cross coverage item
Syntax:
cross item-name-1, item-name-2, ... [using coverage-item-option,
...] };
Example:
<'
extend instruction_s {
event fetch_e;
cover fetch_e is {
item opcode;
item op1;
cross opcode, op1;
};
};
'>
Intel Confidential
88
Cross item GUI report
Intel Confidential
89
Automatic coverage collection
Intel Confidential
90
Test Ranking
Intel Confidential
91
Get a coverage summary report
Note: The coverage database must be analyzed with the same coverage
model that was used when the coverage database was created.
Intel Confidential
92
Agenda
Intel Confidential
93
E libraries of method
Intel Confidential
94
File operations
Intel Confidential
95
Low-Level File Routines
• add_file_type() • read()
• close() • read_lob()
• flush() • write()
• open()
• write_lob()
Intel Confidential
96
General File Routines
• file_age() • file_extension() • file_is_temp()
• file_append() • file_is_dir() • file_is_text()
• file_copy() • file_is_link() • file_rename()
• file_delete() • file_is_readable() • file_size()
• file_exists() • file_is_regular() • new_temp_file()
Intel Confidential
97
High level file reading/writing
• write_string_list() • write_ascii_struct()
• read_ascii_struct() • write_binary_struct()
• read_binary_struct()
98
File Iteration Actions
• for each file matching
• for each line in file
Intel Confidential
100
UNIX OS interface routine
• spawn() • output_from_check()
• spawn_check() • get_symbol()
• system() • date_time()
• output_from() • getpid()
101
Pattern matching and string operations
Specman string library includes routines that:
• Convert expressions into a string
• Manipulate substrings •append(), appendf(), quote(), to_string()
102
E String matching support
Intel Confidential
103
Arithmetic routines
Routine Description
min(x, y) Get the minimum of two numeric value
max(x, y) Get the maximum of two numeric value
abs(x) Get the absolute value
odd(x) Check if an integer is odd
even(x) Check if an integer is even
ilog2(x) Get the base-2 logarithm of a number
ilog10(x) Get the base-10 logarithm value of a number
ipow(x, y) Raise to a power
isqrt(x) Get the square root
div_round_up(x,y) Divide and round up
Intel Confidential
104
Agenda
Intel Confidential
105
Access modifiers purpose
Intel Confidential
106
Package definition
Intel Confidential
107
Package as name space
• syntax
package <package name>;
example :
package coco;
struct any_coco_s {
};
Will use the bobo package struct
pacakge bobo
•use scope operator (::) to declare
Struct any_coco_s {…}; specific type
• Eaxmple: struct
struct x_package::packet_s
my_struct like any_coco_s {{};
};
pacakge bobo
struct my_struct like coco::any_coco_s {
};
Intel Confidential
108
Usage access modifiers for types
• syntax
package <type declareation>
only code in the same package
• example can extend or create an
instance to this struct or type
package sturct data_item { };
package color: [green, blue, white];
Intel Confidential
109
Struct members’ access modifiers
Intel Confidential
110
access modifiers : privet
package P1;
struct s1 {
private f: bool;
};
struct s2 {
m(x: s1) is {
var i: bool = x.f; // not the same struct
};
};
struct s3 like s1 {
m() is also { f = 4; }; // same struct and package
when TRUE’f s3 {} ; // cant use a privet as
// determinant
};
Intel Confidential
111
access modifiers : protected
package P1;
struct s1 {
protected m() is {
};
};
struct s2 {
m(x: s1) is {
x.m(); // Not in the same struct
};
};
struct s3 like s1 {
m() is also { }; // In the same struct family
};
‘>
Intel Confidential
112