Given the following Verilog code, what value of "a" is displayed?
Electrical Engineering Technical Interview Questions and Answers
(Continued from previous question...)
2. Given the following Verilog code, what value of "a" is displayed?
Given the following Verilog code, what value of "a" is displayed?
always @(clk) begin
a = 0;
a <= 1;
$display(a);
end
This is a tricky one! Verilog scheduling semantics basically imply a
four-level deep queue for the current simulation time:
1: Active Events (blocking statements)
2: Inactive Events (#0 delays, etc)
3: Non-Blocking Assign Updates (non-blocking statements)
4: Monitor Events ($display, $monitor, etc).
Since the "a = 0" is an active event, it is scheduled into the 1st "queue".
The "a <= 1" is a non-blocking event, so it's placed into the 3rd queue.
Finally, the display statement is placed into the 4th queue.
Only events in the active queue are completed this sim cycle, so the "a = 0"
happens, and then the display shows a = 0. If we were to look at the value of
a in the next sim cycle, it would show 1.
(Continued on next question...)
Other Interview Questions
- What is the difference between a Verilog task and a Verilog function?
- Given the following Verilog code, what value of "a" is displayed?
- Given the following snipet of Verilog code draw out the waveforms for clk ...
- What is the difference between the following two lines of Verilog code?
- What is the difference between ...
- Using the given, draw the waveforms for the following versions of a ...
- What is the difference between running the following snipet of code on Verilog vs Vera?
- Given $a = "5,-3,7,0,-5,12"; Write a program to find the lowest number in the string.
- Write the code to sort an array of integers.
- Write the code for finding the factorial of a passed integer. Use a recursive subroutine.
- In C, explain the difference between the & operator and the * operator.
- Write a function to determine whether a string is a palindrome (same forward as reverse, such as "radar" or "mom").
- Write a function to output a diamond shape according to the given (odd) input.
- Given the following FIFO and rules, how deep does the FIFO need to be to prevent underflowing or overflowing?
- Draw the state diagram to output a "1" for one cycle if the sequence "0110" shows up (the leading 0s cannot be used in more than one sequence).
- Explain the differences between "Direct Mapped", "Fully Associative", and "Set Associative" caches.
- Design a four-input NAND gate using only two-input NAND gates.
- Draw the state diagram for a circuit that outputs ...
|