Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

You can use cascaded full adders to add any two binary numbers together. Is there a circuit for when I only want to add 1 (incrementing the value)? Is there a similar circuit for subtracting (i.e. adding 0b1111 1110)? I'm working with 8 bit numbers, but this applies for all word lengths.

share|improve this question
2  
A circuit besides a full adder? You could just use one where one set of inputs is static, either 00...01 (++) or FF...FF (--) You could optimize/eliminate some of the input gates with the knowledge of constant inputs. – Nick T Dec 14 '10 at 15:45
@Nick T, I was thinking of doing this but wasn't certain how to approach it. – Thomas O Dec 14 '10 at 15:53
You could feed the carry-in line, but I suspect you don't have access to silicon... – tyblu Dec 14 '10 at 22:50

3 Answers

up vote 3 down vote accepted

Let's see. In a simple ripple carry adder, sum,carry-out = a + b + carry-in

c[0] = carry-in
for i in n
    sum[i] = a[i] ^ b[i] ^ c[i]
    c[i+1] = (a[i]&b[i]) | (a[i]&c[i]) | (b[i]&c[i])
carry-out = c[n]

Now if we want to compute sum,carry-out = a + 0 + 1, set b[] = all 0 and simplify:

c[0] = 1
for i in n
    sum[i] = a[i] ^ c[i]
    c[i+1] = a[i] & c[i]
carry-out = c[n]

which is simpler. Subtraction by 1 can be similarly simplified (exercise for reader: what is b[] and carry-in in that case?)

Happy hacking!

share|improve this answer

If you're talking about discrete logic, like 7400 series logic, then the chip you're looking for is called a counter. Two 74191 (4-bit up/down synchronous counter) chips cascaded will give you what you want, and there are other chips that do a similar function.

If you want the most compact way to add '1', then you could use half-adders for each bit instead of full adders. Not too sure about subtraction though.

share|improve this answer
Thanks. I'm considering building a transistor computer so whereever I can save transistors it is good. – Thomas O Dec 14 '10 at 15:53
3  
Transistor computers are easy to make when you're building the transistors on a single silicon wafer :) – W5VO Dec 14 '10 at 16:07
Food for thought, if you're talking about making a discrete transistor CPU: The Intel 4004 (4 bit CPU) has 2300 transistors (excluding main ROM/RAM, and I/O. – W5VO Dec 14 '10 at 17:01
@Thomas: I don't want to discourage you, but even the most simple CPU needs a few thousand transistors and the more components the greater the chance that something is wrong somewhere. I wouldn't want to debug it anyway. Why don't you build one with standard 74HCxx logic? This may increase your chances considerably, and it should be a serious challenge too. – stevenvh Dec 14 '10 at 17:14
1  
@stevenvh Actually I should have written relay computer and it's been done before (web.cecs.pdx.edu/~harry/Relay/.) I doubt I'd actually build it, but it would be a design project to do in my spare time. – Thomas O Dec 14 '10 at 17:29
show 2 more comments

What you are looking for is a edge triggered T-triggers. Input = output of previous stage AND count clock.

Here is schematics for transistor-based T-trigger:

http://forum.cxem.net/index.php?app=core&module=attach&section=attach&attach_rel_module=post&attach_id=45908

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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