TA的每日心情 | 开心 2014-5-14 13:12 |
---|
签到天数: 180 天 连续签到: 1 天 [LV.7]常住居民III
|
再次吐槽一下,有些例程写的真心磨叽,想好更好的理解,还是得自己写
多个数码管显示的代码:- module mutiSeg7
- (
- CLK, RSTn, LED,en
- );
- input CLK, RSTn;
- output [7:0] LED;
- output [5:0] en;
- reg [5:0]rEn = 6'b111_110;
- parameter T1ms = 16'd50_000;
- 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;
- //1ms
- reg [31:0] count;
- always @(posedge CLK or negedge RSTn)
- if(!RSTn)
- count <= 0;
- else if (count == T1ms)
- count <= 26'b0;
- else count <= count + 26'b1;
-
- reg[7:0] rLED;
- always @(posedge CLK or negedge RSTn)
- if(!RSTn)
- rEn <= 6'b111_110;
- else if(count == T1ms)
- case(rEn)
- 6'b111_110:
- begin
- rEn <= 6'b111_101;
- rLED <= _0;
- end
- 6'b111_101:
- begin
- rEn <= 6'b111_011;
- rLED <= _1;
- end
- 6'b111_011:
- begin
- rEn <= 6'b110_111;
- rLED <= _2;
- end
- 6'b110_111:
- begin
- rEn <= 6'b101_111;
- rLED <= _3;
- end
- 6'b101_111:
- begin
- rEn <= 6'b011_111;
- rLED <= _4;
- end
- 6'b011_111:
- begin
- rEn <= 6'b111_110;
- rLED <= _5;
- end
- default:
- begin
- rEn<= 6'b111_110;
- rLED <= _0;
- end
- endcase
- assign LED = rLED;
- assign en = rEn;
- endmodule
-
复制代码 会在一排数码管上显示012345
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[5]
- set_location_assignment PIN_P6 -to en[4]
- set_location_assignment PIN_M6 -to en[3]
- set_location_assignment PIN_M7 -to en[2]
- set_location_assignment PIN_P8 -to en[1]
- set_location_assignment PIN_N8 -to en[0]
复制代码 |
|