File

advertisement
INTRODUCING
SPECMAN
Aarthi Nadarajan
Interns – Basic Intro
WHAT IS SPECMAN ?
Language “e”
 The ‘e’ Language has constructs necessary for
verification automation


Specman Elite is the tool from Verisity (now
Cadence) that simulates ‘e’ code stand-alone
or also with HDL simulator
‘E’ AS A PROGRAMMING LANGUAGE
High Extensibility
 All common procedural actions
 No complex pointer arithmetic
 Automated memory management
 Predefined data structures

A SAMPLE VERIFICATION ENVIRONMENT
GETTING STARTED
What are structs
What are units
Code Structure
Basic ‘e’ Language
Interns – Basic Intro
WHAT ARE STRUCTS AND UNITS ?

Structs are dynamic objects and created on the fly
when you want to use it and are usually destroyed by
garbage collection mechanism.

Units are static objects which stay alive from start to
end . They are generated at simulation zero time.
CODE STRUCTURE
Purpose
Syntax
Code delimitation
<'
'>
Inline comments
Code block
Names
Hierarchy path (between
structs and their
members)
-- VHDL style
// Verilog Style
{... ; ... ; ... ; };
start with letter
include only letters,
numbers,
and underscores
. (dot)
DEFINING UNITS AND STRUCTS
• The e language is case sensitive.
Example Code
• Both for predefined syntax keywords and user-defined names.
Example:
struct my_struct {
};
struct is a keyword. All syntax
keywords are lower-case.
struct MY_STRUCT {
};
The name my_struct is different
from the name MY_STRUCT.
BASICS OF ‘E’ LANGUAGE
Interns – Basic Intro
PREDEFINED TYPES
Name
Description
bool
Boolean value: TRUE or FALSE
packet_valid: bool;
Integer, default 32 bits
length: int;
addr: int(bits: 24);
Unsigned integer, default 32 bits
addr: uint(bits: 8);
bit
1-bit unsigned integer
valid: bit;
byte
8-bit unsigned integer
data: byte;
time
64-bit unsigned integer
delay: time;
string
String of ASCII characters
prompt: string;
list
Resizable, ordered array
payload: list of byte;
int
uint
Example
DEFINING ENUMERATED TYPES
Syntax:
type enum-type: [name1[=exp], ...] [(bits|bytes: width-exp)];
Example:
type opcode: [ADD, SUB];
• By default the new enumerated type is 32 bits, but it can be sized
according to the number of bits required.
type direction: [READ, WRITE](bits: 1);
• Enumerated type statement. Default first enum value is 0.
Subsequent
enum values increment by 1. This internal value is used for
comparisons (with strong type matching maintained).
• Values can be explicitly assigned with the syntax:
type opcode: [ADD = 4, SUB = 6];
IMPORT ‘E’ FILES
• Specman e files are called modules.
To reference statements or struct members that are declared in other
modules, use the import statement so that Specman loads those
modules first.
The import statement must be before any other statements.
Syntax:
import file-name, … | ( file-name, … );
Example:
<'
import my_packet, my_port;
...
'>
LISTS IN ‘E’

Lists
• List types hold ordered collections of data elements where
each data element conforms to the same type.
• Items in a list can be indexed with the subscript operator
[ ], by placing a non-negative integer expression in the
brackets.
• List indexes start at zero. You can select an item from a
list by specifying its index.
• Lists are dynamically resizable.
• Lists contain many predefined methods.
• Lists are defined by using the list of keyword in a
variable or a field definition.
METHODS
• e methods are similar to C functions, Verilog tasks, and
VHDL processes.
• An e method is an operational procedure containing actions
that define its behavior.
Syntax:
method_name([arg: type, …])[:return_type] is {
action;
};
METHODS
Methods can:
• Contain actions (procedural code).
• Declare and use local variables.
• Have zero to fourteen input arguments/parameters.
• Optionally return a value
• Optionally consume time if declared to be a “Time-Consuming
Method(TCM)”
What values can be read or written inside a method?
• Locally declared variables within the method
• Fields within the local struct’
• Arguments (parameters) and return value of the method
• Fields in other structs using path notation
PROCEDURAL CONTROL
Procedural flow control elements:
1. if then else
Syntax
if bool-exp [then] {action; ...} [else if bool-exp [then]
{action; ...}] [else {action; ...}]
2. case labeled-case-item
Syntax
case case-exp {labeled-case-item; . [default: {default-action; .}]}
3. case bool-case-item
Syntax
case {bool-case-item; ... [default {default-action;...}]}
PROCEDURAL LOOP CONSTRUCTS
1. while
Syntax
while bool-exp [do] {action; ...}
2. repeat until
Syntax
repeat {action; ...} until bool-exp
3. for each in
Syntax
for each [type] [(item-name)] [using index (index-name)]
in [reverse] list-exp [do] {action; .}
4. for from to
Syntax
for var-name from from-exp [down] to to-exp [step
step-exp] [do] {action; .}
5. for
Syntax
for {initial-action; bool-exp; step-action} [do] {action;
...}
CONSTRAINTS

Constraints are directives that influence the
behavior of the Specman test generator.
They are declared within a struct and
influence the generation of values for data
items within the struct and its subtree.
1. Hard Constraints
2. Soft Constraints
CONSTRAINTS

Constraints can be defined in many ways:
. By defining a range of legal values in the field or
variable declaration
. By defining a list size in the list declaration
. By using one of the keep construct variations
within a
struct definition
. By using a gen...keeping action within a
method
DEFINING CONSTRAINTS
keep
Syntax
keep constraint-bool-exp
keep for each
Syntax
keep for each [(item-name)] [using [index (indexname)]
[prev (prev-name)]] in
gen-item {constraint-bool-exp | nested-for-each; .}
DEFINING CONSTRAINTS

keep soft
Syntax
keep soft constraint-bool-exp

keep soft - select
Syntax
keep soft gen-item==select {weight:
value; .}
INHERITANCE

There are two ways to implement object-oriented inheritance in e: like inheritance or
when inheritance
Like inheritance is the classical, single inheritance
familiar to users of all object-oriented languages and is
specified with the like clause in new struct definitions.
When inheritance is a concept unique to e and is specified
by defining subtypes with when struct members.
When inheritance provides the following advantages compared
to like inheritance:
-Ability to have explicit reference to the when fields
-Ability to have multiple, orthogonal subtypes
-Ability to extend the struct later
TIME CONSUMING METHODS

A TCM is a time-consuming method that is distinguished from a regular method by the
presence of @event and can use time-consuming actions such as sync and wait.
Invoking TCMs:
1.tcm()
Syntax
[[struct-exp].]method-name([parameter-list])
Description
-Calling a TCM
-You can call a TCM only from another TCM.
INVOKING TCM’S
2.start tcm()

Syntax
start [[struct-exp].]method-name([parameter-list])

Description
A start action can be used within another method, either a TCM or a regular method. A started TCM
begins execution either when its sampling event occurs or immediately, if the sampling event has
already occurred for the current Specman tick.
A started TCM runs in parallel with the TCM that started it on a separate thread.
Notes
. A TCM that has a return value cannot be started with a start action.
. You cannot start a TCM before the run phase begins or after the check phase begins.
PACKING AND UNPACKING

Packing performs concatenation of scalars, strings, list elements, or struct fields in the
order that you specify
Unpacking performs the reverse operation, splitting a single expression into multiple
expressions.
1.pack()
Syntax
pack(option:pack option, item: exp, .): list of bit
Parameters
packing.high Places the least significant bit of the last
physical field declared or the highest list item at index
[0] in the resulting list of bit.
packing.low Places the least significant bit of the first
physical field declared or lowest list item at index [0]
in the resulting list of bit.
USING SPECMAN
RUNNING A TEST
USING SOME DEBUG OPTIONS- BASIC
COVERAGE AND EXIT
Download