Tuesday, 28 January 2014

Debugging character display generation

Working on the character generator for the VIC-IV, I have a bug where the left edge of the character display gets two characters of junk, before beginning the real stuff.  Annoyingly, the bug only shows up on the FPGA, and not in simulation.

I don't have fancy gear to probe the internals of the FPGA here at home, nor the knowledge of how to us it, anyway. Also, as I use a Mac, it is a pain to get those tools to work in the first place.

To work around this I have added video generator debug registers that allow you to specify the exact pixel position on screen that you want to know several internal video generator state registers.  These values then get latched at that position of the frame, so that they can be read out some other registers at ones leisure.  

Of course, I want an automated means of setting the position, reading the results (one frame later of course), and then advancing the position along a raster, so that I can capture the entire sequence of events over the entire raster.

So I set about creating this.  When the debug registers are set, the VIC-IV draws a red cross-hair showing the pixel being interrogated, as can be seen below:



I then wrote a C program that talks to the board over my serial monitor interface, setting the registers, waiting a couple of frames (just to be sure), and then reading the results out from the debug registers, and rendering them in a useful way.

This displays information like the log at the end of this post.  It looks mostly like gobbledygook, and there is a bug that causes some wrong columns of output in this example, but the cycles_to_next_card and chargen_active and chargen_active_soon signals tell me that something is indeed going wrong at the left of each raster.  cycles_to_next_card should drop down to 1 eight cycles before chargen_active goes to 1.

In the process I realised that I was missing one other rather important signal.  So back to spending an hour or so rebuilding the FPGA program to get more information.  Then hopefully I will have what I need to fix this bug that has been hanging around for a while and spoiling the otherwise very nice looking display.

display_y=100, display_x=145, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=146, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=147, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=148, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=149, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=150, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=151, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=152, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=153, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=154, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=0
display_y=100, display_x=155, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=156, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=254, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=157, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=253, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=158, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=252, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=159, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=251, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=160, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=250, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=161, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=249, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=162, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=248, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=163, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=255, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=164, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=254, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=165, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=253, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=166, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=252, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=167, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=251, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=168, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=250, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=169, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=1, chargen_active=0, chargen_active_soon=1
display_y=100, display_x=170, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=40, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=171, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=39, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=172, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=38, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=173, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=37, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=174, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=36, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=175, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=35, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=176, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=34, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=177, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=33, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=178, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=32, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=179, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=31, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=180, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=30, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=181, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=29, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=182, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=28, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=183, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=27, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=184, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=26, chargen_active=2, chargen_active_soon=0
display_y=100, display_x=185, x_chargen_start_minus16=198890353, next_card_number=154, cycles_to_next_card=25, chargen_active=2, chargen_active_soon=0

No comments:

Post a Comment