Optimization question (somewhat ALU-related)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Optimization question (somewhat ALU-related)

knarf_navillus
This came up while building my ALU, but I'll try to use non-specific examples in order to avoid spoilers. So, suppose I have an ALU-like chip with the following interface:

CHIP ALU {
    IN
        x[16], y[16],  // 16-bit Inputs
        f;                 // Operation: Or16 if 0, And16 if 1

    OUT
        out[16];  // 16-bit ouput
}

So, the f input is just a selector that decides which operation (AND/OR) to perform on the inputs. My usual strategy has been to perform both operations first, then use a Mux to decide which one to actually output:

Or16(a=x, b=y, out=xory);
And16(a=x, b=y, out=xandy);
Mux16(a=xory, b=xandy, sel=f, out=out);

This seems wasteful, though, because I'm always performing an operation I don't need and then throwing it away. Is there any way around this? I thought of using DMux's in order to make the decision before doing the operation, but then it occurred to me that both operations would be done anyway (one operation would just be operating on 0's). Plus, I'd still have to Mux at the end in order to avoid connecting multiple internal pins to the same output pin. Even more wasteful.

Now that I think about it, I'm not sure it's even possible to have a part in a chip that doesn't "run". I'll have to think about that some more.

Thanks,
Frank
Reply | Threaded
Open this post in threaded view
|

Re: Optimization question (somewhat ALU-related)

ybakos
knarf_navillus wrote
This seems wasteful, though, because I'm always performing an operation I don't need and then throwing it away.
I think I understand your thinking. The short answer is "hardware is not like software," and you really can't view an unused portion of a circuit as "wasteful." (Unless, of course, it really is never used.)

In my own TECS class, I have a mix of CS and EE students. And the CS students (software-oriented) tend to raise the same question you have, while the EE students (hardware-oriented) always stress the fundamental point that hardware "operations" are not like software operations.
Reply | Threaded
Open this post in threaded view
|

Re: Optimization question (somewhat ALU-related)

knarf_navillus
ybakos wrote
In my own TECS class, I have a mix of CS and EE students. And the CS students (software-oriented) tend to raise the same question you have...
That's hilarious! I definitely am thinking about this with a software mindset. I'm used to checking first, and performing the operation after (e.g., if f==true, then do And, else do Or). Instead, it feels like I'm saying, "Go ahead and do both operations and I'll decide afterwards (via Mux) which result I want to use and which I want to throw away."

Thank you for clarifying for me. Cheers.

Frank
Reply | Threaded
Open this post in threaded view
|

Re: Optimization question (somewhat ALU-related)

cadet1620
Administrator
In reply to this post by knarf_navillus
knarf_navillus wrote
This seems wasteful, though, because I'm always performing an operation I don't need and then throwing it away. Is there any way around this? I thought of using DMux's in order to make the decision before doing the operation, but then it occurred to me that both operations would be done anyway (one operation would just be operating on 0's). Plus, I'd still have to Mux at the end in order to avoid connecting multiple internal pins to the same output pin. Even more wasteful.

Now that I think about it, I'm not sure it's even possible to have a part in a chip that doesn't "run". I'll have to think about that some more.

Thanks,
Frank
For hardware, the subcircuits are always there and it takes very little power for them to always compute their values. The circuitry to power down the unneeded subcircuits would take more power that what was saved.

For very large ICs like microcontrollers, there is often a power management circuit available in the IC to power down sections that are unused. One of my current projects uses a microcontroller that includes lots of interfaces I don't need -- for instance an interface that's popular in the automotive industry.  I'm only using maybe 2/3 of the chip's I/O functionality.  If I was running in an environment where I had limited power, like batteries, I could power down the sections I wasn't using.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Optimization question (somewhat ALU-related)

throwaway
 
cadet1620 wrote
For hardware, the subcircuits are always there and it takes very little power for them to always compute their values. The circuitry to power down the unneeded subcircuits would take more power that what was saved.

For very large ICs like microcontrollers, there is often a power management circuit available in the IC to power down sections that are unused. One of my current projects uses a microcontroller that includes lots of interfaces I don't need -- for instance an interface that's popular in the automotive industry.  I'm only using maybe 2/3 of the chip's I/O functionality.  If I was running in an environment where I had limited power, like batteries, I could power down the sections I wasn't using.

--Mark
That explains a lot.  And yes, I come from a software oriented approach.  I grimaced when I first started the projects because it is certainly 'shoot first, ask questions later' approach.

I'm having a blast by the way.  Thank you Nisan and Shocken for making this freely available.