Docsity

Understanding Structs and Members in Docsity: Data Structures and Constraints, Slides of Computer Science

Partial preview of the text

Download Understanding Structs and Members in Docsity: Data Structures and Constraints and more Slides Computer Science in PDF only on Docsity!

Specman Notes

Specman Elite

• From Verisity (http://www.verisity.com)

• Presents a high-level language for writing test

environments

– Test Benches

– Coverage

– Constraint based test generation and checking

Files

• Copy the tutorial tar file

• Copy the emacs specman-mode file

– If you use emacs

– If you like language editors

• Untar the tutorial directories into your own

account ( ./src and ./gold )

Running

(make sure X and DISPLAY are right)

specview &

On Line Help

• Verisity has all their help on line

– e language ref

– Command ref for Specman Elite

– Usage etc.

• Tutorial is on OUR web page (large pdf)

– Do not print it, just do it.

– Its not great

File Format

  • A code segment is enclosed with a begin-code marker <' and

an end-code marker '>.

  • Both the begin-code and the end-code markers must be

placed at the beginning of a line (left most), with no other text

on that same line (no code and no comments).

  • The following three lines of code form a code segment:

import cpu_test_env;

Several code segments can appear in one file. Each code

segment consists of one or more statements.

Pre Defined Constants

Constant Description

TRUE For Boolean variables and expressions.

FALSE For Boolean variables and expressions.

NULL For structs, specifies a NULL pointer. For

character strings, specifies an empty string.

UNDEF UNDEF indicates NONE where an index is

expected.

MAX_INT Represents the largest 32-bit int (231 -1)

MIN_INT Represents the smallest 32-bit int (-231).

MAX_UINT Represents the largest 32-bit uint (232-1).

Keywords

  • all of
  • all_values
  • and
  • as a
  • as_a
  • assert
  • assume
  • async
  • attribute
  • before
  • bit
  • bits
  • bool
  • break
  • byte

bytes c export case change check that compute computed consume continue cover cross cvl call cvl callback cvl method cycle

default define delay detach do down to dut_error each edges else emit event exec expect extend

fail fall file first of for force from gen global hdl pathname if #ifdef #ifndef in index

Keywords

  • type
  • uint
  • unit
  • until
  • using
  • var
  • verilog code
  • verilog function
  • verilog import
  • verilog simulator
  • verilog task
  • verilog time
  • verilog timescale
  • verilog trace
  • verilog variable
    • vhdl code
    • vhdl driver
    • vhdl function
    • vhdl procedure
    • vhdl driver
    • vhdl simulator
    • vhdl time
    • when
    • while
    • with
    • within

Syntactic Elements

  • Statements Statements are top-level constructs and are valid within the begin-code <' and end-code '> markers. Statements end with a semicolon ‘;’
  • Struct members Struct members are second-level constructs and are valid only within a struct definition.
  • Actions Actions are third-level constructs and are valid only when associated with a struct member, such as a method or an event.
  • Expressions Expressions are lower-level constructs that can be used only within another e construct. The syntax hierarchy roughly corresponds to the level of indentation shown below: statements struct members actions expressions

Struct & Struct Members

• Struct members are second-level constructs and are

valid only within a struct definition.

struct struct-type: struct-descriptor [like base-struct-type: struct-descriptor] {

[member: struct-member; ...]}

Example:

type packet_kind: [atm, eth];

struct packet {

len: int; keep len < 256; kind: packet_kind;

};

Struct Members

  • field declaration
    • Defines a data entity that is a member of the enclosing struct and has an explicit data type.
  • method declaration
    • Defines an operational procedure that can manipulate the fields of the enclosing struct and access run-time values in the DUT.
  • subtype declaration
    • Defines an instance of the parent struct in which specific struct members have particular values or behavior. (e.g., when )
  • constraint declaration
    • Influences the distribution of values generated for data entities and the order in which values are generated. (e.g., keep )
  • cover age declaration
    • Defines functional test goals and collects data on how well the testing is meeting those goals.
  • temporal declaration
    • Defines e event s and their associated actions.(e.g., on, expect, assume )

Fields

-! Ungenerated Fields

  • A field defined as ungenerated (with the “!” option) is not generated

automatically.

  • This is useful for fields that are to be explicitly assigned during the test, or

whose values involve computations that cannot be expressed in

constraints.

  • Ungenerated fields get default initial values (0 for scalars, NULL for structs,

empty list for lists).

  • An ungenerated field whose value is a range (such as [0..100]) gets the

first value in the range.

  • If the field is a struct, it will not be allocated and none of the fields in it will

be generated.

Fields

  • % Physical Fields
  • A field defined as a physical field (with the “%” option) is packed when the

struct is packed.

  • Fields that represent data that is to be sent to the HDL device in the

simulator or that are to be used for memories in the simulator or in

Specman Elite, need to be physical fields.

  • Nonphysical fields are called virtual fields and are not packed

automatically when the struct is packed, although they can be packed

individually.

  • If no range is specified, the width of the field is determined by the field’s

type. For a physical field, if the field’s type does not have a known width,

you must use the (bits | bytes : num) syntax to specify the width.