always
區塊和always @*
區塊之間是否有區別?Verilog:「always」和「always @ *」之間的區別
3
A
回答
3
always @*
是always
塊的一種類型。它用於推斷組合邏輯。
always @(posedge clock)
用於推斷時序邏輯。
有關更多詳細信息,請參閱IEEE標準(例如1800-2009)。
0
他們不一樣!我曾經認爲他們是一樣的。但事實並非如此。
總是@(*)意味着任何東西,編譯器會自動填充它。如果是組合邏輯,請使用它!所以你不會忘記任何東西,並使功能失效。
總是意味着這句話總是會被執行!如果沒有延遲,系統暫停並且當你模擬時沒有結果!很煩人。
例如,在FSM的下一個狀態邏輯部分中:如果始終使用而不是總是@(*),則不起作用。
以下是我寫的一個簡單的序列檢測器,其中這兩個不同。如果需要,你可以編寫一個tb來運行它。
`時間刻度爲1ns/10馬力
模塊seq_detect3(//檢測序列10110 中,//序列輸入 CLK,時鐘//正邊沿觸發 RST,//復位,高電平有效的同步 匹配//匹配,匹配的「1」 );
input in, clk, rst;
output match;
wire in, clk, rst;
reg match;
reg [5:0] state, next_state;
parameter IDLE = 6'b000001; //no bit matched
parameter STATE1 = 6'b000010; //first 1 bit matched
parameter STATE2 = 6'b000100; //first 2 bits matched
parameter STATE3 = 6'b001000; //first 3 bits matched
parameter STATE4 = 6'b010000; //first 4 bits matched
parameter STATE5 = 6'b100000; //all 5 bits matched
//-----------S.M. & O.F.L.-----------
always @ (posedge clk) begin
if(rst) begin
state <= IDLE;
match <= #1 0;
end
else begin
state <= next_state;
if(state == STATE5) begin
match <= #1 1;
end
else begin
match <= #1 0;
end
end
end
//-----------next state logic-----------
always @(*) begin //Can not replaced by always here!!
case(state)
IDLE: if(in) next_state = STATE1; //0 keep, 1 next
else next_state = IDLE;
STATE1: if(in) next_state = STATE1; //0 next, 1 keep
else next_state = STATE2;
STATE2: if(in) next_state = STATE3; //0 idle, 1 next
else next_state = IDLE;
STATE3: if(in) next_state = STATE4; //0 s2, 1 next
else next_state = STATE2;
STATE4: if(in) next_state = STATE1; //0 next, 1 s1
else next_state = STATE5;
STATE5: if(in) next_state = STATE3; //0 idle, 1 s3
else next_state = IDLE;
default: next_state = IDLE;
endcase
end
endmodule
相關問題
- 1. Verilog在Always塊中遞歸
- 2. php isUserExist always always
- 3. MKStoreKit -isSubscriptionActive always always False
- 4. always_comb和always @(*)
- 5. visual basic make key always always
- 6. 如何將「Always Always」值添加到CommaDelimitedList
- 7. OnBind()on service always always returns False - Android
- 8. Azure WebSite Always On
- 9. Couchbase rereduce always false
- 10. Cache.Get always returns null
- 11. max_execution_time always 300
- 12. _REQUIREDNAME always nil
- 13. stringFromDate always Nil
- 14. placeholder visible always false
- 15. Sparkle Always Up Date
- 16. DropDownList SelectedIndex always = 1
- 17. tf.train.get_checkpoint_state always None
- 18. IF Statement Always True
- 19. WebAPI [FromBody] always null
- 20. activemq brokerName always localhost?
- 21. cursor.getCount always = 0
- 22. slider AutoToolTip always on
- 23. carrierwave content_type always nil
- 24. SerialPort.Read()always TimeoutException
- 25. browser position.address.postalCode always null
- 26. angularjs routing:param always undefined
- 27. page.Isvalid always return false?
- 28. UITextField always resignFirstResponder
- 29. CGImageSourceCreateWithURL return always nil
- 30. Ajax readyState always 1