CODING Stle For Synth
CODING Stle For Synth
CODING Stle For Synth
en
Priority encoded Multiplexer using if-else if
statement
Depending on the choice of “select” inputs, if - else if can be effectively used to
model priority encoded “cascading” multiplexers.
d 0
c 1
0
en[0]
b 1
0
en[1] out
a 1
en[2]
Synthesis of Case statements
x[1] sample[1]
y[3]
sample[2]
x[2]
y[2]
sample[3]
x[3]
y[1]
sample[4]
x[4]
y[0]
Synthesis of For loops
integer k;
for ( k = 0; k <= 7; k = k + 1)
{ c_temp, sum[k] } = a_in[k] + b_in[k] + c_in;
c_out = c_in;
end
a
b
c d_out
d_out
b
en
General coding guidelines for
efficient synthesis
General coding guidelines for efficient synthesis
Do not mix positive and negative edge triggered flip-flops in the same
design
a b c d
F = a + b + c + d;
would typically be
implemented as:
(a + b) is grouped together
by default,
then c and d are added one
at a time.
z
Use of Parentheses
F = (a + b) + (c + d);
would typically be implemented a b c d
as:
end
Order dependency Non blocking Vs.
blocking
• In the sample code shown, the order of the non-blocking
assignments have been changed.
• But an identical logic will be generated by the synthesis tool.
end
Order dependency Non blocking Vs.
blocking
•Blocking assignment example
CK
Order dependency
Non blocking Vs. blocking
•A blocking assignment with order changed
end
Non blocking Vs. blocking assignments with
multiple drivers
reg d_out ;
en
reg data_out ;
always @(d_in or en or set or reset)
if (set) d_in d_out
d_out = 1’b1 ; Latch
else if (reset)
d_out = 1’b0 ;
else if (en)
d_out = d_in;
en
reg d_out ;
always @ (posedge clk) Edge
d_out = d_in; d_in sensitive d_out
Flip-flop
reset set
reg d_out ;
always @(posedge clk or
posedge set or posedge reset)
Edge
if (set) d_in sensitive d_out
d_out = 1’b1 ;
else if (reset) Flip-flop
d_out = 1’b0 ; clk
else
d_out = data_in;
en
Edge sensitive D-Flip flop with
Asynchronous Set and Reset -Hardware
Edge sensitive D-Flip flop with
Asynchronous Set and Reset
For asynchronous set and reset, both the set and reset variables must be in
the sensitivity list.
Asynchronous assignments can be done using else if clauses and they should
occur first based on priority.
Synchronous assignments should come last one in the if clause.
The asynchronous clauses result in combinational logic that drives the set
and reset inputs of the flip-flops.
General limitations of D-Flip flop inference
• Logic which do not affect the outputs of the FSM should not
Reference