Saturday, October 5, 2024

Modifying George Wiley's RK-05 emulator to emulate IBM 1130's 2310 disk drive and 2315 disk cartridge

GOAL

I want an emulator to install on any IBM 1130 which will emulate the internal disk drive, allowing a file on an SD card to be opened and used as if it were a real 2315 disk cartridge. This should allow the physical internal disk to spin up and move the disk arms, providing realistic sounds, but avoid lowering the nearly irreplaceable disk heads onto the rotating disk surface. 

My emulator will emit the sector pulses every 5 milliseconds to indicate the start of a new sector, although 1130 disk sectors are pairs of physical sectors thus 10 milliseconds long. It will respond appropriately when the controller requests a movement of the arm radially to a new sector. Then it will produce a string of bits that match what the real disk drive would produce if it was reading a sector. When the controller is writing to a sector, it will watch the stream, remove the 0 words and sync pulse, then grab each 16 bit word from the 20 bit stream produced by the controller. 

I store the contents of a disk cartridge in a file, organized in the same format as used by the simh based IBM 1130 simulator, thus virtual cartridges can be interchanged between simulators and real 1130 systems. The cartridge being accessed is stored in RAM on the FPGA on the emulator but transferred to and from an SD card on a processor board linked via a Serial Peripheral Interface (SPI) link to the FPGA. The SD card can hold a library of virtual disk cartridges (IBM named these the 2315 cartridge). 

PAST ISSUES 

I attempted this with development boards centered on single chip solutions (System on a Chip - SoC) which required complex interconnect channels between the ARM processors and the FPGA inside the SoC. The most serious issue is that the on-board DRAM are connected to the ARM side, which requires the FPGA logic to use interconnects to reach memory. I could never get the interconnects all activated by modifying the boot loader, in spite of every published example, YouTube video and published Intel/Altera document. 

APPROACH USED BY GEORGE

George on the other hand installed a discrete FPGA chip and a discrete Raspberry Pi Pico processor on his board. The two communicate using a SPI link. It is slightly different from my approach - I had been using the real Sector and Index pulses from the physical drive inside the IBM 1130, whereas he just generates them virtually. It has the great advantage that it works so any gremlins concerning the interaction of the C code on the Pi and the logic in the FPGA are already worked out.

IMPORTANT DIFFERENCES BETWEEN THE RK-05 AND THE 2310

The recording frequency of the IBM 2310 drive is half of that on the RK-05, 720 KHz versus 1.44 MHz. A 2315 cartridge holds 512 KW of 16 bit data, while the RK-05 cartridges are roughly twice the size. IBM invented the disk drive, evolving it from Ramac through 1300 series to the 23xx series for the early 1960s computers. 

They licensed the technology to many minicomputer and mainframe vendors, who evolved it but retained key aspects such as the 14" disk platter size and 203 physical cylinders. DEC, Diablo and others immediately doubled the bit density by increasing the frequency (with new ceramic heads). 

The RK-05 has eight or twelve sectors, which are all passed along to the DEC computer unaltered. The 2310 has eight physical sector slits but the 1130 controller passes along every other pulse, thus logically dividing the disk into four pie shaped sectors. The controller still needs 8 pulses but the emulator logic to fetch a sector of data from DRAM and feed it to the controller must deal with the 4 larger sectors instead. 

The RK-05 and every other drive derived from the 2310 will accept an absolute cylinder address and seek in one operation out to the intended location The 2310, on the other hand, will only seek one or two cylinders at a time (relative seek), either towards cylinder 203 or towards cylinder 0 which is called Home. 

My changes have to track where the 2310 arm is sitting now, so that when I get a relative seek from the IBM 1130 I have to convert it to an absolute seek for the emulator logic so it can get to the correct file contents based on the target cylinder. I also have to emit the Home signal when we are at cylinder zero as that is the only way that software on the 1130 can know the current cylinder number when the software starts using the disk. 

The 2310 and its derivatives all use the same MFM-ish recording scheme - emitting a clock pulse in every bit cell but only emitting a data pulse if the bit value is 1. Thus a bit cell is two pulse times, the first always containing a 1 for the clock and the second containing the actual data value. However, the various computer systems using the technology organize bits, words and the rest in very different ways.

The RK-05 writes each word sequentially while accumulating a checksum that it will write as the last word after the data in the sector. The 2310 writes every 16 bit data word followed by four check bits - 20 bits on disk for each 16 bits of data. The check bits emit 1 values until the total of 1 bits in the 20 bit field is an even multiple of four (looks for zero modulo 4). Thus, the final four bits can be 0000, 1000, 1100 or 1110 but always ends with a 0. There is no checksum for the 2310. 

Each 2310 sector begins with  250 microsecond long interval, called a preamble, writing zero bits (clock pulses but no data pulses). It then writes a 1 bit that is the sync word (conceptually b0000000000000001), which ensures that the disk drive knows which pulses are clock and which pulse times are for data. It also knows that where a word boundary starts, since the disk is just an undifferentiated string of bit cells. The data words begin after this. In reality, the 1130 sync word is b00000000000000011110 to complete a 20 bit word with the check bits. Various DEC drives have their own preamble durations. 

George's emulator is more generalized - it supports various DEC formats for sector counts, sector sizes, word sizes and even a format that records a header field then the data field on each sector, thus it will have two preambles and two sync words. I don't need any of these variations so I am hacking away at his logic and code just to support the 2310. 

USING TOOLCHAIN TO SIMULATE MY LOGIC TO VERIFY THE CHANGES

I modified the timing module to implement the lower 720KHz clock rate, then verified its operation by simulation. I changed the sector and index pulse module to produce the eight physical sector pulses but to only trigger the read/write logic with every other pulse, matching how the 1130 combines two physical into one logical sector. This was also simulated successfully. 

I then updated the sector read logic to handle the 20 bit words, format of the sector and timing of the 2310. I worked through this with the simulator until everything worked as I wished. 

Going forward, I will modify the disk write module and the seek module, making them behave as they should for the 2310. Once they work the C code on the Raspberry Pi needs to be updated to be certain it reads the IBM 1130 Simulator (simH based simulators) format disk files rather than the more flexible file format adopted by George. The last steps are electrical - getting the right signals with the right polarities and voltage ranges to interface with the IBM 1130 controller logic. 




No comments:

Post a Comment