Verilog 7 Logic Synthecdgz
Verilog 7 Logic Synthecdgz
Design
ספרתיVLSI מבוא לתכנון
1 09/03/07
Objectives
Verilog and VHDL are the two most popular HDLs used to
describe the functionality at the RTL level
There are restrictions on the way these constructs are used for the
logic synthesis tool. For example:
The while and forever loops must be broken by a @(posedge clock) or
@(negedge clock) statement to enforce cycle-by-cycle behavior and to
prevent combinational feedback
Logic synthesis ignores all timing delays specified by #<delay>
construct. Therefore, pre- and post-synthesis Verilog simulation results
may not match. The designer must use a description style that
eliminates these mismatches
The initial construct is not supported by logic synthesis tools. Instead,
the designer must use a reset mechanism to initialize the signals in the
circuit
…
7 Introduction to Digital VLSI 09/03/07
Gil Rahav
Freescale Semiconductor Israel
Verilog HDL Synthesis: Timing Delays
Only operators such as “===“ and “!==“ that are related to “x” and
“z” are not allowed (equality with “x” and “z” does not have much
meaning in logic synthesis)
ADR_BLK
While writing the RTL, the designer has to decide if to keep the
hierarchy of the design or to write a flat code
Flattened synthesis optimization
Can take longer to execute
Saves from calculating timing budgets between blocks (uses
synthesis tools’ strengths in optimizing for timing)
output
a[3:0] b[3:0]
a[3:0] b[3:0]
Add Shift-left
4-bit ALU
flags control flags
control Subtract Shift-right
output
output
Merge glue logic into the related combinational logic description of the
lower-level architectural statements
Related combinational logic is grouped into the same block that contains
the destination register for the combinational logic path
Allows improved sequential mapping during optimization (no hierarchical
boundaries between combinational and sequential logic)
Simplifies the description of the timing interface
Critical Critical
Reg Path
Reg
Path
No No
Critical Reg Critical Reg
Path Path
4
A module mux (A, B, C, D, OUT, SEL);
input [3:0] A, B, C, D;
B 4 input [1:0] SEL;
OUT output [3:0] OUT;
C
reg [3:0] OUT;
D
always @(SEL or A or B or C or D)
2
case(SEL)
2’b00: OUT = A;
SEL 2’b01: OUT = B;
2’b10: OUT = C;
If you desire combinational logic, 2’b11: OUT = D;
specify all branches of a case default: OUT = 4’bx;
endcase
statement, including the default
branch endmodule
If the assignments are not complete
in all brunches of the decision, the
synthesizer adds latches to maintain
the state of the circuit
30 Introduction to Digital VLSI 09/03/07
Gil Rahav
Freescale Semiconductor Israel
Functions in Synthesis
An always block, without all its module dffn (q, data, clk);
conditions specified, leads to a latch input data, clk;
output q;
In the example below, is a false case, reg q;
the value of data must be held and always @( negedge clk)
the synthesizer must use a storage q <= data;
element. endmodule
endmodule
inputs R outputs
Combinational
E
Logic
G
If the sampling and assignment of the reg does not cross clock
boundaries then the reg may be optimized away
You can model reset for any type of edge or level sensitive
storage device
Flip-flop Latch
module dffsetclr (q, clk, reset, d); module latch (q, enable, set, clr, d);
input clk, d, reset; input enable, d, set, clr;
output q; output q;
reg q; reg q;
always @(posedge clk or posedge always @(enable or set or clr or d)
reset) begin
begin if (set)
if (reset) q <= 1;
q <= 0; else if (clr)
else q <= 0;
q <= d; else if (enable)
end q <= d;
end
endmodule endmodule
b c b d c d
always @(a or b or c or d) b a
if (a) temp = a ? c :
out = b + c; d;
a
else out = b + temp;
out = b + d;
out out
All FSMs must have a reset, and their state changes must be
synchronous to one edge of a single clock
48 Introduction to Digital VLSI 09/03/07
Gil Rahav
Freescale Semiconductor Israel
Finite State Machine: Implicit vs. Explicit FSMs
Implicit FSMs:
state A
Do not need a state register
Handle only linear state changes well
Each state is separated by clock state B1 state B2
boundaries
Are not handled by most synthesis state C
tools
state D
state 1
Explicit FSMs:
Are clearer and more well-defined
state 2
Can handle default conditions
Handle complex (nonlinear) state
state 3
changes
You specify a state variable that define
state 4
the state of the state machine
module imp (out, datain, clk, rst); From each always block that
output out; models sequential logic, synthesis
input clk, datain, rst; extracts a single FSM
reg out;
always @(posedge clk or posedge rst) If the always block has only one
if (rst) out <= 1’b0; // asynchronous clock cycle (a degenerate FSM), it
// reset
is implemented with combinational
else
begin logic plus a register
if (!out) // state out == 0 Registers are created whenever
begin
if (datain) out <= 1’b0;
data is written in one clock cycle
else out <= 1’b1; and read in another clock cycle for
end the stored variables
else // state out == 1
out <= 1’b0; If the FSM has more than one
end cycle, the synthesis tool
endmodule datain = 0 generates control logic,
including a state variable, and
0 1
datain = 1
adds registers for the stored
variables
50 Introduction to Digital VLSI 09/03/07
Gil Rahav
Freescale Semiconductor Israel
Explicit Style of FSM
Computer aided logic synthesis tools have greatly reduced the design
cycle time and improved productivity. They allow designers to write
technology-independent, high-level descriptions and produce technology-
dependent, optimized, gate-level netlists. Both combinational and
sequential RTL descriptions can be synthesized