top left Image    Arithmetic and Logic Unit (ALU)

For many I guess the ALU is the sexy bit of a processor, processors are supposed to do sums after all. And I had a lot of fun looking at options.
My first port of call was the 74181. I remembered having been fascinated with it many years ago. It is however quite complicated (read big) and a lot of its options didn't seem particularly relevant or even usable for the Megaprocessor. So I gave up on that.
All I could think that I needed from an ALU for the Megaprocessor was :
  • arithmetic functions
    • A + B
    • A - B (which can be done by A + -B)
    • - A (which could be done by 0 - A)
  • logic functions
    • A & B
    • A | B
    • A ^ B
    • ~A (which can be done by A ^ 0xFFFF)

I spent a few happy hours trying to combine them into a single block (there's quit a lot of the adder that looks like it'll give you the logic functions) but in the end decided simple was best. So my ALU has a logic unit that looks like:
schematic for logic unit
and an adder unit that looks like:
schematic of adder unit

I also chose to implement this using the explicit simple gates as per the diagram. Working directly with the transistors I could have defined a magic logic gate that could implement the adder function in one go. But I thought that this would obscure how things worked.

Whilst the ALU works on 16 bits at a time I actually implemented the logic and adders in blocks of 8 bits. 16 bit widths would have made for a very expensive board so a bit risky. Also my pcb manufacturer has a minimum order quantity of 3 boards so actually doing 8 bit units works quite well because you're going to get enough pcbs anyway to do the 16 bits. I thought briefly about doing smaller units as they would be cheaper, but then you start getting into a set of messy connections.
8 bit logic unit
8 bit adder

I also spent a bit of time dithering about whether or not I should do look ahead carry generation to speed the adder, inspired by the 74182, partner to the '181. A ripple adder is slow. But it looked like the look ahead carry generation would near enough double the size of the adder which seemed a high price if you're building it by hand. And again I was worried that adding a feature like this might obscure how things worked so I decided not to.
If I had my time again this is a decision I might change. It would have been rather fun. And also whilst speed is not a major requirement for the Megaprocessor it's always better to have more rather than less.

link to previous
link to next








© 2014-2016 James Newman.