hdl-util / hdmi

Send video/audio over HDMI on an FPGA
https://purisa.me/blog/hdmi-released/
Other
1.04k stars 111 forks source link

sawtooth sound output problem #26

Closed DavidJRichards closed 2 years ago

DavidJRichards commented 2 years ago

Greetings, thanks for the great project.

I am porting the project onto an ebaz4205 ZYNQ 7010 board and nearly everything is now working, however there is a problem with the sawtooth sound module which I do not understand.

If I remove the instance of the sawtooth module and replaced it with inline equivalent code in the top module then everything works and sound is heard, when the sawtooth module is used there is silence.

My system is Vivado 2020.2, a bit more recent than the other Xilinx project which is perhaps 2019. I have successfully built 640x480 and 720p versions. These both show video and both suffer the same audio problem.

Working code from top with sawtooth placed inline. The sawtooth module is a direct copy of your own version in Github.

localparam int NUM_PCM_STEPS = (AUDIO_BIT_WIDTH + 1)'(2)**(AUDIO_BIT_WIDTH + 1)'(AUDIO_BIT_WIDTH) - 1;
localparam real FREQUENCY_RATIO = real'(WAVE_RATE) / real'(AUDIO_RATE);
localparam bit [AUDIO_BIT_WIDTH-1:0] INCREMENT = AUDIO_BIT_WIDTH'(NUM_PCM_STEPS * FREQUENCY_RATIO);
always @(posedge clk_audio)
  audio_sample_word <= audio_sample_word + INCREMENT; 

There are some issues with picture stability when running at the higher resolution but the problem exists at 640x480 too where the stability is not a problem. The clock frequencies are as close as I can get them sing a 33.333 MHz input to the Zynq clock generator. I used the clock wizard to derive the factors.

Any ideas how to debug this problem gratefully received. I have also made a rom lookup sinewave generator based on the sawtooth module layout, this too only works when used inline. The current sources are in my Github fork of the demo repo.

Kind regards, David.

DavidJRichards commented 2 years ago

Somehow I had managed to add an initialiser to the audio buffer, removing it cured the problem.

logic [AUDIO_BIT_WIDTH-1:0] audio_sample_word;// = 16'd0;
sameer commented 2 years ago

Strange problem and interesting resolution, happy to hear you figured that one out :slightly_smiling_face:

As for the picture stability issue, there could be a number of reasons. Could you describe what visual artifacts you're seeing? A picture or two might be helpful

DavidJRichards commented 2 years ago

Hi, the problem I have with higher resolutions is that the tv/monitor takes a long time to achieve a lock onto the signal and then drops it regularly too. otherwise its ok! The ability to display a picture seems to depend a lot on the actual monitor used, my cheap TV is very good, the old Iyama monitor doesn't always manage 720p. when a picture is displayed then it is generally good quality. image

sameer commented 2 years ago

I see. Couple troubleshooting trips:

If none of those are an issue, my guess would be that it's related to the clock setup. Using an oscilloscope and/or Xilinx ILA, check that there is no clock lock loss and the waveform looks good for the two clocks.

DavidJRichards commented 2 years ago

Thanks for the tips. The interfaces I'm using are home-made hacks and are unlikely to meet any published requirements, I have no access to a 'scope capable of showing anything meaningful on the signal wires. However I can try monitoring the clock with a logic analyzer to see if it is always operating and I have some more cables I can try.

I'm going to continue my testing on a faster device with built-in HDMI interface chip, I'm expecting it to work much better. Thanks for your help. David.

IMG_20210714_212757-COLLAGE

sameer commented 2 years ago

I built one a while back but it was not as good as yours:

hdmi 2.0 pcb breakout with soldered wires

It looks like you have all the ground pins connected, right? Not sure what else it could be

DavidJRichards commented 2 years ago

All the grounds are connected. I have in addition to the ebaz4205 a Pynq-Z2, this has a Zynq 7020 chip. I have ported the HDMI code onto this and it works ok at 1080p@60Hz with 16bit48kbit stereo sound, something the ebaz could not manage. The new Artix board should arrive shortly too ... image