The IBM System/360 was a groundbreaking family of mainframe computers announced on April 7, 1964.
System/360 was an extremely risky "bet-the-company" project for IBM, costing over $5 billion, but
the System/360 ended up as a huge success,
setting the direction of the computer industry for decades.
The S/360 architecture was so successful that it is still supported by IBM's latest mainframes, almost 60 years later.
I'm developing a microcode-level simulator1
for the IBM System/360 Model 50
(link to the simulator);
this blog post provides background to understand the Model 50 and the simulator.
Screenshot of the simulator running in a browser.
The radical decision behind System/360 was to use a single architecture for the
entire product line of computers.3
The name symbolized “360 degrees to cover the entire circle of possible uses.”
Using a common architecture seems obvious now (e.g. x86),
but prior to the System/360, IBM (like other computer manufacturers) produced multiple computers with entirely incompatible architectures.
Internally, the different System/360 models had completely different implementations to support a wide range of cost and performance levels:
the fastest model was over 1000 times as powerful as the slowest.
Low-end models used simple hardware and an 8-bit datapath while advanced models used wide datapaths, fast semiconductor registers, out-of-order instruction execution, and caches.2
Despite these internal differences, the models all looked the same to the programmer.
Architecture of System/3604
You might expect a computer architecture from the 1960s to be simple, but System/360 is remarkably complex, partly because it merged six computer families into
one architecture.
It is a 32-bit architecture that supports many datatypes.
As well as 32-bit integers and half words,
it supports decimal arithmetic on numbers up to 31 digits long.
Floating-point arithmetic supports short (32 bit), long (64 bit), or extended (128 bit) values.
The processor also supports character strings up to 256 bytes long.
The System/360 instruction set has about 100 different instructions and several addressing modes.
Some of these instructions are straightforward arithmetic, logic, or control operations.
Other instructions are more complex, such as the "character move" that copies up to 256 characters in memory,
or the floating-point instructions.
One of the most complex instructions is "edit",
which formats a sequence of decimal digits for printing, for example inserting commas, a minus sign, or decimal point; removing leading zeroes, or
filling leading spaces with characters.
The number 1234567 could be "edited" into the string "$***12,345.67" for printing on a check.
Keep in mind that this is a single instruction, not a library function like printf
.
IBM System/360 Model 50 control panel. The dataflow diagram in the upper right illustrates the system's internal design. Photo by
Sandstein,
CC BY-SA 3.0.
The System/360 architecture also included I/O, defining IBM's "channel" architecture.
A channel is a programmable I/O subsystem with its own instruction set.
On larger systems, the channel was an independent unit connected to the computer. But smaller systems such as the Model 50 used the same microcode engine to run
CPU programs and channel programs.
The point is that System/360 has a large and complex instruction set. A single instruction could result in hundreds of memory accesses and processing steps.
The dense instruction set helped programmers to cram programs into the extremely limited core memory of the 1960s.
However, the complex instruction set was a problem for the computer designer, who had to implement the complex circuitry to carry out these instructions.
The solution was microcode.
The System/360 Model 50 in a datacenter. The console and processor are at the left. An IBM 1442 card reader/punch is behind the IBM 1052 printer-keyboard that the operator is using. At the back, another operator is loading a tape onto an IBM 2401 tape drive. Photo from IBM.
Microcode
One of the hardest parts of computer design is creating the control logic that tells each part of the processor how to carry out each instruction.
In 1951, Maurice Wilkes came up with the idea of microcode: instead of building the control circuitry from complex logic gates, the control logic could be replaced with code (i.
e.
microcode) stored in a special memory called a control store.
To execute an instruction, the computer internally executes several simpler microinstructions, specified by the microcode.
Microcode turns the processor's control logic into a programming task instead of a logic design task.5
Microcode played a key role in the success of the System/360, helping IBM produce a line of computers with the same instruction set architecture but widely different implementations.
It also allowed a processor to support different instruction sets;
System/360 machines could be backward compatible with customers' older machines6
so customers could keep their existing software.
For these reasons, the System/360 computers used microcode unless there was a compelling reason not to.7
Another advantage of microcode is that it provides an easy way to fix design flaws and bugs in the field. Instead of modifying the hardware, a service engineer could
replace the microcode with a new version. The photo below shows a copper sheet with microcode etched into it for the Model 50.
Microcode can be implemented in a variety of ways.
Many computers use "vertical microcode", where a microcode instruction is similar to a machine instruction, just less complicated.
The System/360 designs, on the other hand, used "horizontal microcode", with complex, wide instructions of up to 100 bits, depending on the model.
These microinstructions were more like a collection of fields, each controlling low-level signals.
This improved performance since multiple parts of the processor could be controlled in parallel.
Hardware of the Model 508
The Model 50 was roughly in the middle of the System/360 lineup, providing a powerful mainframe that could be used by a medium-sized business or university department.
The Model 50
typically
rented for about $18,000 - $32,000 per month (equivalent to $120,000-$200,000 a month in current dollars).
IBM S/360 Model 50. The console was attached to the main frame, about 5 feet deep. The storage frame and power frame are the black cabinets at the back. Photo from
Pinterest.
The Model 50 occupied three large cabinets, each 5 feet long, about 2 feet wide, 6 feet tall, and weighing nearly a ton each.9
The main frame, behind the console, contained the CPU, I/O channel circuitry, and the microcode storage.
Behind this, the power cabinet contained the computer's power supplies.
To the left, the cabinet at the back contained the main storage: one or two core memory modules, each with 128 kilobytes of memory.
(I wrote in detail about the Model 50's core memory earlier.)
The computer's cables ran under a raised floor to the I/O devices, which typically included tape drives, a card reader, printers, disk drives, I/O controllers, and so forth.
The System/360 processors weren't implemented with integrated circuits, but with SLT (Solid Logic Technology) modules, hybrid modules that contain a few transistors, diodes,
and resistors.
A typical module implemented a logic gate, so it takes many circuit boards full of modules to construct the processor.
A logic board using SLT modules. Each square metal can is a module.
Like most computers of the 1960s, the Model 50 used magnetic core memory, with a tiny ferrite ring to store each bit.
The photo below shows a core plane that stores 32768 bits (along with 512 bits for I/O).
A stack of 18 planes formed a 64-kilobyte memory module, with two parity bits.10
A Model 50 core plane is arranged as a grid of cores. The Y lines run horizontally. X and sense/inhibit lines run vertically. The sense/inhibit lines form loops at the top and bottom. Each of the four vertical pairs of blocks has separate sense/inhibit lines. Each core plane was about 10¾ × 6¾ × ⅛ inches.
The Model 50's internal architecture
To the programmer, all processors within System/360 look the same; internal circuitry, however,
may be entirely different.
It's important to keep in mind that the internal architecture of the Model 50 is very different from the architecture that the programmer sees.11
In particular, the processor's internal registers are invisible to the programmer.
The programmer instead sees 16 general-purpose registers and 4 floating-point registers, but to the processor these are part of the 64-word local store, a small high-speed core memory.
The diagram below shows the complex data flow through the computer.12
The black boxes are internal registers; the processor has a surprisingly large number of registers, used for a variety of purposes.
The internal components are connected by buses.
Most of the internal communication is over the 32-bit buses, shown in black. The 8-bit "mover" bus is shown in gray.
This diagram shows the data flow through the IBM 360/50 and appears in the upper-right corner of the console. I drew this version since I couldn't find a clear photo of it.
The heart of the computer is the 32-bit adder, which performs addition.
For subtraction, the argument is complemented by the True/Complement circuit (TC).
The adder has an associated shifter to perform bit-shifts; this is especially important for multiplication, division, and floating-point calculations.
Operating in parallel with the adder is the "mover", which operates on bytes. It can extract a byte from a 32-bit word, as well as manipulating 4-bit pieces of the byte.
The mover also performs Boolean operations (AND, OR, XOR).
(Unlike most processors, the Model 50 separates arithmetic and logical operations, instead of having an ALU perform both.)
The computer's main core-memory storage is on the left. To access memory, an address is put in the Storage Address Register (SAR). Data is then read or written through the Storage
Data Register (SDR). To the left of main storage, is the Instruction Address Register (the Program Counter or PC in modern terms).
At the top is the Local Store, 64 words of high-speed core memory that holds the programmer's registers as well as some internal storage.
The local store is accessed through the Local Store Address Register (LSAR).
At the right are the I/O channels: the low-speed Multiplexor Channel and the high-speed Selector Channel.
You can think of these as DMA (direct memory access) paths for I/O.
The multiplexor channel communicates over an 8-bit bus through the mover, while the selector channel communicates over a 32-bit bus.
Although the channels are conceptually separate from the processor, the channels use the same buses, circuitry, and microcode engine as the processor.
This limits I/O performance compared to more advanced System/360 models that have independent circuitry for the channels.
An example of the microcode
As you can see, the processor has many registers and functional units. The microcode needs to control these components to carry out program instructions.
The microcode architecture is very complex and takes over 100 pages to explain thoroughly,15
so I'm only able to scratch the surface here.
Each microinstruction is 90 bits long and performs multiple tasks.
In the documentation, IBM used an 11-line block to represent each microinstruction, showing all the activities that are taking place in parallel.
A sample microinstruction is shown below, part of the microcode that implements an add instruction.
At this point, earlier microinstructions have fetched and decoded the instruction and put the arguments into the R and L registers.
This microinstruction performs the actual 32-bit addition, but there's a lot more happening than just the addition.
One microinstruction, part of the integer addition code. This microinstruction is at micro-address 0220.
Starting with the line "R+L→R" (red), this indicates that the ALU is taking inputs from registers R and L, and the result is going into the R register.
In other words, the two arguments are added.
The result R is stored into the desired programmer-visible register in local storage (blue).
The processor registers FN and J select the address in local storage.
Meanwhile, the SETCRALG
line sets the Condition code register based on the sign (i.e. "algebraic" value) of the result, indicating if the result is positive,
negative, or zero.
The line "BC⩝C" indicates that signed overflow is detected and used as the carry flag14
while CAR (yellow) indicates the microcode branches on this carry (overflow) value.
Thus, the microcode will take one path if the addition was valid and a second error path if overflow occurred.
A microinstruction can "emit" an arbitrary 4-bit value (green) which can be used in a variety of ways.
In this case, the binary value 1000 is emitted, fed into the W register, and then the M register, for use by the next microinstruction.
As you can see, the CPU performs many activities in parallel for one microinstruction, which increases the computer's performance.
All the activities of a microinstruction are
encoded into a 90-bit word consisting of 28 fields.13
The microinstruction discussed above (micro-address 0220) is highlighted in the documentation below.
A single microinstruction is very complex, which is why it takes an 11-line block of text to represent it.
Part of the
microcode listing. The previously-discussed microinstruction is highlighted. Note that the micro-address 0220 matches the address in the upper-left corner of the microinstruction diagram.
The processor documentation contains hundreds of pages of microcode;16 one page of the floating-point multiply code is below.
Each box is one microinstruction, and the lines between them indicate the complex control paths.
I'm not going to explain this microcode,17 but I wanted to show its complexity.
Part of the floating-point multiply microcode. (Click for a larger view.) From
ALD vol 18.
The console
The discussion above has shown the complex internal architecture of the Model 50. The numerous lights and controls on the console19 provide a view into this internal state.
There were three main uses for the console.
The first use was basic "operator control" tasks such as turning the system on, booting it, or powering it off, using the controls in the lower section of the console.
These controls were consistent across the S/360 line and were usually the only controls the operator needed.
The three hexadecimal dials in the lower right selected the I/O unit that held the boot software.
Once the system had booted, the operator generally typed commands into the system rather than using the console.
Control panel of the IBM System/360 Model 50. This panel has marginal check controls for auxiliary storage in the upper right, replacing the dataflow diagram.
The second console function was "operator intervention": program debugging tasks such as examining and modifying memory or registers
and setting breakpoints.
The lights and toggle switches in the lower half of the console were used for operator intervention.
The operator could enter a 24-bit address using the row of 24 toggle switches, and enter a 32-bit data value
using the row of 32 toggle switches above.
The lights allowed the contents of memory to be examined.
With other switches, the operator could set a breakpoint, single-step through a program, and perform other
debugging operations.
The third console function was system maintenance and repair performed by an IBM customer engineer.
The customer engineering displays took up the top half of the console and provided detailed access to the computer's complex internal state.
To save space, the Model 50 had four roller knobs on the right side, with 8 positions for each knob.
Each knob position selected a different function for the row of 36 lights (32 bits plus parity).
The legends above the lights rotate with the knobs, showing the meaning of each light.
For example, one position would display the L register, while another position would display the current
microinstruction.
In the photo below, the upper roller and lights are displaying part of the microcode currently being executed (ROS = Read Only Store).
The roller below shows some of the internal registers and counters.
Closeup of two rollers and the associated lights.
Finally, the voltmeter and voltage control knobs in the upper left of the console were used by an IBM customer engineer for "marginal checking". By raising and lowering the voltage levels, borderline components could be detected and replaced before they caused problems.
The simulator
The simulator is at righto.com/360 and the code is on Github.
I implemented the simulator in JavaScript so it can run in a browser. It runs a sample program by executing the Model 50's microcode, simulating each microinstruction
and the hardware.
Each microinstruction is displayed graphically, along with the current instruction, the registers, the local storage, and core memory.
It displays the console lights accurately based on the internal state, on a zoomable virtual console.
Each row of lights can display 8 different elements, which you can change by clicking on a roller.
You can step also through the microcode, one microinstruction at a time.
This simulator is still under development so don't expect it to work perfectly. I also haven't implemented the toggle switches, so you can't enter a program from
the console yet.
I also need to implement the I/O system, which has its own registers and a different microcode format.
To build the simulator, I extracted the binary microcode from the listings using a custom OCR tool.
I implemented the hundreds of micro-operations, which were tricky to get correct.
While most micro-operations are simple operations such as moving a register to the bus, some microinstructions are much more complex, especially for floating-point
operations.20
Another complication is that a microinstruction performs many tasks in parallel and it was hard to determine the exact order in which to perform them.
My eventual goal with the simulator is to move it into the physical world. Specifically, I plan to drive the lights on CuriousMarc's Model 50 control panel to make the panel
operate accurately. We also plan to hook up his IBM tape drives and card reader so we can have all the pieces
of a Model 50 mainframe working together, except for the processor itself.
I plan to port the simulator to C so I can run it in a microcontroller to drive the physical console.
An FPGA implementation is another possibility; this would provide the maximum speed, but would be harder to implement.
I announce my latest blog posts on Twitter, so follow me @kenshirriff for updates and future articles. I also have an RSS feed. Thanks to
Richard Cornwell for discussion and data.
Notes and references