TA的每日心情 | 开心 2014-5-14 13:12 |
---|
签到天数: 180 天 连续签到: 1 天 [LV.7]常住居民III
|
感觉黑金开发板的例程很磨叽,很不规范,因此决定自己写。数码管的代码:- module seg7
- (
- CLK, RSTn, LED,en
- );
- input CLK, RSTn;
- output [7:0] LED;
- output en;
- reg rEn = 1'b0;
- parameter T1s = 26'd50_000_000;
- reg [31:0] count;
-
- reg [3:0] number = 4'b0000;
-
- parameter _0 = 8'b1100_0000,
- _1 = 8'b1111_1001,
- _2 = 8'b1010_0100,
- _3 = 8'b1011_0000,
- _4 = 8'b1001_1001,
- _5 = 8'b1001_0010,
- _6 = 8'b1000_0010,
- _7 = 8'b1111_1000,
- _8 = 8'b1000_0000,
- _9 = 8'b1001_0000,
- _a = 8'b1000_1000,
- _b = 8'b1000_0011,
- _c = 8'b1100_0110,
- _d = 8'b1010_0001,
- _e = 8'b1000_0110,
- _f = 8'b1000_1110;
-
-
- always @(posedge CLK or negedge RSTn)
- if(!RSTn)
- count <= 0;
- else if (count == T1s)
- count <= 26'b0;
- else count <= count + 26'b1;
- always @(posedge CLK or negedge RSTn)
- if(!RSTn)
- number <= 4'b0000;
- else if(count == T1s)
- number <= number + 1'b1;
- reg[7:0] rLED;
- always @(posedge CLK or negedge RSTn)
- if(!RSTn)
- rLED <= 8'b0000_0001;
- else if(count == T1s)
- case(number)
- 0:rLED <= _0;
- 1:rLED <= _1;
- 2:rLED <= _2;
- 3:rLED <= _3;
- 4:rLED <= _4;
- 5:rLED <= _5;
- 6:rLED <= _6;
- 7:rLED <= _7;
- 8:rLED <= _8;
- 9:rLED <= _9;
- 10:rLED <= _a;
- 11:rLED <= _b;
- 12:rLED <= _c;
- 13:rLED <= _d;
- 14:rLED <= _e;
- 15:rLED <= _f;
- default:rLED <= _0;
- endcase
- assign LED = rLED;
- assign en = rEn;
- endmodule
-
复制代码 tcl代码- #------------------GLOBAL--------------------#
- set_global_assignment -name RESERVE_ALL_UNUSED_PINS "AS INPUT TRI-STATED"
- set_global_assignment -name ENABLE_INIT_DONE_OUTPUT OFF
- #复位引脚
- set_location_assignment PIN_M1 -to RSTn
- #时钟引脚
- set_location_assignment PIN_R9 -to CLK
- #数码管对应的引脚
- set_location_assignment PIN_M8 -to LED[0]
- set_location_assignment PIN_L7 -to LED[1]
- set_location_assignment PIN_P9 -to LED[2]
- set_location_assignment PIN_N9 -to LED[3]
- set_location_assignment PIN_M9 -to LED[4]
- set_location_assignment PIN_M10 -to LED[5]
- set_location_assignment PIN_P11 -to LED[6]
- set_location_assignment PIN_N11 -to LED[7]
- set_location_assignment PIN_N6 -to en
复制代码 下载后数码管从0显示到f,比较简单,看官勿喷~
|
|