看板 Electronics 關於我們 聯絡資訊
※ 引述《peter921 (PP)》之銘言: : 小弟我是最近才學到verilog..... : 現在是寫個jk counter的simulate來練習.... : 但是在sim的時候會出現個error : # ** Error: (vsim-3601) Iteration limit reached at time 0 ns. : google一下好像是有死迴圈的樣子...(是嗎?) : 可是我照著書上的格式打的說.... : 能幫找一下錯誤嗎?我找了三天了...囧 : code: : module sti_jk; : reg j,k,clk,clr; : wire q,qbar; : initial : $monitor($time, " Count Q = %b", q); <=出錯後這行會反白... : JK_flip_flop qqqq(q,,j,k,clk,clr); : initial : begin : clr=0;clk = 1'b0;j=1'b1;k=1'b1; : forever #10 clk = ~clk; : end : endmodule : jk的code@@: : module JK_flip_flop (q,qbar,j,k,clk,clr); : output q,qbar; : input j,k,clk,clr; : wire temp; : assign q = temp & ~clk & ~clr; : assign qbar =~q; : assign temp =(( j & ~q)|(~k & q)); : endmodule : 先謝謝各位板友了... 把你一開始initial的值代入 q = temp & (1'b1) & (1'b1) temp = ((1'b1 & ~q) | (1'b0 & q)) 這兩個的初始值到底是多少????? if q=0, then temp=1 => q=1 if q=1, then temp=0 => q=0 這兩個condition很明顯互相矛盾 所以simulator會一直作iteration變成infinity loop 此電路只要clk=1'b0,clr=1'b0這個condition一發生就會遇到這樣的問題 換個方法寫吧, flip-flop不是用這樣寫的 況且flip-flop看的是trigger, 這樣寫會變成latch ※ 編輯: SILee 來自: 61.59.105.115 (10/29 08:32)
peter921:謝了...我會用其他方法再試試的@@" 10/29 23:23