Sunday, January 19, 2025

Slow debugging of entire Diablo Archiver under simulation

SLOW TEST CYCLE DUE TO SERIAL LINK SPEED

The full design for the archiver writes out on the serial USB link at 115,200 baud which imposes additional delays waiting for the simulation to reach some logic point in an upload. Each character emitted takes approximately 87 us. 

Thus, the initial header message (21 characters) ties up 1.83 milliseconds during which the uploader state machine waits before it reads the first word of the first sector. The trailer message for the sector doesn't complete until after 168 ms, at which point we move to the next sector. 

Completing one sector involves eight sectors. We need to wait through four of them to see that the head and sector advance properly and wait through another four to see cylinder, head and sector are set correctly. That take the simulation over 1.347 of simulated duration to complete. 

Since it requires a couple of minutes to start a simulation and then time passes at 2 us per real second, 500,000 times slower, a complete cylinder of upload would take 7.8 days to complete. The full cartridge in simulation would chew up 4.34 years of actual time. 

I can afford to wait to see a couple of words from the first sector be uploaded, but even waiting for a single sector to finish would require almost an entire day of wall clock time. Luckily I had simulated just the uploader module previously which ran fast enough to test key points where sector, head or cylinder numbers are incremented and the proper end of the function when we wrapped up the 203rd cylinder. 

This is because the effort to simulate all the memory interface, FIFO, clock and my user logic cells involves much more computation that a single module of the design such as uploader. Still, I would rather simulate as much as I can before I am trying to debug with the actual disk running and spot errors in real time. I don't want to subject the heads or any cartridge to excess time at risk; I want to fly the heads on each pack for the minimum necessary to archive the contents then shut down the drive. 

UPLOADER DOUBLE CHECKED AS FAR AS BEGINNING TWO WORDS OF SECTOR 0

I could tolerate the time necessary to startup and watch the design read from RAM and upload words 0 and 1 of sector 0, head 0, cylinder 0. This matched the experience of the partial simulation I did yesterday and reassured me. However, I did find a race hazard in the logic during the simulation that I corrected before signing off on the uploader. 

Ironically, it slightly elongates the real time needed for simulating the uploader, with each character on the serial link taking 91us vs 87. 

SETTING UP TO SIMULATE ARCHIVING

I have a test bench that simulates the disk drive operation so that I can test out the archiver logic. While the serial link speed is not a factor here, the physical disk drive timing does impose its own painfully slow simulation rate. 

One spin of the disk platter to get to sector 0 will take 40 ms of simulated time, or 5.6 hours of wall clock time before we read a sector. The sector itself takes 10ms to pass under the head, or 1.39 hours of wall clock to complete. 

If I set up the test bench to position the simulated disk platter at the ideal starting position, I have the chance to see a sector read and written to RAM in under 1.5 hours of real time. Still quite painful but feasible. An entire cartridge being archived will take well over a year on the simulator, which I will not attempt.  

No comments:

Post a Comment