|
|
@@ -20,7 +20,6 @@ module pwm_scheduler #(
|
|
|
localparam integer SLOT_BITS = (PWM_SLOT_CLKS <= 1) ? 1 : $clog2(PWM_SLOT_CLKS);
|
|
|
|
|
|
reg [CHANNEL_BITS-1:0] current_channel;
|
|
|
- reg [CHANNEL_BITS-1:0] data_channel;
|
|
|
reg [PHASE_BITS-1:0] phase;
|
|
|
reg [SLOT_BITS-1:0] slot_counter;
|
|
|
wire [PWM_DUTY_WIDTH-1:0] selected_duty = target_rd_data[PWM_DUTY_WIDTH-1:0];
|
|
|
@@ -31,7 +30,6 @@ module pwm_scheduler #(
|
|
|
always @(posedge clk or negedge rst_n) begin
|
|
|
if (!rst_n) begin
|
|
|
current_channel <= {CHANNEL_BITS{1'b0}};
|
|
|
- data_channel <= {CHANNEL_BITS{1'b0}};
|
|
|
phase <= {PHASE_BITS{1'b0}};
|
|
|
slot_counter <= {SLOT_BITS{1'b0}};
|
|
|
logical_pwm_on <= {CHANNEL_COUNT{1'b0}};
|
|
|
@@ -39,10 +37,10 @@ module pwm_scheduler #(
|
|
|
slot_counter <= slot_counter + 1'b1;
|
|
|
end else begin
|
|
|
slot_counter <= {SLOT_BITS{1'b0}};
|
|
|
- // target_rd_data belongs to the address requested during the
|
|
|
- // preceding slot because output_target_ram has one-cycle latency.
|
|
|
- logical_pwm_on[data_channel] <= logical_on;
|
|
|
- data_channel <= current_channel;
|
|
|
+ // The synchronous RAM has already seen current_channel during
|
|
|
+ // the preceding clock in this slot, so the returned data belongs
|
|
|
+ // to the channel currently being completed.
|
|
|
+ logical_pwm_on[current_channel] <= logical_on;
|
|
|
if (current_channel == CHANNEL_COUNT - 1) begin
|
|
|
current_channel <= {CHANNEL_BITS{1'b0}};
|
|
|
if (phase == PWM_PHASE_COUNT - 1)
|