Category CP/M computer

CP/M computer

SCHEMATICS COMING SOON

Introduction

Although from the mid 1970’s and with limited memory, CP/M machines are still very useable today. Some of the available software programs are marvels of engineering. There were C, COMAL, Fortran and Pascal compilers available, as well as wordprocessors, text editors, spreadsheets and games.

The first CP/M machines consisted of a CPU, RAM, a boot ROM and one or two serial ports. The CP/M operating-system was designed for for use with 8″ floppy disks. These disks were large and could hold 180kBytes each. Later the smaller 5 1/4″ disks were adopted.

The CP/M machines did not initially come with a monitor and keyboard. Instead a teletype terminal and a line printer was used for input and output, respectively. Later on VT100 terminals were used, and around 1980 the typical CP/M machine came with the VT100 terminal built in. However, for software compatibility the built-in VT100 terminal and the main computer unit were still, two separate units, but on a single PCB.

In this post, I will design and built a CP/M machine using standard components. A VT100 terminal is also in the works, but it will be a plug-in board. For mass-storage, I will be using SD Cards.

A lot of software has been written for CP/M, and I imagine my ‘clone’ is ideal for places where a VDU, keyboard and floating point algorithms are required. I  have seen CP/M machines used  for telescope control, tracking stars, for example. After all, a CP/M machine is SO much easier to program than a microcontroller.

Hardware Overview

The machine will be using a 4 MHz Z80 CPU, an 8-bit ROM, a static RAM and some control logic. The supply of Z80 SIOs is unreliable, so I will use tWO 16550UARTS  for the serial portS. I initially wanted to use Compact Flash instead of the floppy drives, but I couldn’t find the cf connectorS locally, so I changed to SD Cards. I will use a couple of TTL gates to interface these.

I have a small wall-mounted PVC enclosure  in mind, and if there is room on the PCB, I plan to include an 8-bit input/8-bit output port too.

CPU

The CPU is a standard 4MHz Z80 CPU.  These days static RAM is really cheap, so the memory refresh pins of the CPU associated with dynamic RAM are unused. I will use a single interrupt for the serial ports.

The CPU needS a single quad-OR gate to combine the RD, WR, IORQ and MEMRQ signals into something useful.

There is no other support logic required to get this CPU running with the exception of a clock signal.  

Clock and Reset Logic

The 16550 serial port chip normally requires an 8 MHz clock. However, I have decided to use a 4 MHz clock to save logic. Obviously all serial-port speeds will have to be re-programmed. i.e. 19200 Baud at 8 MHz will only be 9600 Baud at 4 MHz.

Two resets switches, or a single multi-position switch, is used on most CP/M machines. These provide: 1) A hard reset that will re-boot the computer, and 2) a Soft reset which simply restarts the CP/M system using the program already loaded into RAM.

Memory

Under CP/M, all programs run from RAM. During power-up, a boot-ROM in the lower part of the memory  is used to load the operating system from the floppy disk into the higher part of RAM. When done, the boot-loader will then jump to an address in RAM and perform an I/O write to switch out the boot ROM and switch in the lower RAM.

The memory on my CP/M computer consists of  a Boot-ROM and a Static RAM. A flip-flop that is reset during a hard reset will switch in the Boot-ROM. An IO Write will set the flip-flop and switch out the ROM. Apart from that, there is nothing special about the memory circuit 

I wanted to do some memory bank switching, but the CP/M operating system uses both the lower and the upper memory areas, and swapping memory banks in the middle of the memory map is really not a good solution, so I have decided against it.

Serial I/O

Only one serial port chips is required. As I use my own VT100 terminal hardware, I can connect that directly to the Z80 bus. A MAX232 is used to convert TTL to +/-12V levels.

SD Cards

SD cards are basically using the SPI data format. The Z80 doesn’t have any I/O ports, so I have added these. For people used to working with microcontrollers like the Microchip PIC, this is a real waste of TTL gates, but in the late 1970’s this was how it was done.

PCB Layout

The CP/M computer consists of two PCBs. I have done this to fit it into the PVC enclosure that I had available. An alternative layout would be on a single 10×16 cm Euro-Card. If there is any interest in the eurocard form-factor, let me know.

Software

Two pieces of software is required to get CP/M to run. The first is the Boot-ROM. The second is the BIOS. The function of the Boot-ROM is explained above. The BIOS is a bit of code that translates CP/M function calls like “load” and “save” into hardware specific I/O operations.

Boot-ROM

In order to understand the Boot-ROM, we need to look at the CP/M file-system and how data is arranged on the floppy drive.

BIOS

The standard BIOS code that comes with CP/M needs to be modified to support our hardware. In particular, we need to handle the SD Cards. On these cards, data is shifted out serially, and one block of data is 512 bytes each. On the original 8″ Floppy drives, data was transmitted byte-wise, and a blocks-size of 128 Bytes were used.

Finally, we need to handle the serial-ports, so that programs like PIP can run successfully.

Comments


Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.