HDL and FPGA Ch05 HVT 2024 RTL Combinational Circuits
HDL and FPGA Ch05 HVT 2024 RTL Combinational Circuits
Jun 2023
Introduction
• We examine HDL design of intermediate-size components: adder,
comparator, multiplexer, etc.
• We discuss more sophisticated Verilog operators, the always
block, and routing constructs, and then demonstrate the RTL
combinational circuit design
Contents
• Verilog Operators
• Always Block for a combinational circuit
• If Statement
• Case Statement
• Routing Structure of Conditional Control
Constructs
• General Coding Guidelines for an Always Block
• Parameter and Constant
• Design Examples
Verilog Operators
Verilog Operators
Notes on Verilog operators
Notes on Verilog operators
Notes on Verilog operators
Notes on Verilog operators
Notes on Verilog operators
Procedural statements
• For system modeling, Verilog contains procedural statements, which are
executed in sequence. These statements are encapsulated inside an always
block or initial block.
• The initial block is executed once when the simulation is started. It can
be used in simulation (testbench)
• Only the always block can be synthesized. Abstract procedural statement
→ known as behavioral description
• An always block can be thought of as a black box whose behavior is
described by the internal procedural statements.
• Procedural statements include a rich variety of constructs but many of
them don't have clear hardware counterparts. A poorly coded always
block frequently leads to unnecessarily complex implementation or
cannot be synthesized at all.
Procedural statements
• Three types of statements are discussed in this
section:
– Blocking procedural assignment
– If statement
– Case statement
always block
Blocking & Non-Blocking Assignments
Variable data types
Example 1
• 1-bit comparator
Example 2
Incorrect description
if statement
Example 3. Priority Encoder
Example 4. Binary Decoder
case statement
A case statement is a multiway
decision statement that compares the
[case-expr] expression with a number
of [item] expressions. The execution
jumps to the branch whose [item]
matches the current value of [case-
expr].
The conditional operator (?:) is like a simplified if-else statement and infers similar priority routing networks.
The number of cascading stages increases proportionally to the number of if-else clauses. A large number
of if-else clauses will lead to a long cascading chain and introduce a large propagation delay.
Multiplexing network
Coding guidelines for always block
• Verilog is for both modeling and synthesis.
• While writing code for synthesis, we need to be aware
of how the various language constructs are mapped to
hardware.
• This is especially true for an always block since variables
and procedural statements can be used within the block.
• We should remember that the purpose of the code is to
infer hardware rather than describing a sequential
algorithm in C.
• Failing to do so frequently leads to unsynthesizable
codes, unnecessarily complex implementation, or
discrepancy between simulation and synthesis.
• In this section, we review some common errors and
suggest a collection of coding guidelines.
Common errors in combinational circuit codes
1. Variable assigned in multiple always blocks
2. Incomplete sensitivity list
3. Incomplete branch and incomplete output
assignment
Variable assigned in multiple always blocks
Incomplete sensitivity list