hdmi icon indicating copy to clipboard operation
hdmi copied to clipboard

something wrong in audio

Open LMN128 opened this issue 4 years ago • 5 comments

Hi, I have something strange in audio signal. It looks like some bits are not reflected or are mixed up. I tried sawtooth example with some changes. Code is here:

logic signed [15:0] audio_sample_word = 16'sd0;
logic signed [15:0] audio_sample_word_minus = 16'sd0;
always @(posedge audio_clk) // Sawtooth wave
begin
  audio_sample_word <= audio_sample_word + 16'sd1;
  audio_sample_word_minus <= audio_sample_word_minus - 16'sd128;
end  
..
hdmi #(.VIDEO_ID_CODE(17), .VIDEO_REFRESH_RATE(50), .AUDIO_RATE(48000), .AUDIO_BIT_WIDTH(16)) hdmi(
 ...
  .clk_pixel(clk_pixel),
  .clk_audio(audio_clk),
  .rgb(rgb),
  .audio_sample_word({audio_sample_word,audio_sample_word_minus}), 

result is here: image

This exaple is for 16bits audio. I have found when want use 24bits the highest two bits are not reflected and have to use this: .audio_sample_word({{2'b0,audio_r,6'b0},{2'b0,audio_l,6'b0}}), Could you help me with this issue, please.

LMN128 avatar Sep 08 '21 06:09 LMN128

Hi Jan,

I'm not aware of any particular logic that would cause that. Could you share the changes you made to that code to use 24 bit audio? That way I can look into this issue with the top testbench. Also, did you already try using a non-signed representation?

sameer avatar Sep 11 '21 16:09 sameer

Hi Sameer, sorry for confusion second problem is not related to 24bits audio, but with 44100Hz sample rate. I use this code:

logic clk_audio;
logic [8:0] audio_divider;

always_ff@(posedge clk_pixel) 
begin
if (audio_divider<9'd306-1) audio_divider++; //generated from clk_pixel 27.0000MHz/281=48042,70Hz ; 27.0000MHz/306=44117,64Hz
else  begin clk_audio<=~clk_audio; audio_divider<=0; end
end

logic [23:0] audio_sample_word [1:0] = '{24'sd0, 24'sd0};
always_ff@(posedge clk_audio)
begin
audio_sample_word[0] <= audio_sample_word[0] + 128;  //sawtooth generator
audio_sample_word[1] <= audio_sample_word[1] - 256;  
end 

logic [23:0] rgb = 24'd0;
logic [9:0] cx, cy, screen_start_x, screen_start_y, frame_width, frame_height, screen_width, screen_height;
// Border test (left = red, top = green, right = blue, bottom = blue, fill = black)
always_ff@(posedge clk_pixel)
  rgb <= {cx == screen_start_x ? ~8'd0 : 8'd0, cy == screen_start_y ? ~8'd0 : 8'd0, cx == frame_width - 1'd1 || cy == frame_height - 1'd1 ? ~8'd0 : 8'd0};

hdmi #(.VIDEO_ID_CODE(17), .VIDEO_REFRESH_RATE(50), .AUDIO_RATE(44100), .AUDIO_BIT_WIDTH(24)) hdmi(
  .clk_pixel_x10(clk_pixel_x10),
  .clk_pixel(clk_pixel),
  .clk_audio(clk_audio),
  .rgb(rgb),
  .audio_sample_word(audio_sample_word),
  .tmds_p(dvdata_p),
  .tmds_clock_p(dvclk_p),
  .tmds_n(dvdata_n),
  .tmds_clock_n(dvclk_n),
  .cx(cx),
  .cy(cy),
  .screen_start_x(screen_start_x),
  .screen_start_y(screen_start_y),
  .frame_width(frame_width),
  .frame_height(frame_height),
  .screen_width(screen_width),
  .screen_height(screen_height)
);

and look at how is signal produced. image When I change sample rate to 48000Hz the signal has nice sawtooth shape.

LMN128 avatar Sep 13 '21 15:09 LMN128

Hi,

l think you are successful to set up and show.

I use the test pattern to test, there are always two block shown.

Is my screen not supported? or something wrong?

Did you have some ideas?

https://imgur.com/ArIkfPk

mopplayer avatar Sep 15 '22 02:09 mopplayer

Hi mopplayer,

Could you create a separate issue for this? Also, what model of TV/monitor are you using?

On Wed, Sep 14, 2022, at 19:42, mopplayer wrote:

Hi,

l think you are successful to set up and show.

I use the test pattern to test, there are always two block shown.

Is my screen not supported? or something wrong?

Did you have some ideas?

https://imgur.com/ArIkfPk

— Reply to this email directly, view it on GitHub https://github.com/hdl-util/hdmi/issues/27#issuecomment-1247511175, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUVICGBIJFQ6ERZMLGVE6TV6KEIZANCNFSM5DUAW5XQ. You are receiving this because you commented.Message ID: @.***>

sameer avatar Sep 16 '22 01:09 sameer

Hi @sameer,

I have created another issue.

Thank you very much.

mopplayer avatar Sep 17 '22 05:09 mopplayer

Should be resolved by https://github.com/hdl-util/hdmi/commit/08936f65be09abac338cd8c13beee289af7e7e59

sameer avatar May 26 '23 14:05 sameer