/*
* HOME(PROJECTS) || RESUME || LINKS || ABOUT
*/

Cat-644

Project links


Hackady.io Project Page This is where the latest news on this project appears
Github repository contains latest code and schematics

Update

I am working on the Operating System for this computer as a project for the 2018/09 Retrochallenge. It is called kittyOS




Introduction

The Cat-644 is an 8-bit computer built around an Atmega-644 microcontroller. I had always wanted to built my own computer 'from scratch' starting around a microprocessor or microcontroller. There are many microcontrollers available, but I chose this particular one because it is easily available in a DIP package, is fast compared to classic 8-bit computers of the 1980's, and there is a large amount of reference material available due to the popularity of Arduino. The Atmega-644 is the larger version of the popular Atmega-328. There are also a few examples of directly driving VGA and NTSC signals from this series of microcontrollers.



Hardware


The AVR is what is referred to as a Harvard architecture. The program and data spaces are seperate. The AVR can only execute instructions out of the flash program memory, not from RAM. This limitation is addressed by having user programs written in an interpreted language. All the most processor intensive operations, such as drawing text or sprites into the framebuffer, disk I/O, etc will be written in C or assembly language, and run out of flash. The AVR also has self-programming capability: It can write to its own flash. If not all of the flash is taken up by the base system code (there is likely to be a large free area), these free flash pages can be made available to the user. The user could install short, custom assembly-language routines into this flash area. The flash has a limited number of write cycles (around 10,000), so these custom software 'devices' should not be re-written often. The idea is that some programs may require a flash routine be semi-permanently installed. When other programs are run, the custom flash routine is not rewritten. Flash routines programs install shouldn't be overwritten until flash is full. If the working set of required flash routines is kept small, erasing and re-writing a flash page should be a relatively rare event. Suppose every day all flash pages are rewritten 5 times. (That is a lot.) One year of operation is only 1825 rewrite cycles. Five years of operation come out to 9125 rewrite cycles. The plan is to grow a small number of reusable shared flash routines that many programs can share.


Comparison to 1980's microcomputers



CPU Comparison

AVR: The CPU runs at 20 Mhz. Most instructions complete in 1 or 2 clock cycles. 32 8-bit registers, allowing many values to be kept in single-cycle access time. Depending on the video mode of the computer, between 50% and 90% of the CPU is left to the display generation. This gives an effective speed of 10 or 2 Mhz.

6502: Typically runs at 1 or 2 Mhz. Most instructions take at least 2 clock cycles. Very limited number of registers: most operations involve accessing RAM. A typically quoted figure for a 1 Mhz 6502 (such as Commodore 64) is 250,000 instructions per second.

Interpreter: Most instructions in the interpreter use 6 (no memory access) or 12 clocks. Assume 10. At an effective clock speed of 10Mhz, this comes out to 1 million emulated instructions per second. At an effective clock speed of 2Mhz, this comes out to 200,000 instuctions per second. The emulated instructions set operates on 16-bit values instead of 8-bit.



Memory

The AVR contains 4k of internal memory. Some 1980's microcomputer have less than this (consider the Timex Sinclair 1000). The commodore VIC-20 has 5k of memory. The CAT-644 contains 128k of SRAM, which can be used as either screen framebuffer, or by user programs as data. (It is technically possible to use it to contain interpreted programs, but currently the interpreter requires the program code be in the internal memory.) The Commodore 64 has 64k of RAM: That's its name



Display

Unlike most 1980's computer which required the use of a TV, the Cat-644 uses the VGA interface. The video resolution can be either 256 by 240 pixels, or 512 by 240 pixels, both at 64 colors. (256 colors is technically possible fairly easily.) The commodore 64 can output up to 320 by 200 pixels, and can, with various tricks, output 128 different colors. There are severe limitations (and very impressive clever tricks) necessary to achieve this. With the cat-644, each pixel can be individually assigned any color. Smooth wrap-around scrolling, and double-buffering is easily accomplished. The Commodore 64 supports monochrome hardware sprites. The Cat-644 supports full-color software sprites, with the rendering performed by the AVR during the VGA blanking interval, at a 20 Mhz clock speed.



Sound

Some 80's computers had no sound capabilities. The original IBM only had a beeper. The Vic-20 had a few 'voices' where you could play multiple tones on top of each other. The Commodore 64 took this further by offering FM-synthesis. The PC had the Adlib card which included a Yamaha FM symthesis chip. (OPL) The Sound Blaster added to this by offering PCM. Modern computers are PCM only, and emulate everything else. The Cat-644 offers simple PCM sound by means of PWM. If the PWM signal is set to a very low frequency, then it can offer the original IBM-PC 'beeper' functionality. There is no means to generate full FM synthesis. This means sound effects can be any short recording. These is probably enough CPU to allow mixing of a small number of either synthesized tones or PCM samples. I would expect Vic-20 style voices with a PCM channel. I have done very limited tests of the sound hardware: I have essentially tested that the hardware works, and the capabilities of it will be entirely up to whatever I can fit into the software.



Repeating some history

Display: The way the video is generated by the Cat-644 is extremely similar to how the Timex Sinclair generated video. The TS1000 'jumps' to video memory. The bus is put in a mode where the CPU 'sees' NOP instrcutions, so once per clock the program counter increments. This incrementing program counter is really just counting through the character ROM to a shift register, and puts the pixels on the screen. It is abusing the CPU as abinary counter. As a result, 90% of the CPU is taken up by the display. It is such a performance problem, that the Sinclair has a 'fast' mode, where the screen is temporarily garbled which it is processing. The Cat-644 does something similar: It outputs counting addresses on the external address bus by repeatedly incrementing a register and outputing its value to the bus. Again, about 90% of the CPU is taken. A 'fast' mode is also provided, where every other line of the screen is output as black, freeing up the CPU. The display is line-doubled in 'slow' mode anyway, so this only creates a scanline effect.


Bus conflict: Due to the limited number of pins on the AVR, the external memory address lines and the SPI bus are shared. This means that SPI devices, such as the SD card, will interrupt the display. This means that to keep the display, the disk must be read or written one block at a time during the vertical blanking interval OR it will temporarily garble the display. The TS1000 also cannot maintain the display when loading from cassette tape.

Weird memory rules: AVR code can only run in flash. The 4k internal SRAM is directly available to the processor. The external SRAM must be accessed through special code: A user must call a function to copy data into or out of this 'extended memory.' DOS programmers will remember IBM PCs had (still have) a 'real' mode where only the first 1MB of memory is accessible to the program. The user must call special functions to copy data in and out of either expanded (A strange bank-switched memory model) or extended (special memory on a 286 or higher) memory. You also can't run code out of extended memory: it is for data only. Also, 286's had special handling for the A20 address line. The CAT-644 connects A0 to A7 directly on the bus, uses a latch for A8 to A15, AND connects A16 to a spare I/O pin, making A16 special.


'Metal junk' PCM sound: Sound output is done by PWM, at a sample rate of about 11 Khz, with a resolution of 8-bit. This is around 'Sound Blaster 1.0' sound capabilities. Like the original sound blaster, I have no output lowpass filter, so the sound is aliased and harsh. Unfortunately, I have no Yamaha synthesizer chip, so it is PCM only.