Assembling an 8-bit computer: how to reduce the number of chips to six


The combination of the old trick with NTSC color coding and modern hardware allows you to build a surprisingly workable machine.

In 8-bit systems, there is something permanently attractive: you can build an autonomous system powerful enough to support adequate user interaction, but simple enough to assemble and program it yourself. Most modern 8-bit machines created by amateurs are tied to classic processors that lived in the golden age of home computers in the 1980s, when millions of TVs were used as displays. Initially, the idea was to build my car based on the Motorola 6809 processorfrom the same era. I tried to use as few chips as possible, but despite my efforts, I still needed 13 additional chips to work with RAM and serial data transfer. Then I thought: what if I use a more modern 8-bit processor? How much can I reduce the number of chips I need?


As a result, I assembled a car on it, which was called Amethyst . Like any home computer, it has a built-in keyboard and can output audio and video. It also has a high-level built-in programming language so that users can write their own programs on it. I managed to reduce the number of microcircuits to six: ATMEGA1284P CPU, USB-interface and four simple integrated circuits.

The 2008 ATMEGA1284P (or 1284P) has 128 kilobytes of flash memory and 16 kilobytes of RAM. It can operate with a frequency of up to 20 megahertz. It has onboard integrated serial controllers and 32 digital inputs / outputs.



Thanks to the built-in memory and serial interfaces, the need for many auxiliary chips disappeared. I could directly generate audio, interrupting and applying a signal to the input / output with different frequencies. Thus, I learned to give out a tone that, however, possessed the characteristic sharpness of a square wave. But what about generating an analog video signal? Will this really require special equipment?

Standard trick


At the end of 2018, I saw a trick that Steve Wozniak used in the 1970s to implement color graphics support in Apple II. In the USA, this trick was used for color broadcasting in the NTSC system back in the 1950s.

Initially, American television was only black and white and used the fairly simple NTSC standard (developed by the National Committee for Television Systems). To form an image on the screen, an electron beam traced points on its surface, row after row. The amplitude of the received video signal determined the brightness of the beam at any given location along the row. Then in 1953, NTSC was upgraded to support color television, while maintaining compatibility with existing black and white TVs.

Engineers decided to present color information in the form of a high-frequency sinusoidal signal. For this, the subcarrier was divided into two components with a phase shift of 90 °, each of which underwent modulation. The result was a signal modulated in both amplitude and phase. The amplitude of the signal determined how saturated the color should be. This high-frequency chroma signal was then added to the low-frequency luminance signal to create the so-called composite video signal. This method is still used for many televisions and cheaper displays.



« »: , [ ], - , [ ]. . [ ] , : . [ ], .


A black and white TV perceives a color signal as noise and ignores it. But a color TV can separate the color signal from the luminance signal using filter loops.

In the 1970s, engineers realized that this filtering scheme could be very useful for home computers because it allows a rectangular digital signal to simulate most of the composite analog signal. The stream of zeros sent by the computer to the TV will be perceived as a constant low-frequency analog voltage, that is, black. The flow of units will be considered as a constant high-frequency voltage, that is, white. But with a sufficiently high bit rate, more complex binary structures will arise that the high-pass filtering schemes recognize as color signals. This trick allowed Apple II to display up to 16 colors.

At first, I thought that I needed to switch the input / output pin very quickly in order to directly generate a video signal. However, I soon realized that with my 1284P running at 14.318 MHz, I couldn't switch it fast enough to display more than four colors. The fact is that its built-in serial interfaces would need two clock cycles to send one bit, which would limit my clock frequency to 7.159 MHz. Apple II used fast direct memory access to connect its external chip to the video output, while its CPU was busy with internal processing. But, since the RAM of my computer is integrated into the chip, I could not use this approach.

So I looked into my drawers and pulled out four 7400 series microcircuits - two multiplexers and two parallel-serial shift registers. I was able to install eight 1284P pins in parallel and send data from them simultaneously to the multiplexers and shift registers, which convert them into a high-speed serial bit stream. Thus, I learned how to generate bits fast enough to display about 215 different colors on the screen. However, I had to pay for it with my computing power: video processing constantly eats up 75% of the processor’s resources.



Compact computer


Amethyst is a single board computer. It is assembled from only six integrated circuits - a processor, a USB interface and four 7400 series microcircuits, which are used to create a 215-color image. The keyboard switches are soldered directly to the board, which also supports audio and four serial I / O connections for peripherals such as game controllers and storage devices. You can write programs and run them thanks to the built-in virtual machine Forth.

I needed a lightweight programming environment for users, which made me choose Forth instead of the traditional Basic. Forth is an old programming language for embedded systems, it supports interactivity and is able to efficiently compile code. With it, you can do quite a lot using the minimum amount of resources. Since the 1284P does not allow compiled machine code to be executed directly from its RAM, user code is instead compiled into intermediate bytecode. This bytecode is then fed as input to a virtual machine running from 1284P flash memory. The virtual machine code was written in assembler and manually optimized to make it as fast as possible.

As an engineer working for a company that produces 3D laser printers, I have access to advanced laser cutting machines. So I easily designed and manufactured a wooden case (I spied the wood finish on the Atari 2600 ). The mechanical keyboard switches were soldered directly to a single Amethyst circuit board. This keyboard has one curious feature - the absence of the usual large gap. Instead, just a button, modestly located above the Enter key.

The complete schematic, PCB files for the circuit board, and source code are available in my GitHub repository . So you can create your own Amethyst or even improve my project. What if you can figure out how to save a couple more chips?


All Articles