Sunteți pe pagina 1din 112

BASIC SPECMAN

Intel Confidential

1
<presentor name>
Chapter 3: Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries

Lab4: Write e2e model using multi-threading in e


Lab5: write a real monitor and checker to bus implemented in RTL

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

• e provides two ways to access DUT signals:


– Tick notation
– Ports
• Intel MMG developed a package named signal_sig
– Provides additional functionality (like signal history)
– Special support for accessing array of elements (Peek/Poke)

Intel Confidential

4
Accessing DUT Signals in Specman

We can drive or sample DUT signals at any hierarchy level


• Use single quotes with '~' to denote top-level:
Syntax: '~.instance_HDL_path.signal_name’

• To drive a DUT signal:


'~.top.sig' = 7;
• To sample a DUT signal:
msg.addr = '~.top.fifo.buffer[0]';

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.

Syntax: 'path_part1(expression)path_part2 '

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;

Note: very useful for accessing arrays


Intel Confidential

6
Access Signals using Ports

• Ports are units that have:


• The HDL path to the signal
• A Direction (in, out, inout)
• A defined type, e.g. uint(bits:12)
• Many other attributes and features
• Ports are struct members

Intel Confidential

7
Port definition: syntax

Syntax:
port-name: [list of] [direction] simple_port of element-type is instance
Example:

Direction is inout (default) type

<'
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

To access a port, use it’s instance name terminated with a ‘$’

<‘
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:

Port type description


simple_port Data connection
event_port Event occurrence
buffer_port Data port with FIFO in it
method_port Method call connection
Index port For accessing multi-dimensional arrays

See the manual for more information


Intel Confidential

10
Intel MMG - Signal_sig package

The Intel signal package (signal_sig):


• Is a wrapper for HDL signal access developed by CCDO team
• Is basically an e unit of type type_sig_u
• Type - can be any e type (not just integers)

• Provide additional support for signal access


• Enable central control over what is driven to the DUT
• The unit automatically decides on access type: port or tick
notation
Note: MMG methodology enforces using this package to access
signals

Intel Confidential

11
Declaring A New Signal Type Of signal_sig

• You must define the signal type before using it


• Any type of signal can be defined (including structs)
• There are many predefined signals types, e.g.:
• unit_sig_u, bit_sig_u, bool_sig_u, byte_sig_u

Syntax: declare type_sig_u;

• Once defined, you can create any number of instances

Intel Confidential

12
Declaring signals using signal_sig: example

Notice signal is in a
container

type address_t : unit(bits :39) ;


Define new type
declare address_t_sig_u ;
Declare new signal
extend example_signals_u { unit class
addr : address_t_sig_u is instance ;
};

Instance of the new


signal
Intel Confidential

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

For full set of fields and methods – look


at the SKL methodology document

Intel Confidential

14
Signal multi-value

• By default all signal access is converted to 2 values: 0 or 1


• Verilog support 4 values logic: 0,1,x,z
• It is possible to drive a literal 4 values to a signal, e.g.:
‘~.top.data’ = 0x54xx // 8 lowest bits are Xs
• e also support a multi-value logic (MVL)
• Each bit is represented by an enum which have these 4 values:
• MVL_0, MVL_1, MVL_X, MVL_Z
• It is supported for simple_ports only
• Access is by using ports methods

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

Driving signals limitations:


• You should drive signal that :
• Are Verilog regs or at the DUT interface
• Driving wires require a Verilog-variable declaration (see next)

Intel Confidential

17
Verilog variable declaration

Verilog variable is used to:


• Drive or force a Verilog wire
• Drive or sample a Verilog wire or reg with a delay
• Drive memories (arrays) in VCS

Syntax:
Verilog variable 'HDL-pathname'[using option, …]

Note: Verilog variable can be a statement or a unit member


(declared inside a unit)

Intel Confidential

18
Verilog variable declaration - Example

Example:

For bus, must specify range

<'
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

Note: Use Verilog variable statement only when it is required


Intel Confidential

19
Use Existing Verilog Code

• Verilog tasks and functions can be called with


parameters from Specman, using:
• Verilog task/function statement or unit member

Syntax: Refer to Chapter 16 of the e Language Reference.

Intel Confidential

20
Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

21
Events

• Events signifies that something happened in the simulation, e.g. :


• Rising, falling or changing of a signal
• A vector reached a certain value

Syntax: event event_name is temporal-exp @sampling_event


Samples every simulator tick

event clock_e is rise('~.top.clk')@sim;

Event name
Choices are rise, fall, or change
Any HDL signal here

More about events: later


Intel Confidential

22
Events (cont’)

• Once some events are defined in e, you can:


• Use these events as sampling clock for more events
• Use this event for synchronization (explained later)

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

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

24
Specman interface to simulator

• Specman run together with the simulator


• The simulator controls the time – it advance the ticks
• Specman request call-backs from the simulator
• The simulator call Specman when the events related to the
requested call-backs happened

ticks
Time
legend
Simulator
Calling
Specman

Call back
requests
Specman
Intel Confidential

25
Specman <-> Simulator interface

• The simulator is the main program


• Specman is a sub-program of the simulator
– It can be compiled with the simulator to form one
executable
– Can be compiled to be shared object
• Running the simulator with Specman:
– You first get into the simulator
– Use a simulator command to switch to Specman
– You can switch back to simulator and continue running
• When Specman works, the time (tick) does not
change

Intel Confidential

26
Test phases - reminder

Specman has 4 major predefined test phases:


• Start - has the following sub-phases
• Setup
• Pre-run generation
• Elaborate
• Run – Longest phase; the only phase that advance the time
• Check – has the following sub-phases
• Extract
• Check
• Finalize
Each phase/sub-phase has an associated method(s):
• Some are predefined in every struct, some exists in sys only
• They are called when the phase is entered

Intel Confidential

27
Test phases associated methods

phase Sub- Method Exists in


Phase
start setup setup() sys only
generate init() Any struct
pre_generate()
post_generate()
elaborate connect_pointers() Any unit
connect_port()
elaborate()
run run run() Any struct
stop_run() Global method
check extract extract() any struct
check check() any struct
finalize finalize finalize() sys only

Intel Confidential

28
Specman interface to simulator – cont’

Switch to Specman

Run until first


Runrequested
until nextevent
requested event
sncmd Call Specman Call Specman
ticks
Run the sim Time

Simulator

Specman

Load A TCM calls


Activate event and TCM. stop_run()
Test
Return to simulator when done
Switch to Execute start phase methods
Execute check and finalize phases
simulator And run() methods
Intel Confidential
Ask the simulator to finish
29 Install callback
Specman predefined events

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.tick_end Emitted at the end of every Specman tick

sys.new_time Emitted every tick and the time has changed since
last tick

Note: assigning to a signal is actually driven only before returning


to simulator (at tick-end)
Intel Confidential

30
Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

31
Time consuming methods - Example

• TCMs have all the characteristics of a regular method


• TCMs may also include time consuming action, like wait for events

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

Is the default sampling event


Syntax:

tcm_name([parameter-list]) [:return-type] @sampling-event is {


action; …

};

Intel Confidential

33
Calling and Starting TCMs

TCM can be executed:

• Sequentially, by calling it from another TCM


• In Parallel to other TCMs, by starting it
Sequential call Parallel start

Action 1 Action 1

Call TCM Start TCM TCM

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]);

Can Call Can Start


Another method TCM
Method
(with/without return value) (non value returning)
Another TCM TCM
TCM Another method (non value returning)
(both with/without return value)

Intel Confidential

35
Time consuming actions
• e has the following time consuming actions:
– Wait, sync
– All of, first of

action description

Wait Wait a cycle – then check condition at every clock

Sync Continue if condition occurred, else check condition


every cycle

All of Wait until all conditions happened

First of Wait until at least one condition (of many) happens

Note: These actions can only be used inside a TCM


Intel Confidential

36
Wait and Sync Actions

Syntax:
wait temporal-expression [@sampling-event];
sync temporal-expression [@sampling-event];

sync : if temporal-expression happened this tick, continue


else wait until it happens
Wait: wait one cycle, then wait until temporal-expression happens

Note: wait [0] is defined to behave like sync cycle.


Intel Confidential

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};…};

Description: Run multiple action blocks in parallel

Continue to the next action after all/first of when:


• All of: all action blocks end their execution
• First of: at least one action block ends its execution

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

• The sampling event can be defined:


– In the current struct
– In another struct
• The sampling event performs two functions:
– Defines the default sampling event for TEs in the TCM
– Must occur before TCM execution begins

Intel Confidential

42
TCMs– Sampling Event (Continued)

Sampling event @clock_e


<' must occur before TCM
struct port_s { execution begins. Causes
reset_delay: uint; an implicit sync action.
keep soft reset_delay in [10..50];
event clock_e is rise('~.top.rclk')@sim;
reset() @clock_e is {
sync @clock_e;
‘~.top.reset' = 0b1;
wait [reset_delay] * cycle; cycle refers to a cycle of
‘~.top.reset' = 0b0; the sampling event—
wait [1] * cycle; @clock_e.
};
run() is also { start reset(); };
}; The TCM must be started or
'> called to execute.

Intel Confidential

43
More about Events

There are other types of event definitions beyond @sim:


• Manually emitted event.
• Event emitted upon success of a temporal expression.

Intel Confidential

44
Event Definition and Emission

• Events are struct members indicating that something occurs


• Events can be emitted automatically or explicitly

<' Automatic Emission


struct pci_s {
event rst_e is rise ('~.top.reset') @clock_e;
};
'>

<' Explicit Emission


struct bus_s {
event trans_started_e;
drive_trans() is {
emit trans_started_e;
};
};
'>
Intel Confidential

45
Basic Event Syntax – Using event port and
tick notation

Syntax: event event-name [is [only] TE [@sampling-event]]

@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

Temporal Expression description


Every sample-event at which boolean-
true (boolean-exp)@sample-event
exp is true

Every sample-event at which exp had


rise/fall/change (exp)@sample-
risen/fallen/changed since previous
event
sample-event

cycle @sample-event Every sample-event

delay(int-exp) Wait a defined simulation ticks

[<num>] * TE TE repeated <num> times

{TE;TE;..} @sampling-event Temporal sequence

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;

notify() @clock_e is { Sync to clock_e


wait true(reset == 1); Reset is set
out("reset is 1");
wait [2] * cycle @clock2_e; After 2 cycles
out("two clock2_e events after reset");
};
@clock_e
};
'> @clock2_e
reset

Intel Confidential

49
Prints: ’two
Print: ‘reset events
clock2_e is 1” after reset’
Temporal Sequence

• Temporal sequence is a sequence of temporal events


• Syntax: {TE1;TE2…} @sample
– Satisfied if TE1 happened and TE2 happened cycle later (and so on for all
TE’s listed)
• Example:
event trans_start is {@req_e;[2] * cycle; @grant_e} @clk_e;
– Means: request then two clock cycles then a grant
– Requires a grant to happen within the third cycle after a request.

@clk_e
@req_e
@grant_e

{@req_e ;[2] * cycle; @grant_e} @clk_e;

Intel Confidential

50
Debugging Events

View events using the Specman event chart:


• Specman> show events -chart
View events using the waveform:
• Specman> set wave viewer
• Specman> wave event struct_name.event_name
• viewer choices: novas, signalscan, mti, virsim, undertow

• No Support for Verdi’s (used at Intel) viewer

Intel Confidential

51
Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

52
Abstract Conversion

• We know how to define a struct.


• We know how to drive DUT signals.
• To provide the DUT with data it can understand, we need to convert
a struct (abstract) to a list of bits or bytes. Specman has a
predefined method pack()/unpack() to do this.

Syntax: expression = pack(packing-options, expression,…);

Elements to pack
Packing ordering options

Intel Confidential

53
Abstract Conversion – pack example

Ordering options (next slide)

var data : list of bit;


data = pack(packing.high, packet.addr, packet.data);

The return type of pack() is based on field/var


type assigned to (list of bit/byte/uint/etc …)

Intel Confidential

54
Packing High Example

data = pack(packing.high, packet.addr, packet.data);

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

addr data[0] data[1]


data = 1 1 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0
17 . . . . . . . . . . . . . . . . . . . . . . . . 0

Intel Confidential

55
Packing Low Example

data = pack(packing.low, packet.addr, packet.data);

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] data[0] addr

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

• Explicitly packing struct fields has two disadvantages:


• It means extra typing
• There are multiple places to edit if the packet changes
• Physical fields make packing easier and less prone to error:
• Physical fields are automatically packed
• Physical fields are defined with a preceding “%” character
• Packs all physical fields of packet

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

• Unpacking is used to convert from low level bits/bytes to structs


• Insert data to physical fields only
• Unpack does not return a value (it’s an action)
• Get the same packing option like pack()
Syntax:
unpack(packing-options, source-exp, target1-exp [, target2-exp] ...])
Example:

var data: list of byte; Ordering options


var p: packet_s Data source: list of sized int/uint
unpack(packing.high, data, p); Destination (struct)

Intel Confidential

60
Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

61
Specify Behavior Upon DUT Errors

•How can we keep track of checking failures?


• How can we have the simulation take appropriate
action upon error detection?
•Let’s talk about Specman error-handling mechanism

Intel Confidential

62
Data-Checking Constructs

• For data comparison, use the check that action.


• For the error part, use the predefined dut_error() method.
• Specifies a DUT error with a specific message string.
• Uses a similar format to out() method.

Syntax: check that <bool-exp>


else dut_error (string);

Note: you can also use dut_error() inside if-then-else

Intel Confidential

63
Check Failure Effects

Check Effect Result

ERROR Stops the run.

ERROR_BREAK_RUN Stops the run at cycle boundary.

1. Stops the run.


ERROR_AUTOMATIC 2. Calls check() for every struct under
sys.

Intel Confidential

64
Check Failure Effects (Continued)

Check Effect Result

1. Reports the error.


ERROR_CONTINUE
2. Continues the run.

1. Reports a WARNING.
WARNING
2. Continues the run.

IGNORE 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:

Specman> set check @pci ERROR


Sets all checks in module pci.e to ERROR

Specman> set check “...after reset..." IGNORE


Sets all checks that include string “after reset” to IGNORE

Specman> set check WARNING Sets all checks to WARNING


Intel Confidential

66
WARNING:
Does not stop the run.

ERROR:
Stops the run.

Intel Confidential

67
Error and warning messages

For test environment error messages:


• Use the error() method for environment error, e.g.
• When a method gets a bad parameter
• Cause an immediate stop of the simulation
• Use warning() method for issue a warning message
• Continue running after the message

• Both get the same parameters as out()/dut_error()


• Examples:
error(“xxx_method: index must be < 5. Got ”, ind);
warning(“xxx_method: got null string! Ignoring it”);

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

Message is Specman infrastructure


• Give control over :
• Verbosity (Unlike out()/outf()/print)
• Where to print (file, screen, or both)
• Message format
• Based on unit hierarchy
• More

Intel Confidential

70
Messaging - syntax

The user primarily deals with these message actions:

No tag is default NORMAL

message ([TAG], VERBOSITY, “string”[,”string”...]) [action block]

message(MEDIUM, “Load[“, uop.opcode, ”] was dispatched\n”) {


print uop;
};
this message will be
printed if
verbosity
notice that this print will>=
goLOW
the
cte.elog – and are not allowed !
This message and action block (!)
Will be printed if
Verbosity >= MEDIUM
Intel Confidential

71
Messaging - syntax

• The verbosity parameter can be set to NONE, LOW,


MEDIUM, HIGH, or FULL
• LOW verbosity = low filtering
– I.e. : a message with low verbosity is a message we
want to see more
– A logger which is setup for LOW verbosity only prints
messages with verbosity of LOW or NONE

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

File name to print to


If empty – will not print to
file

Intel Confidential

73
Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

74
Writing modular code

Writing modular code is


• Separating the test environment into modules, such that:
• Each module does only one functional task
• Modules know very little about:
• Other modules
• The surrounding environment

First step for creating a modular environment is:


• Define the main modules of the environment
• What is the task of each module
• What is each module interface to the rest of the environment

Intel Confidential

75
Test environment’s major functional blocks

Test 3
Test 2
Checker
Test 1

Input monitor Output monitor


Input collector Output collector

Stimuli
BFM DUT
generator Input Output

Intel Confidential

76
Test environment’s major functional blocks
(cont’)

Functional block Task


Stimuli-generator Generate stimuli to be injected
BFM Drive stimuli into the DUT
Collector Low level data collector (from DUT signals)
Monitor High level monitor – analyze collected data
Checker Check the DUT output is as expected
test Control the stimuli generation. Not part of the
test environment

Intel Confidential

77
Connection between functional blocks

To make the code as modular as possible:


• Define a separate unit for each functional block
• Each unit/functional block should be in a separate file
• Use method_port to connect between elements, e.g.:
• Stimuli generator to the corresponding BFM
• Collector to the corresponding monitors
• Monitors to the corresponding checker

Intel Confidential

78
Defining and using method ports

To define and use method port:


1. Define the method type
2. Define a method port instance in the corresponding unit
3. Binding method ports
4. Using the method port
Optional return
Optional parameters For TCM
type only
5. method_type type-name ([params]) [:return-type] [@sys.any]
6. port-inst-name: direction method_port of type-name
7. keep bind(port-exp1, port-exp2)
8. port-inst-name$(param-list)
in or out As defined above

One in and one out port


Intel Confidential

79
Defining and using method ports – example

method_type burst_method_t(b: burst);


1. Define the method type
unit driver {
write: out method_port of burst_method_t is instance;
2. Define method port instance
send(b: burst) @clock is {
write$(b); //calls the write out method port
};
};
4. Using the method port
unit bfm {
write: in method_port of burst_method_t is instance;
write(b: burst) is {
start sig_drive(b); // 2. Define method port instance
};
};
The implementation of the method port
unit agent {
driver: driver is instance;
bfm : bfm is instance;
keep bind(driver.write, bfm.write);
Intel Confidential
3. Binding the ports
};
80
Agenda

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

81
What is coverage?

Coverage is checking the effectiveness of the DUT testing by:


• Measuring the generated stimuli
• a must when using random generation
• Coverage of major DUT internal states and state transition
• Cross of both of the above

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

Specman support the following coverage features:


• Functional coverage definition and measurement of:
• Data in the test environment
• Data/states inside the DUT
• Cross coverage of between multiple coverage items
• State transition coverage
• Code coverage (coverage of code blocks)
• Coverage of checker activation
• Event emission coverage
• Test ranking – measure the effectiveness of tests

Intel Confidential

83
Process of collecting coverage

The process of collecting coverage using Specman is:


• Define coverage elements in e (a coverage model) and specify the
coverage goals
• Run tests, collecting and saving the coverage data to files
• Read the saved coverage databases into Specman
• Get accumulated coverage results

Test 3 e Test environment


Test 2
Coverage elements
Test 1

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

There can be three types of coverage items in a coverage group:

Item type Description


basic DUT signals/registers
transition The transition from each state to another
cross Cross product of two (or more) previously defined
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

Collecting coverage of data checks:


• To insure checking/checkers are activated
• Activating:
set_config(cover, collect_checks_expects, TRUE|FALSE);
• The configuration should be done before the e files are loaded/compiled

Collecting event coverage:


• Help insuring correct behavior of the test environment
• Activating:
set_config(cover, auto_cover_events, TRUE|FALSE);
• Results are displayed in the session.events predefined coverage group

Intel Confidential

90
Test Ranking

Ranking tests according to their coverage contribution to:


• Identify redundant tests
• Select the best test suite for a mini-regression
• Find how much coverage you can achieve in a given amount of CPU
time
• Identify all tests which contribute to particular coverage buckets.

For more information, see chapter 9 in Specman command reference


manual

Intel Confidential

91
Get a coverage summary report

• Activating again the Test environment


• Read all existing coverage files
• Type at Specman prompt: read cover files-wild-card
• To see result press the coverage button on the Specview GUI
• To print textual report:
• Type at Specman prompt: show cover options

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

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

93
E libraries of method

E comes with the following sets of libraries methods:


• List methods – already discussed in the first day of training
• File operations
• Operating system (Unix) interface methods
• String manipulation routines
• Arithmetic routines

Intel Confidential

94
File operations

Specman file operation is 4 folded:


• Low-Level File Routines – open/close/write
• File query Routines – Useful Unix-like functions
• High level file reading/writing - Reading and
Writing Structs, lists
• File Iteration Actions – High level for loops

Intel Confidential

95
Low-Level File Routines
• add_file_type() • read()
• close() • read_lob()
• flush() • write()
• open()
• write_lob()

• All Unix level routines


• Write/read_lob()- Write/read a list of bits to/from a
binary file

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()

• All Unix level query routine


• New_temp_file() - Create a unique temporary file
name

Intel Confidential

97
High level file reading/writing
• write_string_list() • write_ascii_struct()
• read_ascii_struct() • write_binary_struct()
• read_binary_struct()

• write_string_list((filename: string, strings: list of string)) :


• Open the file
• Write each string in the list as a separate line
• Close the file
• Writing structs (binary or Ascii) –
• Efficient way to do partial restore
• The whole struct content is written to file
• Can be read back into a struct instance of the same type
• Can create a readable text file or a binary file
Intel Confidential

98
File Iteration Actions
• for each file matching
• for each line in file

• for each file matching: iterate over files-names matching a


string
• for each line in file filename – iterate over all lines in file
• Open a file, loop over all it’s lines, close the file
Example:
for each file (f_name) matching "*.txt" do {
for each line in file f_name {
if (it ~ "/error/“) {
out(f_name,”:”,it);
};
};
Intel Confidential
};
99
Files operation summary

Specman file operation is 4 folded:


• Low-Level File Routines – rarely required
• File query Routines – for simple Unix file commands
• Reading and Writing Structs, lists – for save/restore
struct context and for creating a file from a list in
one line of code
• File Iteration Actions – most effective for text file
parsing

Intel Confidential

100
UNIX OS interface routine
• spawn() • output_from_check()
• spawn_check() • get_symbol()
• system() • date_time()
• output_from() • getpid()

• System, spawn, Spawn_check


• Execute unit command – output to the screen
• Spawn_check() – print error if the Unix returns an error code
• Output_from, output_from_check() –
• Same as above, but returns the output of UNIX command as a list
of string
• The most useful OS interface routines
• Getpid() – Returns the Specman current process ID as an
integer
Intel Confidential

101
Pattern matching and string operations
Specman string library includes routines that:
• Convert expressions into a string
• Manipulate substrings •append(), appendf(), quote(), to_string()

• Manipulate regular expressions •str_join(), str_split(), str_split_all(), str_sub()


•str_match(), str_replace(), str_insensitive()
• Change the radix
•bin(), dec(), hex()
• Chopping and padding •str_chop(), str_exactly() , str_len(), str_pad()
• Are useful within macros •str_expand_dots()
• Manipulate the characters case •str_lower(), str_upper(), str_insensitive()
• Others •str_empty()

• Most of these routines returns a string


• Every change of a string actually create a new string
• Specman have special handling and optimization of string allocation
• Still, you need to use the above carefully
Intel Confidential

102
E String matching support

Specman support two kind of string matching:


• Unix like file matching
• It has just 3 special notations:
• " " (blank) - represent any sequence of white space (inc. tabs)
• * (asterisk) - Any sequence of non-white space characters
• ... (ellipsis) - Any sequence of characters
• It only match a whole string
• Perl like regular expression
• Has all special notation like Perl, e.g.: \w, \s, etc
• It match a whole of just part of the string
Notes: the default value of a string is NULL. If no constraints
applies, string is generated as NULL

Intel Confidential

103
Arithmetic routines

The arithmetic routine includes the following:

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

• Requirement for testing a RTL in simulated environment


• Signal access
• Events definition and usage
• Specman notation of time
• Multiple threading (TCMs)
• Converting between structs and signals
• Handling messages and errors
• Writing modular test environment
• E coverage
• E libraries
• Access modifiers

Intel Confidential

105
Access modifiers purpose

• Access modifier limits the access to a set of:


• Files that belong to the same package
• Structs that inherit the same parent

• You can restrict the access to:


• Types (structs, enums, etc)
• Struct-members (fields, methods, etc)

Intel Confidential

106
Package definition

• Package statement can declare a file to be part of a


specific package
• A file can belong to just one package
• if no package is declared – default is MAIN
• All files of a specific package share one name space
• help solve name space collisions
• E.G. Two types with same name
• Specman solves type access automatically:
• 1st looks in the package
• then look outside the package

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

• User can declare a type as restricted to package


• i.e.: no one can use this type outside this package

• 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

• You can define access rights to struct-member


• Only inside the same struct or package or both

Attribute Same Same Both


struct package
Protected V X V
Package X V V
Private X X V

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

S-ar putea să vă placă și