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

Pages: 1-4041-

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 !! .....

Name: Duke Nukem 2011-08-23 1:27

>>36,37,39,40
EAT SHIT AND DIE!!!

Name: Anonymous 2011-08-23 7:35

>>36
Yes it is, the problem being your 'it's someone else's problem' attitude. If you don't know how to write for people, please leave, SHIT TROLL

Name: n3n7i 2011-08-23 7:36

lol

i dont understand? =/

Name: Anonymous 2011-08-23 7:37

BUNTH OF FARTITHS IN THITH THREAD

Name: Anonymous 2011-08-23 7:38

>>43

As a long time lurker of /prog/, I want to dedicate my first post to say GET OUT SHIT TROLL.

Name: n3n7i 2011-08-23 7:46

>>1 & 10 were the 'Good' posts in this thread....

I guess i don't know how to write for a bunch of $%^$%&%^UR^&I^&OI

Name: ( ≖‿≖) 2011-08-23 8:12

>>46
YEAH
Tell them what they really are! Show your true anger!

Name: n3n7i 2011-08-23 9:37

Nah, that will be all...

I did a basic ternary LSFR loop on paper though =)

Name: Anonymous 2011-08-23 12:13

>>38
The details of the inside would be nice. I'm still confused as to how this works from a circuitry standpoint.

Do you use a regular full adder 4 times, effectively adding the denary numbers together? How do I make it so that it knows that the number is above 9... like... if...

A and B and C and D
A and B and !C and D
A and !B and C and D

Are all the combinations that I think can give you a binary number equivalent to >9 so would I have to wire it so that those states result in a carry. Also what if what I get results in a carry of greater than 1? Like 1111 + 1111?

Looking back this shit is a hundred times more complicated than anything we were taught or I'm just not understanding something.

Name: Anonymous 2011-08-23 13:07

1111 + 1111
= 11110
Carry is never greater than 1.

Name: Anonymous 2011-08-23 13:12

I AM THE KING OF FARTS, BOW DOWN AND SMELL MY HEAVENLY ODORS

Name: Anonymous 2011-08-23 13:14

I AM THE KING OF FARTS, BOW DOWN AND SMELL MY HEAVENLY ODORS

Name: Anonymous 2011-08-23 21:39

>>50
Oh... OH! I'm such a howling retard that I was thinking in terms of decimal carries instead of binary carries.

Goddamnit.

Name: Anonymous 2011-08-23 22:58

>>49
Here's the insides of the BCD full adder: http://pastebin.com/94fRF4hm

First you should understand how multi-digit adders work. They are nothing but a chain of full adders (like in http://en.wikipedia.org/wiki/Adder_%28electronics%29#Ripple_carry_adder ).

A digital comparator shouldn't be very hard to implement. You start with the digit in the most significant position. If the digits of both numbers in that position are equal, you move on to the next one; otherwise, you're done because you can say which one is larger. Your homework is to apply that to make a 4-bit comparator (it's even easier since you're comparing against a constant).

Also, if r=x+y+c where 0≤x≤9 and 0≤y≤9 and 0≤c≤1, then 0≤r≤19.

Name: Anonymous 2011-08-23 23:04

<DOUBLES!

Name: Anonymous 2011-08-23 23:59

data:image/svg+xml
What the fuck. Could you be any more perverse?

Here's my version, showing 61+85=146:
http://img839.imageshack.us/img839/6292/bcdadd.png

And for additional perverseness (which happens to be 1/2 the size of yours while being more informative):
http://pastebin.com/1ksMrcxf

Name: Anonymous 2011-08-24 0:12

/prog/ has become /ee/.

Name: Anonymous 2011-08-24 0:13

>>56
What program is this?

Name: Anonymous 2011-08-24 1:41

>>57
programming and ee are intimately related.

Name: Anonymous 2011-08-24 2:13

>>59
Just like my dick and your anus. Seriously though, I agree.

Name: Anonymous 2011-08-24 2:48

Thanks so much for helping with this, you are all gentlemen and scholars.

Name: Anonymous 2011-08-24 2:57

>>56
You could just not be a dick about it, you know.  On the other hand, what program are you using?  Inkscape isn't very appropriate for this kind of job.

Name: Anonymous 2011-08-24 19:16

>>62
http://www.capilano.com/dww_overview
Yeah, proprietary software, and it sometimes crashes, but I haven't found anything quite as easy to use and portable from the FOSS community (no, I will NOT install 300MB of shitty bloated libraries just to use your 2MB app.)

Name: Anonymous 2011-08-24 20:32

>>63
Any FOSS Linux-compatible variants (MMLogic is FOSS I think but it only runs on Windows)? I'm too damn lazy to try them out myself.

Name: Anonymous 2011-08-24 20:50

>>64
http://appdb.winehq.org/objectManager.php?sClass=version&iId=18016
Old enough that it works in WINE. No Verilog or VHDL support though.

There are also a bunch of similarly sluggish and not-so-featureful but portable Java ones like
http://ozark.hendrix.edu/~burch/logisim/

And for *nix only, I used it once, not bad but a bit laggy:
http://www.tkgate.org/

Name: Anonymous 2011-08-25 1:34

<-Are those doubles I see?
I'M ON A ROLL!

Name: Anonymous 2011-08-25 2:56

>>64,65
Ah, finally finding out what that program was called after so many years brings a nostalgic tear to my eye, like seeing an old friend -- MMLogic was what pushed me into electronics and programming back when I was six or seven years old. Fuck, I loved it.

Name: Anonymous 2013-09-01 14:08


 English version drops tonight. Are you ready?

Name: Anonymous 2013-09-01 15:39


Time enough has passed for a moebeetus thread. heart-stopping images abound. Lay it on thick

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