9

Got myself a bunch of 74LS181, because they were cheap and they have been used in the VAX 11/780. And now I made myself a little tester breadboard where I am trying to figure this out in practice. My head is spinning from all this active low and high and open collector (A=B), etc.

I wonder if the VAX or some PDP-8 might have used this ALU in active low mode? Then they would have to have all the registers in active low also, or inverting buffers, crazy. I'm only thinking about the active high mode now.

But then the carry-in is weird, it has to be held high the whole time. This is extremely annoying because how will I do an add-with-carry if I have to hold the carry high just to make an add?

The A=B output is also weird, because you would want a zero flag, but there is none, the A=B flag is an all-1 flag (I suppose it's a zero flag in active low mode? Why would they bias this device to be more useful in active low mode?

And all that complexity comes just for having a huge amount of weird functions which I have no idea how to use?

  1. OK not A (regardless of B)
  2. OK A (regardless of B), but mind the carry or else it's A-1, also OK
  3. ?? not A or not B, that's a strange one
  4. ?? A or B, but mind the carry, and it's on the arithmetic side, there is a pure logical A or B also near the end
  5. ?? not A and B
  6. ?? A or not B
  7. OK all bits off
  8. OK minus 1, all bits on
  9. ?? A nand B, sure, a universal gate, but in an ALU?
  10. ?? A plus (A and not B), woah!
  11. OK not B (regardless of A), symmetric to 1st
  12. ?? (A or B) plus (A and not B), but mind the carry!!!
  13. OK A xor B
  14. OK A minus B, with carry L, test 7 - 2 = 5 the output carry is H, that seems so weird! Do we have to think of carry being active low?
  15. ?? A and not B, perhaps useful to clear in A the bits of B
  16. ?? (A and B) - 1
  17. ?? not A or B
  18. ?? A plus (A and B)
  19. ?? not A xor not B
  20. OK A plus B, but with carry H, if L you get A plus B + 1, so how can you do an add with carry? Or does this mean carry is actually active low? That would fit with the subtraction weirdness?
  21. OK B (regardless of A and carry)
  22. ?? (A of not B) plus (A and B), whoa!!!! Who in the world would have ever used this?
  23. OK A and B
  24. ?? (A and B) - 1
  25. OK all bit on
  26. OK A plus A (a left shift)
  27. ?? A or not B
  28. ?? (A + B) plus A
  29. OK A or B
  30. ?? (A + not B) plus A
  31. OK A (regardless of B and carry)
  32. OK A minus 1 (if carry is H)

Of 32 functions only 15 (less than half!) seem useful to me.

But then, I remember that the PDP-8 instruction set has no OR, so people had to use some weird combination of AND and TAD. Perhaps among the seemingly useless functions are some useful ones?

Any right shift perhaps?

Anything useful to speed up multiplication or division loops?

enter image description here

Note, I am not asking "why" is it the way it is. I am sure there is a certain beauty and symmetry, to all of this and a minimization of transistors. My question was how more than half of the functions that seem so weird were actually useful to anyone?

enter image description here

7
  • 2
    Be sure to search retrocomputing for "74181" and "181" and "weird instructions" - this kind of thing has been discussed before in comments and answers, nothing definitive but still illuminating.
    – davidbak
    Sep 24 at 20:06
  • @davidbak, have a link? Because nothing other than this question comes up. Sep 25 at 9:56
  • 3
    A key point to help you understand is that there are 16 possible logic functions between two boolean variables. The 74181 offers all of these, though the order differs based on whether you're taking high voltages to be 1, or low voltages. As an added feature, it bolts on an arithmetic (adding) mode to all of these. Some combinations are more useful than others, but it'd be more work to exclude functions from the simple (elegant) circuit.
    – Kaz
    Sep 25 at 10:21
  • 1
    6 up-votes in 2 days and "closed" for nonsense reasons. Whatever, this site is not worth worrying. I got my answers and I keep the rest to myself. Sep 25 at 19:51
  • 1
    "My question was how more than half of the functions that seem so weird were actually useful to anyone?" - who says 'more than half of the functions that seem so weird' were actually useful? Sep 25 at 20:41

2 Answers 2

15

Note, I am not asking "why" is it the way it is. I am sure there is a certain beauty and symmetry, to all of this

Might still be useful to peek at Ken Shirriff's write up about the '181 - great as always - going into details why these functions are the way they are.

Likewise the datasheet states straight out that these are simply the 16 possible logic functions that can be done:

Datasheet excerpt about all 16 logic functions of two input inclused

Since the arithmetic functions are the logic ones but including carry, they as well have to be 16, even though some may be less useful.

... and a minimization of transistors.

But that's exactly the reason why one can access 'weird' functions no one needs (*1).

When looking at the '181 it's mandatory to keep in mind that in 1970 it was at the top end of what later would be called medium scale integration: Designs with 10 to 100 gates. The '181 had about 75 gates with roughly 300 transistors. For back then as cutting edge as some multi-billion transistor devices of today.

To operate the network as it is, it needs five inputs as control signals. To present only the 15 function you see as useful (*2), a 16-to-32 demultiplexer would be necessary. Unless one comes up with some clever (and very small) circuit this means a 4-to-16 decoder and a 16-by-5 ROM this will be at least 100+ transistors. That's a good 35% penalty in size and more in cost, to a chip already at the forefront of capabilities. And all for what?

The point of the '181 is not to bring a well rounded high level ALU, like some FPGA would, but to reduce a full board of TTL into a single chip plus a bit glue logic. Of course this comes at the

My question was how more than half of the functions that seem so weird were actually useful to anyone?

Who says they had to useful to begin with?

They are simply the internal control lines for the circuitry given. They are the low level interface to a circuitry that got integrated into a single chip, not a shiney polished 2022's design with more transistors than ants in my garden (*3).

Today it's a no-brainer to throw gates worth several '181 at a chip just to beautify input. Back then the '181 was already top end. Adding another 100+ transistors, just for that, would have been rather frivolous.

But also questionable from a usability point - who says a circuit does need all 15? If not, the same problem as before arises: Useless functionality to be considered - but this time with an even more expensive chip.

So the question might be rather:

Why have these functions be included in the data sheet.

It's a defined circuit, the workings won't change (*4), so better document what's visible to anyone looking at the published design (*5).

It also has been a different time, a time when designers wanted to know the internal circuit of a 7400's gate, so they can use it in other ways then just at logic level :))


*1 - Not counting cases were - usually by chance - they came handy.

*2 - Beauty is in the eye of the beholder - or in this case usefulness is quite dependent on what to be done. For example not A and B would be quite useful as masking operation. It will reset all bits in B set in A, so one can use the same mask (in A) in a SET-BIT(s) instruction (A OR B) as for a RESET-BIT(s) (not A and B). A CPU where one doesn't need to write 255-CONST :))

Solomon Slow reminded of an important use in modern (GUI) graphics: Bit-Blitting. For a basic bitmap display not A and B is the very function to save screen content under a moving mouse pointer, or dragged icon, as well as to mask out the background when painting an icon.

*3 - Believe me, they are plenty.

*4 - Unlike unused code points in an ISA wich may be reassigned with later versions.

*5 - After all, reading such a basic and quite symmetric schematic is like browsing a 4th grade school book.

5
  • 2
    PERQ workstations, manufactured in the 1980s, used '181 chips in a single CPU that was microcoded to execute both conventional program op-codes, and also, specialized "raster-op" instructions (like what graphics co-processors do in modern computers, but for a one-bit-per-pixel display.) Some of the "odd" functions of the '181 (e.g., not A and B) were used in the "raster-ops". Sep 25 at 1:40
  • 1
    @SolomonSlow Which is, as mentioned, very handy for masking. Masking is a basic BitBlit operation. An icon consists of its image and a mask for its shape. To draw that icon the mask is first cut out of the existing screen content using not mask and screen, then the icon is drawn using screen or icon. If necessary the same mask can as well used to 'save' the background before drawing the icon with screen and mask - like useful when dragging the icon around (avoids calling redraw all the time) having that not-A function allows to use the very same mask for both use cases.
    – Raffzahn
    Sep 25 at 2:28
  • 1
    I think it's also important to note that operations like A, B, /A, /B, -A, -B, etc. are also often useful, because they would allow fuctions like "LD A,value" and "CPL A" to be processed without having to route signals around the ALU. I don't think it would be possible to pick a set of 16 functions that would be sufficient to accommodate everything that system designers might find useful.
    – supercat
    Sep 25 at 17:26
  • @supercat exactly, my question included that already. Even A and (not B) I remarked was possibly useful for masking operations, I just didn't make the same comment for not A and B. So, I would now be up to 17 useful operations. Sep 25 at 19:54
  • @GuntherSchadow So with17 useful operations, it needs FIVE pins (bits) to select any - 5 pins equal 32 possible operations. So what again was the question?
    – Raffzahn
    Sep 25 at 21:31
6

The seven "obviously useful" arithmetic operations you can do with the 74181 are

  • increment A
  • decrement A
  • add with carry
  • subtract with carry
  • add
  • subtract
  • shift left (A+A)1

The others might not be so obviously useful (notwithstanding that they might be useful in some obscure - or even some not obscure - cases), but need to be documented in order to provide a full truth table for the chip. So, basically, the "not-so-obvious functions" were not designed into the chip, but are a by-product of the optimised implementation of the above obvious ones)

Why do the internals of the chip look so weird compared to a cascade of full adders that we've all (hopefully) learned about in school?

The answer is performance: A cascade of adders does stabilize its output only after all digits have been fully processed (and the digits are calculated in a serialized manner, and for a considerable number of digits this can seriously add up). If you could "guess" whether a carry is going to be produced per digit, the next digit could already start to work and stabilize before the first digit is fully processed (that's called "carry lookahead", and works with a companion chip, the 74182) - So the overall execution time is much lower than a cascade of full adders.

(1) No, there's no right shift.

5
  • 2
    Is there a reason you consider logic function like AND/OR/XOR/NOT as 'not useful' or outputting A/B without change?
    – Raffzahn
    Sep 24 at 19:46
  • 1
    @Raffzahn Absolutely not. I simply concentrated on the "A" part of the ALU ;). And note I really absolutely avoided "not useful"
    – tofro
    Sep 24 at 19:47
  • 1
    L is for Loosers? :)) SCNR. And to be OT again: Hasn't the question already included all of that?
    – Raffzahn
    Sep 24 at 19:48
  • @Raffzahn I am sincerely curious to understand your sentiment. Sep 25 at 19:53
  • @GuntherSchadow What sentiment?
    – Raffzahn
    Sep 25 at 21:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.