作者horsehead ( NNNN)
看板Electronics
標題Re: [請益] verilog如何在一個always判斷觸發源?
時間Wed Nov 4 23:03:12 2009
※ 引述《Darrens (小胖子)》之銘言:
: 謝謝各位的回答
: 我是使用Quartus II還有Max plus II兩個軟體來模擬
: 程式如下
: module counter(CLK, reset, count);
: input CLK, reset;
: output [6:0] count;
: reg [6:0] count;
: always@(reset or CLK)
: begin
: if(reset==1)
: begin
: count=0;
: end
: else if(CLK==0)
: begin
: count=count+1;
: end
: end
: endmodule
: 但跑出來count的值卻不正確
: 不會像一般那樣,一直加1
: 我有用另一套軟體模擬卻是正確的
: 但我程式最後還是要燒到fpga裡
: 卻連maxplus2的模擬都過不了
: 想請問一下
: 這到底是什麼問題啊??
: 我實在是找不到問題所在= =
: 有沒有人可以好心幫幫我…
: 非常感謝~~
always@(negedge CLK or posedge reset)
if(reset==1)
count=0;
else
count=count+1;
你要這樣寫 不然以你的寫法 當然會出問題
你的設計中沒有clk關鍵字 你的counter 會有race condition
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.73.132
※ 編輯: horsehead 來自: 61.228.73.132 (11/04 23:03)