Dvlsi Unit-2 Notes
Dvlsi Unit-2 Notes
UNIT- 2
INTRODUCTION TO VERILOG
1 List out the important coding practices while writing synthesizable Verilog for sequential hardware.
Ans (a) Use an edge-triggered clock in the sensitivity list using the posedge or negedge keywords.
(b) Use non-blocking assignments—that is, “<=” inside always blocks although it is possible to get
sequential hardware by certain uses of the blocking “=” operator.
(c) Do not mix blocking and non-blocking statements in an always block.
(d) Do not make assignments to the same variable from more than one always block. This is not a
compile-time error and hence may go unnoticed.
(e) Avoid unwanted latches by assigning a value to combinational output signals in every possible
execution path in the always block. This can be done by
i. including else clauses for if statements,
ii. specifying all cases for case statements or have a default clause at the end, or
iii. Unconditionally assigning default values to all combinational output signals at the beginning of the
always block.
2 Write a Verilog description of the following combinational circuit using concurrent statements. Each gate
has a 5-ns delay, excluding the inverter, which has a 2-ns delay.
Ans
3 Develop behavioral model of the Mealy state machine for BCD to Excess-3 Code Converter based on its
state table. The state change occurs on the rising edge of the clock. The output is computed by a
conditional assignment statement whenever State or Z changes.
Ans
4 Write Verilog code for the following circuit using concurrent statements and always block with sequential
statements. No latches should be generated. Assume that the gate delays are negligible.
Ans
5 Write a Verilog description of the Synchronous (4-bit) up/down decade counter with output Q works as
follows: All state changes occur on the rising edge of the CLK input, except the asynchronous clear
(CLR). When CLR = 0, the counter is reset regardless of the values of the other inputs. If the LOAD input
is 0, the data input D is loaded into the counter. If LOAD = ENT = ENP = UP = 1, the counter is
incremented. If LOAD = ENT = ENP = 1 and UP = 0, the counter is decremented. If ENT = UP = 1, the carry
output (CO) = 1 when the counter is in state 9. If ENT = 1 and UP = 0, the carry output (CO) = 1 when the
counter is in state 0.
Ans
9 Write a Verilog module that describes a 16-bit serial-in, serial-out shift register with inputs SI (serial
input), EN (enable), CK (clock, shifts on rising edge), and a serial output (SO).
Ans
10 Write a ‘conditional signal assignment’ statement, ‘if-else statement’ and ‘case statement’ to represent the
4-to-1 MUX shown subsequently. Assume that there is an inherent delay in the MUX that causes the
change in output to occur 10 ns after a change in input.
Ans
12 Write at least two different Verilog modules that are equivalent to the following pseudo code: A = B1 when
C = 1 else B2 when C = 2 else B3 when C = 3 else 0; Draw a circuit to implement the statement
Ans