
视频地址:http://union.bokecc.com/flash/single/290666218ACBA694_ADEEBE819D4B8D38_false_EEA982EE6B20F4D1_1/player.swf
照猫画虎的学着传一下视频,跑马灯程序是在网友程序改了一下方向。
程序如下:
module LEDMO( clk, rst, led0,led1,led2,led3,led4,led5,led6,led7, led_r,led_g,led_y );
input clk; input rst;
output led0,led1,led2,led3,led4,led5,led6,led7;
output led_r,led_g,led_y;
reg[31:0] count;
reg[10:0] led_out;
always @(posedge clk or negedge rst)
begin
if(!rst)
count<=31'd0;
else
if(count==31'd220_000_000)
count<=31'd0;
else
count<=count+1'b1;
end
always @(posedge clk or negedge rst)
begin
if(!rst)
led_out <= 1'b0;
else
if(count >= 31'd0 && count < 31'd20_000_000)
led_out <= 11'b011_1111_1111;
else if(count >= 31'd20_000_000 && count < 31'd40_000_000)
led_out <= 11'b101_1111_1111;
else if(count >= 31'd40_000_000 && count < 31'd60_000_000)
led_out <= 11'b110_1111_1111;
else if(count >= 31'd60_000_000 && count < 31'd80_000_000)
led_out <= 11'b111_0111_1111;
else if(count >= 31'd80_000_000 && count < 31'd100_000_000)
led_out <= 11'b111_1011_1111;
else if(count >= 31'd100_000_000 && count < 31'd120_000_000)
led_out <= 11'b111_1101_1111;
else if(count >= 31'd120_000_000 && count < 31'd140_000_000)
led_out <= 11'b111_1110_1111;
else if(count >= 31'd140_000_000 && count < 31'd160_000_000)
led_out <= 11'b111_1111_0111;
else if(count >= 31'd160_000_000 && count < 31'd180_000_000)
led_out <= 11'b111_1111_1011;
else if(count >= 31'd180_000_000 && count < 31'd200_000_000)
led_out <= 11'b111_1111_1101;
else if(count >= 31'd200_000_000 && count < 31'd220_000_000)
led_out <= 11'b111_1111_1110;
end
assign led0 =led_out[0];
assign led1 =led_out[1];
assign led2 =led_out[2];
assign led3 =led_out[3];
assign led4 =led_out[4];
assign led5 =led_out[5];
assign led6 =led_out[6];
assign led7 =led_out[7];
assign led_r = led_out[8];
assign led_g = led_out[9];
assign led_y = led_out[10];
endmodule
回复
打赏帖 | |
---|---|
汽车电子中巡航控制系统的使用被打赏10分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K314】芯片启动流程分析被打赏40分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K146】S32DS RTD 驱动环境搭建被打赏12分 | |
【分享开发笔记,赚取电动螺丝刀】【IAR】libc标注库time相关库函数使用被打赏23分 | |
LP‑MSPM0L1306开发版试用结果被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【LP-MSPM0L1306】适配 RT-Thread Nano被打赏23分 |