Your Ad Here

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.