在CME-M5开发板上运行的第1个Verilog HDL跑马灯程序
0赞
发表于 2013/3/13 0:05:43
阅读(3366)
/***************************************** 程序名称:8位LED跑马灯 程序功能:8个LED灯,从1至8循环间隔500ms逐个点亮,单个LED亮时,其它7个LED灭 FPGA型号:CME-M5C06N3L144C7 开发工具版本:Primace 4.2 程序版本:V0.0.1 作者:谭鹏超 ******************************************/ module pmdled(clk0,rst_n,led); input clk0; //输入时钟 input rst_n; //复位按键 output[7:0] led; //8个LED输出口 parameter led_cnt = 24'h989680; //500ms,计数2000000次 reg[7:0] r_led; reg[23:0] r_cnt; //分频计数器 reg r_clk1Hz; //分频输出 //1Hz分频 always @(posedge clk0 or negedge rst_n) begin if(!rst_n) begin r_cnt <= 24'h000000; end else if(r_cnt == led_cnt) begin r_clk1Hz <= ~r_clk1Hz; r_cnt <= 24'h000000; end else begin r_cnt <= r_cnt+1'b1; end end //Led灯移位控制 always @(posedge r_clk1Hz or negedge rst_n) begin if(!rst_n) begin r_led <= 8'hfe; end else begin r_led[0] <= r_led[7]; r_led[7:1] <= r_led[6:0]; end end //移位后的LED值分配给输出端口 assign led =r_led; endmodule
该程序使用Primace 4.2编译时,还有下面这个警告:
-
Warning: RTLW_XASYNCINIT_001:'/cygdrive/E/CMEFPGA/01StudyVideo/00Practice/PMDLED/PMDLED/src/PMDLED.v', line 11... In this procedure block, variable 'r_clk1Hz' (bit-0) is not initialized in asynchronous branch(es) even though the process is controlled by asynchronous controls.
-
来源:爱捣鼓网
作者:爱捣鼓
原文链接:http://www.aidaogu.com/forum.php?mod=viewthread&tid=198