Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Logic Gates and Full Adders

Name: Anonymous 2011-08-21 16:25

Greetings /prog/

I admittedly haven't been here before, haven't even been to this site but I was lingked here from /g/ so... I was wondering if you could give me a hand with something. I'm a first year computer science student (I know I know there's no jobs and it's a waste of time and whatever) and I was looking through some past papers when I came across a question that has me a little perplexed.

The question asked how I would go about building a denary full adder using these logic gates in order (XNOR,NOR,NOT,NAND). Now logic gates and all that related shit are my arch nemesis but I have no fucking clue how this would even work. Is this somethign that's trivially simple and I'm just being dense or is this as puzzling as it seems?

Sorry if these kind of questions are taboo or whatever, I wasn't willing to lurk for a few months before asking.

Name: Anonymous 2011-08-21 16:41

Alright faggot, let's have it.

I'm a first year computer science student (I know I know there's no jobs and it's a waste of time and whatever)
Wrong. There aren't any jobs for clueless uninterested faggots like you.

logic gates and all that related shit are my arch nemesis but I have no fucking clue how this would even work
The wikipedia articles on them are trivial. Get a pencil and paper and don't come out until you can write out the truth table for (((A & B) | !(C & !D)) & (A | D)). Are you about to begin 1st year in CS or have you just finished it in April? If it's the latter, I have bad news for you -- either you really suck at this or your university sucks shit.

Sorry if these kind of questions are taboo or whatever
No questions are taboo, but stupid questions that can be solved via a bit of reading are frowned upon. First show us that you're putting some effort into it and maybe we'll answer.

Name: Anonymous 2011-08-21 16:49

Oh wow, harsh. Okay.

Right, basic truth tables I can understand. It's more the more complicated circuit diagram stuff which I'm a little fuzzy on. I exaggerated when I said it was my nemesis.

What really confuses me is how you can make a full adder with denary, I understand how you do it with binary well enough but I just can't seem to wrap my head around how it would work in base 10.

Name: Anonymous 2011-08-21 16:50

full adder
Easy.
denary
Not so easy.

Name: Anonymous 2011-08-21 17:03

Oh wow, harsh. Okay.
I think that was the most gentle answer you can get from /prog/

And it's good this way. Programmers don't need to be nice.

Name: Anonymous 2011-08-21 17:06

| Programmers don't need to be nice

Not that I'm complaining about people not being polite on the internet but I don't think many professions require people to be nice.

Polite sage for offtopic

Name: Anonymous 2011-08-21 17:08

Name: Anonymous 2011-08-21 17:11

>I know I know there's no jobs and it's a waste of time and whatever
Is this true?
I was thinking of studying CS to get out of NEETdom but if there's no jobs it's just a waste of time.

Name: Anonymous 2011-08-21 17:12

I know I know there's no jobs and it's a waste of time and whatever
Is this true?
I was thinking of studying CS to get out of NEETdom but if there's no jobs it's just a waste of time.

Name: Anonymous 2011-08-21 17:59

>>3
Fine, I'll help you.

First you have to consider how (naive) adders work. Let x0 be the first digit of the first number, y0 be the first digit of the second number, c0 be the first carry (which can take values 0 or 1), r0 be the first digit of output, and B the base in which you're working in.

Then r0 ≡ x0 + y0 (mod B). That's easy for the first digit. But what if x0+y0>B? We need to take that into account, and so if x0+y0>B then c0=1, otherwise c0=0.

Now let's move on to the next digit. It's the same thing, except now we have to take into account the carry from the previous digit. Therefore, r1 ≡ x1 + y1 + c0 (mod B). As before, if x1 + y1 + c0 > B, then c1=1, otherwise c1=0. This is the general case of the adder. It's important to understand this. It is a function to which you give three inputs, i.e. your two digits and whether the previous adder produced a carry, and produces two outputs, i.e. the resulting digit and whether this addition produced a carry.

Adding multi-digit numbers is simply a matter of chaining together all these adders.

Now let's look at the problem of implementing a base-10 adder using logic (binary) gates.

A base-10 digit takes 3.32 bits, so you need 4 bits to fit one.

Your adder function thereby takes a 4+4+1=9 bit input (first_digit,second_digit,prev_carry), and produces a 4+1 bit output (out_digit,carry).

Hope this gets you started.

Good luck.

Name: dubzbot-ng 2011-08-21 19:38

<--- check 'em dubz

Name: Anonymous 2011-08-21 19:49

Thank you for the help but I feel that I'm missing something fundamental here, whilst I understand the theory I don't understand... oh god this is so fucking hard to word.

I understand how it works with binary because it's all single bits, 1 is true and 0 is false. Is there something I'm missing or would this just involve a lot full adders connected together?

Sorry about this, computer systems/architecture was the module I was least competant at and as such I'm currently trying to improve on it.

Name: Anonymous 2011-08-21 20:02

>>12
You need to work in BCD.

See hint >>7

Name: Anonymous 2011-08-21 20:25

>>12
Read my post until you understand it completely (especially the last part).

Let's say you want to write, as described in my post, an
adder function (...) [that takes] a 4+4+1=9 bit input (first_digit,second_digit,prev_carry), and produces a 4+1 bit output (out_digit,carry).
Any digit between 0 and 9 inclusively can be represented as a 4-bit number (assuming you know how binary works). Valid "digits" are therefore 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001. Now you add together the two input digits (which is each 4-bit wide), along with the carry from the previous adder. The result r is a 5-bit number between 0 and 19. Now, if the r < 10 then you can just output (result_digit=r,carry=0). However, if r ≥ 10, you must compute r-10 -- this is actually equivalent to computing r+22, ignoring overflow/carry (because 22 is http://en.wikipedia.org/wiki/Two%27s_complement of 10). Then you can output (result_digit=r+22,carry=1).

If you still don't get it, I'll make a diagram. But I really recommend using a program like LogiSim or MMLogic to play around with logic gates.

Name: Anonymous 2011-08-21 23:35

If you still don't get it, I'll make a diagram.
No, I think a better idea is that if he still doesn't get it he goes back to wherever he came from and you learn how to correctly sage threads.

Name: Anonymous 2011-08-22 1:18

>>15
Your suggestion has been refused. Check my sage.

Name: Anonymous 2011-08-22 5:42

>>16
noko
Please go back to the imageboards ASAP. Your mere presence here reduces the average IQ by at least 15 points.

Name: Anonymous 2011-08-22 6:46

>>14
I think I get it bet a diagram would be fucking awesome.

Name: Anonymous 2011-08-22 6:47

>>18
Ugh, but not bet. I need to reread my posts before I make them.

Name: Anonymous 2011-08-22 13:50

>>17
You are incredibly predictable. No, I'm not 66going back to the imageboards99, I don't even come from there! All in all, get fucked                          .

>>18-19
Alright but you'll have to wait about 3-4 hours for it because I have other things to do right now.

Name: Anonymous 2011-08-22 18:58

>>20
Take your time, there's not rush.

Name: Anonymous 2011-08-22 18:59

>>21
*no rush

Jesus christ I need to take my own advice and stop rushing when I type.

Name: Anonymous 2011-08-22 20:22

Name: n3n7i 2011-08-22 21:40

...this is a good question really =)
Problem is... aren't most of those op's Strictly Binary? (Or is that the point..?)

XorNot // XNor(?) Is pretty simple in base 2
A = 1 // B = 0 
XNor(A, B) = (A==B) ...
so If A Equals B | XNor(A, B) = 1 | else XNor(A, B) = 0

I'll just step up to Trinary (ternary?) // Base 3 anyway
Now, say A=0.... B can Equal 0-2 ?

Should it be XNor(0, 2) = 0 /or/ XNor(0, 1) = 0 ?
...And be it XNor(0, 0) = 2 /or/ XNor(0, 0) = 1 ?

..They only work with binary?
....I'm doing it wrong, hey? =)

Name: Anonymous 2011-08-22 22:14

>>24
Can you please get out of here?

Name: n3n7i 2011-08-22 22:25

Nooo.........

Any use for a ternary XOR ? ..It's linear and cyclic  ^^

0,0=1
0,1=0
1,0=0

1,1=2
1,2=1
2,1=1

2,2=0
2,0=2
0,2=2

Name: Anonymous 2011-08-22 22:26

>>26
Get the fuck out of my /prague/, you ungodly shitposter.

Name: n3n7i 2011-08-22 22:31

ternary LFSR perhaps? ...could be interesting

Name: Anonymous 2011-08-22 22:48

>>28
Java programmer detected: you must stop pushing the '.' key sometimes, you know?

Name: Anonymous 2011-08-22 22:55

Name: 29 2011-08-22 22:59

>>30
FUCK

Name: n3n7i 2011-08-22 23:25

Public Display of !n7elligence == Troll ?

...Did i spell LSFR wrong? LFSR rolls off the tounge better
tsss what were they thinking... LSFR...

Name: n3n7i 2011-08-22 23:42

Is it not supposed to be linear? That seems pretty useless....
Mine is waaaay better =D
(Making up for all the times i havent?[pressed the ......]) ? =)

Name: Anonymous 2011-08-22 23:42

die you fucking double-shitposting maniac

Name: n3n7i 2011-08-22 23:44

3^n (NOT -1) Maxim Length anyone?

Name: n3n7i 2011-08-23 0:34

>>34

It's not my post's fault you do not understand....

Name: n3n7i 2011-08-23 0:37

I can lead a horse to water, but i can't make it drink....
I can show you the door, but it's you that has to walk through...
..etc?

Name: Anonymous 2011-08-23 1:07

>>21-22
Here's the first diagram: http://pastebin.com/ztseN7GP
(copy-paste the text from the pastebin to your browser's address bar to see the image)

It shows how adders should be connected to each other.

I'll make the detailed view of the insides of an adder unit later on (I'm real tired right now).

Name: n3n7i 2011-08-23 1:09

>>http://c2.com/cgi/wiki?ThreeValuedLogic

>>We should also consider the question of state inversion in ternary systems (as well as 4-state systems and so on). In a binary system, inversion is trivial - not 0 is 1, not 1 is 0. In three-value logic, inversion (!) is not necessarily as simple as claimed above. The inversion of 0 can be either 1 or 2. Inversions are often most useful when they are reversible, so that if !0 = 2, then !2 = 0. This leaves 1 to invert to itself. Another approach, however, has !0=1, !1=2, and !2=0 - this is invertible but not reversible, as !(!0) = 2, not 0. There are 6 reversible ternary inverters (including the identity).


>>is invertible but not reversible,
=) Left-handed // Right-handed Op's? ...Reversed enough>?>
if (!)0=2 (i)2=0

Name: n3n7i 2011-08-23 1:14

Its Cyclic-3 anyway

!(!(!0))) = 0 .... !!! Not !! .....

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List