Wednesday, May 22, 2013

Race Condition

RACE CONDITION 

1.Verilog is easy to learn because its gives quick results. 
2. Although many users are telling that their work is free from race condition.But the fact is race condition is easy to create, to understand, to document but difficult to find. 
Here we will discuss regarding events which creates the race condition & solution for that. 


What Is Race Condition? 
When two expressions are scheduled to execute at same time, and if the order of the execution is not determined, then race condition occurs. 


EXAMPLE 
module race(); 
wire p; 
reg q; 
assign p = q; 

initial begin 
= 1; 
#1 q = 0; 
$display(p); 
end 
endmodule 



The simulator is correct in displaying either a 1 or a 0. The assignment of 0 to q enables an update event for p. The simulator may either continue or execute the $display system task or execute the update for p, followed by the $display task. 
Then guess what can the value of p ? 
Simulate the above code in your simulator. Then simulate the following code . Statement "assign p = q;" is changed to end of the module. 



EXAMPLE 
module race(); 
wire p; 
reg q; 

assign p = q; 

initial begin 
= 1; 
#1 q = 0; 
$display(p); 
end 
endmodule 



Analyze the effect if I change the order of the assign statement. 



Why Race Condition? 



To describe the behavior of electronics hardware at varying levels of abstraction, Verilog HDL has to be a parallel programming language and Verilog simulator and language itself are standard of IEEE, even though there are some nondeterministic events which is not mentioned in IEEE LRM and left it to the simulator algorithm, which causes the race condition. So it is impossible to avoid the race conditions from the language but we can avoid from coding styles. 

Look at following code. Is there any race condition? 



EXAMPLE: 
initial 
begin 
in = 1; 
out <= in; 
end 



Now if you swap these two lines: 


EXAMPLE 
initial 
begin 
out <= in; 
in = 1; 
end 



Think, is there any race condition created? 
Here first statement will schedule a non-blocking update for "out" to whatever "in" was set to previously, and then "in" will be set to 1 by the blocking assignment. Any statement whether it is blocking or nonblocking statements in a sequential block (i.e. begin-end block) are guaranteed to execute in the order they appear. So there is no race condition in the above code also. Since it is easy to make the "ordering mistake", one of Verilog coding guidelines is: "Do not mix blocking and nonblocking assignments in the same always block". This creates unnecessary doubt of race condition. 


When Race Is Visible? 



Sometimes unexpected output gives clue to search for race. Even if race condition is existing in code, and if the output is correct, then one may not realize that there exists race condition in their code. This type of hidden race conditions may come out during the following situation. 

When different simulators are used to run the same code. 
Some times when the new release of the simulator is used. 
Adding more code to previous code might pop out the previously hidden race. 
If the order of the files is changed. 
When using some tool specific options. 
If the order of the concurrent blocks or concurrent statements is changed.(One example is already discussed in the previous topics) 

Some simulators have special options which reports where exactly the race condition is exists. Linting tools can also catch race condition. 



How To Prevent Race Condition? 



There are many details which is unspecified between simulators. The problem will be realized when you are using different simulators. If you are limited to design guidelines then there is less chance for race condition but if you are using Verilog with all features for Testbench, then it is impossible to avoid. Moreover the language which you are using is parallel but the processor is sequential. So you cant prevent race condition. 



Types Of Race Condition 



Here we will see race condition closely. 
Types of race condition 



Write-Write Race: 



it occurs when same register is written in both the blocks. 


EXAMPLE: 
always @(posedge clk) 
= 1; 
always @(posedge clk) 
= 5; 



Here you are seeing that one block is updating value of a while another also. Now which always block should go first. This is nondeterministic in IEEE standard and left that work to the simulator algorithm. 



Read-Write Race: 



it occurs when same register is read in one block and writes in another. 


EXAMPLE: 
always @(posedge clk) 
= 1; 
always @(posedge clk) 
= a; 



Here you are seeing that in one always block value is assign to a while simultaneously its value is assign to b means a is writing and read parallel. This type of race condition can easily solved by using nonblocking assignment. 



EXAMPLE 
always @(posedge clk) 
<= 1; 
always @(posedge clk) 
<= a; 

More Race Example: 



1) Function calls 


EXAMPLE: 
function incri(); 
begin 
pkt_num = pkt_num + 1; 
end 
endfunction 

always @(...) 
sent_pkt_num = incri(); 

always @(...) 
sent_pkt_num_onemore = incri(); 



2) Fork join 


EXAMPLE: 
fork 
=0; 
= a; 
join 



3) $random 


EXAMPLE: 
always @(...) 
$display("first Random number is %d",$random()); 
always @(...) 
$display("second Random number is %d",$random()); 



4) Clock race 


EXAMPLE 
initial 
clk = 0; 
always 
clk = #5 ~clk; 



If your clock generator is always showing "X" then there is a race condition. There is one more point to be noted in above example. Initial and always starts executes at time zero. 

5) Declaration and initial 


EXAMPLE: 
reg a = 0; 
initial 
= 1; 



6)Testbench DUT race condition. 

In test bench , if driving is done at posedge and reading in DUT is done at the same time , then there is race. To avoid this, write from the Testbench at negedge or before the posedge of clock. This makes sure that the DUT samples the signal without any race. 


EXAMPLE: 
module DUT(); 
input d; 
input clock; 
output q; 

always @(posedge clock) 
= d; 

endmodule 

module testbench(); 

DUT dut_i(d,clk,q); 

initial 
begin 
@(posedge clk) 
= 1; 
@(posedge clock) 
= 0; 
end 
endmodule 

The above example has write read race condition. 

Event Terminology: 



Every change in value of a net or variable in the circuit being simulated, as well as the named event, is considered an update event. Processes are sensitive to update events. When an update event is executed, all the processes that are sensitive to that event are evaluated in an arbitrary order. The evaluation of a process is also an event, known as an evaluation event. 

In addition to events, another key aspect of a simulator is time. The term simulation time is used to refer to the time value maintained by the simulator to model the actual time it would take for the circuit being simulated. The term time is used interchangeably with simulation time in this section. Events can occur at different times. In order to keep track of the events and to make sure they are processed in the correct order, the events are kept on an event queue, ordered by simulation time. Putting an event on the queue is called scheduling an event. 



The Stratified Event Queue 



The Verilog event queue is logically segmented into five different regions. Events are added to any of the five regions but are only removed from the active region. 

1) Events that occur at the current simulation time and can be processed in any order. These are the 
active events. 
1.1 evaluation of blocking assignment. 
1.2 evaluation of RHS of nonblocking assignment. 
1.3 evaluation of continuous assignment. 
1.4 evaluation of primitives I/Os 
1.5 evaluation of $display or $write 

2) Events that occur at the current simulation time, but that shall be processed after all the active events are processed. These are the inactive events. 
#0 delay statement. 

3) Events that have been evaluated during some previous simulation time, but that shall be assigned at this simulation time after all the active and inactive events are processed. These are the nonblocking assign update events. 

4) Events that shall be processed after all the active, inactive, and non blocking assign update events are processed. These are the monitor events. 
$strobe and $monitor 

5) Events that occur at some future simulation time. These are the future events. Future events are divided into future inactive events, and future non blocking assignment update events. 

Example : PLI tasks 

The processing of all the active events is called a simulation cycle. 


Determinism 



This standard guarantees a certain scheduling order. 

1) Statements within a begin-end block shall be executed in the order in which they appear in that begin-end block. Execution of statements in a particular begin-end block can be suspended in favor of other processes in the model; however, in no case shall the statements in a begin-end block be executed in any order other than that in which they appear in the source. 

2) Non blocking assignments shall be performed in the order the statements were executed. 

Consider the following example: 


initial begin 
<= 0; 
<= 1; 
end 


When this block is executed, there will be two events added to the non blocking assign update queue. The previous rule requires that they be entered on the queue in source order; this rule requires that they be taken from the queue and performed in source order as well. Hence, at the end of time step 1, the variable a will be assigned 0 and then 1. 



Nondeterminism 




One source of nondeterminism is the fact that active events can be taken off the queue and processed in any order. Another source of nondeterminism is that statements without time-control constructs in behavioral blocks do not have to be executed as one event. Time control statements are the # expression and @ expression constructs. At any time while evaluating a behavioral statement, the simulator may suspend execution and place the partially completed event as a pending active event on the event queue. The effect of this is to allow the interleaving of process execution. Note that the order of interleaved execution is nondeterministic and not under control of the user. 



Guideline To Avoid Race Condition 



(A). Do not mix blocking and nonblocking statements in same block.
(B). Do not read and write using blocking statement on same variable.( avoids read write race) 
(C). Do not initialize at time zero. 
(D). Do not assign a variable in more than one block.( avoids write-write race) 
(E). Use assign statement for inout types of ports & do not mix blocking and nonblocking styles of declaration in same block. It is disallow variables assigned in a blocking assignment of a clocked always block being used outside that block and disallow cyclical references that don't go through a non-blocking assignment. It is require all non-blocking assignments to be in a clocked always block. 
(F). Use blocking statements for combinational design and nonblocking for sequential design. If you want gated outputs from the flops, you put them in continuous assignments or an always block with no clock. 



Avoid Race Between Testbench And Dut 



Race condition may occurs between DUT and testbench. Sometimes verification engineers are not allowed to see the DUT, Sometimes they don't even have DUT to verify. Consider the following example. Suppose a testbench is required to wait for a specific response from its DUT. Once it receives the response, at the same simulation time it needs to send a set of stimuli back to the DUT. 

Most Synchronous DUT works on the posedge of clock. If the Testbench is also taking the same reference, then we may unconditionally end in race condition. So it~Rs better to choose some other event than exactly posedge of cock. Signals are stable after the some delay of posedge of clock. Sampling race condition would be proper if it is done after some delay of posedge of clock. Driving race condition can be avoided if the signal is driven before the posedge of clock, so at posedge of clock ,the DUT samples the stable signal. So engineers prefer to sample and drive on negedge of clock, this is simple and easy to debug in waveform debugger also. RACE CONDITION 


Verilog is easy to learn because its gives quick results. Although many users are telling that their work is free from race condition.But the fact is race condition is easy to create, to understand, to document but difficult to find. Here we will discuss regarding events which creates the race condition & solution for that. 

What Is Race Condition? 



When two expressions are scheduled to execute at same time, and if the order of the execution is not determined, then race condition occurs. 


EXAMPLE 
module race(); 
wire p; 
reg q; 
assign p = q; 

initial begin 
= 1; 
#1 q = 0; 
$display(p); 
end 
endmodule 



The simulator is correct in displaying either a 1 or a 0. The assignment of 0 to q enables an update event for p. The simulator may either continue or execute the $display system task or execute the update for p, followed by the $display task. 
Then guess what can the value of p ? 
Simulate the above code in your simulator. Then simulate the following code . Statement "assign p = q;" is changed to end of the module. 



EXAMPLE 
module race(); 
wire p; 
reg q; 

assign p = q; 

initial begin 
= 1; 
#1 q = 0; 
$display(p); 
end 
endmodule 



Analyze the effect if I change the order of the assign statement. 



Why Race Condition? 



To describe the behavior of electronics hardware at varying levels of abstraction, Verilog HDL has to be a parallel programming language and Verilog simulator and language itself are standard of IEEE, even though there are some nondeterministic events which is not mentioned in IEEE LRM and left it to the simulator algorithm, which causes the race condition. So it is impossible to avoid the race conditions from the language but we can avoid from coding styles. 

Look at following code. Is there any race condition? 



EXAMPLE: 
initial 
begin 
in = 1; 
out <= in; 
end 



Now if you swap these two lines: 


EXAMPLE 
initial 
begin 
out <= in; 
in = 1; 
end 



Think, is there any race condition created? 
Here first statement will schedule a non-blocking update for "out" to whatever "in" was set to previously, and then "in" will be set to 1 by the blocking assignment. Any statement whether it is blocking or nonblocking statements in a sequential block (i.e. begin-end block) are guaranteed to execute in the order they appear. So there is no race condition in the above code also. Since it is easy to make the "ordering mistake", one of Verilog coding guidelines is: "Do not mix blocking and nonblocking assignments in the same always block". This creates unnecessary doubt of race condition. 


When Race Is Visible? 



Sometimes unexpected output gives clue to search for race. Even if race condition is existing in code, and if the output is correct, then one may not realize that there exists race condition in their code. This type of hidden race conditions may come out during the following situation. 

When different simulators are used to run the same code. 
Some times when the new release of the simulator is used. 
Adding more code to previous code might pop out the previously hidden race. 
If the order of the files is changed. 
When using some tool specific options. 
If the order of the concurrent blocks or concurrent statements is changed.(One example is already discussed in the previous topics) 

Some simulators have special options which reports where exactly the race condition is exists. Linting tools can also catch race condition. 



How To Prevent Race Condition? 



There are many details which is unspecified between simulators. The problem will be realized when you are using different simulators. If you are limited to design guidelines then there is less chance for race condition but if you are using Verilog with all features for Testbench, then it is impossible to avoid. Moreover the language which you are using is parallel but the processor is sequential. So you cant prevent race condition. 



Types Of Race Condition 



Here we will see race condition closely. 
Types of race condition 



Write-Write Race: 



it occurs when same register is written in both the blocks. 


EXAMPLE: 
always @(posedge clk) 
= 1; 
always @(posedge clk) 
= 5; 



Here you are seeing that one block is updating value of a while another also. Now which always block should go first. This is nondeterministic in IEEE standard and left that work to the simulator algorithm. 



Read-Write Race: 



it occurs when same register is read in one block and writes in another. 


EXAMPLE: 
always @(posedge clk) 
= 1; 
always @(posedge clk) 
= a; 



Here you are seeing that in one always block value is assign to a while simultaneously its value is assign to b means a is writing and read parallel. This type of race condition can easily solved by using nonblocking assignment. 



EXAMPLE 
always @(posedge clk) 
<= 1; 
always @(posedge clk) 
<= a; 

More Race Example: 



1) Function calls 


EXAMPLE: 
function incri(); 
begin 
pkt_num = pkt_num + 1; 
end 
endfunction 

always @(...) 
sent_pkt_num = incri(); 

always @(...) 
sent_pkt_num_onemore = incri(); 



2) Fork join 


EXAMPLE: 
fork 
=0; 
= a; 
join 



3) $random 


EXAMPLE: 
always @(...) 
$display("first Random number is %d",$random()); 
always @(...) 
$display("second Random number is %d",$random()); 



4) Clock race 


EXAMPLE 
initial 
clk = 0; 
always 
clk = #5 ~clk; 



If your clock generator is always showing "X" then there is a race condition. There is one more point to be noted in above example. Initial and always starts executes at time zero. 

5) Declaration and initial 


EXAMPLE: 
reg a = 0; 
initial 
= 1; 



6)Testbench DUT race condition. 

In test bench , if driving is done at posedge and reading in DUT is done at the same time , then there is race. To avoid this, write from the Testbench at negedge or before the posedge of clock. This makes sure that the DUT samples the signal without any race. 


EXAMPLE: 
module DUT(); 
input d; 
input clock; 
output q; 

always @(posedge clock) 
= d; 

endmodule 

module testbench(); 

DUT dut_i(d,clk,q); 

initial 
begin 
@(posedge clk) 
= 1; 
@(posedge clock) 
= 0; 
end 
endmodule 

The above example has write read race condition. 

Event Terminology: 



Every change in value of a net or variable in the circuit being simulated, as well as the named event, is considered an update event. Processes are sensitive to update events. When an update event is executed, all the processes that are sensitive to that event are evaluated in an arbitrary order. The evaluation of a process is also an event, known as an evaluation event. 

In addition to events, another key aspect of a simulator is time. The term simulation time is used to refer to the time value maintained by the simulator to model the actual time it would take for the circuit being simulated. The term time is used interchangeably with simulation time in this section. Events can occur at different times. In order to keep track of the events and to make sure they are processed in the correct order, the events are kept on an event queue, ordered by simulation time. Putting an event on the queue is called scheduling an event. 



The Stratified Event Queue 



The Verilog event queue is logically segmented into five different regions. Events are added to any of the five regions but are only removed from the active region. 

1) Events that occur at the current simulation time and can be processed in any order. These are the 
active events. 
1.1 evaluation of blocking assignment. 
1.2 evaluation of RHS of nonblocking assignment. 
1.3 evaluation of continuous assignment. 
1.4 evaluation of primitives I/Os 
1.5 evaluation of $display or $write 

2) Events that occur at the current simulation time, but that shall be processed after all the active events are processed. These are the inactive events. 
#0 delay statement. 

3) Events that have been evaluated during some previous simulation time, but that shall be assigned at this simulation time after all the active and inactive events are processed. These are the nonblocking assign update events. 

4) Events that shall be processed after all the active, inactive, and non blocking assign update events are processed. These are the monitor events. 
$strobe and $monitor 

5) Events that occur at some future simulation time. These are the future events. Future events are divided into future inactive events, and future non blocking assignment update events. 

Example : PLI tasks 

The processing of all the active events is called a simulation cycle. 


Determinism 



This standard guarantees a certain scheduling order. 

1) Statements within a begin-end block shall be executed in the order in which they appear in that begin-end block. Execution of statements in a particular begin-end block can be suspended in favor of other processes in the model; however, in no case shall the statements in a begin-end block be executed in any order other than that in which they appear in the source. 

2) Non blocking assignments shall be performed in the order the statements were executed. 

Consider the following example: 


initial begin 
<= 0; 
<= 1; 
end 


When this block is executed, there will be two events added to the non blocking assign update queue. The previous rule requires that they be entered on the queue in source order; this rule requires that they be taken from the queue and performed in source order as well. Hence, at the end of time step 1, the variable a will be assigned 0 and then 1. 



Nondeterminism 




One source of nondeterminism is the fact that active events can be taken off the queue and processed in any order. Another source of nondeterminism is that statements without time-control constructs in behavioral blocks do not have to be executed as one event. Time control statements are the # expression and @ expression constructs. At any time while evaluating a behavioral statement, the simulator may suspend execution and place the partially completed event as a pending active event on the event queue. The effect of this is to allow the interleaving of process execution. Note that the order of interleaved execution is nondeterministic and not under control of the user. 



Guideline To Avoid Race Condition 



(A). Do not mix blocking and nonblocking statements in same block.
(B). Do not read and write using blocking statement on same variable.( avoids read write race) 
(C). Do not initialize at time zero. 
(D). Do not assign a variable in more than one block.( avoids write-write race) 
(E). Use assign statement for inout types of ports & do not mix blocking and nonblocking styles of declaration in same block. It is disallow variables assigned in a blocking assignment of a clocked always block being used outside that block and disallow cyclical references that don't go through a non-blocking assignment. It is require all non-blocking assignments to be in a clocked always block. 
(F). Use blocking statements for combinational design and nonblocking for sequential design. If you want gated outputs from the flops, you put them in continuous assignments or an always block with no clock. 



Avoid Race Between Testbench And Dut 



Race condition may occurs between DUT and testbench. Sometimes verification engineers are not allowed to see the DUT, Sometimes they don't even have DUT to verify. Consider the following example. Suppose a testbench is required to wait for a specific response from its DUT. Once it receives the response, at the same simulation time it needs to send a set of stimuli back to the DUT. 

Most Synchronous DUT works on the posedge of clock. If the Testbench is also taking the same reference, then we may unconditionally end in race condition. So it~Rs better to choose some other event than exactly posedge of cock. Signals are stable after the some delay of posedge of clock. Sampling race condition would be proper if it is done after some delay of posedge of clock. Driving race condition can be avoided if the signal is driven before the posedge of clock, so at posedge of clock ,the DUT samples the stable signal. So engineers prefer to sample and drive on negedge of clock, this is simple and easy to debug in waveform debugger also. 

//content is copied from testbench.in and a bit edited .
//you can give your inputs as comments

Testbench components


eVC ARCHITECTURE: eVC is an e Verification Component. It is ready –to-use, configurable verification environment.
       Agents are the key to eVC architecture. Agents are either active or passive. Active  agents are agents that drive DUT signals. Passive agents never drive signals, either because they just monitor an interface within the DUT or because, according to the protocol, no signals ned to be driven.

Types of Agents:
i.        MASTER AGENT: A transmit agent that can send data to the DUT’s receive port. It can be either active or passive.
ii.      SLAVE AGENT: A receive agent that can collect data from the DUT’s transmit port. It can be either active or passive.

Description of all the components :

1. Config.
It decides whether the agent is active or passive
2. Sequence
Sequence is a class which is used to generate some random input, it has the set of random inputs that is stored in seq_lib. Test case is nothing but the set of inputs to test the DUT which forms Sequence library.

3. Sequencer:
A sequencer is an advanced stimulus generator that controls the items that are provided to the driver for execution. By default, a sequencer behaves similarly to a simple stimulus generator and returns a random data item upon request from the driver. This default behavior allows you to add constraints to the data item class in order to control the distribution of randomized values
.
5. Driver:
The driver’s role is to drive data items to the bus following the interface protocol. The driver obtains data items from the sequencer for execution. The UVM Class Library provides the uvm_driver base class, from which all driver classes should be extended, either directly or indirectly.

6. Monitor
Monitor is used to sample input and output at DUT ] interfaces.
7. Scoreboard
It generates true output for the random input that is generated by the sequences. As input is detected, data will be added to the scoreboard as a list. When output is detected, it will be compared against scoreboard data in the list.
8. Checker
Checker is used to match the output data with the expected output (to verify the output).
9. Functional Coverage
It checks the functional coverage and tells if the test plan goals have been met.
There are 3 types of functional coverage
Basic item coverage, transition item coverage, cross coverage
a)      Basic Item Coverage: This coverage tells if all legal values of an interesting variable have been covered.
b)      Transition Item Coverage: This coverage is used for state machines which form the control logic for any design. It tells if all legal transitions of a state machine have been covered.
c)       Cross Coverage: This coverage allows to examine the cross product of two or more basic or transition items to check if all interesting combinations of basic and transition items have been covered

Driver in system verilog


The driver’s role is to drive data items to the bus following the interface protocol. The driver obtains data items from the sequencer for execution. The UVM Class Library provides the uvm_driver base class, from which all driver classes should be extended, either directly or indirectly.

Callback in system verilog or verification

Callback is mechanism of changing to behavior of a verification component such as driver or generator or monitor without actually changing to code of the component. 

Monday, May 20, 2013

Interview Questions Collection

1. What is callback ?

2. What is factory pattern ?

3. Explain the difference between data types logic and reg and wire

4. What is the need of clocking blocks ?

5. What are the ways to avoid race condition between testbench and RTL using SystemVerilog?

6. Explain Event regions in SV.

7. What are the types of coverages available in SV ?

8. What is OOPS?

9. What is inheritance and polymorphism?

10. What is the need of virtual interfaces ?

11. Explain about the virtual task and methods .

12. What is the use of the abstract class?

13. What is the difference between mailbox and queue?

14. What data structure you used to build scoreboard

15. What are the advantages of linkedlist over the queue ?

16. How parallel case and full cases problems are avoided in SV

17. What is the difference between pure function and cordinary function ?

18. What is the difference between $random and $urandom?

19. What is scope randomization

20. List the predefined randomization methods.

21. What is the dfference between always_combo and always@(*)?

22. What is the use of packagess?

23. What is the use of $cast?

24. How to call the task which is defined in parent object into derived class ?

25. What is the difference between rand and randc?

26. What is $root?

27. What is $unit?

28. What are bi-directional constraints?

29. What is solve...before constraint ?

30. Without using randomize method or rand,generate an array of unique values?

31. Explain about pass by ref and pass by value?

32. What is the difference between bit[7:0] sig_1; and byte sig_2;

33. What is the difference between program block and module ?

34. What is final block ?

35. How to implement always block logic in program block ?

36. What is the difference between fork/joins, fork/join_none fork/join_any ?

37. What is the use of modports ?

38. Write a clock generator without using always block.

39. What is forward referencing and how to avoid this problem?

40. What is circular dependency and how to avoid this problem ?

41. What is cross coverage ?

42. Describe the difference between Code Coverage and Functional Coverage Which is more important and Why we need them

43. How to kill a process in fork/join?

44. Difference between Associative array and Dynamic array ?

45. Difference b/w Procedural and Concarent Assertions?

46. What are the advantages of SystemVerilog DPI?

47. How to randomize dynamic arrays of objects?

48. What is randsequence and what is its use?

49. What is bin?

50. Why always block is not allowed in program block?

51. Which is best to use to model transaction? Struct or class ?

52. How SV is more random stable then Verilog?

53. Difference between assert and expect statements?

54. How to add a new processs with out disturbing the random number generator state ?

55. What is the need of alias in SV?

56. What is the need to implement explicitly a copy() method inside a transaction , when we can simple assign one object to other ?

57. How different is the implementation of a struct and union in SV.

58. What is "this"?

59. What is tagged union ?

60. What is "scope resolution operator"?

61. What is the difference between Verilog Parameterized Macros and SystemVerilog Parameterized Macros?

62. What is the difference between




view source

print?

1.logic data_1;

2.var logic data_2;

3.wire logic data_3j;

4.bit data_4;

5.var bit data_5;




63. What is the difference between bits and logic?

64. Write a Statemechine in SV styles.

65. What is the difference between $rose and posedge?

66. What is advantage of program block over clockcblock w.r.t race condition?

67. How to avoid the race condition between programblock ?

68. What is the difference between assumes and assert?

69. What is coverage driven verification?

70. What is layered architecture ?

71. What are the simulation phases in your verification environment?

72. How to pick a element which is in queue from random index?

73. What data structure is used to store data in your environment and why ?

74. What is casting? Explain about the various types of casting available in SV.

75. How to import all the items declared inside a package ?

76. Explain how the timescale unit and precision are taken when a module does not have any timescalerdeclaration in RTL?

77. What is streaming operator and what is its use?

78. What are void functions ?

79. How to make sure that a function argument passed has ref is not changed by the function?

80. What is the use of "extern"?

81. What is the difference between initial block and final block?

82. How to check weather a handles is holding object or not ?

83. How to disable multiple threads which are spawned by fork...join


84 Why cannot initial statement be synthesizeable ?


85 Consider a 2:1 mux; what will the output F be if the Select (sel) is "X" ?





86a What is the difference between blocking and nonblocking assignments ?


86 What is the difference between wire and reg data type ?


87 Write code for async reset D-Flip-Flop.


88 Write code for 2:1 MUX using different coding methods.


89 Write code for a parallel encoder and a priority encoder.


90 What is the difference between === and == ?


91 What is defparam used for ?


92 What is the difference between unary and logical operators ?


93 What is the difference between tasks and functions ?


94 What is the difference between transport and inertial delays ?


95 What is the difference between casex and case statements ?


96 What is the difference between $monitor and $display ?


97 What is the difference between compiled, interpreted, event based and cycle based simulators ?


98 What is code coverage and what are the different types of code coverage that one does ?


99 How will you handle multiple interfaces in UVM.


100 Explain APB and AHB using state machine


101 Explain Polymorphism and Inheritance using examples.


102When to use blocking and when to use non-blocking assignments.


103How do you control sequences in UVM {through testcase}.






1. Explain NAND flash operation


2. Diff btwn task & function


3. Types of arrays.


4. Advantage of dynamic array over associative array


5. Can you declare everything as associative array?


6. Explain packed and un packed array


7. Types of sequences


8. Explain ahb signals


9. Explain in details split and retry in hresp


10. Diff btwn @posedge and $rose


11. Uvm how driver and sequencer interact


12. How data passes from layer to layer in uvm


13. Diff btwn reg n wire


14. Diff between blocking n non blocking


15. Draw waveform for the code


Module ex;


Input [2:0] a;


Begin


a<= 3’b000;


a<=#5 3’b010;


a = #10 3’b101;


a<= #20 3’b111;


end


endmodule


16. How do you pass an array to a function.


17. About PREADY signal: is there a PREADY input to the slave


18. Without constraint, how will u generate random number between the range ‘x’ and ‘y’.


19. How to reduce the number of clock cycles taken for a transfer in APB/AHB protocol.. Eg: suppose a transfer takes 4 clock cycles, how can we make it in 3.


20. What does an ISR do. Suppose you have to write an isr, what all things you will write in that handler.


21. SIMULATOR related: when we compile any code, we give a filelist and the compiler compiles all the files in the list. Suppose some of the files is calling another file(`include option), then how will we compile that included file/directory


22. Basic verification approach: how will you verify an IP, in an SOC environment… how will you build the VC(approach).


23. Why sv over Verilog( explain properties of oops)


24. What is inheritance and polymorphism explain with example


25. Why/explain casting is used in terms of class and handles


26. Data types in sv


27. Randomization?


28. Cyclc randomization


29. How probability distribution is achived


Ex. 50% of time a =0


25% of time a = ( 1 - 1000)


25% of time a = (1001 – 2^32 - 1) how do you achieve this


30. Explain wait, randcase


31. Explain semaphore and mailboxes?


32. Mailboxes how does it work


33. Diff btwn mailbox and Que


34. Explain addr phase and data phase in AHB


35. Explain uvm flow


36. As soon as you get the spec how do you start verification


37. Why phases are required









Interview Question related to Mux, gates

1. EX-NOR gate using 2:1 mux 

In a 2:1 Mux ,

Give 2nd input as A and 1st input as A bar .
and give B as a Select line...

final output y = Output of EXNOR 


//add your inputs/questions/articles/solutions in the comment section.
Thank you !

Ethernet and more

Ethernet is a protocol under IEEE 802.33 standard User Datagram Protocol (UDP) UDP is a connectionless transport protocol. I...