作者p7pp7 (经验法则)
看板Electronics
标题[问题] verilog语法问题
时间Thu Apr 19 04:29:01 2012
最近刚学硬体描述语言
有个基本的语法问题想请教各位前辈
主要是希望能够控制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)
1F:→ lovepy:再多加一组counter用来计算跑的次数每跑完一次就加一 04/19 18:35
2F:→ lovepy:在次数小於x时就执行从右到左 超过就执行左到右直到x+y停 04/19 18:36
3F:推 vaca1:你sequential电路要用 <= 不要用 = ... 04/23 23:58