K
Kevin Neilson
Guest
I'm designing another FSM and I've run into the problem I always have
when trying to pipeline them for high-speed designs. I'll show a simple
example.
STATE2: begin
if (condition)
begin
state <= STATE3;
y <= a*b+c;
end
end
The problem occurs if I need to add pipelining to meet speed
requirements: in this case, the multiplier inputs, output, and adder
output must be registered. So I have to end up doing this in the FSM:
STATE2: begin
if (condition)
begin
state <= STATE3;
a_pipe <= a;
b_pipe <= b;
end
end
and outside the FSM I have to have concurrent FSMs or other logic:
always@(posedge clk)
begin
m <= a_pipe * b_pipe;
p <= m + c;
y <= p;
end
The whole simplicity of the FSM is destroyed. Debugging and maintaining
it becomes very difficult. The output y isn't available for three
cycles, so I have to figure out what states the FSM might be in at that
point and ensure that I don't use y before it's ready. Using any sort
of FSM editor (like those bubble diagram schematic editors) is
completely precluded. A similar problem crops up when 'condition' is a
complex equation and has to be pipelined into the past. A common
example if 'condition' has a comparison that doesn't meet timing:
if (stuff && wide_counter==32'b3) ...
If this doesn't meet timing, I can instead pipeline the condition
outside the FSM:
wide_counter_eq_3 <= wide_counter==32'b2; // will be 3 on next cycle
and then inside the FSM:
if (stuff && wide_counter_eq_3) ...
but this can get messy and get screwed up if the counter doesn't always
increment from 2 to 3.
My question: what is the cleanest way to describe an FSM requiring
pipelining? Is there some sort of tool that will let me make a nice
bubble diagram but also indicate which operations need pipelined and
will then generate the proper synthesizable HDL?
-Kevin
when trying to pipeline them for high-speed designs. I'll show a simple
example.
STATE2: begin
if (condition)
begin
state <= STATE3;
y <= a*b+c;
end
end
The problem occurs if I need to add pipelining to meet speed
requirements: in this case, the multiplier inputs, output, and adder
output must be registered. So I have to end up doing this in the FSM:
STATE2: begin
if (condition)
begin
state <= STATE3;
a_pipe <= a;
b_pipe <= b;
end
end
and outside the FSM I have to have concurrent FSMs or other logic:
always@(posedge clk)
begin
m <= a_pipe * b_pipe;
p <= m + c;
y <= p;
end
The whole simplicity of the FSM is destroyed. Debugging and maintaining
it becomes very difficult. The output y isn't available for three
cycles, so I have to figure out what states the FSM might be in at that
point and ensure that I don't use y before it's ready. Using any sort
of FSM editor (like those bubble diagram schematic editors) is
completely precluded. A similar problem crops up when 'condition' is a
complex equation and has to be pipelined into the past. A common
example if 'condition' has a comparison that doesn't meet timing:
if (stuff && wide_counter==32'b3) ...
If this doesn't meet timing, I can instead pipeline the condition
outside the FSM:
wide_counter_eq_3 <= wide_counter==32'b2; // will be 3 on next cycle
and then inside the FSM:
if (stuff && wide_counter_eq_3) ...
but this can get messy and get screwed up if the counter doesn't always
increment from 2 to 3.
My question: what is the cleanest way to describe an FSM requiring
pipelining? Is there some sort of tool that will let me make a nice
bubble diagram but also indicate which operations need pipelined and
will then generate the proper synthesizable HDL?
-Kevin