Re: [問題] VERILOG 時脈問題

看板Electronics作者 (...)時間15年前 (2010/08/16 11:52), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串3/3 (看更多)
※ 引述《zx33571163 (mm)》之銘言: : always@(posedge clk or negedge reset ) : begin : if(!reset) : begin : count=0; : end : else : begin : count1<=0; : buffer<=bufin; : count <=count+1; : begin : if(count==n) : begin : 判斷<=1; : end : end : end : end : end : always@(posedge clk ) : begin : if(判斷==0) : begin : bufout<= 1'bz; : end : else if(判斷==1) : begin : count <=0; : bufout<= buffer; : count1<=count1+1; : begin : if(count1==n) : 判斷<=0; : end : end : end : endmodule : 我這樣寫 : 實際的輸出結果會比我想要的輸出 "慢1個CLOCK" : 請問是哪出問題? : 也就是判斷==1 但bufout晚1個CLOCK出來 把你的code看過一下 大概覺得你的function應該是下面我打的那樣吧 一種output是flip-flop 所以在output讀到input值的時候 會在下一個clk出現 另一種不是flip-flop的就單純接一個MUX 直接讀input值 同時出現在ouput 因為verilog和C語言很不一樣 你每個code寫出來就是硬體的一部份 所以建議要寫verilog 先把電路架構都想一下 再寫會比較好 還有combinational和sequential最好要分開寫 不要混在一起@@ 1.output 為flip-flop always@(count or bufin) //combinational begin if(count==4'd9) begin count_tmp=0; bufout_tmp=bufin; end else begin count_tmp=count+1; bufout_tmp=1b'z; end end always@(posedge clk or negedge rst_n) //sequential begin if(~rst_n) begin count<=0; bufout<=0; end else begin count<=count_tmp; bufout<=bufout_tmp; end end 2.output 接MUX always@(count or bufin) //com begin if(count==4'd9) begin count_tmp=0; bufout=bufin; end else begin count_tmp=count+1; bufout=1'dz; end end always@(posedge clk or negedge rst_n) //seq begin if(~rst_n) count<=0; else count<=count_tmp; end -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.115.116.88

08/16 11:57, , 1F
combinational裡面的count==4'd9可以改到自己想要的值出現
08/16 11:57, 1F

08/16 12:44, , 2F
印象中1'bz沒有辦法合成, 應該隨便給個0或1吧
08/16 12:44, 2F
文章代碼(AID): #1CQBO66p (Electronics)
文章代碼(AID): #1CQBO66p (Electronics)