Skip to content

Commit

Permalink
[rtl, aon_timer] Reset core.prescale_count on wkup_ctrl write
Browse files Browse the repository at this point in the history
The AON timer core has an internal counter `prescale_count_q` which is
not reset upon each write to wkup_ctrl.
This causes issues if the WKUP timer is re-configured to a lower
prescaler value than it was before, and the `prescale_count_q` variable
is greater than the new prescaler value, forcing the
`prescale_count_q` counter to overflow itself causing a non-spec
compliant behavior.

In order to mitigate the above, the internal `prescale_count_q` is
reset after wkup_ctrl write. Thus, the aon timer is forced to count
from scratch the new intended prescaler value.

Signed-off-by: Antonio Martinez Zambrana <[email protected]>
  • Loading branch information
antmarzam committed Dec 12, 2024
1 parent ee42e18 commit ca3ed02
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions hw/ip/aon_timer/rtl/aon_timer_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ module aon_timer_core import aon_timer_reg_pkg::*; (
always_ff @(posedge clk_aon_i or negedge rst_aon_ni) begin
if (!rst_aon_ni) begin
prescale_count_q <= 12'h000;
end else if (reg2hw_i.wkup_ctrl.prescaler.qe) begin
prescale_count_q <= 12'h000;
end else if (prescale_en) begin
prescale_count_q <= prescale_count_d;
end
Expand Down
1 change: 1 addition & 0 deletions hw/ip/aon_timer/rtl/aon_timer_reg_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package aon_timer_reg_pkg;
typedef struct packed {
struct packed {
logic [11:0] q;
logic qe;
} prescaler;
struct packed {
logic q;
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/aon_timer/rtl/aon_timer_reg_top.sv
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ module aon_timer_reg_top (
.d ('0),

// to internal hardware
.qe (),
.qe (reg2hw.wkup_ctrl.prescaler.qe),
.q (reg2hw.wkup_ctrl.prescaler.q),
.ds (),

Expand Down

0 comments on commit ca3ed02

Please sign in to comment.