1
0
mirror of https://github.com/UzixLS/zx-sizif-xxs.git synced 2025-07-19 07:11:28 +03:00

fix clipping in sound mixer

This commit is contained in:
UzixLS
2021-05-05 16:29:40 +03:00
parent c7da9b5135
commit bb63bf074c

View File

@ -23,18 +23,19 @@ module mixer(
output dac_r
);
localparam WIDTH = 11;
reg [10:0] dac_l_cnt, dac_r_cnt;
assign dac_l = dac_l_cnt[10];
assign dac_r = dac_r_cnt[10];
reg [WIDTH:0] dac_l_cnt, dac_r_cnt;
assign dac_l = dac_l_cnt[WIDTH];
assign dac_r = dac_r_cnt[WIDTH];
wire [9:0] dac_next_l =
wire [WIDTH-1:0] dac_next_l =
sd_l0 + sd_l1 +
ay_a0 + ay_b0 +
ay_a1 + ay_b1 +
{beeper, tape_out, tape_in, 6'b000000}
;
wire [9:0] dac_next_r =
wire [WIDTH-1:0] dac_next_r =
sd_r0 + sd_r1 +
ay_b0 + ay_c0 +
ay_b1 + ay_c1 +
@ -47,8 +48,8 @@ always @(posedge clk28 or negedge rst_n) begin
dac_r_cnt <= 0;
end
else begin
dac_l_cnt <= dac_l_cnt[9:0] + dac_next_l;
dac_r_cnt <= dac_r_cnt[9:0] + dac_next_r;
dac_l_cnt <= dac_l_cnt[WIDTH-1:0] + dac_next_l;
dac_r_cnt <= dac_r_cnt[WIDTH-1:0] + dac_next_r;
end
end