Verilog Interview Questions - 3

1. How are blocking and non-blocking statements executed?


In a blocking statement, the RHS will be evaluated and the LHS will be then updated, without interruption from any other Verilog statement. A blocking statement "blocks" trailing statements.
In a non-blocking statement, RHS will be evaluated at the beginning of the time step. Then the LHS will be updated at the end of the time step.

2. How do you model a synchronous and asynchronous reset in Verilog?


Synchronous reset:
always @(posedge clk)
begin
--
if(reset)
--
end

Asynchronous reset:
always @(posedge clk or posedge reset)
begin
--
if(reset)
--
end
The logic is very simple: In asynchronous reset, the always block will invoked at positive edge of the reset signal, irrespective of clock's value.

3. What happens if there is connecting wires width mismatch?


For example there are two signals rhs[7:0], and lhs[15:0]. If we do rhs = lhs. Then it is equivalent to rhs = lhs[7:0]. Assignment starts from LSBs of the signals, and ends at the MSB of smaller width signal.

4. What are different options that can be used with $display statement in Verilog?


%b or %B - Binary.
%c or %C - ASCII character.
%d or %D - Decimal.
%h or %H - Hexadecimal.
%m or %M - Hierarchical name.
%o or %O - Octal.
%s or %S - String.
%t or %T - Time.
%v or %V - Net signal strength.

5. Give the precedence order of the operators in Verilog.


You can find it here

6. Should we include all the inputs of a combinational circuit in the sensitivity list? Give reason.


Yes, in a combinational circuit all the inputs should be included in the sensitivity list other wise it will result in a synthesis error.

7. Give 10 commonly used Verilog keywords.


always, and, assign, begin, case, default, else, end, module, endmodule, reg, net, etc.
Click here for the complete list.

8. Is it possible to optimize a Verilog code such that we can achieve low power design?


Yes. Try to optimize the code such that the data transitions are reduced. Try to make as small as possible, because less number of transistors means less amount of power dissipation. Try to reduce the clock switching of the filp-flops.

9. How does the following code work?
wire [3:0] a;
always @(*)
begin
case (1'b1)
a[0]: $display("Its a[0]");
a[1]: $display("Its a[1]");
a[2]: $display("Its a[2]");
a[3]: $display("Its a[3]");
default: $display("Its default")
endcase
end


The case checks a[0] to a[3], if any one of the is 1'b1, then the first appearing 1'b1 will be executed. suppose a[0] = 0, a[1] = 1, a[2] = 1, and a[3] = 0,then Its a[1] will be displayed. If all are zeros then Its default, will be displayed.

10. Which is updated first: signal or variable?


Signal.

Comments

(追記) (追記ここまで)

Popular posts from this blog

1. How do you convert a XOR gate into a buffer and a inverter (Use only one XOR gate for each)? Answer 2. Implement an 2-input AND gate using a 2x1 mux. Answer 3. What is a multiplexer? Answer A multiplexer is a combinational circuit which selects one of many input signals and directs to the only output. 4. What is a ring counter? Answer A ring counter is a type of counter composed of a circular shift register. The output of the last shift register is fed to the input of the first register. For example, in a 4-register counter, with initial register values of 1100, the repeating pattern is: 1100, 0110, 0011, 1001, 1100, so on. 5. Compare and Contrast Synchronous and Asynchronous reset. Answer Synchronous reset logic will synthesize to smaller flip-flops, particularly if the reset is gated with the logic generating the d-input. But in such a case, the combinational logic gate count grows, so the overall gate count savings may not be that significant. The clock works as a filter for sma...
225 comments
Designing a FSM is the most common and challenging task for every digital logic designer. One of the key factors for optimizing a FSM design is the choice of state coding, which influences the complexity of the logic functions, the hardware costs of the circuits, timing issues, power usage, etc. There are several options like binary encoding, gray encoding, one-hot encoding, etc. The choice of the designer depends on the factors like technology, design specifications, etc. One-hot encoding In one-hot encoding only one bit of the state vector is asserted for any given state. All other state bits are zero. Thus if there are n states then n state flip-flops are required. As only one bit remains logic high and rest are logic low, it is called as One-hot encoding. Example : If there is a FSM, which has 5 states. Then 5 flip-flops are required to implement the FSM using one-hot encoding. The states will have the following values: S0 - 10000 S1 - 01000 S2 - 00100 S3 - 00010 S4 - 00001 Adv...
3 comments
Cross Module Reference   Cross Module Reference abbreviated as XMR is a very useful concept in Verilog HDL (as well as system Verilog). However it seems to be less known among many users of Verilog. XMR is a mechanism built into Verilog to globally reference (i.e., across the modules) to any nets, tasks, functions etc. Using XMR, one can refer to any object of a module in any other module, irrespective of whether they are present below or above its hierarchy. Hence, a XMR can be a:   Downward reference OR Upward reference   Consider the following hierarchy:     Module A   Net x   Instance P of Module B     Net x   Instance M of Module D   Net x   Instance Q of Module C   Net x   Instance N of Module E    Net x   Instance R of Module B   Net x   Instance M of Module D   Net x ...
10 comments