System Verilog Basics: March 02, 2010
System Verilog Basics: March 02, 2010
System Verilog Basics: March 02, 2010
Unified HDVL
Superset of verilog (IEEE 1394 - 2001).
Many of the desirable features of HDL and
modern S/W languages.
1) OOPS semantics including classes
2) constraint randomization, sequence generation
3) Functional Coverage
4) Assertions
Verification Features
1) New Data types.
2) OOPS (as against AOP in ‘e’).
3) Arrays and Queues.
4) Interfaces and Modports.
5) Clocking and Program Blocks.
6) Constraint Random Stimulus Generation.
7) Intelligent Automated Self Checking.
Fully compatible with verilog 1364 – 2001.
Adds new identifiers.
SV Over Verilog (Major)
Packed Arrays:
1) Dimensions declared left side of object name
2) Contiguous set of bits
Examples :
bit [7:0] data;
bit [21:0] address;
Unpacked Arrays:
1) Dimensions declared right side of object name.
2) size can be modified at run time.
3) Fixed, Dynamic and Associative
Fixed Array
Static
Supports multiple dimensions
Out of bound writes are ignored – No compilation error
Out of bound reads give ‘x’ – even for 2 state
Examples:
int data [256];
bit [31:0] addr [1024];
bit [31:0][3:0] d [8];
Dynamic Arrays
position in queue
Zero represents the first and $ represents last
int p[$];
int q[$] = {2,3,4};
q = {q,6}; q = {q[1:$]}; q = {q[0:pos-1], 3, q [pos:$]};
Queue : Methods()
size() The size() method returns the number of items in the
queue. If the queue is empty, it returns 0.
Insert() The insert() method inserts the given item at the specified
index position.
Q.insert(i, e) is equivalent to: Q = {Q[0:i-1], e, Q[i,$]}
delete() function void delete(int index);
The delete() method deletes the item at the specified index
position.
pop_front() The pop_front() method removes and returns the first
element of the queue. e = Q.pop_front() is equivalent to: e
= Q[0]; Q = Q[1,$]
Pop_back() The pop_back() method removes and returns the last
element of the queue. e = Q.pop_back() is equivalent to: e
= Q[$]; Q = Q[0,$-1]
push_back() The push_back() method inserts the given element at the
end of the queue. Q.push_back(e) is equivalent to: Q = {Q,
e}
Events
Declare Events
event my_event;
Trigger Events
-> my_event;
Wait for Events – triggered is built in.
@ my_event or wait (my_event.triggered)
Events can be passed as argument.
Refreshers/Experiments
Value of str?
string str = “hello”;
bit [11:0] b = 12’h5a4;
str = b;
Queue operation
Predict the outputs at successive steps
int j = 1,b[$] = {3,4},q[$] = {0,2,5};
initial begin
q.insert(1,j);
q.insert(3,b);
q.delete(1);
q.push_front(6);
j =q.pop_back;
q.push_back(8);
j = q.pop_front;
end
Cont’d
tq = q.min;
tq = q.max;
tq = f.unique;