Your Ad Here

Saturday, March 14, 2009

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