Specman Cheat Book
Specman Cheat Book
Field Guide
Syntax Conventions
Comments, Identifiers & Literals
Types, Constants, Fields & Variables
Operators, Loops and Flow Control
Structs & Units
Methods & TCMs
Checking & Coverage
Packing & Simulator Interface
Events & Temporal Expressions (TE)
Generation & Constraints
Lists & List Pseudo-Methods
Actions (Predefined Routines)
Miscellaneous & Specman Test Flow
e Language
Field Guide
Revision 1.0 (for e v3.3)
->
name
->
expr
->
[xyz]
->
[]
->
->
Choice
...
->
->
Explanatory note
Syntax Conventions
Comments, Identifiers & Literals
Types, Constants, Fields & Variables
Operators, Loops and Flow Control
Structs & Units
Methods & TCMs
Checking & Coverage
Packing & Simulator Interface
Events & Temporal Expressions (TE)
Generation & Constraints
Lists & List Pseudo-Methods
Actions (Predefined Routines)
Miscellaneous & Specman Test Flow
Legal Characters
Identifiers
Case sensitive
Start with letter, then any combination of a-z, A-Z, _ and
0-9
File names follow these same rules and end with ''e''
Binary
-2'b11, 4'b10_01
Hex
Octal
String Literals
Any ASCII character or escape sequence enclosed in
Escape sequences: \n = new line \t = tab
\f = form feed \ = quote
\\ = backslash \r = carriage return
Examples
Decimal
Examples
Decimal
0..9
Binary
-0b11, 0B10_01
Hex
Octal
Character Literals
Single ASCII character enclosed in & preceded by 0c
var c: uint (bytes:2) = 0cA
Name
Description
32 bit signed integer
32 bit unsigned integer
1 bit unsigned integer (values: 0 or 1)
8 bit unsigned integer (values: 0..255)
64 bit unsigned integer (values: 0..263-1)
1 bit boolean (values: 0=FALSE, 1=TRUE)
A group of ASCII characters enclosed in
Struct to control access to shared resources
Used for file I/O
Default
0
0
0
0
0
FALSE
NULL
UNDEF
MAX_INT
FALSE
MIN_INT
NULL
NULL
NULL
TRUE
Variables (Actions)
var var_name : [ type ] [ = expr ]; // create a variable
// assign to existing variable
var_name = expr;
Description
List indexing
List slicing
Bit slicing
Method call
Field selection
~
!, not
{;}
%{ }
Unary +, *, /, %
+, >>, <<
<, <=, >, >=
is [not] a
==, !=
===, !==
~, !~
[not] in
&, |, ^
&&, ||, and, or
=>
a?b:c
Bitwise not
Boolean not
List concatenation
Bit concatenation
Unary plus, minus
Multiply, divide, modulus
Add and subtract
Shift right, shift left
Comparison
Subtype identification
Equality, inequality
Verilog four-state comparison
String matching
Range list operator
Bitwise AND, OR, XOR
Boolean AND, OR
Boolean implication
Conditional operator (Ex: if a then b else c)
Defining (Statements)
struct struct_type [like struct_type] {
struct_member;... };
unit unit_type [like unit_type] { unit_member;... };
Extending (Statements)
extend struct_type { new_struct_member;... };
extend unit_type { new_unit_member;... };
Common
Methods
unit my_unit {
kind
: [GOOD, BAD];
unit_int : int;
};
extend my_struct {
struct_int2 : int; // Add a new field to my_struct
};
Description
init()
pre_generate()
extract()
check()
quit()
finalize()
copy()
do_print()
print_line()
do_pack()
do_unpack()
extend sys {
test_bench : my_unit is instance;
my_unit is instance; // instance of my_unit
hdl_path()
get _unit()
};
result = expr;
return = [ expr; ]
};
Example: define
struct test {
method1() is
method2() is
tcm1() @ clk
};
parity_calc2() :byte is {
var tmp : byte = 0;
for each (byte) in data {
tmp = tmp ^ byte;
{ out(Hello - m1); };
{ out(Hello - m2); };
is { wait; out(Hello - tcm1); };
};
};
extend test {
method1() is also { out(2nd msg - m1); };
tcm1() is first { wait; out(1st msg - TCM); );
method2() is only { out(Only msg - m2); };
return tmp;
};
run() is also {
start tcm1; //tcm1 defined in prev example
parity1 = parity_calc1(data);
parity2 = parity_calc2();
};
};
};
no_collect
count_only
global
text = string
weight = uint (default 1)
when = bool_expr radix = DEC | HEX | BIN (default DEC)
};
no_collect
at_least = uint (default 1)
text = string
weight = uint (default 1)
when = bool_expr radix = DEC | HEX | BIN (default DEC)
ignore | illegal = cover_item_boolean_expr
ranges={range( [n..m], name, [every_count, at_least] );
range( [n..m], name, [every_count, at_least] ); }
extend global {
setup_test() is also {
set_config(cover, mode, normal);
};
};
// appends to hdl_path()
Packing (Expressions)
dest_name =pack( option, src_name [, src_name, ... ] );
unpack(option, src_name, dest_name [, dest_name, ...] );
options: packing.high packing.high_big_endian
packing.low
packing.low_big_endian
packing.network
list_of_bits.swap( unit_size, group_size );
Example of packing and unpacking:
struct packet {
%addr : uint (bits:4); keep addr == 2b1111;
%data : uint (bits:8); keep data == 8b10101010;
};
extend sys {
pkt1 : packet;
!pkt2 : packet;
test() is {
var packed : list of bit;
var swapped : list of bit;
packed=pack(packing.high, pkt1);//1111_10101010
unpack(packing.low, packed, pkt2); // oops!
swapped=packed.swap(4,12);
};
};
// named event
// temporal event
// extending
Predefined Events
sys.any
sys.tick_start
session.start_of_test
struct.quit sys.new_time
sys.tick_end
session.end_of_test
@[struct_instance.]event_name // event as a TE
TE @sampling_event
// TE w/ associated sampling event
change | rise | fall (expr)@
@sampling_event // transition TE
change | rise | fall ( '~/HDL/path' )@
@sim // HDL related TE
true(bool_expr)@
@sampling_event
// boolean condition TE
//
occurrence
of a sampling event
cycle @sampling_event
// specify a sim time delay of expr
delay( expr )
// repetition of TE, expr=numeric
[ expr ] [*TE]
Description
init()
pre_generate()
post_generate()
keep name.reset_soft()
keep unit_name.hdl_path() == [~/HDL/][path/]string;
keep struct_name is [not] a value['field] struct_type;
Constraint Examples:
x : int [0..10];
// same as keep x in [0..10]
keep soft x == 1
// x defaults to 1
keep x <= y;
// x less than or equal to y
keep x in {3,4,5}; // x must be 3 or 4 or 5
keep x+y == z;
// restrict x+y to value z
keep parity = parity_calc(); // force w/ method
// if x is 1, then y must be in range 1..10
// translates to: x != 1 or y in [0..10]
keep x == 1 => y in [0..10];
struct packet {
kind :[good, bad];
addr : uint;
data : uint;
};
extend sys {
pkts : list of packet
keep pkts.size() < 20;
// gen < 20
keep for each (pkt) in pkts {
index > 0 =>
pkt.addr == prev.addr; // same addr
index==2 =>
pkt is a good packet;
// #3=good
};
list1 : list of packet;
!list2 : list of packet;
keep list1.is_all_iterations(.addr);
gen_one() is {
gen list2 keeping {
it.is_a_permutation(list1);
};
};
Arithmetic (Expressions)
int= op=value // (op can be: +,-,*,/,%,&,|,^) ex: x +=1 increments x by 1
int=[min][max[(expr1,expr2); // min / max of expr1 or expr2
// absolute value of expr
int=abs(expr);
// TRUE if expr is odd
bool=odd(expr);
// TRUE if expr is even
bool=even(expr);
// log base-n of expr (n=2, 10)
int=ilogn(expr1);
// x to the power of y (xy)
int=ipow(expr1, expr2);
// square root of expr
int=isqrt(expr);
int=div_round_up(expr1,, expr2); // expr1 / expr2 round nxt int
Bitwise (Expressions)
bit=bitwise_op(expr);
string_list=deep_compare_physical(struct1,struct1,max);
Misc (Actions/Expressions)
Actions
set_config(category, option, value [option,value])
[ [with] {action;...} ];
// set config for only specified actions
value_type=get_config(category, option); // value of option
// write config to file.ecfg
write_config(filename);
// read config from file.ecfg
read_config(filename);
// sets keep-across-restore
set_keep(TRUE | FALSE);
// gets keep-across-restore
bool=get_keep();
The keep-across-restore value controls whether config
& debug settings are retained across restores and reloads.
// concat & send to Specman
specman(command[,,...] );
spawn(command[,,...] );
spawn_check(command);
Expressions
Miscellaneous
Compile Time Directives
// load e file; if no ext, .e used
import filename;
#ifdef [`]macro then { e code }; // if macro def, incl e code
#ifndef [`]macro then { e code};// if macro not def, incl e code
Initialization
Load
global.init()
Test
Macros
global.setup_test()
Pre-Run Generation
global.generate_test()
<struct>.init()
<struct>.pre_generate()
<struct>.post_generate()
Sharing Resources
resource_name: locker; // define locker filed in shared resrc
// reserve resource (waits until avail)
resource_name.lock();
resource_name.unlock(); // release the resource
State Machines
Simulation Run
global.start_test()
<struct>.quit()
Gen action
(on the fly)
global.run_test()
sys.time
global.stop_run()
<struct>.run()
Post-Run Check
File I/O
global.extract_test()
global.check_test()
<struct>.check()
Finalization
Legend
global.finalize_test()
Extendable method
Recursive call
Simulation run time
Non-extendable method
B u i l d y o u r k n o w - h o w.
Learn more than just e syntax. Learn how to apply
the language as a power tool for verifying todays
ultra complex systems.
Qualis offers a family of methodology-based training courses focused on Specman Elite. Youll go
from learning the basics of e to learning an
advanced verification methodology applying random constrained test generation, data/temporal
checking, and functional coverage. Detailed
course descriptions are available on our website at
www.qualis.com/learning.catalog.html/.
Attend a public course in North America or
Europe, or schedule a private onsite class. Start
building your verification knowledge today.
FAX: +1.503.670.0809
Web: http://www.qualis.com