2 Replies - 8777 Views - Last Post: 09 September 2014 - 06:20 PM Rate Topic: -----

#1 NeoTifa  Icon User is online

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • 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
  • 4 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.

Posted Image

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?! :D/>/>/> 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. :P/>/>/>

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!

Posted Image

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!

Posted Image

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.

Posted Image

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.




4.) 4 Bit Adder

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:

Posted Image

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  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • 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.
Was This Post Helpful? 1
  • +
  • -

#3 NeoTifa  Icon User is online

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • 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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1