[問題] verilog語法問題

看板Electronics作者 (經驗法則)時間12年前 (2012/04/19 04:29), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串7/7 (看更多)
最近剛學硬體描述語言 有個基本的語法問題想請教各位前輩 主要是希望能夠控制led燈跑的次數 如果是寫成這樣的話 always @(posedge clk) begin if(rst) // the rst is high begin if(count == 24'h3B8D80) // test for the delay begin count = 0; // clear the count led = led << 1; // shift right one bit of the led rgister if(led == 8'h00) // the led has shift 8 bits position begin led = 8'h01; // re-set the inital vaule of the led end end else begin count = count + 1; // delay time + 1 end end 燒出來的結果 led燈會由左跑到右 然後一直repeat 如果我希望控制它的次數 應該要怎樣修改這段程式呢 有想過在 if(count == 24'h3B8D80) // test for the delay begin 兩行中間 加入如 if (right_number<=3) 又覺得似乎沒有這麼簡單 如果希望能夠讓led燈從右到左跑x次 再從左至右y次 應該要怎麼寫呢 感謝各位前輩幫忙!!!! 為聊表小弟感謝之意,願奉上1000p幣給好心幫忙的大大!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.40.161.214 ※ 編輯: p7pp7 來自: 114.40.161.214 (04/19 04:33)

04/19 18:35, , 1F
再多加一組counter用來計算跑的次數每跑完一次就加一
04/19 18:35, 1F

04/19 18:36, , 2F
在次數小於x時就執行從右到左 超過就執行左到右直到x+y停
04/19 18:36, 2F

04/23 23:58, , 3F
你sequential電路要用 <= 不要用 = ...
04/23 23:58, 3F
文章代碼(AID): #1FZoGGNj (Electronics)
文章代碼(AID): #1FZoGGNj (Electronics)