Close

Update

A project log for Tetra - 4-bit CPU

Experiment to create a minimal 4-bit CPU that can do something fun

kaimackaimac 11/21/2022 at 19:301 Comment

Here's where the design is at the moment:


The accumulator (A) can take the value B, A+B, A nand B, or IN, where B is either a 4-bit immediate, or a 4-bit value from RAM. The accumulator can be sent to an output register, or written to RAM.

The 8-bit RAM address is generated from 4 bits in the instruction word, and 4 bits from a page register (PG). So there are sixteen pages, each 16 words (nibbles) in size - an address of $3F is location F on page 3.

In the diagram I've got the input to PG coming from an immediate value, but thinking about it now, why doesn't it come from the accumulator? Then you can compute page addresses and have some indirection. The only reason I can see for not doing that is that you can't have a value in the accumulator and then save it to a specific 8-bit address - you need to clobber the accumulator to update PG. But you could save it temporarily to the current page - perhaps location 0 of each page is kept free for such a thing. More thinking is necessary here - a lot of this stuff has been paged out of my head.

Instructions come from a 4K ROM and are 8 bits wide. The 4-bit operand is either an immediate value or a RAM location. Or - in the case of a jump - the lower 4 bits of the 12-bit jump target. So where do the other 8 bits come from? They come from the next location in ROM, which handily is already available - it's the input to the instruction register rather than the output. All thanks to the "pipelined" nature of instruction fetching. The jump logic will be the topic of the next update.

Discussions

kaimac wrote 11/22/2022 at 21:01 point

I see now - if PG has to be set from the accumulator, then a value loaded from any RAM address could only be saved back to the same page. That's not very useful.

What I could do instead is set PG from the output of the "B" mux - then PG can be set to an immediate value, or the accumulator via the '541 buffer.

  Are you sure? yes | no