ASIC Verification: Verilog FAQ

Saturday, March 29, 2008

Verilog FAQ

What are the differences between blocking and nonblocking assignments?

There is one good paper by Stuart Sutherland about the blocking and non-blocking assignments. This paper can be downloaded from here.


Can you use a Verilog function to define the width of a multi-bit port, wire, or reg type?

The width elements of port declarations require a constant in both MSB and LSB. Before Verilog 2001, it is a syntax error to specify a function call to evaluate the value of these widths. For example, the following code is erroneous before Verilog 2001 version.

reg [ high(val1, val2) : low(val3, value4)] reg1;

In the above example, high and low are both function calls of evaluating a constant result for MSB and LSB respectively. However, Verilog-2001 allows the use of a function call to evaluate the MSB or LSB of a width declaration.

What is the difference b/w the following 2 lines of code?
#5 reg_a = reg_b;
reg_a = #5 reg_b;
Ans: 

Which one is better, asynchronous or synchronous reset for the storage elements?

There is one good paper by Stuart Sutherland about the synchronous and asynchronous reset. This paper can be downloaded from here.

What is the difference b/w the following 2 verilog codes?
a. assign c = condition ? a :b;
b. if(condition) c = a; else c = b;

Ans:


What logic gets synthesized when I use an integer instead of a reg variable as a storage element? Is use of integer recommended?

An integer can take the place of a reg as a storage element. The default width of the integer declaration is 32 bits. If you use integer in your RTL and store a 4 bit value, then the most significant 28 bits will be removed by the optimizer in the synthesis tool in order to minimize the area.

Although the use of integer is a legal construct, it is not recommended for the synthesis of storage elements.


How do you choose between a case statement and a multi-way if-else statement?

A case statement is typically chosen for the following scenarios:
  • When the conditionals are mutually exclusive and only one variable controls the flow in the case statement. The case variable itself could be a concatenation of different signals.
  • To specify the various state transitions of a finite state machine
  • Use of casex and casez allows use of x and z to represent don’t-care bits in the control expression
A multi way if statement is typically chosen in the following scenarios:
  • Synthesizing priority encoded logic
  • When the conditionals are not mutually exclusive
What is the difference between full_case and parallel_case synthesis directive?

There is one good paper by Stuart Sutherland about the full and partial case. This paper can be downloaded from here.

What is the difference b/w casex and casez statements? Which one is preferred?

Ans:
What is delta simulation time?
Ans:

How can you reliably convey control information across clock domains?

The readers are encouraged to read about good design implementation article here.


What are combinatorial timing loops? Why should they be avoided?

Combinatorial timing loops are hardware loops in which the output of either a gate or a long combinatorial path is fed back as an input to the same gate or to another gate earlier in the combinatorial path. These paths are generally created unintentionally when a variable from one combinatorial block is used to drive a signal that is used in the same combinatorial block from which the variable was derived. This typically happens in large size combinatorial blocks, wherein it is difficult to visually track that a loop is getting created.

These combinatorial feedback loops are undesirable for the following reasons:
  • Since there is no clock edge in between to break the path, the combinatorial loops will infinitely keep oscillating and triggering a square waveform, whose duty cycle is dependent upon the sum of ON delays and OFF delays across the combinatorial path.
Combinatorial loops can be caught quite early by one of the following means:
  • Periodic use of linting tools throughout the development process. This is by far the best and easiest way to catch and fix loops early in the design cycle.
  • If the loop is undetected during simulation, many synthesis tools have suitable reporting commands, which detect the presence of a loop. Note that synthesis tools proceed with the static timing analysis by breaking the timing arc of the loop for critical path analysis.

1 comment:

Anonymous said...

I am really glad I have found this info. Today bloggers publish just about gossips and internet and this is actually annoying. A good website with exciting content, that's what I need. Thanks for keeping this website, I'll be visiting it. Do you do newsletters? Cant find it. If any ones needs some expert web design or seo search engine optimization help check out my los angeles web design seo company website http://gotwebsiteandflyers.com los angeles web design xrumer linklist company they are able to move your blog reign on the internet. My partner and I absolutely love your blog and find nearly all of your post's to be just what I'm looking for. I would like to thank you for the efforts you have put in writing this web site. I am hoping the same high-grade website post from you in the upcoming also. Actually your creative writing skills has inspired me to get my own website now. Really the blogging is spreading its wings quickly. Your write up is a good example of it.