原创 System Verilog Queues which can shrink and grow !

2013-5-19 00:52 2428 1 2 分类: 消费电子

Dear Readers,

System Verilog has new data type called ‘queue’ which can grow and shrink. With SV queue, we can easily add and remove elements anywhere that is the reason we say it can shrink and grow as we need. Queues can be used as LIFO (Last In First Out) Buffer or FIFO (First In First Out) type of buffers.

Each element in the queue is identified by an ordinal number that represents its position within the queue, with 0 representing the first element and $ represents the last element.

The size of the queue is variable similar to dynamic array but queue may be empty with zero element and still its a valid data structure.




Lets take a few examples to understand queue operation with different methods we have in system verilog.
 
############################################### 
int a;
Q[$] = {0,1,2,3};  // Initial queue
 
initial begin
   //Insert and delete
   Q.insert (1, 1); // This means insert 1 at first element in the queue which becomes {0,1,1,2,3}
   Q.delete(2); // This means delete 2nd element from the queue. {0,1,2,3}
 
   //Push_front
   Q.push_front (6);  //Insert ‘6’ at front of the queue. {6,0,1,2,3}
 
   //Pop_back
   a = Q.pop_back; // Poping the last element and stored it to local variable ‘a’,  a = 3 in this case. Resultant Queue = {6,0,1,2}
 
   //push_back
   Q.push_back(7) // Pushing the element ‘7’ from the back. {6,0,1,2,7}
  
   //Pop_front:
   a =Q.pop_front; Poping the first element and stored it to local variable called ‘a’, a=6 in this case. Resultant Queue = {0,1,2,7}
 
end
##################################################### 
 
When you create a queue System Verilog actually allocates extra space and because this we can add and remove the element based on need in our test bench. This is very useful feature in test bench implementation. System Verilog automatically allocates the additional space so we don't need to worry about the limits and queue will not run out of space.
 
Queue is very useful data type in System Verilog for developing a test benches. It can be used in development of various entity in the test bench like scoreboard, monitor, transaction class, drivers etc.
 
Hope this helps in basic understanding of queue and its methods.
 
Happy Reading!
ASIC With Ankit

文章评论1条评论)

登录后参与讨论

duxiaoshuang520_151560515 2014-9-17 12:16

来瞧瞧!

594509107_469195137 2014-8-1 12:45

594509107_469195137 2014-7-14 16:15

594509107_469195137 2014-7-7 18:17

594509107_469195137 2014-6-30 12:00

2.4G调光调色温模块控制方案  QQ594509107

594509107_469195137 2014-6-24 16:56

594509107_469195137 2014-6-17 17:47

2.4G调光调色温控制方案

visitor_251768931 2013-11-22 03:37

Can you please talk about multidimensional queue's. Maybe a 3D queue.


 

相关推荐阅读
ankitgopani 2015-03-16 06:30
System Verilog : Functional Coverage Guidelines
We have been implementing every possible checks to make sure design is verified but what have we d...
ankitgopani 2014-11-14 09:12
Semicon M&A, takeover & impacts!
Dear Readers,   Mergers and acquisition are common in today’s global market. If you take a his...
ankitgopani 2013-05-27 13:09
What is "this" in System Verilog ?
  Dear Readers,   Here I would like to share some understanding on keyword called "this". Wh...
ankitgopani 2013-05-01 01:03
Verilog to System Verilog : A Successful journey towards SV
Dear Readers, We have been using standard languages and methodologies for ASIC/FPGA design and Ve...
ankitgopani 2013-03-13 21:53
What are the major factor which could trigger re-spin?
Dear Readers, I have been hearing on re-spins of chips. Many companies have gone through this pa...
广告
EE直播间
更多
我要评论
1
1
广告
关闭 热点推荐上一条 /4 下一条