Verilog Interview Questions Part 1
Verilog Interview Questions Part 1
Verilog Interview Questions Part 1
1) Write a verilog code to swap contents of two registers with and without a temporary register?
With temp reg ;
always @ (posedge clock)
begin
temp=b;
b=a;
a=temp;
end
Without temp reg;
always @ (posedge clock)
begin
a <= b;
b <= a;
end
Click to view more
2) Difference between blocking and non-blocking?(Verilog interview questions that is most commonly
asked)
The Verilog language has two forms of the procedural assignment statement: blocking and non-blocking.
The two are distinguished by the = and <= assignment operators. The blocking assignment statement (=
operator) acts much like in traditional programming languages. The whole statement is done before control
passes on to the next statement. The non-blocking (<= operator) evaluates all the right-hand sides for the
current time unit and assigns the left-hand sides at the end of the time unit. For example, the following
Verilog program
// testing blocking and non-blocking assignment
module blocking;
reg [0:7] A, B;
initial begin: init1
A = 3;
#1 A = A + 1; // blocking procedural assignment
B = A + 1;
$display("Blocking: A= %b B= %b", A, B ); A = 3;
#1 A <= A + 1; // non-blocking procedural assignment
B <= A + 1;
#1 $display("Non-blocking: A= %b B= %b", A, B );
end
endmodule
produces the following output:
Blocking: A= 00000100 B= 00000101
Non-blocking: A= 00000100 B= 00000100
The effect is for all the non-blocking assignments to use the old values of the variables at the beginning of
the current time unit and to assign the registers new values at the end of the current time unit. This reflects
how register transfers occur in some hardware systems.
blocking procedural assignment is used for combinational logic and non-blocking procedural assignment
for sequential
Click to view more
towards modeling hardware structure as opposed to abstract hardware modeling. Unlike VHDL, all data
types used in a Verilog model are defined by the Verilog language and not by the user. There are net data
types, for example wire, and a register data type called reg. A model with a signal whose type is one of the
net data types has a corresponding electrical wire in the implied modeled circuit. Objects, that is signals, of
type reg hold their value over simulation delta cycles and should not be confused with the modeling of a
hardware register. Verilog may be preferred because of it's simplicity.
Design reusability
VHDL. Procedures and functions may be placed in a package so that they are avail able to any design-unit
that wishes to use them.
Verilog. There is no concept of packages in Verilog. Functions and procedures used within a model must
be defined in the module. To make functions and procedures generally accessible from different module
statements the functions and procedures must be placed in a separate system file and included using the
`include compiler directive.
15) What are different styles of Verilog coding I mean gate-level,continuous level and others explain
in detail?
16) Can you tell me some of system tasks and their purpose?
$display, $displayb, $displayh, $displayo, $write, $writeb, $writeh, $writeo.
The most useful of these is $display.This can be used for displaying strings, expression or values of
variables.
Here are some examples of usage.
$display("Hello oni");
--- output: Hello oni
$display($time) // current simulation time.
--- output: 460
counter = 4'b10;
$display(" The count is %b", counter);
--- output: The count is 0010
$reset resets the simulation back to time 0; $stop halts the simulator and puts it in interactive mode where
the
user can enter commands; $finish exits the simulator back to the operating system
17) Can you list out some of enhancements in Verilog 2001?
In earlier version of Verilog ,we use 'or' to specify more than one element in sensitivity list . In Verilog
2001, we can use comma as shown in the example below.
// Verilog 2k example for usage of comma
always @ (i1,i2,i3,i4)
Verilog 2001 allows us to use star in sensitive list instead of listing all the variables in RHS of combo
logics . This removes typo mistakes and thus avoids simulation and synthesis mismatches,
Verilog 2001 allows port direction and data type in the port list of modules as shown in the example below
module memory (
input r,
input wr,
input [7:0] data_in,
input [3:0] addr,
output [7:0] data_out
);
18)Write a Verilog code for synchronous and asynchronous reset?
Synchronous reset, synchronous means clock dependent so reset must not be present in sensitivity disk eg:
file:///C|/Users/sumit/Desktop/verilog_interview_questions%20part%201.htm (6 of 7)2/18/2011 10:59:35 AM
Verilog FAQ
Synthesis FAQ
Digital FAQ
Timing FAQ
ASIC FAQ
Cmos FAQ
Misc FAQ
Home