• It Subtracts

    Michael Möller06/20/2020 at 18:12 0 comments

    SUB (ALU)

    The Full adder ('283) is placed in top row, plus an inverter for the Breg input, so it becomes a SUBtractor. The IOD (the I/O-detector, previously called ZER) signals on all-1's on the XFR-register output.

    Placed, but not yet wired, is the LEQ detection on the SUB output.


    Of course, I had to test this interim stage, before having done the LEQ. I loaded 4, 5, -1, 5, 3 into the RAM, and then microstepped and verified that all the expected lights lit up. Thus it did one SUB(nobranch) instruction, and the correct numeric result. Yes ! Wave !

    Onwards to wiring up the LEQ and then need to write tiny test programs. Thinking, "read INP and add it to running total on OUT". Oh, no conditional branch in that. Hmm... I only have room for 4 instructions and 3 variables 

    The Halt is not done, and I have to think how it should stop the clock.

    8 bit ready

    So far it is a 4 bit data/addr. There is room (in the blue boxes) for the chips One counter, one Adder, one inverster one OR gate)  to make it 8bit as soon as the 4bit is working. The Bus-display needs widening, too. But before that, I'll do an Arduino "interface" so I can load RAM with program. Toggling in with the Load button gets tedious real quick. 

    μ-sequencer (3rd version)

    Another "minor" rework of the controlsequence logic. I just stared hard at the logisim circuit long enough, tweak and simulated and found a way to free up 3 gates, even with the additional constraints included. I also managed to reduce the wiring mess, a little.

    ToDo: include some logic to reset the sequencer in the non-branch case or indeed skip the 8th step as it is a 3bit counter.

    The A1 etc refer to chip/gate. (The inverters top left do not exist in the real circuit, only in the simulator, beacuse the signal is active low, so the Input buttons are easier to work with as active high.)

  • More corrections

    Michael Möller06/06/2020 at 20:18 0 comments


    I now unconditionally copy Register A into Result (what 2nd argument points to) to test my write back.

    The "bus" in the middle will have LEDs for all 24 lines, when I get to a CPU project with 8 data 16 address. At the moment 4 bit databus.

    I have reaaranged a little (as described in previous log) but I am NOT happy with the layout as a whole. Implementation is "organic growth", but I do not want to rearrange everything or every step. The jumperwires are for temporary fixes (like LEQ tied low, as there is no SUB to generate the signal yet, but I can still test how it would work on the µ-sequencer)

    Ooops ?

    At this point I discover a few (more) errors in the design <sigh>

    1. µstep5 needs the SXP else it loads random data. 
    2. Total misunderstanding - I have indirection on the jump, too, ie it jumps to the location of the content of what the 3rd arguments point to. Great for subroutines and such like, but very difficult when you do not want a jump, even if the result is negative (which is quite often).
    3. Using "0" as the special location required a multi input NOR, which required too many chips, so that changes to "-1". (I afterwards noticed this was assumed by some other emulator implementations, too). 
    4. There was no HALT condition in the diagrams, only loosly planned in my head
    5. The INP is LSB on left, LEDs are LSB on right.
    6. POTENTIAL - Unsafe conditions like DOD & WRE ( & DATA ) changing simultaneously  - ignoring  it for the while being

    Updated design

    Block schematic 

    RAMMemoryADDRAddress to memory
    SELSelect address sourceDATAbidirectional data (a bus)
    INPInput, currently DIP switchSXPSelect XFR or PC as source for ADDR
    OUTOutput Buffer (goes to display)LDPLoad PC with new value
    XFRTransfer Buffer, for the indirect argumentsINC'Increment PC
    PCProgram counterIODInput/Output-Detect, ie address is -1
    AregA registerLDX'Load the XFR register
    BregB registerDODDataOutputDeny (=not RAM on Databus)
    SUBSubtraction unitWREWrite Enable
    In these schematic the signals are all positive. (In the circuit half are negative=true)

    The '-mark is for edge triggered (otherwise they are static levels)
    ENIEnable Input (INP on databus)
    ENREnable Result (SUB on databus)
    LDA' & LDB'Load A and B register, respectivly
    LDOLoad Output Register
    LEQLess-or-Equal result in SUB


    Signals activation by step above the box, with hollow arrows show the alternative on a condition being true. The listing shows data flow, and the last is the special event when pressing the "load"-button (two pulses generated, not the clock)


    This shows the complex truth with negative/positive and static/edge logic mix. The output suffixes mean "~"inverted, "+"ve and "-"ve edge. The LD1 and LD2 are the two pulses from the manual Load button. The counter reset takes away the 8th redundant µstep, and I should do it for the nonbranch 7th step, too,  but I've run out of room for more gates.

    Next Planned Step(s)

    in the probable order

    • Implement the corrections
    • The IOD circuit (one multi-input AND)
    • The ALU (adder plus inverters)
    • LEQ circuit 
    • OUT connection plus some display

    And when it runs, extend to 8 bit data/addr and loading of programs from Arduino

  • 3 Registers OK

    Michael Möller05/17/2020 at 18:52 1 comment

    Progress is getting easier. I now have the XFR register working, and verified that indirect addressing works. YEAH! There was a debugging session - now that I needed to load the RAM with data, I discovered that the data was not loaded in the correct address. Finally (with a help of a Saleae logic analyzer) I had that Doh! moment - the monostable generating the LD1/2 pulses (you can see the capacitors on the picture) was wired wrong and fired LD1 and 2 at the same time, instead of after each other. Now the manual load works as advertised

    Then there was a challenge with the PC jumping ahead 3 adresses when going from 7 to 8 - it turned out the LoadCounter line was floating (the LDP signal is not hooked up yet). It proves again that ALL inputlines to a chip must be tied High/Low if they do not have a signal. Of course I knew that, I was just being lazy/forgetfull/optimistic. 

    Hooking up the A and B registers was trivial, and the readout is temporary, just to convince myself that I load them with the indirected content.

    Next is placing the ALU, where A/B display is. I'll use the '283 simple adder, and inverters to make it a subtraction - 2 chips (4 for 8bit wide. Note the room reserved for extending SEL and PC when going from 4 to 8bit). The LEQ detection is challenging me trying to minimize chipcount to do it.

    It is getting tight on breadboard space. (I have more of them, but I'd rather not) Planning to move the INP and (not yet constructed) OUT unit to the left. That places all human I/O on the left, and right is Internal, I thus will use the "bus" (the strip board i the middle), and it is planned to have LEDs on it, too, so that removes one of LED bars. I had sort of semi-planned not to use "bus" in SUBLEQ ("only" ENR and INP (and RAMdata) are tristate) but that's the fun or point of doing a project like this - challenging the loosly laid plans to deliver in RealLife. 

  • Microsequencer (almost)

    Michael Möller05/14/2020 at 20:01 0 comments

    The Microsequencer is causing gnashing of teeth. ( I've updated the diagram/tables in previous log wit the corrected correction fix, revised. )

    But now most signals work - ie they match my intended flow from the post "Block diagram". Time will tell if that works.

    Still missing is LDO and LDP signals, but they're easy.

  • Microsequencer

    Michael Möller05/04/2020 at 16:30 0 comments

    Actually I only wanted to test the Manual Load circuit, where two monostabes trigger the Input latch and a write to the RAM. They would need to go through some sort of "OR" operation wit the signals from the MicSeq which would generate the same signals under some conditions. 

    Originally I thought the MicSeq would be dead easy, as I had one (negative) logic line for each step, and a simple OR or AND would be enough for where a condition is needed. Like, "Increment PC on step 2 and 4 and on 6 if LEQ is false". But, the 74LS138 has a negative signal, and most registers trigger on an edge and need delaying until the RAM output has stabilised (ie can not trigger on the same edge). That is handled by AND-ing in the clock, so I get two edges on one step.

    Note: Where it says "Seq" in the table it that step, ie Sequence5 in the ENR(EnableResult) column. I've tried to factor where I can but it still ends up with 26 gates on 7 chips (using triple-input gates doesn't help the chip count) ! And this is not even a proper instruction decoder, as there is only ONE instruction. Sigh. Defenitly will be using a EPROM in the future, but for now I wire this up. Suddenly I get worried I will rewire countless times as I discover errors, so I start using LogiSim and yes ... errors. The above is the corrected version, and below the circuit. (yeah, I could format it prettier, but that's not the point here)

    If you trace backwards you can see that DOD (RAM DataOutputDisable) is simple, only one OR and NOT gate, but that the LXP (Load the indirect address register) is 5 gates.

  • PC unit (and microsequences)

    Michael Möller04/13/2020 at 13:04 0 comments


    I'll think I start with the Program Counter. It is a counter. I happen to have a lot of 74LS197 (salvage from a surplus store) so I use one (or two) of them.

    4 bit counter. I use the Arduino tester, to verify that I truly understand the chip. It actually is two counters; one single bit, and one with 3 bits. There is NO CARRY. OK, as the count clock is negative-edge sensitive it simply means putting the highest digit of the previous stage into the clock of the next counter.

    The Clear will go to the global Reset line. 


    It will be another 74LS197 counter driven by the clock going into the 3->8 decoder 74LS138, where one of the 8 lines is high low for each tick. Route to each latch/tristate, with inverters, as appropiate. I hope that the "random logic" to get things happen at the correct clock edge will remain reasonably simple.


    The microsequencer works as advertised, ie one of each of the 8 controllines go low at the desired step. (The rest is not on the above picture:) The PC gets the INC on step 2 and 4, and conditionally on step 6. Currently 4 ddressbits cycle correctly, address the RAM, and data can be stored and retrieved (for now by manually setting datalines and manually toggling WriteEnable). It is a 4bit machine for this phase, and the LED bar shows address and data.

    The button debounce is giving me headaches - I cant get 100% releiable single step, and I do not know if reason is the button is too bad, the breadboard gives way/glitches, or I have stray signal pickup. (The latter seems likely - I sometimes get a "step" when touching some wire). It will do for the while being.

    (Some while later): Clock works. The PC increments as it should at right microstep, including a manual simulated LEQ branch (ie do not increment, but the jump isnt there yet). Also the RAM access works. A manual (moving jumpers) load of data shows that read and write work.

    The green display is temporarily both 4 bit address and 4 bit data. (Everything is 4 bit for the while being)

  • Block diagram

    Michael Möller04/13/2020 at 11:12 0 comments

    I think I now have the right block diagram. The first one was easy, took 5 minute sketch, the SUBLEQ is sooo easy. Yeah - after thinking about it, there was an error here. Oh and an ommision here. And hey, indirect addressing on everything!  "Rinse and Repeat" the design a few cycles.

    Note that input and output is included as an extension to the pure SUBLEQ. There is no other instruction than SUBLEQ, so INP and OUT are memorymapped, ie addressing location 0 will read INP (switches) or write OUT (7seg digit).  Edit: It is not strictly memory mapped, as referencing address zero changes the way the instruction executes, rather than redirect the address.

    XFR, Areg and Breg are latch-registers, PC is a presettable counter, SEL a 2-to-1 selector, SUB does subtraction and signals LEQ. The ZER senses address zero. ENI/ENR are tri-state gates (can't seem to design my way out of using tri-state on the databus, as it is bidrectional).

    This of course needs some squencer to control, the microsequencer

    The last line is the Hardwired Loader - to be implemented as a push button that transfers INP to RAM, then increments PC.

  • Flashback to Project start

    Michael Möller04/13/2020 at 10:47 0 comments

    It started about 3 years ago with viewing the Ben Eater series on building a simple CPU with just breadboards and TTL. Although the 74's are "relativly cheap", there are lots of them, and the total expenditure kept me back. Ben Eater sells the kit, but that makes it a boring repeat. In autumn 2019 I bought a selection of chips, both to cover that project, and a "suitable" selection of others, and a few to spare.

    I want to experiment with the challenges of of doing my own. I know the architecture of CPUs as such, so this is purely fun, as a puzzle. I want to extend the BenEater design with more RAM, an IO subsystem (keypad input, Serial?), something to load RAM, Interrupt handling, and paging. Of course at that point it isn't a "simple CPU" anymore.

    As the title picture shows, I have constructed a tray so I can easily take it out to play, and put it back even in mid work. On a wooden base I have a large conductivefoam area to store chips, there is a 5V supply,  and an Arduino to act as a test generator, and bulk storage IO device. Breadboards obviously, and a strip-board bus in the middle (rather than using even more breadboard)

    "Walk before you run" - so this first project on my CPU constructor kit simplifies CPU capabilities even further: One instruction, avoid "bus"/Tristate, start with 4bit (address and data).