RTL Design Guidelines: Udit Kumar, PHD, Iit Delhi. 15+ Years Experience, Author
RTL Design Guidelines: Udit Kumar, PHD, Iit Delhi. 15+ Years Experience, Author
Website: https://www.sites.google.com/view/learnvlsi
LinkedIn: https://www.linkedin.com/company/learnvlsi
Note: Views expressed here are personal views and not endorsed by present or past employer.
Disclaimer
⚫ The intention of this presentation is information sharing.
So consider this material as information purpose only.
⚫ We explicitly disclaim any liability for mistakes and omissions
in the material presented.
⚫ We have done our best to ensure the correctness of the
material and have no obligation or duty to any person or
organization for any loss or damages stemming from the
contents.
⚫ We make no claim, promises, or guarantees regarding the
correctness, completeness, patent infringement, or sufficiency
of the same.
⚫ Take prior approval for Commercial usage of this information.
Outline
⚫ Need for Design Guidelines?
⚫ Guidelines for
Naming
Reset and Clocks
Best coding practices
Coding style to avoid unwanted Latches
Multiple always blocks VS FSM
⚫ Generic FSM Design
⚫ Block/Interface integration and organization
⚫ Rules to avoid Simulation shoot-through
Importance of Design Guidelines
⚫ Faster design development
⚫ Less bugs
⚫ Optimized design
⚫ Helps in debugging
⚫ Helps in understanding the
code by other person.
clk clk
Clock Dividers and Soft reset
soft_reset
soft_reset
rst_n
clk
http://www.sunburst-design.com/papers/CummingsSNUG2003Boston_Resets.pdf
Clock
⚫ Use one edge of the clock in the whole design.
⚫ Avoid combination logic on the clock path.
⚫ Avoid convergence and divergence in the clock path clock
must be last element if there are convergence.
⚫ Only use specially designed module in the clock path. e.g. Mux
in the clock path must be glitch free mux.
⚫ Keep clock generation or reset generation in one module in
whole design.
Register Initialization
module flop (clk, din, dout) ; module flop (clk, din, dout) ; module flop (clk, din, rst_n, dout) ;
input clk; input clk; input clk, rst_n;
input din; input din; input din;
output dout; output dout; output dout;
always @ (posedge clk) begin initial begin always @ (posedge clk or negedge
dout <= din; dout=1’b0; rst_n) begin
end end if (!rst_n) begin
endmodule dout <= 1’b0;
always @ (posedge clk) begin end else begin
dout <= din; dout <= din;
end end
endmodule end
endmodule
rst_n
Mismatch between
simulation and synthesis Expected: Post Synthesis
Blocking Vs non blocking usage
// Implement a functionality of mux
module #(parameter WIDTH=8) mux
(D0, D1, sel, dout) ;
⚫ Use blocking assignment for
input sel;
input [WIDTH-1:0] D0, D1; combinational logic.
output [WIDTH-1:0] dout;
⚫ Use non-blocking assignment
always @ ( D0 or D1 or sel) begin
if (sel) for sequential logic.
dout = D0;
else
end
dout = D1; ⚫ Do not use non-blocking
Blocking
endmodule assignment for signal being
used further as clock.
// Implement a functionality of D flip flop Issue explained later in the
module #(parameter WIDTH=8) flop
(clk, din, dout) ; slides.
input clk;
input [WIDTH-1:0] din;
output [WIDTH-1:0] dout;
module flop (in1, in2, in3, sel, dout) ; module flop (in1, in2, in3, sel, dout) ; module flop (clk, sel, din, dout) ;
input in1, in2, in3, sel; input in1, in2, in3, sel; input clk, sel, din;
output dout; output dout; output dout;
reg dout; reg dout;
reg dout;
always @ (in1 or in2 or sel) always @ (in1 or in2 or sel)
if (sel) dout = in2; always @ (posedge clk) begin
dout = in1; if (sel) if (sel) begin
end dout = in1; dout <= din;
endmodule end end
endmodule
end
endmodule
Miscellaneous
⚫ Avoid Combinational Output
⚫ Avoid overflow/underflow in addition/subtraction.
⚫ Variable assignment/comparison must be done to variable of
same width.
⚫ Do no use full case and parallel case synthesis directive to
avoid simulation and synthesis mismatch.
⚫ Do not use case equality (===) or case inequality (!==), not
synthesizable.
⚫ There should be no gate or behavioral code instantiated at
the chip top level or core top level
⚫ Do not instantiate gate/cells in the RTL code.
Multiple always block Vs FSM
⚫ In each file, do not have large number of always blocks.
⚫ Many times, We tend to write sequence of activities as part of
different always blocks, that create difficulty in code
understanding, especially by others.
SETUP/
SETUP/ HOLD
HOLD
C1 C2
⚫ Within each domain, setup & hold time checks ensure proper
functioning of the design.
⚫ No timing check exists on CDC Paths.
Clock crossing: Minimum Solution
⚫ A synchronizer is a device that samples the asynchronous
signal and output a signal that is synchronized to a destination
clock domain.
Asynchronous signal synchronizer
AW AS
AW
C1
Clk
Synchronized signal
Clk
AW
AS
Assignment:
How to calculate number of Synchronizer flop for given frequency.
Use System Verilog Features: struct, interface
⚫ To share multiple related signals between the blocks, use struct or interfaces.
⚫ This can also be helpful when your signal list is changing over time, individual
signal taking will be an effort, whereas this can be simplified by adding one extra
element into the struct.
Block 2
Sub block
Block 1
<struct>.<reg_name>
TX
Configuration registers
RX
<struct>.<err_name>
What is Shoot-thru?
⚫ When any signal jumps over an extra register within one
clock cycle.
E.g. Input “din” crosses 2 register within one clock cycle.
dint
din dout
D D
Shoot-thru:
(events in data path ) <= (events in clock path)
How Simulation Shoot-thru occurs?
dint dout
din
D D
Reason : Extra Delta
delay in Clock Path
clk cint
dout 0>1
clk
cint
din
dint Consequence : dout
same as din within
dout single clock
Will Verilog coding rules help?
25
Verilog VHDL
dint<= din after 1
dint <= #1 din ;
ns;
dint
dout
din
D D
clk cint
clk cint
Next webinars:
Low Power RTL Design (Tentative: 26th March 2022)
For more updates, follow Learn VLSI LinkedIn Page :
https://www.linkedin.com/company/learnvlsi