
视频地址: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
回复
打赏帖 | |
---|---|
C语言函数宏的三种封装方式被打赏50分 | |
嵌入式LinuxC语言程序调试和宏使用技巧被打赏50分 | |
让代码中包含最新的编译时间信息被打赏50分 | |
【分享开发笔记,赚取电动螺丝刀】STM32F769LVGL优化显示被打赏26分 | |
rtthread硬件加密--2crc加密分析被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】STM32F769驱动ST7789以及显示优化被打赏36分 | |
【分享开发笔记,赚取电动螺丝刀】S32K146 PAL模拟I2C驱动适配被打赏23分 | |
我想要一部加热台+电源硬件设计规范被打赏16分 | |
我想要一部加热台+LED背光驱动芯片RT9293知识被打赏18分 | |
【分享开发笔记,赚取电动螺丝刀】S32K146 ADC 模块配置使用被打赏24分 |