2回答

0收藏

Verilog 基础--跑马灯

FPGA/DSP FPGA/DSP 4021 人阅读 | 2 人回复 | 2013-04-23

  1. module runLED
  2. (
  3.         CLK, RSTn, LED
  4. );

  5.         input CLK, RSTn;
  6.         output [3:0] LED;
  7.         
  8.         parameter T1s = 26'd50_000_000;
  9.         reg [31:0] count;
  10.         
  11.         
  12.         always @(posedge CLK or negedge RSTn)
  13.                 if(!RSTn)
  14.                         count <= 0;
  15.                 else if (count == T1s)
  16.                         count <= 26'b0;
  17.                 else count <= count + 26'b1;
  18.         
  19.         reg[3:0] rLED;

  20.         always @(posedge CLK or negedge RSTn)
  21.                 if(!RSTn)
  22.                         rLED <= 4'b0001;
  23.                 else if(count == T1s)
  24.                         begin        
  25.                                 if(rLED == 4'b0000)
  26.                                         rLED <= 4'b0001;
  27.                                 else
  28.                                         rLED <= {rLED[2:0], 1'b0};
  29.                         end        

  30.         assign LED = rLED;
  31. endmodule
  32.                
复制代码
最近买了黑金动力社区的开发板,学一学Verilog的基本逻辑,以前一直在用Sysgen做图像处理算法方面,有点走火入魔,回头发现其实用Verilog写图像处理也是可以的,因此决定认真学习Verilog,首先是学习黑金动力的例程,说实话,C语言看久了,就感觉它的代码很磨叽,因此决定自己写。虽然简单,但是还算好理解。
tcl代码:
  1. #------------------GLOBAL--------------------#
  2. set_global_assignment -name RESERVE_ALL_UNUSED_PINS "AS INPUT TRI-STATED"
  3. set_global_assignment -name ENABLE_INIT_DONE_OUTPUT OFF


  4. set_location_assignment        PIN_M1        -to RSTn


  5. set_location_assignment        PIN_R9        -to CLK

  6. set_location_assignment        PIN_J1        -to LED[0]
  7. set_location_assignment        PIN_J2        -to LED[1]
  8. set_location_assignment        PIN_K1        -to LED[2]
  9. set_location_assignment        PIN_K2        -to LED[3]
复制代码
国内的ubuntu的更新源还是上海交大最给力
分享到:
回复

使用道具 举报

回答|共 2 个

倒序浏览

沙发

Hayasaky

发表于 2013-4-23 19:19:24 | 只看该作者

来膜拜大神了……
板凳

libing64

发表于 2013-4-24 10:56:15 | 只看该作者

Hayasaky 发表于 2013-4-23 19:19
来膜拜大神了……

哪有什么大神啊,顶多算一个Veriog新手
国内的ubuntu的更新源还是上海交大最给力
您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条