Welcome to the Parallax Discussion Forums, sign-up to participate.

# Trying to understand 32 bit registers

Posts: 1,495
I just watched a video about a 4 bit adder. It makes sense to me: An XOR gate is connected in parallel to an AND gate and the "carry-out" is connected to the "carry-in" of the next adder.
Does that mean the Propeller has a 32-bit adder for each register?
Larry

If the grass is greener on the other side...it's time to water your lawn.

• Posts: 22,755
edited October 2017
No. Some internal registers (like the cog counters, program counter, etc.) probably can increment (+1), some decrement (-1). There's usually one central adder / logic block (arithmetic / logic unit - ALU) for each cog. The Propeller reads from one cog memory location (source) to a temporary register, then reads from another memory location (destination). The ALU gets one input from the temporary register and a second input from the memory output (usually another temporary register). The ALU output is connected to the memory write circuitry and after enough time for the ALU to finish its work, the memory is instructed to write the result back to a memory location (destination). To simplify things, this time is fixed (clock cycle) based on the worst case timing.
• Posts: 1,495
Ah, the ALU. I've heard of it. Thanks Mike.
Larry

If the grass is greener on the other side...it's time to water your lawn.
• Posts: 22,755
Most computers have one. It's usually the most complex piece of logic with the longest logic paths (and times to a stable result). Some computers have separate integer and floating point ALUs. Some may have several of each plus a very complicated unit to keep track of which ones are busy and whether one of them depends on a result that another unit is still working on.

The ALU in the Propeller has what's called a "barrel shifter" that can shift a value left or right from 1 to 31 bits with or without sign extension or a carry bit as the 33rd bit ... all in a single operation.
• Posts: 1,681
And an XOR parity-tree circuit that can set the carry flag to the parity of any subset of the registers bits (the
TEST instruction does this, it can be very useful.

So the ALU has add/sub/neg/abs/or/and/nand/xor/shift/rotate/parity/reverse/compare circuitry and probably a few
things I've forgotten.

The registers are just a block of SRAM that the ALU gets to read/write.

All of this times 8 of course as each cog has its own.