Friday, August 20, 2010

fork…join_none and for loop

An interesting case with fork…join_none block defined inside a for loop in system verilog is shown here as an example:

image

 

The intended result of this code is to display the iteration count value, i, from 0 to 3. That is, each call to system task, $display, will hold a unique value of i.

But the output of the above example is:

image

This can be explained as: Each iteration in the for loop initiates a parallel thread to display the value of variable i (iteration count). Because of join_none keyword, none of the threads (blocks) are waited for completion of their execution. So the immediately next statement after the for loop (zero time delay) is executed, which in this case is $display (“THE END”) system task and hence is the first line of output observed.

By the end of execution of for loop (zero time), the value of i is 4. This is the value that gets updated across all the threads (blocks) that has been initiated to display the value of i. Even before the threads begin to start executing the value of i has been changed to 4, which is what is observed in the output. This result implies that variable i is a static variable.

For this particular example replacing join_none by join statement will result into the expected output. That is, each parallel thread will display unique value of i and the output seen is i changing in consecutive order from 0 to 3.

In case join_none statement cannot be replaced because, say for example, of time consuming user defined task being called and the logic requires that no time is to be spent before executing the next statement following the for loop, then create an automatic variable inside a for loop and assign i to it before starting the fork…join_none block.

image

Here, keyword automatic can be ignored as well. Variable k is roughly similar to C automatic variable. Now, the lifetime of automatic variable k is the lifetime of each fork...join_none block. So each block will have a unique value of k, which doesn’t get changed even after completion of for loop. 

image

Wednesday, March 3, 2010

Part Select or Slice implementation in SV

To optimize the following system verilog code:

sample[0] = &dq[7:0];

sample[1] = &dq[15:8];

sample[2] = &dq[23:16];

sample[3] = &dq[31:24];

...

so on for 64-bit packed array dq. This was simplified by using for loop with system verilog slice or part select of packed arrays as:

for (int i=0,j=0; i<ST_W; i+=8, j++) begin //ST_W=DATA_WIDTH/16

sample[j] = &dq[i+:8];

end

The index i represents position of the slicing which is added to a constant 8 to determine the size of part select or slice. Thus, the code can be reused for any data width with reduced code density and easy readability.

Saturday, November 14, 2009

GVIM syntax highlight for systemverilog

Gvim syntax file for SystemVerilog & AVM can be downloaded from the following link: http://www.sibridgetech.com/download/systemverilog_avm.zip  

For gvim (portable) installed on windows, the following steps need to be followed:

1. The unzipped file needs to saved in ...\GVimPortable\App\vim\vim71\syntax directory.
2. Then, edit the file ..\GVimPortable\App\vim\vim71\filetype.vim to add the following lines (search line containing "verilog" in the file and insert the below lines beneath it):

" System Verilog
au BufNewFile,BufRead *.sv,*.svh setf systemverilog_avm

3. Close and open any systemverilog file having .sv and/or .svh extension.


Friday, November 13, 2009

TLM in OVM

Here's a very good demonstration of the need and importance of TLM in OVM.

Wednesday, September 16, 2009

ಅತ್ತು ಅತ್ತು ಮತ್ತತ್ತು

ಯಕ್ಷನ ವಿರಹದಿ೦ದ ಬೆ೦ದ ಯಕ್ಷಿಯ ಚಿತ್ರ - ಬೇ೦ದ್ರೆಯವರ ದೃಷ್ಟಿಯಲಿ  :

ಅತ್ತು ಅತ್ತು ಮತ್ತತ್ತು ಕೆದರಿಕೊ೦ಡಿಹುದು ಕಣ್ಣ ಪೊಗರು
ಬೆಚ್ಚನುಸಿರನು೦ಡು೦ಡು ಸೊಪ್ಪೆಯಾಗಿಹುದು ತುಟಿಯ ಚಿಗುರು
ಗಲ್ಲದಲ್ಲಿ ಕೈ, ಓರೆ ಮೋರೆ, ನಿಡಿಗೂದಳುದ್ದ  ಚಿ೦ತೆ
ಮೋಡ ಮುಸಕಲಿರೆ ಮ೦ಕುಕವಿದ ಆ ದೀನ ಚ೦ದ್ರನ೦ತೆ II

Monday, July 27, 2009

Best poll question ever


Best poll question I've come across (Adult Discretion Advised), which beats even the daily polls by Sagarika "faze the nation" Ghose on CNN-IBN.

Note (DON'T SAY I DIDN'T WARN):
The first link leads to "Adult Discretion Advised" kind of site, so please follow the advise, especially when you are in office. 

Wednesday, March 18, 2009

Life is Just is

Like a small stone wading thru the water to the depth -- half resisting but willing, half willing but resisting -- all the while following the natural laws, I've let myself go thru new phase of life. I only fulfill the natural laws of life without questioning and without seeking for answers.

Life is neither a question nor an answer to an unknown question. It is just is.

Tuesday, March 3, 2009

Terrorism LeT loose

Few good articles analysing today's heinous act by Pakistan terrorists:

1. Prem Panicker's take on today's terrorist attack on SL cricketers:
http://www.rediff.com/cricket/2009/mar//03prem-panicker-sri-lanka-team-attacked-in-pakistan.htm

2. B.Raman, India's best defence analyst, hints that this attack might be ordered by LTTE and executed by fringe terrorist-group in Pakistan.
http://ramansterrorismanalysis.blogspot.com/2009/03/hum-repays-old-debt-to-ltte-in-lahore.html

All this after Imran Khan had given strong/personal assurance to India about terrorists not attacking any cricketers if they tour Pakistan.

Saturday, February 7, 2009

Memento


--------------------------------------------------
Natalie: ... Even if you get your revenge, you are not gonna remember it, you are not even gonna know that it happened.
Lenny: My wife deserves a vengeance. It doesn't make any difference whether I know about it. Just because there are things that I don't remember, doesn't make my actions are meaningless. The world just doesn't disappear when  you close your eyes, does it? Anyway, maybe I'll take a photograph...

In movie 'Don', zeenat Aman in old/Priyanka Chopra in new, have opposite view on a similar situation. They want Don to recover back his memory before they can have their revenge. They reason it as saying Don should know why exactly he is being killed and also who (she is a sister of one of Don's victim) is killing him. 

--------------------------------------------------


Teddy: You can't trust a man's life to your little notes and pictures
Lenny: Why not?
Teddy: Because, Your notes could be unreliable
Lenny: memories are unreliable
Teddy: Ah... Please...
Lenny: No No No...really. Memories aren't just perfect. They are not even that good. Ask the Police. Eyewitness testimonies are unreliable. Cops don't catch the thieves by sitting around and remembering stuff, right?... They collect facts, they make notes and they draw conclusions. Facts, not memories. That's how you investigate.
Teddy: I know. That's what I used to do.
Lenny: Look, memories can change the shape of the room, it can change the color of a car, and memories can be distorted. They are just an interpretation, they are not a record. And they are irrelevant if you have the facts.



Powered By Blogger