@@ -480,26 +480,44 @@ module top #(
480
480
// will cause the HDMI receiver to clip the audio or amplify anything such as the Mockingboard
481
481
// audio that is added to it.
482
482
483
- reg speaker_audio;
483
+
484
+ reg [7 : 0 ] speaker_audio;
484
485
reg [7 : 0 ] speaker_audio_counter;
485
486
reg prev_speaker_bit;
486
487
487
488
always_ff @ (posedge clk_pixel_w) begin
488
489
if (clk_audio_r) begin
489
490
if (speaker_bit != prev_speaker_bit) begin
490
- speaker_audio_counter <= 8'b11111111 ;
491
- end else if (speaker_audio_counter != 0 ) begin
492
- speaker_audio_counter <= speaker_audio_counter - 8'd1 ;
491
+ speaker_audio_counter <= 8'd255 ;
492
+ end else begin
493
+ speaker_audio_counter <= speaker_audio_counter != 0 ? speaker_audio_counter - 8'd1 : 0 ;
493
494
end
494
495
prev_speaker_bit <= speaker_bit;
495
496
496
- if (prev_speaker_bit && (speaker_audio_counter != 0 )) begin
497
- speaker_audio <= APPLE_SPEAKER_ENABLE | sw_apple_speaker_w;
497
+ if ((speaker_audio_counter != 0 ) && (APPLE_SPEAKER_ENABLE | sw_apple_speaker_w)) begin
498
+ if (speaker_bit) begin
499
+ speaker_audio <= speaker_audio != 8'd127 ? speaker_audio + 8'd1 : 8'd127 ;
500
+ end else begin
501
+ speaker_audio <= speaker_audio != 8'd0 ? speaker_audio - 8'd1 : 8'd0 ;
502
+ end
503
+ end else begin
504
+ speaker_audio <= speaker_audio != 8'd0 ? speaker_audio - 8'd1 : 8'd0 ;
505
+ end
506
+ end
507
+ end
508
+
509
+ /*
510
+ reg [7:0] speaker_audio;
511
+ always_ff @(posedge clk_pixel_w) begin
512
+ if (clk_audio_r) begin
513
+ if (speaker_bit) begin
514
+ speaker_audio <= speaker_audio != 8'd127 ? speaker_audio + 8'd1 : 8'd127;
498
515
end else begin
499
- speaker_audio <= 1'b0 ;
516
+ speaker_audio <= speaker_audio != 8'd0 ? speaker_audio - 8'd1 : 8'd0 ;
500
517
end
501
518
end
502
519
end
520
+ */
503
521
504
522
// //
505
523
logic [2 : 0 ] tmds;
@@ -508,9 +526,9 @@ module top #(
508
526
// wire [15:0] sample = {ssp_psg_mix_audio_o, 2'b00};
509
527
reg [15 : 0 ] audio_sample_word[1 : 0 ], audio_sample_word0[1 : 0 ];
510
528
always @ (posedge clk_pixel_w) begin // crossing clock domain
511
- audio_sample_word0[0 ] <= ssp_audio_w + { mb_audio_l, 4'b00 } + { speaker_audio, 13 'b0} ;
529
+ audio_sample_word0[0 ] <= ssp_audio_w + { mb_audio_l, 4'b00 } + { speaker_audio, 8 'b0} ;
512
530
audio_sample_word[0 ] <= audio_sample_word0[0 ];
513
- audio_sample_word0[1 ] <= ssp_audio_w + { mb_audio_r, 4'b00 } + { speaker_audio, 13 'b0} ;
531
+ audio_sample_word0[1 ] <= ssp_audio_w + { mb_audio_r, 4'b00 } + { speaker_audio, 8 'b0} ;
514
532
audio_sample_word[1 ] <= audio_sample_word0[1 ];
515
533
end
516
534
0 commit comments