main
lincaigui 7 months ago
commit 59600be9cc

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

Binary file not shown.

@ -0,0 +1 @@
## FPGA数码管静态显示

@ -0,0 +1,67 @@
module static_led(
input wire sys_clk ,
input wire sys_rst_n ,
output reg [7: 0] seg_led ,//
output reg [5: 0] sel_led //
);
parameter MAX = 28'd50_000_000;//1s
parameter NUM = 4'd10;//10
reg [27: 0] cnt_s;
reg [3: 0] cnt_10;
//cnt_s
always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)begin
cnt_s <= 28'd0;
end
else if(cnt_s == MAX - 1'd1)begin
cnt_s <= 28'd0;
end
else begin
cnt_s <= cnt_s + 1'd1;
end
end
//cnt_10
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_10 <= 4'd0;
end
//91s
else if((cnt_10 == NUM - 1'd1) && (cnt_s == MAX - 1'd1))begin
cnt_10 <= 4'd0;
end
//1s1
else if(cnt_s == MAX - 1'd1)begin
cnt_10 <= cnt_10 + 1'd1;
end
//沿
else begin
cnt_10 <= cnt_10;
end
end
//sel_led
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
sel_led <= 6'b111_111;//6
end
else begin
sel_led <= 6'b000_000;//6
end
end
//seg_led
always @(*)begin
case(cnt_10)
4'd0 : seg_led = 8'b1100_0000;
4'd1 : seg_led = 8'b1111_1001;
4'd2 : seg_led = 8'b1010_0100;
4'd3 : seg_led = 8'b1011_0000;
4'd4 : seg_led = 8'b1001_1001;
4'd5 : seg_led = 8'b1001_0010;
4'd6 : seg_led = 8'b1000_0010;
4'd7 : seg_led = 8'b1111_1000;
4'd8 : seg_led = 8'b1000_0000;
4'd9 : seg_led = 8'b1001_0000;
default : seg_led = 8'b1100_0000;
endcase
end
endmodule

@ -0,0 +1,27 @@
`timescale 1ns/1ns
module static_led_tb();
parameter CYCLE = 20;
reg sys_clk;
reg sys_rst_n;
wire [7: 0] seg_led;
wire [5: 0] sel_led;
always #(CYCLE / 2) sys_clk = ~sys_clk;
initial begin
sys_clk = 1'b0;
sys_rst_n = 1'b0;
#(CYCLE);
sys_rst_n = 1'b1;
#(CYCLE * 5 * 11);//1100ns
$stop;
end
static_led static_led_inst(
.sys_clk (sys_clk ),
.sys_rst_n (sys_rst_n),
.seg_led (seg_led ),//
.sel_led (sel_led ) //
);
defparam static_led_inst.MAX = 5;//5 * 20 = 100ns
endmodule

@ -0,0 +1,114 @@
#
#
set_location_assignment PIN_E1 -to sys_clk
set_location_assignment PIN_E15 -to sys_rst_n
#UART
#set_location_assignment PIN_M2 -to uart_rx
#set_location_assignment PIN_G1 -to uart_tx
#LED
#set_location_assignment PIN_D16 -to led[3]
#set_location_assignment PIN_F15 -to led[2]
#set_location_assignment PIN_F16 -to led[1]
#set_location_assignment PIN_G15 -to led[0]
#
#set_location_assignment PIN_M15 -to key_in[2]
#set_location_assignment PIN_M16 -to key_in[1]
#set_location_assignment PIN_E16 -to key_in[0]
#
set_location_assignment PIN_B7 -to seg_led[0]
set_location_assignment PIN_A8 -to seg_led[1]
set_location_assignment PIN_A6 -to seg_led[2]
set_location_assignment PIN_B5 -to seg_led[3]
set_location_assignment PIN_B6 -to seg_led[4]
set_location_assignment PIN_A7 -to seg_led[5]
set_location_assignment PIN_B8 -to seg_led[6]
set_location_assignment PIN_A5 -to seg_led[7]
#w·
set_location_assignment PIN_A4 -to sel_led[0]
set_location_assignment PIN_B4 -to sel_led[1]
set_location_assignment PIN_A3 -to sel_led[2]
set_location_assignment PIN_B3 -to sel_led[3]
set_location_assignment PIN_A2 -to sel_led[4]
set_location_assignment PIN_B1 -to sel_led[5]
#ds18b20
# set_location_assignment PIN_E6 -to dq
#
#set_location_assignment PIN_J1 -to buzzer
#SDRAM
#
#set_location_assignment PIN_T8 -to addr[0]
#set_location_assignment PIN_P9 -to addr[1]
#set_location_assignment PIN_T9 -to addr[2]
#set_location_assignment PIN_R9 -to addr[3]
#set_location_assignment PIN_L16 -to addr[4]
#set_location_assignment PIN_L15 -to addr[5]
#set_location_assignment PIN_N16 -to addr[6]
#set_location_assignment PIN_N15 -to addr[7]
#set_location_assignment PIN_P16 -to addr[8]
#set_location_assignment PIN_P15 -to addr[9]
#set_location_assignment PIN_R8 -to addr[10]
#set_location_assignment PIN_R16 -to addr[11]
#set_location_assignment PIN_T15 -to addr[12]
#
#set_location_assignment PIN_R5 -to dq[0]
#set_location_assignment PIN_T4 -to dq[1]
#set_location_assignment PIN_T3 -to dq[2]
#set_location_assignment PIN_R3 -to dq[3]
#set_location_assignment PIN_T2 -to dq[4]
#set_location_assignment PIN_R1 -to dq[5]
#set_location_assignment PIN_P2 -to dq[6]
#set_location_assignment PIN_P1 -to dq[7]
#set_location_assignment PIN_R13 -to dq[8]
#set_location_assignment PIN_T13 -to dq[9]
#set_location_assignment PIN_R12 -to dq[10]
#set_location_assignment PIN_T12 -to dq[11]
#set_location_assignment PIN_T10 -to dq[12]
#set_location_assignment PIN_R10 -to dq[13]
#set_location_assignment PIN_T11 -to dq[14]
#set_location_assignment PIN_R11 -to dq[15]
#bank
#set_location_assignment PIN_R7 -to bank[0]
#set_location_assignment PIN_T7 -to bank[1]
#dqm
#set_location_assignment PIN_N2 -to dqm[0]
#set_location_assignment PIN_T14 -to dqm[1]
#
#set_location_assignment PIN_R4 -to sdram_clk
#
#set_location_assignment PIN_R14 -to cke
#set_location_assignment PIN_T6 -to cs_n
#set_location_assignment PIN_R6 -to ras_n
#set_location_assignment PIN_T5 -to cas_n
#set_location_assignment PIN_N1 -to we_n
#flash
#set_location_assignment PIN_H2 -to miso
#set_location_assignment PIN_C1 -to mosi
#set_location_assignment PIN_H1 -to sclk
#set_location_assignment PIN_D2 -to cs_n
#EEPROM
#set_location_assignment PIN_L2 -to sda
#set_location_assignment PIN_L1 -to sclk
#VGA
#
Loading…
Cancel
Save