Friday, February 3, 2023

Developed address computation module to generate RAM address for read or write of a word

VIRTUAL CARTRIDGE FILES ON A SD CARD

The ubiquitous simh simulator package has been used to create simulators for a wide range of computers, among them the IBM 1130. Disk images for use with that simulator are in a specific format which I have chosen to use for this project. That allows interchange of disk files easily between the simulator running on a PC and the actual 1130 system using this virtual cartridge system. 

The disk cartridge consists of up to 203 cylinders, each have a head on both its upper and lower surfaces. The surface holds four sectors of data in one rotation, each sector consisting of 321 words of data. The IBM 1130 word size is 16 bits, consisting of the high order bit 0 down to the least significant bit 15. 

Therefore, the disk files used with simh have groups of 642 bytes that hold the 321 contiguous words of a sector. These groups or sectors are arranged with sector numbers 0 to 3 under head 0 followed by sectors 0 to 3 under head 1. That constitutes a cylinder of information, eight sectors in total, which is 2,568 words or 5,136 bytes. 

Cylinder 0 starts at the beginning of the disk file, cylinder 1 is at byte 5,136, cylinder 2 is at 10,272 and the final cylinder begins at byte 1,037,474 and extends to the end of the file at byte 1,042,607. Within any cylinder we see sector 0 of head 0 at the start, sector 3 of head 0 is at 1,926, sector 0 of head 1 is at 2,568 and sector 3 of head 1 is at 4,494 into that cylinder. 

INDEXING TO A SPECIFIC WORD FOR READING OR WRITING

Cylinders are eight bit binary values, heads are single bit, sectors are two bit values and words within a sector requires a 9 bit binary index. Simply combining the 11 bits of cylinder & head & sector gives us the relative sector number inside the file, which when multiplied by 642 yields the first byte address of the sector. 

Adding the word number (times 2) indexes within that sector to the word itself we are interested in fetching. This must be added to the base of our memory mapped file over inside the Linux system, which points us at the word we want to read or write. 

In operation, the operator will select one of the virtual 2315 disk images from the SD card, it will be opened under Linux and memory mapped. The resulting location for the memory mapped file is sent over to the FPGA where it is kept as the base for all this arithmetic. 

SIMULATION TO VERIFY CORRECT OPERATION

I set up a testbench which provides a base address, which will eventually come from the Linux side but is arbitrarily chosen for unit testing purposes. I then vary the word, sector, head and cylinder values, watching the generated memory address to verify that it is the correct location in Linux memory to grab our intended word of the opened virtual cartridge file. 

I registered the address with our FPGA clock but let the multiplier and adders run outside so they settled down by the time I latched in the final result. 

VERY SIMPLE AND WORKS PROPERLY

The simulations showed this producing correct addresses with clean transitions at clock edges, including properly generating a result with the highest possible valid word address in the disk file. 

It is time now to move on to prepare the Terasic DE10-Nano board with the appropriate Linux image on the hard processor side (HPS) so that I can begin to design and test the bridge traffic between the HPS and the FPGA sides. 

No comments:

Post a Comment