# Computer Logic and Organization for Beginners pt 2

Page 1 of 1

## 2 Replies - 10172 Views - Last Post: 09 September 2014 - 06:20 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=353415&amp;s=9d5ba89fa34d0ce297ee5d9d46ecf27d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 NeoTifa

• NeoTifa Codebreaker, the Scourge of Devtester

Reputation: 4655
• Posts: 19,489
• Joined: 24-September 08

# Computer Logic and Organization for Beginners pt 2

Posted 09 September 2014 - 04:21 PM

POPULAR

Computer Logic and Organization for Beginners - Part 2

• Introduction
• Logisim
• Our First Circuit: 1 bit adder
• Other arithmetic

1.)Introduction

Hello, and welcome to part 2 of my Computer Logic and Organization series. This is a continuation of the more hardware look on how the inner workings of the computer works. In this tutorial, we'll go through the basics of building our first circuit. I'm using a free software I used at Wright State University that simulates the circuits virtually.

Computer Logic and Organization for Beginners Pt 1

2.) Logisim

Logisim is a free software I have used before that digitally simulates circuits. It gives you all kinds of functionality, so I'm going to give you a quick crash course. You can download Logisim here. Once you have it downloaded, just save it somewhere familiar.

This is the basic layout. I don't know for sure what all the stuff is officially called, so I just called it "goodies window" and workbench. If you open the folders, you can see the various premade components ready for use for whatever devious tasks you plan. But where's the fun in premade stuff when we can make our own?! />/>/> Anywho, you can go ahead and poke around a bit if you want.

3.) Our First Circuit: 1 Bit Adder

So we're gonna learn how to add 2 1-bit numbers together. How freaking exciting, huh? But how do we do this? Since it's only 2 1-bit numbers, we can just use a truth table. Z = X + Y and Cout is the carry out for the overflow, because 1 + 1 = 2, which is 10, which is 2 bits.

X Y | Z Cout
------------
0 0 | 0 0
0 1 | 1 0
1 0 | 1 0
1 1 | 0 1

You know what, lets get crazy and add a carry in bit! Just for funsies (also for portability). C = carry in. Normally I'd write Cin but it's easier to type. />/>/>

C X Y | Z Cout
--------------
0 0 0 | 0 0
0 0 1 | 1 0
0 1 0 | 1 0
0 1 1 | 0 1
1 0 0 | 1 0
1 0 1 | 0 1
1 1 0 | 0 1
1 1 1 | 1 1

So how do we turn this into a circuit, you may ask? Lets do a K-map! Yay, using what we learned!

I don't recall a table function so I just used wires to make the maps lol. For the output Z, we can see that it's a checkerboard. This means XOR. The Cout is slightly more complicated. I wrote out the equation for ya. So now lets turn those equations into a circuit!

You can use the hand tool to flip the bits to check that the inputs and outputs match your table. For all the gates I changed the number of inputs to 2 and made the gate size narrow so it's not freaking huge. Now for the XOR gate, in order to get it to work properly, you need to change the multi-input behavior to true when odd like so.

Now we have our first circuit! Fun! Save it as something useful, say, 1bitadder.circ like I did. Go ahead and just click the green plus sign (or go to program -> add new circuit) and create one called 1bitadder. Cut and paste the circuit into the new circuit.

Just like with OOP, 'encapsulation' is WAAYYYYY easier than reinventing the wheel. This is why I added a carry out and a carry in, because you can pass the carry out to the carry in of another adder, and that way we can 'stack' them to make, say, a 4 bit adder, or even an 8 bit, 16 bit, etc. Go ahead and create yet another circuit called 4bitadder. Click on 1bitadder and put 4 of them in the new circuit, like so:

I was lazy and haven't put it in a new circuit yet, so it's just in main. I changed the bits to 4 bits and used splitters. Not the prettiest thing, but I'm half asleep. Noticed how I used the carry outs for the carry ins. The most significant bit is towards the top.

I think this will conclude this episode of the series. Next time we'll look at some other arithmetic functions and how to build circuits on them, and maybe even our first ALU! Cheers!

This post has been edited by modi123_1: 09 September 2014 - 06:24 PM

Is This A Good Question/Topic? 5

## Replies To: Computer Logic and Organization for Beginners pt 2

### #2 ludiklovn

Reputation: 1
• Posts: 3
• Joined: 17-May 14

## Re: Computer Logic and Organization for Beginners pt 2

Posted 09 September 2014 - 05:03 PM

Thank you for the nice article. May i suggest that you link previous one at the beginning, i think it will make navigation easier when there are more of them.

### #3 NeoTifa

• NeoTifa Codebreaker, the Scourge of Devtester

Reputation: 4655
• Posts: 19,489
• Joined: 24-September 08

## Re: Computer Logic and Organization for Beginners pt 2

Posted 09 September 2014 - 06:20 PM

I don't think I can edit tutorials, but if a mod would do the honors, I'd be appreciative.