System Verilog Data Type
System Verilog Data Type
The wire nets act like real wires in circuits. The reg type holds their values until
another value is put on them, just like a register hardware component. The
declarations for wire and reg signals are inside a module but outside any initial
or always block.
• As the difference between reg and wire types often causes confusion, a new
binary data type was introduced in System-Verilog.
• The logic type was introduced as a replacement for both the reg and wire
types. As the logic type combines the characteristics of the reg and wire
types, we can use it in pretty much any part of our System-Verilog code.
• This is in contrast to the reg and wire types which can only be used in
procedural blocks and continuous assignment respectively. All of this
makes the logic type much more flexible. As a result, it is easier to
understand and work with.
• As a general rule, we should use the logic type for any binary signal in our
System-Verilog design. The only exception to this is when we want to drive
a signal from more than one source. As it's illegal to drive a logic type from
more than one source, we would have to use a wire type for this.
System-Verilog bit Type
•
System-Verilog int Type
• By default, the int type is a 32 bit signed number which we can use to model
whole numbers in System-Verilog.
• We should generally use the int type instead of the integer type within our
System-Verilog testbenches.
String
Event:
• An identifier declared as an event data type is called a named event.
• Named event is a data type which has no storage.
• The event is used to convey an important message between the classes.
• The message could be that generated completed the process of sending all
the stimuli.
• message something like this could be send between the classes with the help
of an event.
• To trigger an event, we used -> operator.
• To sense an event, used this two operator edge sensitive_blocking @(),
level_sensitive_non-blocking wait().
• System-Verilog event is used to synchronize between two or more processes
or threads.
Triggered:
• The "triggered" event property evaluates to true if the given event has been
triggered in the current time-step and false otherwise.
• If event_identifier is null, then the triggered event property evaluates to
false.
• an event trigger shall unblock the waiting process whether the wait executes
before or at the same simulation time as the trigger operation.
• In the following example, event "e" is triggered at time 20,40,60,80 . So the
Value of "e.triggered" should be TRUE at time 20,40,60,80 and FALSE at
rest of the time.
Wait():
Race Condition:
• For a trigger to unblock a process waiting on an event, the waiting process
must execute the @ statement before the triggering process executes the
trigger operator, ->. If the trigger executes first, then the waiting process
remains blocked.
• event_name.triggered statement, an event trigger shall unblock the waiting
process whether the wait executes before or at the same simulation time as
the trigger operation.
• event_name.triggered statement, an event trigger shall unblock the waiting
process whether the wait executes before or at the same simulation time as
the trigger operation.
• The triggered event property, thus, helps eliminate a common race condition
that occurs when both the trigger and the wait (using @) happen at the same
time.
• A process that blocks waiting for an event might or might not unblock,
depending on the execution order of the waiting and triggering processes
(race condition).
• However, a process that waits on the triggered state always unblocks,
regardless of the order of execution of the wait and trigger operations.
In fixed size array, array size will be constant throughout the simulation,
Once the array is declared no need to create it.
By default, the array will be initialized with value ‘0’.
Fixed Size Array Example
The space for a dynamic array doesn’t exist until the array is explicitly
created at run-time, space is allocated when new [number] is called. the
number indicates the number of space/elements to be allocated.
You look up data by using an index which acts like a key to that location. This is
like a tag memory in a cache subsystem where the cache lines are sparsely located
at indices which are known as tags. You store data at a given key (index) and look
it up using the same key. This way you can take advantage of limited sparse
memory. When the size of the collection of variables is unknown or the data space
is sparse, an associative array is a better option over a dynamic array.
where data_type is the data type of the array elements. array_id is the name ofthe
array. And index_type is the data type used as the index (or key).Some examples
of associative arrays. We will see each one in detail:
num(), first() and last() method’s
Queues
The 0th position represents the first and $ represents the last element of the queue.
A queue is actually a one-dimensional unpacked array. Queues are declared using
the same syntax as unpacked arrays. The only difference is that a queue can grow
and shrink automatically. Thus, like arrays, queues can be manipulated using the
indexing, concatenation, slicing operator syntax, and equality operators. The
difference between an array and a queue is that an array is a non-variable size
collection of the same type of variables, while a queue is a variable size ordered
collection of homogeneous objects.
Queues are declared using the same syntax as unpacked arrays but specifying“$”
as the array size.
module tb;
int arr[$];
initial begin
arr ={1,2,3};
$display("arr : %op", arr);
end
endmodule