1

I'm working on a circuit which performs basic operations such as addition and subtraction using logic gates.

Right now, it takes 3 inputs, two 4 bit numbers, and a 3 bit opcode which indicates what operation to perform.

It seems that a 3-8 decoder would be a good idea here. This is my mockup!

enter image description here

To give a little more context, here is what my adder circuit looks like (+). I designed it to take two 4 bit numbers X & Y:

enter image description here

However, what I am confused about is the fact that I have to feed in 4 inputs or 4 wires to each of the circuit that handles it's respective operations (+, -, =, etc). It appears to only connect one wire to the circuit I need to get to. I need to actually connect 8 wires, as I have to feed in the to 4 bit numbers.

UPDATE: I ended up using a MUX to select the output that I want.

enter image description here

10 Rep
  • 2,217
  • 7
  • 19
  • 33
Bob Shannon
  • 638
  • 2
  • 10
  • 19

1 Answers1

1

An adder doesn't need an input to tell it to add, because that's all it does.

A 4-bit full adder should have

  • 4 input signals for each operand, total 8
  • A carry-in input signal if you are also using it for subtraction
  • 5 output signals, the high-order one may be used to generate an overflow flag

Your decoder is a separate component from all the function generators. You could put a tristate buffer on each function generator to connect them to a common data bus, and then the decoder would generate the tristate enable signals. Otherwise, you probably don't need a decoder, but you might look at a multiplexer (mux) instead.

Potatoswatter
  • 134,909
  • 25
  • 265
  • 421
  • I see. I've updated my answer to include my adder circuit. It takes 8 individual inputs corresponding to 4 bit numbers X & Y. However, this one particular adder circuit is part of a bigger one that is supposed to support numerous operations. The part where the circuit decides which operation to perform is where I'm stuck. – Bob Shannon Apr 25 '14 at 03:33
  • @Bob It performs all the operations, all the time. Combinational logic circuits don't have GOTO. You need either a data bus with tristate buffers, or a mux, to select the output from one of the units to become the output of the entire ALU. – Potatoswatter Apr 25 '14 at 03:47
  • A multiplexer to select the output I want sounds like what I want. A decoder won't "turn off" the circuits I don't want? Putting a multiplexer at the end seems like it would be unnecessary. – Bob Shannon Apr 25 '14 at 03:55
  • 1
    @Bob Who said you're going to turn off the circuits not used on a particular clock cycle? That feature is called [power gating](http://en.wikipedia.org/wiki/Power_gating), and it's certainly more advanced than what you're studying so far. Note that CMOS logic uses negligible power as long as the inputs don't change. – Potatoswatter Apr 25 '14 at 04:17
  • Interesting. I've followed your suggestion as to using a MUX to select the outputs that I want, see updated question. Thanks! – Bob Shannon Apr 27 '14 at 08:29
  • 1
    @Bob Good luck… out of curiosity, are you self-teaching? You might look into an academic-oriented Xilinx or Altera FPGA development kit. Last I checked, they were available to the public for $100 or so. Code up your circuits in a language like Verilog (or convert from schematics) and see them implemented in real hardware. – Potatoswatter Apr 27 '14 at 12:43
  • Thanks. I am currently taking an introductory course in digital systems, but it seems that I am teaching the material to myself at this point. Those development kits look interesting. I may just have to try and turn this into hardware (maybe using LEDs for the output). That would be pretty cool. – Bob Shannon Apr 27 '14 at 18:16