Systemverilog Quick Reference
Systemverilog Quick Reference
Systemverilog Quick Reference
Product Version: IUS 8.2 Release Date: May 2008 This quick reference describes the SystemVerilog constructs supported by Cadence Design Systems. Note: Numbers in parentheses indicate the section of the IEEE 1800 Standard for SystemVerilog. Limitations for each construct are described in the SystemVerilog Reference. Abbreviations exprexpression numnumber argsarguments varvariable decldeclaration ididentier
(10.5.3) Iterates over the elements of an array. return [expression]; | break; | continue; (10.6) Jump statements. nal function_statement (10.7) Executes when simulation ends, without delays. begin [:block_id]{block_item_declaration} {statement_or_null} end [:block_id] (10.8) Groups statements so that they execute in sequence. always @ (event iff expression) (10.10) iff adds conditional qualication to an event control.
Processes
always_comb procedural_statement; (11.2) Describes combinational logic. always_latch procedural_statement; (11.3) Describes latched logic. always_ff procedural_statement; (11.4) Describes registered logic. fork [:block_id]{block_item_declaration} {statement_or_null} join | join_any | join_none [:block_id] (11.6) fork...join completes when all spawned processes nish. fork...join_any completes when any of the processes nish. join_none completes a fork...join block immediately. wait fork; (11.8.1) Stops execution until all spawned processes nish. disable fork; (11.8.2) Disables all active threads of a calling process
Data Types
logic [range] name [range] (4.3) A 1-bit, unsigned 4-state integer. bit [range] name [range] (4.3) A 1-bit, unsigned 4-state integer. byte name [range] (4.3) An 8-bit, signed 2-state integer or ASCII character. shortint name [range] (4.3) A 16-bit, signed 2-state integer. int name [range] (4.3) 32-bit, signed 2-state integer. longint name [range] (4.3) 64-bit, signed 2-state integer. chandle name; (4.6) Stores pointers that are passed using DPI. string name [= initial_value]; (4.7) Stores and manipulates ASCII strings. enum data_type {item1, item2...} var (4.9) User-dened enumerated type with a set of explicitly named values. typedef data_type name; (4.9) Declares a user-dened type. struct [packed [signing]] { structure members } name; (4.11) Groups variables or constraints under a single name. union [packed [signing]] { union members } name; (4.11) Similar to a structure, but members share the same storage space. uwire variable_name; Behaves like a single-driver wire net. [virtual] class name [port_list][extends class_name]; class_item endclass[:name] (4.12) Object-oriented data type that encapsulates data members and methods. event variable_name [= initial_value]; (4.3) Can be assigned, compared, and passed as arguments. function void name[port_list]; function_body endfunction (12.3.1) Represents non-existent data. Casting to void discards a functions return value.
Operators
= += -= *= /= %= &= ^= |= <<= >>= <<<= >>>= (8.2) Assignment operators can be used on integral types and within statements. ++ -(8.2) Increment and decrement operators can be used on integral types. ==? !=? (8.5) Wild equality operator (==?) treats X or Z values in the right-hand operand as dont care. Not equal counterpart is (!=?). == equality != inequality [] indexing {... ; ...} concatenation <, <=, >, >= boolean comparison (4.7) Supported operators for strings. <<, >>, <<<, and >>> shift operators % modulus operator / division * multiplication (13.4) Supported operators for constraint expressions.
Assignment Patterns
typeName'{key:value;{, key:value}} or '{simple_type | default:value; {, key:value}} (8.13) Species the correspondence between a collection of expressions and the elements of an array or the members of a structure.
Random Constraints
rand | randc <property>; (13.3) Species that a property is either a random variable (randc) or a random-cyclic (randc) variable. [static] constraint name {constraint_block} (13.4) Declares a constraint
Constraint Blocks
expr inside {set}; (13.4.3) Species a set of legal values for a given variable. expr dist {value_range := | :/ dist_weight, ...} (13.4.4) Species a set of weighted values. expr -> constraint_set (13.4.5) Constrains values when a condition is successful. if (expr) constraint_set [else constraint_set] (13.4.6) Constrains values when a condition is met. foreach (array_id [loop_vars]) constraint_set (13.4.7) Uses loop variables and indexing expressions to specify iteration over elements in an array. solve identifier_list before identifier_list; (13.4.9) Denes the order in which random values should be generated.
mailbox [#(<type>)] name [=new()]; (14.3) Class-based FIFO structure; allows procedures to safely exchange data. ->> [delay_or_event_control] hierarchical_event_id; (14.5.2) Non-blocking event trigger operator. hierarchical_event_id.triggered (14.5.4) Species that an event persist throughout the time step in which it was triggered.
Compiler Directives
`dene (23.2) Text substitution macro `begin_keywords and `end_keywords (23.4) Denes reserved keywords for a block of code. `remove_keyword and `restore_keyword Removes particular keywords from any set of keywords.
Clocking Blocks
[default] clocking name @(clocking_event); default default_skew; | clocking_direction list_of_clocking_decl_assign; endclocking[: name] (15.1) Denes a group of signals that are synchronized to a specic clock.
Program Blocks
program name [(port_list)]; program items endprogram[: name] (16.1) Similar to a module, but facilitates the creation of a testbench and has special syntax and semantic restrictions.
String Methods
Str.len() Str.getc(int) Str.toupper() Str.tolower() Str.itoa(integer) Str.realtoa(real) Str.atoi() Str.atobin() Str.atooct() Str.hextoa(integer) Str.octtoa(integer) Str.bintoa(integer) Str.compare(Str2) Str.icompare(string) Str.atoreal() Str.substr(intA, intB) Str.atohex() Str.putc(int, byte)
Packages
package name; [timeunits_decl] {{attribute_instance} package_item} endpackage [:name] (19.2) Mechanism for sharing declarations among modules, interfaces, and programs. package_id::item_name //Class scope resolution operator import package_id :: *; // Wildcard import import package_id::item_name; // Explicit import (19.2.1) Ways to reference items within a package.
Interfaces
interface name [(port_list)]; interface items endinterface [: name] (20.2) Encapsulates the communication between blocks of a digital system. modport name (port_list); (20.4) Denes the direction of ports in an interface declaration. interface_port_name.task_function_name(args); (20.6) Declares tasks and functions in interfaces. virtual [interface] name interface_id; (20.8) Variable that represents an interface instance.
Queue Methods
queueid.insert(index, object) queueid.delete(index) queueid.size queueid.pop_front
queueid.push_front(object) queueid.push_back(object)
queueid.pop_back
Semaphore Methods
new(keyCount) get(keyCount) put(keyCount) try_get(keyCount)
Mailbox Methods
new(bound) mailbox_id.num() mailbox_id.put(msg) mailbox_id.try_put(msg) mailbox_id.get(msg) mailbox_id.try_get(msg) mailbox_id.peek(msg) mailbox_id.try_peek(msg)