Your Ad Here

Thursday, August 6, 2009

combination between Method & TCM in Specman Environment

Currently we can see the Combination exists between the Methods & TCM in Specman Environment.

TCM :
TCM can Start another TCM ( Using start keyword )
TCM can call another Method .

Methods :
Methods can start TCM.
Methods can call another Method.
Methods cannot call a TCM.

Thursday, May 7, 2009

Time Consuming Method (TCM) in specman e-language

TCM's are defined as the methods that have the notion of time, as designated by their sampling event.
· TCM's can be executed over several simulation cycles.
Syntax:
tcm_name([arg: type,...]) [:return-type] @sampling-event is {
---- Required action parameters;
};
TCM’s are attached with sampling_event. The sampling_event fills two functions.
· Implicit sync action at beginning of TCM( must occur before TCM execution begins)
· Default sampling event for TEs in the TCM


Ex: <'
unit port_u {
reset_value: bit;
reset_delay: uint;
reset () @clk is {
---- This indicates the TCM is @sync with clk
reset_value = 0b1;
wait [reset_delay] * cycle;
reset_value = 0b0;
wait [1] * cycle;
};
run() is also {
start reset();
}; };
'>

Wednesday, April 22, 2009

Declaration of Specman e-language Basic Temporal Expressions

Cadence Specman Elite e-language TE (Temporal Expression), is always associated with a sampling event indicating when the Temporal Expression needs to be evaluated by Specman elite e-language.
1) true(Boolean-exp)@sample-event
The above expression indicates for every Sample-event that the Boolean Expression is true.
2) rise/fall/change (exp)@sample-event
The above expression indicates for every Sample-event that the Expression is rising (falling/change).
3) Cycle @sample-event
The above Expression indicates for every sampling event.
4) [Number] * TE

The above expression indicates the TE’s is repeated for number of times.

Wednesday, April 15, 2009

Importance Of Using Sampling Events in specman elite e-language

In order to drive / sample signals correctly, there is a need to synchronize with the simulator.
To achieve the above task there is a need to make use of the Specman elite Temporal Language Expression.
The Temporal language of the e-language is the basis for capturing behavior over time for below purpose:
-> To synchronizing with the DUT.
-> In order to develop protocol checkers for automation.
-> In order to develop a Functional coverage for better understanding of the scenarios.

The Temporal Language is mainly built using the below concept:


-> Temporal expressions (TEs)
-> Temporal operators, for defining complex expressions.
-> Event struct members, for defining occurrences of events during the run.
-> Expect struct members, for checking temporal behavior

Tuesday, April 14, 2009

Accessing / Sampling the DUT signals using specman elite e-language

Specman elite e-language supports in driving or sampling
-> VHDL signals at any hierarchy level
-> Verilog registers and wires at any hierarchy level.
In order to access the DUT we need to use single quotes with '~' to denote top-level module name.
'~/instance HDL path /signal name

Ex:
‘~/top_tb/data_in’
Here the top_tb refers to the Top HDL module name and data_in refers to the signal name present in the top_tb module.
-> To Drive a Value from Specman elite e-language to DUT, apply the following mechanism.
‘~/top_tb/reset’ = 1;
-> To Sample a DUT value to Specman elite Variables ( Struct / Unit) , apply the following mechanism.
Packet_u.data_out = ‘~/top_tb/data_out”;

specman elite e-language supports creation of Bus Functional Module (BFM)

Specman elite e-language supports the creation of Bus Functional Module , Popularly known as BFM.
In order to construct BFM targeting the DUT (Design Under Test), we need to use e-language Temporal Expressions using the concept of TCM ( Time Consuming Methods).
The TCM is similar to Methods , but supported with the events and other Temporal related expressions like wait, sync...
The Initial TCM needs to be started to execute the defined functionality ( which in turn may call / start other dependent TCM's).
e.g
<'
unit packet_bfm_u {
// definition of fields
// Declaration of TCM
packet_gen() @clk_rise is {
// Apply the packet generation functionality
} ; // end of TCM def

run() is also {
// start the TCM
start packet_gen();
};
'>

Sunday, April 12, 2009

Advantage of using Specman Elite stimulus variation feature

The Specman elite e-language stimulus Variation concept mainly helps in,

· Reusability
· Maintainability
· Extendibility

An Approach to Creating SUBTYPES using e-language:
Consider a Network Packet example having address, length, data as its fields and using the defined fileds need to calculate parity . The defined Network Packet may be either GOOD or BAD.
Whenever the packet is of type GOOD assign the parity calculated to parity field and if the packet is of type BAD then do not assign the parity to the parity field.
In order to achieve the required condition, we need to create a subtype using when inheritance.

Following are the steps to be taken while creating subtypes.
· Define a new enumerated type (i.e. Good and Bad)
· Define a field on enumerated type in the struct to represent various subtypes.
· Write a when block and add struct members in the when block that correspond to properties of the specific subtypes.

filename : packet.e
<’
---- Declaration of enumerated types
type packet_kind_t: [Good, Bad];
struct packet_s {
pkt_Kind: packet_kind_t;
Address : uint (bits: 2);
Length : uint (bits: 6);
Data : list of byte;
Keep data. size () = = length;
Parity : byte;
---- User Method for calculating parity Value
Parity_calc () : byte is {
----- User Actions Needs to be entered for calculating parity;
};
--- Subtype creation
When Good ‘pkt_kind packet_s {
Keep parity = = parity_calc ();
};
When Bad ‘pkt_kind packet_s {
Keep parity! = Parity_calc ();
};
};
‘> ---- End of struct

filename : packet_top.e

<'
import packet.e;
extend sys {
packet : packet_s ;
};
'>

filename : packet_test.e
<'
import packet_top.e;
// For Writing Test cases using constraint use the extend feature supported by e-language
extend packet_s {
// Apply the Constraints Required
keep soft pkt_kind == GOOD;
keep soft length == 10;
keep soft Address in [0x1000..0x2000];
};
'>

Saturday, April 11, 2009

Specman elite example for creating subtype packet structure

The below example demonstrates how to generate WR only packet using specman elite e-language without applying the constraints to the enumerated fields declared.

< '
type packet_wr_rd_t : [ WR, RD];
struct packet_s {
packet_wr_rd : packet_wr_rd_t ; // Declaration of the field
Address : byte ; // Common field for both RD / WR
keep soft Address == 0x10;// Apply the Subtype to control the generation
when WR' packet_s {
wr_data : byte ; // default value, can be overwritten using testcase
keep soft wr_data == 0x0 ;
}; // end of WR subtype creation.
}; // end of struct definition
'>

filename : packet_top.e
<'
extend sys {
// The below assignment make sure that only WR related Packet is generated, which is indirect
// way of applying the constraints
pkt : WR packet_s;
};
'>

Friday, April 10, 2009

specman elite e-language supports subtype stimulus creation

Specman elite e-language supports the formation of subtype stimulus creation.
In order to achieve we need to use the enumerated define types.
e.g If we want to control the generation of fields w.r.t subtypes, it is better to use enumerated types as a controlling parameters.
Let's have requirements in mind for the Read / Write scenario. We all Know that Address field is common for both Read / Write Transcation, whereas we need to generated write data when we are performing the Write Transcation.
Here is how we control the generation using the specman e-language subtype declaration.
The following example demonstrates , if the enumerate type declared is WR in nature it generates Write Address and Write Data else it only performs Read Transcation.
< '
type packet_wr_rd_t : [ WR, RD];
struct packet_s {
packet_wr_rd : packet_wr_rd_t ; // Declaration of the field
keep soft packet_wr_rd == WR;
Address : byte ; // Common field for both RD / WR
keep soft Address == 0x10;
// Apply the Subtype to control the generation
when WR' packet_s {
wr_data : byte ;
// default value, can be overwritten using testcase
keep soft wr_data == 0x0 ;
}; // end of WR subtype creation.
}; // end of struct definition

'>

Thursday, April 9, 2009

specman e-language constraint usage example

Adding a small example for using the constraint feature with the help of specman elite e-language.

file name : packet_def.e
<'
packet_kind_t : [ small, medium, large]

'>
file name : packet.e
<’
struct packet_s {
Addr: uint (bits: 32);
Kind: packet_kind_t;

my_method () is {
// define the actions required e.g parity_calculation
};

// call the above mentioned method in run phase

run() is also {

my_method();

};

}; // end of struct def

'>

file name : packet_top.e

<'

import packet_def.e;

import packet.e;

extend sys {

pkt : packet_s ;

};

'>

// Writing the Top Test case for applying constraints

file name : packet_test.e

<'

import packet_top.e;

extend packet_s {

keep soft Kind = = Small ;

keep soft addr in [10..40];
};
‘>

Wednesday, April 8, 2009

specman elite possible ways of generating fields

Specman Elite e-language supports three possible ways of generating the fields.

· Random generation

· Directed-Random generation

· Directed generation

Random generation:

The Random generation is not supported by constraints.

Ex: address: int (bits: 32);

Directed-Random generation:

The Directed-Random generation supports the generation by constraining to a range of values. Here, even though the generation is random it is been restricted within the Range of 1000 to 2000 address locations.

Ex: keep address in [0x1000..0x2000];

Directed generation:

The Directed generation supports the generation by constraining to a specific value.Here, the generation of address value is specified to the location of 1245.

Ex: keep address = = 0x1245;


Soft Constraints

For constraints that might need to be overridden, we use soft constraints. Basically, Soft constraints are obeyed if not contradicted by hard constraints.
The last loaded soft constraint prevails if there is a contradiction with other soft constraints.

Syntax :

keep soft Boolean-expression;

Ex: keep soft length = = 64;

· Soft constraints are used to define the default range of values of fields:

Ex: keep soft packet_length in [60..100];

· The test writer has the option to ignore the soft constraint by using predefined method reset_soft().

Ex: keep packet_length.reset_soft ();

· Soft constraints are used to set initial settings for tests

Ex: keep soft errors = = FALSE;

Monday, April 6, 2009

Controlling order of generation using specman e-language

Specman elite e-language generates the fields based on the Order of declaration.
Consider an example, which illustrates the order of generation.

Ex: <’

type packet_kind_t: [Small, Medium, Large];

struct packet_s {

Kind: packet_kind_t;

Address: uint (bits: 32);

keep Kind = = Small => Address < 40; };

‘>

The above example explains that the packet_kind_t (kind) of enumerated type is generated first followed by address.The constraints definition says if the kind is Small in nature then generate address below 40.

Suppose, unknowingly if the address is declared first followed by Kind then the above constraint statement doesn’t hold good.

In order to achieve the same result, add an explicit generation order constraint supported by Specman Elite e-language.

The below example shows the constraints for such Operation.

Syntax:

keep soft gen (control- field) before (control –field);

Ex: <’

type packet_kind_t: [Small, Medium, Large];

struct packet_s {

Address: uint (bits: 32);

Kind: packet_kind_t;

keep Kind = = Small => Addr < 40;

keep soft gen (Kind) before (Address); };

‘>

Tuesday, March 31, 2009

specman e-language supports constraint random generation

specman e-language supports the concept of constrained random generation.

. Constraints are applied on struct members e.g Fields and methods.

· Constraints are Boolean equations

· Constraints are declarative statements

Specman e-language categories the constrained mechansim as follows :

1) Random Generation without any constraints parameters
2) Directed Random constrained Generation [ e.g from .. to ]
3) Directed constrained Generation

For constraining a Field use the following syntax :
keep Boolean-expression

Ex: struct packet_s {

Length : uint(bits:6);

Address : uint(bits:2);

// application of Directed Constraints Parameter for Length field

keep Length = = 10;

// application of Directed Random Constraints Parameter for Address field

keep Address in [0..2];
};




For constraining elements in a list (array):

keep for each (item) in list_name {

Boolean-expression; };


Ex: Struct packet_driver_s {

Packets : list of packet_s;

// Constraints list for the individual fields

keep for each (pkt) in packets {

pkt.len < 10; }; };



The syntax for implication constraints are given below:

keep Boolean-expr1 => Boolean-expr2;

Ex:

keep size = = SHORT => length < 10;

keep size = = LONG => length > 20;

Or, suppose if we want to constraint using lists:

Ex:

keep for each (pkt) in packet {

index = = 0 => pkt.addr = = 1 and pkt.kind = = GOOD;

index = = 1 => pkt.addr = = 2 and pkt.kind = = BAD; };


Weighted Constraints:

Weighted constraints are used on a specific application. It allows selection weight for value or range of values. In order to achieve a weighted constraint we need to apply a soft control on the distribution of generated values.

syntax: keep soft gen-item = = select {weight: value ;};

Ex: <’

keep soft length = = select {

20:14;

25:10;

10:20; };

‘>

Thursday, March 19, 2009

specman e-language usage examples for extending methods

Here i am listing examples of extending methods using specman e-language concept.

Ex : extending using is_also

---> Filename packet.e
<’

struct packet_s {

my_method () is {

out (“I am here”);
};
};

‘>

-------> new file packet_extend.e

<’

import packet.e;

extend packet_s {

my_method () is also {

out("to learn e-language”);
};
};

‘>

when we execute the packet_extend.e we can see finally the output appearing as "I am here to learn e-language".


Ex : extend using is first

---> Filename packet.e

<’

struct packet_s {

my_method () is {

out (“I am here”);
};
};

'>

---> New file : packet_extend.e
<’

import packet_extend.e;

extend packet_s {

my_method () is first {

out (“to learn e-language”);
};
};

'>

when we execute the packet_extend.e we can see finally the output appearing as "to learn e-language i am here".


Ex: extend using is only

---> Filename packet.e

<’

struct packet_s {

my_method () is {

out (“I am here”); }; };

'>

---> New file packet_extend.e

<’

import packet.e;

extend transaction_s {

my_method () is only {

out (“to learn e-language”);
};
};

'>

when we execute the packet_extend.e we can see finally the output appearing as "to learn e-language ", this extend method operator overrules the previous contents of the same method defined.

Wednesday, March 18, 2009

How to extend methods in e-language

Specman e-language has the built in features to extend the predefined and
user-defined methods in order to have new contents.
The extension can be done in the same file where the original method is declared or in another new file.
Specman e-language supports the following features for extending the methods

a) is first => which means add before the existing e code
b) is also => which means add after the existing e code
c) is only => which means override/replace the existing e code

Sunday, March 15, 2009

what are different output actions in e-language

e-language supports both formatted and non-formatted print statements, this is similar to any other high-level programming language.

print -> print data, useful at the command line and for struct printing.

Outf() -> it is a predefined method available in Specman e-language. This helps in printing the statements in a formatted manner.

Out() -> it is predefined method available in Specman e-language. This helps in printing the statements without formatted manner.

How to use methods using return values

The below code describes how to use methods using the return values
Ex: file_name : packet.e

<’

struct packet_s {

length: uint;

legal: bool;

legal_value (len: uint): bool is {

If (length >= len) then {

Result = TRUE;
};

If (result = FALSE) then {

legal = FALSE;
};
};

length_calc() is {

var length_incr : uint := 0;

if (length == 0) then {

length_incr = length_incr + 1;
};

// call the Legal_value method

legal_value(length_incr);
};

run() is also {

length_calc() ; // Need to call this method as it is calling other method

};
};

‘>

How to use methods using local struct fields

The below example shows how to use local struct fields for writing method using e-language.

Ex : file_name : packet.e

<’

struct packet_s {

length: uint (bits; 6);

legal_value(): bool is {

if (length >= 64) then {

return (TRUE);
};
}; // end of method

// extend the pre-defined method to call the local method

run() is also {

// call the method declared

legal_value();

}; // end of run() method
};

‘>

Saturday, March 14, 2009

Procedural Control statements in e-language

e-language is high-level programming language, it supports all Procedural flow control statements. The defined flow control statements are:

· If-else statement

· Case statement

· For loop

· While loop

· Repeat-Until loop

Ex: If statement execution

<’

struct packet_s {

Flag: bool;

Check_flag (): bool is {

If (flag = TRUE) {
Out (“flag is true”);
}
else {
Out (“flag is false”);
}; // end of if cond
}; // end of method

run() is also {

Check_flag(); // calling the method declared
};
}; // end of declared struct

‘>


Ex: Case Statement Execution

<’
struct packet_s {

Flag: bool;

Check_flag (): bool is {

Case flag {

TRUE: {out (“flag is true”)};

FALSE: {out (“flag is false”)};
}; // end of case statement
}; // end of method

run() is also {

Check_flag();
};

}; // end of struct

‘>

Ex: For loop condition execution
<’

struct packet_d {

! Pkt: Packet_s; // on-the fly generation

No_of_Pkt: uint (bits: 4);

Keep No_of_Pkt in [1.. 10];

Packet_gen () is {

For i from 0 to (no_of_Pkt-1) {

gen Pkt; }; // on_the_fly gen (gen is specman keyword)

}; // end of method


run() is also {

Packet_gen();
};
}; // end of struct

‘>

writing procedural code using e-language

Procedural Code forms one of the important features of the e-code.
Procedural Code is executed by struct / unit members called Methods (e.g similar to functions in c-language).

Ex: <’

struct packet_s {

Addr: uint (bits: 2);

my_address (addr: uint): bool is {

if (Addr == 0) {
result= TRUE;
}

else {
result= FALSE;
}; // end of if condition
}; // end of method declaration

// calling my_address method

run() is also {
my_address();
}; // end of run() method

}; // end of struct declaration

‘>

The above declared method has a return type of bool in nature and it cannot be executed until it is called.
In order to make it happen, the declared method is called in the pre-defined specman method run().
Since the run() is already a pre-defined method present in specman elite, we need to extend the method in order to call the my_address method.

Important Features of Methods:

i) Methods can contain actions (i.e. calculating parity, factorial...),

ii) Methods can Declare and use Local Variables,

iii) Methods can have Zero to Fourteen input arguments/parameters,

iv) Methods can optionally return a value.

v) Methods Optionally Consume time if declared to be a “Time-Consuming Methods (TCM)”, .

Friday, March 13, 2009

Types of Stimulus Generation in e-language

Stimulus needs to be generated and driven to the DUT in order verification process.

The Specman Elite e-language supports two types of stimulus generation :

i) Pre-Run Generation

ii) On-the-Fly Generation

Pre-Run Generates fields or struct once the Specman Test command is issued and sends them to the DUT with the help of BFM. The main advantage of this process is, it quickly shows what the generator will produce but consumes lot of memory in order to save all the generated values.
Pre-Run generation requires an understanding of the interface between struct definition and the Specman Elite Constraint Solver.

Ex: top file name : packet_top.e
<’

import packet.e;

extend sys{

Legal: bool;

Packet: packet_s;// Instantiate of struct

};

‘>



On-The–Fly Generation Generates items “on-the-fly” at the time they are driven into the DUT. On-the-Fly generation is achieved by using the “!” (Bang operator) Before the field, so that initially the field will be empty.
The main advantage of this mechansim is that it saves memory and the generation can be activated based on the DUT interaction.

Ex: top file name : packet_top.e
<’

import packet.e;

extend sys {

! Cur_packet: packet_s;

! Packet_count: uint;

};

‘>

** sys is a Specman Elite pre-defined struct

extend feature in e-language

e-language supports extensibility feature in order to add new elements in the declared struct or unit. This feature is very useful in writing Top level Testcases using the constraint parameters.
To understand more, we will look at a small example listed below :

Ex: The e-description for the Packet structure

file name : packet.e

<’ struct packet_s {

Addr: uint (bits: 2);

Len: uint (bits: 6);

Data: list of byte; };

‘>

Extension file name : packet_ext.e

<’ import packet.e;

extend packet_s {

Legal: bool;

Parity: byte; };

‘>

The Legal and Parity fields will be added into the packet structure based on the order of generation if the packet_ext.e is executed.

import, extend are the pre-defined keywords of Specman Elite e-language.

Thursday, March 12, 2009

Creation of Stimulus using e-language

In order to start verification process, we need to generate the input stimulus defined by protocol for the given DUT (Device under Test) either using a random approach or using a constrained random. To generate the required information we need to declare the struct followed by the corresponding fields. Each field should be of Specific type either predefined or user-defined (e.g enumerated types). To generate the defined fields we make use of Specman elite generator to generate each field with a random value unless it is not constrained. Let’s consider a Network packet having data, length and address, which are to be generated randomly.

Ex : Let's look at the Network Packet Structure definition
file name : packet.e

<’
struct packet_s {

Addr: uint (bits: 2);
Len: uint (bits: 6);
Data: list of byte;

};
‘>


once the struct is defined, it needs to be Instantiated at the specman top level for generation.

Ex : file name top.e

<'
import Packet.e ;

extend sys {

packet : packet_s; // Instantiate the packet struct

};

‘>

Wednesday, March 11, 2009

How to write an e-program block

The e program block is indicated by the keyword struct.

The Program Block contains the following format.

struct struct_name {

--- Field declaration;

--- Methods with /without return type;

};

The main e-Program block is where:

· Fields are declared inside the struct_name

· Variables are declared inside the methods

· Executable statements are carried out

· Calls to methods with arguments are made

Tuesday, March 10, 2009

Basic syntax of e-language

Specman e-language is case sensitive in nature for both the predefined syntax keywords and user-defined names.
The name my_struct_s and my_STRUCT_S are both different structs defined in the e-language.

struct my_struct_s {
--- Action to be performed
}

struct my_STRUCT_S {
---- Action to be performed
}

Here struct is a specman e-language keyword.

The important aspect of the e-language is that the e-code written should be within the delimiters (e.g <' '>) and the code written outside the delimiters are considered as comments. In order to have single inline comments within the delimiters we can have both the VHDL / Verilog format ( e.g -- or // ) .

Ex :
The below code shows a sample e-language code structure
<'
struct my_packet_s {
// Field Declaration ( single line comment)
Addr : byte;
Data : byte;
Len : uint (bits:6);
method_name() is {
--- Action required
}
}; // end of struct my_packet_s

'>

Know more about what e-language supports

e-language can be distinguished as Programming Language ( like any other programming languages e.g C, C++) and as well Simulation Language ( Simulation related concept).
e-language supports the lexical elements and also some of the basic Programming Concepts (e.g data types).
It supports the following sections.
1) Lexical Elements
2) Data types and Variable Declaration
3) Arrays ( one-dimensional)
4) Enumerated Types

5) Operators
6) Variable assignment


Monday, March 9, 2009

Introduction to specman e-language

Specman e verification language is an HVL (Hardware Verification Language) Language and an IEEE standard language used by most of the verification engineers for Block/SOC Verification. It is one of most advanced language in terms of methodology and technology for building the Verification environment.
Specman e-language has a unique concept called Aspect-oriented Programming, that enables easier reuse and provide "extendibility" features for derivative environments and follows the eRM Methodology.
According to the eRM (e Reusable Methodology) the Verification environment is designed to have a Stimulus Generator, Driver, BFM (Bus Functional Module) and to intergrate all these elements it has an Agent which could be Transmitter (Tx) or Receiver (RX).

The Top Verification Environment categories into Active and Passive Elements. The Active Elements consists of Stimulus Generator, Driver and BFM whereas the Passive Elements Consists of Monitors (e.g Checkers, Signal Map and Functional Coverage). These Elements can be Enabled / Disabled by built in switch depending on the requirement. The Functional Coverage is one of the important element in the Specman e-verification which gives the verification engineer to cover all the important functionality in terms of coverage elements.