added 10Hz

This commit is contained in:
irobo 2026-05-13 07:54:08 +03:00
parent e0e4278141
commit 87983abfcf
4 changed files with 53 additions and 15 deletions

View File

@ -61,4 +61,8 @@ set_global_assignment -name POWER_BOARD_THERMAL_MODEL "NONE (CONSERVATIVE)"
set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
set_location_assignment PIN_7 -to pin
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to pin
set_location_assignment PIN_10 -to pin_10
set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to pin_10
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top

58
blink.v
View File

@ -1,21 +1,55 @@
module blink( module blink #(
input clk, // Выбор частоты мигания (F_BLINK), Гц:
output reg led // 1 -> 1
// 2.5 -> 25 (см. ниже, делим на 10)
// 5 -> 5
// 10 -> 10
parameter integer MODE = 4 // по умолчанию 1 Гц
)(
input wire clk, // 50 MHz
output reg led,
output reg pin,
output reg pin_10
); );
localparam MAX_COUNT = 50_000_000 - 1; // для 50 MHz ~1 секунда localparam integer F_CLK = 50_000_000;
reg [26:0] cnt;// 2^26 = 67_108_864 // Предрасчитанные MAX_COUNT для половины периода:
//
// 1 Гц: T=1 c T/2=0.5 c 25_000_000
// 2.5 Гц: T=0.4 c T/2=0.2 c 10_000_000
// 5 Гц: T=0.2 c T/2=0.1 c 5_000_000
// 10 Гц: T=0.1 c T/2=0.05 c 2_500_000
always @(posedge clk) localparam integer MAX_1HZ = 25_000_000 - 1;
begin localparam integer MAX_2_5HZ = 10_000_000 - 1;
if(cnt >= MAX_COUNT) localparam integer MAX_5HZ = 5_000_000 - 1;
begin localparam integer MAX_10HZ = 2_500_000 - 1;
// Выбор MAX_COUNT по MODE
// MODE:
// 1 -> 1 Гц
// 2 -> 2.5 Гц
// 3 -> 5 Гц
// 4 -> 10 Гц
localparam integer MAX_COUNT =
(MODE == 1) ? MAX_1HZ :
(MODE == 2) ? MAX_2_5HZ :
(MODE == 3) ? MAX_5HZ :
(MODE == 4) ? MAX_10HZ :
MAX_1HZ; // по умолчанию 1 Гц
reg [25:0] cnt; // хватает до > 33 млн (2^25 = 33_554_432)
always @(posedge clk) begin
if (cnt >= MAX_COUNT) begin
cnt <= 0; cnt <= 0;
led <= ~led; // переключение LED led <= ~led;
end pin <= led;
else pin_10 <= led;
end else begin
cnt <= cnt + 1; cnt <= cnt + 1;
end
end end
endmodule endmodule

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="US-ASCII" standalone="yes"?> <?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
<cof> <cof>
<eprom_name>EPCS64</eprom_name> <eprom_name>EPCS4</eprom_name>
<flash_loader_device>EP4CE6</flash_loader_device> <flash_loader_device>EP4CE6</flash_loader_device>
<output_filename>output_file.jic</output_filename> <output_filename>output_file.jic</output_filename>
<n_pages>1</n_pages> <n_pages>1</n_pages>

View File

@ -6,6 +6,6 @@ Page_0 0x00000000 0x00059D8A
Notes: Notes:
- Data checksum for this conversion is 0x1A5EA7E1 - Data checksum for this conversion is 0x0276151E
- All the addresses in this file are byte addresses - All the addresses in this file are byte addresses