Posts

Showing posts from 2021

8-bit CPU: It's alive!

Image
With updated version of Clock module complete, the only thing missing is the Control Logic. Let's build it to complete the CPU. Control logic The main idea of the Control logic is the same as in Ben Eater's CPU, with the difference that I'm using 28C64 EEPROMs. The address line usage is a bit different, through: 3 lines from microstep counter, allowing 8 microsteps in total 4 flags from Flags register 6 lines from Instruction Register, allowing 64 instruction opcodes This uses all 13 address lines, whole 8 KiB of the EEPROM, no room for byte-select bit, the contents of each ROM will have to be different. Notice, that I moved Flags bits to the middle of the input address. I like this layout better, because now all bytes for an instruction are grouped together. It also allows for easy expansion to 256 opcodes, the data layout will stay the same, I'll only need to replace EEPROMs with larger ones (28C256) and connect remaini

8-bit CPU: Quarter-Clock

Image
My Clock module worked fine (to be honest, I did not use it that much), but I have some new ideas to try out. Also, as I'm approaching the end of first stage of my build, the requirements for the Clock has changed. I could try to "patch" the existing module, but it's actually easier to re-build it on a new breadboard.   At first, however, I had to play around with Digital simulator, it might have been quite hard to iron out the details building hardware directly. Here's what I came up with: There's a lot is going on, I'll try to explain step by step.

8-bit CPU: Generating machine code

I developed some demo programs using an assembly-like constructs in Python. All is nice and it utilizes real hardware for calculations. Still that is just Python code running on PC and sending control signals to my registers, ALU and memory. Eventually, I'll have to run the code on the 8-bit computer autonomously. For that I need to convert it to sequence of binary instruction opcodes and arguments - machine code. I've also tried to hand-assemble some simple programs, but it feels quite tedious and error-prone.

8-bit CPU: Putting it together

Image
Looking at modules I have built so far, I realized that I have almost all I need for a complete computer. Long time ago I built Clock module and Program Counter . I've just updated Output module , There's ALU, 2 general-purpose registers, Flags register . Also I have RAM module and MAR register . I even have an Instruction Register. What's missing? Control Logic, of course!

8-bit CPU: Display updates

Image
The display module turned out quite nice, but there were some flaws I wanted to fix. In order to connect the module to the Computer, some additional hardware has to be added as well. Flicker I noticed that with a corner of an eye I can catch some flickering, but when I at it directly, it appears to be fine. Ben used 10 nF capacitor and 100 K resistor with 555 timer. I had no 100 K resistor, so I used 330 K instead. If we put the values in NE555 calculator , it gives around 218 Hz. Each display switches 4 times slower, resulting in 54 Hz. My eyes have always been sensitive to flicker, I remember when old CRT monitors gave me headaches with their 60 Hz. After short consideration I replaced it with 10 K resistor. It pushes up the frequency to almost 7 kHz. While this may feel as an overkill, all chips are rated for much higher frequencies than that. And now there definitely is no visible flickering. Mode indication I found out that it is a bit confusing not to know in which mode

8-bit CPU: Test module and Python-assembly code

Image
I have ALU block and Memory block, as a next step I wanted to connect both of them to my Arduino test device. It worked, but was very clumsy (3 devices, held together just by wires). I decided to re-build the Test module differently - on breadboard, so I can connect modules together. It is an Arduino Nano , driving a pair of 74HC595 shift registers. To expand further, 3 pins from each shift register drives 74HC138 demultiplexers. Control lines from demultiplexers are for Out and Load lines (7 for each type), the rest are for general purpose (for example - ALU's Subtract). I played around with more tests, implemented ld and st "instructions" (load a register from memory location and store register value in memory) in my Python-assembly. Then I started to think: there are 2 registers, ALU, Flags, memory. I even have some sort of assembly language. What if I try to implement something more interesting, utilizing resources I have?  The "classic" program for BE-SAP

8-bit CPU: Memory

Image
Time for another important part of the computer - memory. Here I think I have to come up with my own design. Ben's version has only 16 bytes, uses nowadays-exotic 74189 memory chips and there are DIP switches for programming. For the memory I plan to use 62256 SRAM chip. It can store 32 KiB of data, I initially plan to use just 256 bytes, so I'll connect remaining address pins to GND. I'm also not in a mood for any DIP switch based programming, so I'll add an EEPROM instead. There are several ways how computer can utilize such setup: split the address space into program and data memory. This is how Ben's 6502 breadboard computer works. Some additional logic gates are used for chip selection, the main issue however is that it is not very flexible. use Harvard architecture , where program and data memories are completely separate. Reading and fetching instruction are two different operations: former accesses RAM, latter - ROM. This is how AVR microcontrollers (heart

8-bit CPU: Wiring and testing the new ALU

Image
Once I had soldered the boards I was eager to test them. At first I "poked around" using jumper wires and boards appeared fine. To be absolutely sure, however, I have to wire them together into a new ALU block and hook it up to my Arduino testing device. Boards are a bit elevated above the breadboards, so it seemed to be a good idea to run wires underneath the PCBs. To save on wiring, I opted for simple, fixed configuration (same as breadboard prototype and Ben's original), instead of my new, dual-output feature. I tested the dual-output some time later, adding jumper wires for missing connections. The concept works fine, but it takes 14 control wires to tame the beast. This will have to wait for proper control logic. The ALU block is not the only piece that is new. My new EEPROM writer features additional pin sockets, giving access to onboard shift register outputs. When no EEPROM needs to be programmed, it can be repurposed to switch control lines. I do not need my ad-h

8 bit CPU: Soldering the boards

Image
The boards arrived, so did parts. Time to put it all together. I've chosen to make boards using SMD parts, soldering those might sound a little scary. What I remember from previous experience (I've soldered a couple of small boards before), it is easier than one could think before trying. Tool-wise it also does not require anything fancy. Good tweezers, small soldering iron, flux pen. Solder wick could be useful, but I did not need that very often. It helps to have brightly lit workplace. Soldering SOIC chip on the board so that it is connected properly is quick and easy. It takes a bit longer if one wants to align it perfectly . Solder one corner pin, check alignment, re-melt and correct until you're happy, then do one in the opposite corner. Finish with the remaining pins. 0805 resistors and capacitors also are quite easy - solder one pad, check, re-melt. Once happy - solder other one. What I struggled a bit with was LEDs. Again - it is not hard to put them on board and s

8-bit CPU: design the PCBs

Image
The idea is clear, now the hard part: design the boards. I've been long time CatSoft Eagle user, but since they've been acquired by Autodesk, things have gone downhill. It did not even wanted to start on my machine (I use Linux as my primary OS). Well, so long and thanks for all the fish! KiCAD seems to be popular in the community , let's learn something new. As planned before, I started with ALU module. The schematics part was quite easy, there are no space constraints when drawing that. PCBs on the other hand... After board outline was set and connectors placed, it started to feel quite terrifying. Can I really fit ALL THAT on this small board? Eventually I did... Next I have to route the tracks, a lot of them. Felt a little lazy to do it all by hand and wanted to see what autorouter produces. Turns out, there is no such feature in KiCAD. Everybody appears to to hate autorouters! There was an option to export the board, autoroute it in FreeRouting and then import it ba

8-bit CPU: Planning PCBs - architectural upgrades and addressing common issues

Image
I built a prototype ALU block and it appears to work fine, where to go now? I should remind that I do not want to build multiple copies of the same circuit. I already wired up the Program Counter board temporarily as B register. I'll need that for the intended purpose later. The logical step is to design a PCBs for parts I've built. I decided to start with ALU, Register and Flags boards. I had some extra ideas for features and improvements, that are not tested on breadboards. The changes are not that complicated so I decided to implement them directly to PCBs. Some of them will allow greater flexibility later on, some should help to prevent come common issues other builders are facing. As for PC, I decided to keep it on breadboard, as only one copy is needed and I'm not really decided if I want to do something different there. Flags I decided to deviate from Ben's design and build Flags register as a separate entity. The main reason is that at some point I plan to build

8-bit CPU: ALU and Flags

Image
Now that I have a pair of devices that can store a byte, I can proceed to do something more interesting. Build a device that add them together, for example. In other words - let's build an ALU. The design follows same basic idea as Ben's - two 4-bit adders, XOR gates and an output buffer. I'm using HC logic here, so I used 74HC283, 74HC86 and 74HC245 chips. Since I've built only one Register and did not want to build another, I connected my Program Counter board as register B. If I keep the counting function disabled, it serves the purpose just fine. It took a lot of wires, but I'm just getting started, let's build Flags register as well.  There were no surprises with Zero flag - 4 NOR and 3 AND gates does the job - just following the Ben's design. Another latch (74HC173) chip to store it, done. The fun starts with the Carry flag: I wanted to support a carry-in signal for the ALU. It is very useful if one wants to perform the addition or subtraction for wid