added UML

This commit is contained in:
irobo 2026-05-14 08:40:45 +03:00
parent f3a68a1f78
commit fac3049b3c
4 changed files with 117 additions and 0 deletions

51
UML/activity.plantuml Normal file
View File

@ -0,0 +1,51 @@
@startuml
start
:posedge clk;
'--- Step timer ---
if (step_cnt >= (freq_idx == 1 ? STEP_2SEC_MAX : STEP_4SEC_MAX)) then (yes)
:step_cnt := 0;
if (freq_idx == 5) then (yes)
:freq_idx := 0;
else (no)
:freq_idx := freq_idx + 1;
endif
else (no)
:step_cnt := step_cnt + 1;
endif
'--- Recalculate half-period ---
:max_count := calc_max_count(freq_idx);
'--- Blink generation for led ---
if (max_count == 0) then (0 Hz)
:blink_cnt := 0;
note right
led_base сохраняет предыдущее
значение (нет мигания)
end note
else (f > 0)
if (blink_cnt >= max_count) then (toggle)
:blink_cnt := 0;
:led_base := ~led_base;
else (count)
:blink_cnt := blink_cnt + 1;
endif
endif
'--- 1 Hz generation for pin ---
if (pin_cnt >= PIN_1HZ_HALF_MAX) then (toggle)
:pin_cnt := 0;
:pin_base := ~pin_base;
else (count)
:pin_cnt := pin_cnt + 1;
endif
'--- Outputs (combinational) ---
:led = ~led_base;
:pin = pin_base;
:pin_10 = led;
stop
@enduml

BIN
UML/activity.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

66
UML/state.plantuml Normal file
View File

@ -0,0 +1,66 @@
@startuml
[*] --> F0 : reset/power-up
state "Blink frequency\nstates" as BlinkFreq {
state F0
state F10
state F20
state F30
state F40
state F50
}
' --- Notes ---
note right of F0
freq_idx = 0
f = 0 Hz (LED заморожен)
step_cnt считает до STEP_4SEC_MAX
end note
note right of F10
freq_idx = 1
f = 10 Hz
max_count = F_CLK/(2*10)-1
step_cnt считает до STEP_2SEC_MAX
end note
note right of F20
freq_idx = 2
f = 20 Hz
max_count = F_CLK/(2*20)-1
step_cnt считает до STEP_4SEC_MAX
end note
note right of F30
freq_idx = 3
f = 30 Hz
max_count = F_CLK/(2*30)-1
step_cnt считает до STEP_4SEC_MAX
end note
note right of F40
freq_idx = 4
f = 40 Hz
max_count = F_CLK/(2*40)-1
step_cnt считает до STEP_4SEC_MAX
end note
note right of F50
freq_idx = 5
f = 50 Hz
max_count = F_CLK/(2*50)-1
step_cnt считает до STEP_4SEC_MAX
end note
' --- Transitions ---
F0 --> F10 : step_cnt >= STEP_4SEC_MAX
F10 --> F20 : step_cnt >= STEP_2SEC_MAX
F20 --> F30 : step_cnt >= STEP_4SEC_MAX
F30 --> F40 : step_cnt >= STEP_4SEC_MAX
F40 --> F50 : step_cnt >= STEP_4SEC_MAX
F50 --> F0 : step_cnt >= STEP_4SEC_MAX
F0 --> [*] : external reset
@enduml

BIN
UML/state.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB