請參考http://www.sunburst-design.com/papers/CummingsSNUG1999Boston_FullParallelCase.pdf
有詳細的說明
下面是我大概整理的簡述
"full" case statement
full_case indicates that all user-desired cases have been specified
Do not use default for one-hot encoding
// this is one fsm in SEL
always @(SEL or A or B or C) begin
case (SEL) //synopsys full_case
3’b001 : OUT <= A;
3’b010 : OUT <= B;
3’b100 : OUT <= C;
endcase
end
如果不用full_case去指定合成
會產生一個多餘的暫存器
請看文件第七頁
但是會有警告出現
因為有些case不能被cover到
但誤用時,如已經是full case
還用指定合成
反而會多出更多的latch
參考page14
Parallel case statement
parallel case一定要用在one-hot state上
其原因在parallel_case這個語法
強迫合成器去將case合成為mux形式
這樣每一個狀態輸入到輸出
為真正的平行
而不是if-else形態
也是因為如此
所以狀態如果可能重複
則可能會有錯誤的情形產生
此處可參考page 11
module intctl2a (int2, int1, int0, irq);
output int2, int1, int0;
input [2:0] irq;
reg int2, int1, int0;
always @(irq) begin
{int2, int1, int0} = 3'b0;
casez (irq)
3'b1??: int2 = 1'b1;
3'b01?: int1 = 1'b1;
3'b001: int0 = 1'b1;
endcase
end
endmodule
Non-parallel case statement with "parallel_case" directive
因為它不是one-hot
module intctl1b (int2, int1, int0, irq);
output int2, int1, int0;
input [2:0] irq;
reg int2, int1, int0;
always @(irq) begin
{int2, int1, int0} = 3'b0;
casez (irq) // synopsys parallel_case
3'b1??: int2 = 1'b1;
3'b?1?: int1 = 1'b1;
3'b??1: int0 = 1'b1;
endcase
end
endmodule
上面這個case為誤用
因為不是one-hot形態
合成時會出現警告
可能會有OVERLAP的情況產生
PRE/POST-SIM在此要注意啦
最後還是建議
有用到case就將所有可能的狀態都給它寫完吧
這樣就不需要用到full_case
如果很需要合成為mux形態
可以的話還是自己把code寫成mux吧
不然要將state改成one-hot
再用parallel_case來強迫合成
就要好好的看看warning 信號
這樣所花的時間精力不會比較省的
如果是別人寫的code
而且又強迫使用parallel_case
那麼pattern就要注意
如果遇到overlap的情形時
是否會有錯誤的輸出囉
test team 的人在此要注意啦
沒有留言:
張貼留言