Académique Documents
Professionnel Documents
Culture Documents
else if (enable)
out <= out + 1;
50. Write a code for 8 bit parity checker?
Ans : assign parity_out = ^data_in; // data_in is 8 bits
51. Write a code for 8 bit shift-left register?
Ans : always @(posedge Clock)
begin
register <= register << 1;
register[0] <= Input;
end
assign output = register[7];
52. Write a code for 8 bit Unsigned adder?
Ans : assign {Carry_Out,SUM} = input_A + input_B + Carry_In;
53. Write a code for comparator?
Ans : assign out = (in_1 >= in_2)? 1'b1:1'b0;
54. When we use FSMs?
Ans : FSMs are widely used in applications that require prescribed sequential activity.
55. Difference between `define and parameter?
Ans : Define Parameter only one constant with the same name can exist in the whole scope
multiple modules can have same parameter name cannot be overridden can be overridden
used to specify macro used to specify constants
56. What value is inferred when multiple procedural assignments made to the same reg
variable in an always block?
Ans : When there are multiple nonblocking assignments made to the same reg variable in a
sequential always block, then the last assignment is picked up for logic synthesis.
57. What are snake paths?
Ans : A snake path, as the name suggests is a path that traverses through a number of
hierarchies, and may eventually return back to the same hierarchy from which it originated.
58. What is constant propagation? How can I use constant propagation to minimize
area?
Ans : Constant propagation is a very effective technique for area minimization, since it forces
the synthesis tools to optimize the logic in both forward and backward directions. Since the
area minimization is achieved using constants, this technique is called constant propagation.
59. What happens to the bits of a reg which are declared, but not assigned or used?
Ans : When any of the bits of a reg declaration is unused, the logic corresponding to those
bits gets optimized
60. Why we use `ifdef and generate for in verilog?
Ans : Both `ifdef and generate constructs can be used for the purpose of area minimization.
61. What is the difference between using `ifdef and generate?
Ans : `ifdef generate we can use it inside the module as well as outside the module. (g)we can
only use it inside the module works on the boolean presence or absence of `define of the
`ifdef variable use the value of a variable using genvar, can be used inside loops used only in
if-else and cannot perform any looping operation the genvar variable can be used inside for
loop or case statements
62. What is retime logic between registers?
Ans : Retiming is the process of relocating registers across logic gates, without affecting the
underlying combinatorial logic structure. This process is achieved by borrowing logic from
one time frame and lending it to the other, while maintaining the design behavior.
63. Why one-hot encoding is preferred for FSMs?
Ans : Since there is one explicit FF per stage of a one-hot encoded state machine, there is no
need of output state decoding. Hence, the only anticipated delay is the clock to q delay of the
FF. This makes the one-hot encoding mechanism preferable for high-speed operation.
64. What are the main factors that affect testability of a design?
Ans : Reset of a FF driven by the output of another FF Presence of tri-state buses in the
design Presence of derived clocks in the design Presence of gated clocks in the design
Presence of latches in the design
65. What are the various methods to reduce power during RTL coding?
Ans : Reduce switching of the data input to the Flip-Flops. Reduce the clock switching of the
Flip-Flops. Have area reduction techniques within the chip, since the number of gates/FlipFlops that toggle can be reduced.
66. What is the advantage of using hierarchical names to refer to Verilog objects?
Ans : It is easy to debug the internal signals of a design, especially if they are not a part of the
top level pinout.
67. What are the disadvantages of using hierarchical name to refer to Verilog objects?
Ans : During synthesis, these hierarchical names get ungrouped or dissolved or renamed,
depending upon the synthesis strategy and switches used, and hence, will cease to exist. In
that case, special switches need to be added to the synthesis compiler commands, in order to
maintain the hierarchical naming. If the Verilog code needs to be translated into VHDL, the
hierarchical names are not translatable.
68. What is the effect of specifying delays in assignments during synthesis?
Ans : Specifying any kind of delay before an assignment, or within an assignment, in a
blocking or non-blocking procedural assignment is ignored by synthesis tools. If the
functionality depends upon the presence of the delay, then a mismatch in functional
simulation will be seen between the model and the synthesized netlist. Ex: reg1 = #3 reg2; //
#3 will be ignored #6 reg3 <= reg4; // #6 will be ignored Since the above construct is
syntactically legal, the synthesis tools will issue a WARNING and not an ERROR.
69. What is the synthesized hardware for the verilog code below?
module generator_ex1(data, select, out);
input [0:7] data;
input [0:2] select;
out out;
assign out = data [select];
endmodule
Ans: 8:1 Mux
70. What is the synthesized hardware for the verilog code below?
module generate_ex2(out,in,select);
input En;
input [0:1] select;
output [0:3] out;
assign out = En? (1 << select) : 4b0;
endmodule
Ans: 2:4 Decoder
71. How to avoid unintentional latches in the design?
Ans : Completely specify all branches for every case and if statement. Completely specify all
outputs for every case and if statement. Use synopsys full-case if all desired cases have
specified.
72. What is a "full" case statement?
Ans : A "full" case statement is a case statement in which all possible case-expression binary
patterns can be matched to a case item or to a case default. If case statement does not include
a case default and if it is possible to find a binary case expression that does not match any of
the defined case items, the case statement is not full.
by the right operand, and the vacated bits are filled with zeros. The arithmetic right shift
operator (>>>) will fill the vacated bits with 0 if the left operand is unsigned, and the most
significant bit if the left operand is signed.
84. What is the difference between the logical (==) and the case (===) equality operators?
Ans : The == are synthesizable while === operators are not synthesizable.
85. What is the difference between assign-deassign and force-release?
Ans : Force - release can be applicable to nets and variables, whereas assign - deassign is
applicable only to variables.
86. What is a critical path in a design?
Ans : There can be more than one critical path in a design. A critical path is the path through a
circuit that has the least slack. Need not necessarily the longest path in the design.
87. If there are only inputs and no output what it will be synthesized?
Ans : A module with only inputs and no outputs will synthesize into a module with no logic,
since there is nothing to be synthesized as an output.
88. what is the difference between casex and casez?
Ans : Casex treats x,z both as dont cares.
89. Write a Verilog code for ring counter?
module ring_counter(clk, initial_count, count);
input clk, initial_count;
output reg [7:0] count;
always @ (posedge clk)
begin
if (initial_count)
count = 8b00000000;
else
count = {count (6:0), count[7]};
endmodule
90. What is `timescale?
Ans : It is compiler directive which indicates the time unit to be used for delays specified in
the testbench.
91. What are different types of Verilog simulators?
Ans : Event-based Simulator:
Event base Simulation method sacrifices performance for rich functionality.
Every active signal is calculated for every device it propagates through during a clock cycle.
Full timing calculations for all devices and the full HDL standard.
Cycle Based Simulator: