diff --git a/UML/activity.plantuml b/UML/activity.plantuml new file mode 100644 index 0000000..ba63f2e --- /dev/null +++ b/UML/activity.plantuml @@ -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 \ No newline at end of file diff --git a/UML/activity.png b/UML/activity.png new file mode 100644 index 0000000..6fa4382 Binary files /dev/null and b/UML/activity.png differ diff --git a/UML/state.plantuml b/UML/state.plantuml new file mode 100644 index 0000000..3804f54 --- /dev/null +++ b/UML/state.plantuml @@ -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 \ No newline at end of file diff --git a/UML/state.png b/UML/state.png new file mode 100644 index 0000000..f72ffdf Binary files /dev/null and b/UML/state.png differ