Systemverilog • Extended Tasks and Functions • C-Like Void Functions

Systemverilog • Extended Tasks and Functions • C-Like Void Functions

SystemVerilog • extended tasks and functions • C-like void functions • pass by reference Ming-Hwa Wang, Ph.D. • default arguments COEN 207 SoC (System-on-Chip) Verification • argument binding by name Department of Computer Engineering • optional arguments Santa Clara University • import/export function for DPI • classes: object-oriented mechanism (abstraction, encapsulation, safe Introduction pointers) SystemVerilog is a standard (IEEE std 1800-2005) unified hardware design, • automatic testbench support with random constraints specification, and verification language, which provides a set of extensions to • interprocess communication synchronization the IEEE 1364 Verilog HDL: • semaphores • design specification method for both abstract and detailed specifications • mailboxes • embedded assertions language and application programming interface • event extension, event variables, and event sequencing (API) for coverage and assertions • clarification and extension of the scheduling semantics • testbench language based on manual and automatic methodologies • cycle-based functionality: clocking blocks and cycle-based attributes • direct programming interface (DPI) • cycle-based signal drives and samples Purpose: provide a standard which improves productivity, readability, and • synchronous samples reusability of Verilog-based code, extends for higher level of abstraction for • race-free program context system modeling and verification, provides extensive support for directed • assertion mechanism and constrained-random testbench development, coverage-driven • property and sequence declarations verification, and formal assertion-based verification • assertions and coverage statements with action blocks • extended hierarchy support Extensions to Verilog • packages for declaration encapsulation with import for controlled • extended data types access • C data types: int, typedef, struct, union, enum • compilation-unit scope nested modules and extern modules for • other data types: bounded queues, logic (0, 1, X, Z) and bit (0, 1), separation compilation support tagged unions • extension of port declarations to support interfaces, events, and • dynamic data types: string, class, dynamic queues, dynamic arrays, variables associated arrays including automatic memory management • $root to provide unambiguous access using hierarchical references • dynamic casting and bit-stream casting • interfaces to encapsulate communication and facilitate communication- • automatic/static specification on per-variable-instance basis oriented design • extended operators • functional coverage • wild equality and inequality • DPI for clean, efficient interoperation with other languages (C provided) • built-in methods to extend the language • assertion API • operator overloading • coverage API • streaming operators • data read API • set membership • Verilog procedure interface (VPI) extension for SystemVerilog constructs • extended procedural statements • concurrent assertion formal semantics • pattern matching on selection statements • loop statements • Extended Literal Values C-like jump statements: return, break, continue • • integer literals and logic literals final blocks that execute at the end of simulation (inverse of initial) • • unsized literal with a preceding apostrophe ( ’), e.g., extended event control and sequence events ’0, ’1, ’X, ’x, ’Z, ’z // sets all bits to this value • extended process control • real literals: fixed-point format or exponent format • extensions to always blocks to include synthesis consistent • time literals: s, ms , us , ns , ps , fs , step simulation semantics • string literals enclosed in quotes: \v for vertical tab, \f for form feed, • extensions to fork … join to model pipelines \a for bell, \x02 for hex number • fine-gram process control • array literals: replicate operator ( {{}} ), index/type keys and default • chandles can be inserted into associative arrays, can be used within values, e.g., a class, can be passed as arguments to functions or tasks, and can int n[1:2][1:3] = ‘{‘{0,1,2}, ‘{3{4}}}; be returned from functions int m[1,2][1,6] = '{2{'{3{4,5}}}}; • chandles shall not be assigned to variables of any other type, shall // same as '{'{4,5,4,5,4,5},'{4,5,4,5,4,5}} not be used as follows: as ports, in sensitivity lists or event typedef int triple [1:3]; $mydisplay(triple'{0,1,2}); expressions, in continuous assignments, in untagged unions, in triple b = '{1:1, default:0}; // indexes 2 and 3 assigned 0 packed types • structure literals, e.g., • string : variable length array of bytes indexed from 0 typedef struct {int a; shortreal b;} ab; • string operators: ==, !=, <, <=, >, >=, {str1, str2, …, strN), ab c = '{0, 0.0}; /* same as c = '{a:0, b:0.0}; c = '{default:0}; or c = ab'{int:0, shortreal:0.0}; */ {multiplier{str}}, str[index], string.method(…) • ab abarr[1:0] = '{'{1, 1.0}, '{2, 2.0}}; str.method(…): len( ), putc(int index, byte c), getc(int index), typedef struct {int a,b[4];} ab_t; toupper( ), tolower( ), compare(string s), icompare(string s), int a,b,c; substr(int i, int j), atoi( ), atohex( ), atooct( ), atobin( ), atoreal( ), ab_t v1[1:0] [2:0] = '{2{'{3{a,'{2{b,c}}}}}}; itoa(integer i), hextoa(integer i), atoreal( ), octtoa(integer i), // expands to '{'{3{'{a,{2{b,c}}}}}, '{3{{a,'{2{b,c}}}}}} bintoa(integer i), realtoa(real r) /* expands to • event data type: event variables can be explicitly triggered and '{'{'{a,'{2{b,c}}},'{a,'{2{b,c}}},'{a,'{2{b,c}}}}, waited for '{'{a,'{2{b,c}}},'{a,'{2{b,c}}},'{a,'{2{b,c}}} } } */ • syntax: event <var_name> [= (<initial_value> | null ) ]; /* expands to • user-defined types: typedef (forward definition and actual definition) '{'{'{a,'{b,c,b,c}},'{a,'{b,c,b,c}},'{a,'{b,c,b,c}}}, • '{'{a,'{b,c,b,c}},'{a,'{b,c,b,c}},'{a,'{b,c,b,c}}}} */ enumeration data types with strong type checking • methods: first( ), last( ), next(int unsigned i=1), prev(int unsigned i=1), num( ), name(int unsigned i) Data Types • structures and unions A data type is a set of values and a set of operations that can be performed • packed and unpacked, signed and unsigned, 2-state and 4-state on those values. Data types can be used to declare data objects or to define • a tagged union saves a value and a tag (or a member name) for user-defined data types that are constructed from other data types. strong type access checking • integer types • class is declared using the class … endclass keywords • 2-state - can simulate faster and take less memory: shortint (16-bit • class properties signed), int (32-bit signed), longint (64-bit signed), byte (8-bit • methods signed or ASCII character), bit (unsigned with user-defined vector • casting: a data type can be changed by using a cast (‘) operation size) • static casting • 4-state - can have unknown (‘x) and high-impedance (‘z) values: • <type> ‘ ( <expression> ) or <type> ‘ { { <literal>, …, logic (unsigned with user-defined vector size), reg (unsigned with <literal> } } user-defined vector size), integer (32-bit signed), time (64-bit • <size> ‘ ( <expression> ) unsigned) • signed ‘ (<expression> ) • integral types - the data types that can represent a single basic integer • $shortrealtobits, $bitstoshortreal, $bits, $itor, $rtoi, $bitstoreal, data type: packed array , packed struct , packed union , enum, time . $realtobits, $signed, $unsigned A simple bit vector type is the data types that can directly represent a • dynamic casting: $cast one-dimensional packed array of bits. • bit-stream casting • real types: real (64-bit signed), shortreal (32-bit signed) • for converting between different aggregate types • void data type - for function returns nothing or represent nonexistent • example data uses bit-stream casting to model a control packet transfer over a • chandle data type - for storing pointers passed using DPI (default null ) • data stream: only allow the following operation with another chandle variable or typedef struct { null or Boolean values: equality ( == ), inequality ( != ), case equality shortint address; (=== ), case inequality ( !== ) reg [3:0] code; • only allow assignment from another chandle or null byte command [2]; } Control; typedef bit Bits [36:1]; Control p; • uses part-select to refer to a selection of one or more contiguous bits of Bits stream[$]; a single dimension packed array, use slice to refer to a selection of one p = ... // initialize control packet or more contiguous elements of an array // append packet to unpacked queue of bits • array querying functions: $left, $right, $low, $high, $increment, $size, stream = {stream, Bits'(p)} $dimensions, and $unpacked_dimensions Control q; • dynamic arrays: any dimension of an unpacked array whose size can be // convert stream back to a Control packet q = Control'(stream[0]); set or changed at run time • stream = stream[1:$]; // remove packet from stream new [ expression ] [ ( expression ) ] • uses bit-stream casting to model a data packet transfer over a byte size( ) • stream: delete( ) typedef struct { • array assignment between fixed-size arrays and dynamic arrays byte length; • arrays as arguments: pass by value shortint address; • associative arrays byte payload[]; • indexing operator: wildcard index type *, string index, class index, byte chksum; integer or int index, signed packed array index, unsigned packed } Packet; array index, packed struct index, user-defined type index function Packet genPkt(); • methods: num( ), delete( [ input index] ), exists( input index), Packet p; first( ref index), last( ref index), next( ref index), prev( ref index) void'(

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us