Computer Science Project 1
Computer Science Project 1
Computer Science Project 1
SCHOOL OF LAW
CERTIFICATE
To the best of my knowledge, the matter embodied in the project has not been submitted to
any other University / Institute for the award of any Degree or Diploma in the year 2016-
2017.
Date: 10/09/2016
In performing our assignment, I had to take the help and guidance of some respected persons
who deserve our greatest gratitude. The completion of this assignment gives me much
pleasure. I would like to show our gratitude to RAVINDER SIR, Course Instructor, Manipal
University Jaipur for giving us good guideline for assignment throughout numerous
consultations. I would also like to expand our deepest gratitude to all those who have directly
and indirectly guided us in writing this assignment.
In addition, a thank you to the Professor who introduced us to the Methodology of work and
whose passion for the underlying structures had lasting effect. I also thank the Manipal
University Jaipur for the consent to include the copyrighted pictures as a part of our paper.
Many people, especially our classmates and team members itself have made valuable
comment suggestions on this proposal which gave us inspiration to improve our assignment. I
thank all the people for their help directly and indirectly to complete our assignment.
SANJANA SACHAN
Table of Contents
CERTIFICATE......................................................................................................... 2
ACKNOWLEDGEMENT........................................................................................... 3
INTRODUCTION..................................................................................................... 4
CHAPTER 1............................................................................................................. 5
Characteristics of binary number system are as follows:.............................................7
Example............................................................................................................ 8
Characteristics of octal number system are as follows:................................................8
Example............................................................................................................ 8
Characteristics of hexadecimal number system are as follows:.....................................9
Example............................................................................................................ 9
CHAPTER 2........................................................................................................... 10
Counting in binary............................................................................................ 11
Converting binary to decimal.............................................................................. 12
CHAPTER 3........................................................................................................... 14
Combinational Logic........................................................................................... 15
CHAPTER 4........................................................................................................... 16
Complement (NOT)........................................................................................... 17
OR................................................................................................................. 17
AND............................................................................................................... 18
XOR............................................................................................................... 18
CONCLUSION....................................................................................................... 20
WEBLIOGRAPHY.................................................................................................. 21
INTRODUCTION
Digital logic is a wide-open and rapidly-growing field, and yet every single digital device
operates on some combination of three basic logic functions: AND, OR, and NOT. Even the
most complex circuit contains some combination of these three functions, and can be reduced
to them in the final analysis. These pages define and describe the three basic functions and
some of the unending ways in which they can be usefully combined.
It includes :
- Digital Circuitry
- Programming
Digital Circuitry
Programming
CHAPTER 1
When we type some letters or words, the computer translates them in numbers as computers
can understand only numbers. A computer can understand positional number system where
there are only a few symbols called digits and these symbols represent different values
depending on the position they occupy in the number.
The digit
The base of the number system (where base is defined as the total number of digits
available in the number system).
The number system that we use in our day-to-day life is the decimal number system.
Decimal number system has base 10 as it uses 10 digits from 0 to 9. In decimal number
system, the successive positions to the left of the decimal point represent units, tens,
hundreds, thousands and so on.
Each position represents a specific power of the base (10). For example, the decimal number
1234 consists of the digit 4 in the units position, 3 in the tens position, 2 in the hundreds
position, and 1 in the thousands position, and its value can be written as
1000 + 200 + 30 + 4
1234
Each position in a binary number represents a 0 power of the base (2). Example 20
Last position in a binary number represents a x power of the base (2). Example
2x where x represents the last position - 1.
Example
Each position in an octal number represents a 0 power of the base (8). Example 80
Last position in an octal number represents a x power of the base (8). Example
8x where x represents the last position - 1.
Example
Letters represents numbers starting from 10. A = 10. B = 11, C = 12, D = 13, E = 14,
F = 15.
Step 2 19FDE16 ((1 x 164) + (9 x 163) + (15 x 162) + (13 x 161) + (14 x
160))10
Counting in binary
You can count in decimal endlessly, even in your sleep, but how would you count in binary?
Zero and one in base-two should look pretty familiar: 0 and 1. From there things get
decidedly binary.
Remember that weve only got those two digits, so as we do in decimal, when we run out of
symbols weve got to shift one column to the left, add a 1, and turn all of the digits to right to
0. So after 1 we get 10, then 11, then 100. Lets start counting
0 0 16 10000
1 1 17 10001
2 10 18 10010
3 11 19 10011
4 100 20 10100
5 101 21 10101
6 110 22 10110
7 111 23 10111
8 1000 24 11000
9 1001 25 11001
10 1010 26 11010
11 1011 27 11011
12 1100 28 11100
13 1101 29 11101
14 1110 30 11110
15 1111 31 11111
Does that start to paint the picture? Lets examine how we might convert from those binary
numbers to decimal.
Theres no one way to convert binary-to-decimal. Well outline two methods below, the more
mathy method, and another thats more visual. Well cover both, but if the first uses too
much ugly terminology skip down to the second.
Method 1
Theres a handy function we can use to convert any binary number to decimal:
an, an-1, a1, etc., are the digits of a number. These are the 0s and 1s youre familiar
with, but in binary they canonly be 0 or 1.
The position of a digit is also important to observe. The position starts at 0, on the
right-most digit; this 1 or 0 is the least-significant. Every digit you move to the left
increases in significance, and also increases the position by 1.
The length of a binary number is given by the value of n, actually its n+1. For
example, a binary number like 101 has a length of 3, something larger, like 10011110
has a length of 8.
Each digit is multiplied by a weight: the 2n, 2n-1, 21, etc. The right-most weight -
20 equates to 1, move one digit to the left and the weight becomes 2, then 4, 8, 16, 32,
64, 128, 256, and on and on. Powers of two are of great importance to binary, they
quickly become very familiar.
Lets get rid of those ns and exponents, and carry out our binary positional notation equation
out eight positions:
Taking that further, lets plug in some values for the digits. What if you had a binary number
like: 10011011? That would mean an values of:
For the sake of this tutorial, assume that the right-most value is always the least-significant.
The least-significant digit in a number is the digit that has the smallest influence on a
numbers ultimate value. The significance of the digits is arbitrary - part of a convention
called endianness. A binary number can be either big-endian, where the most-significant
digit is the left-most, or little-endian which well use in this tutorial (and youll usually see
binary numbers written this way).
Now, plug those digits into our binary to decimal equation. Because our number is little-
endian the least-significant value should be multiplied by the smallest weight.
1 * 27 + 0 * 26 + 0 * 25 + 1 * 24 + 1 * 23 + 0 * 22 + 1 * 21 + 1 * 20
= 1 * 128 + 0 * 64 + 0 * 32 + 1 * 16 + 1 * 8 + 0 * 4 + 1 * 2 + 1 * 1
= 128 + 16 + 8 + 2 + 1
= 155
Youll quickly notice that it takes many more digits to represent a number in binary than it
does in decimal, but its all done with just two digits!
Method 2
Another, more visual way to convert binary numbers to decimal is to begin by sorting
each 1 and 0 into a bin. Each bin has a successive power of two weight to it, the 1, 2, 4, 8, 16,
were used to. Carrying it out eight places would look something like this:
128 64 32 16 8 4 2 1
So, if we sorted our 10011011 binary number into those bins, itd look like this:
128 64 32 16 8 4 2 1
1 0 0 1 1 0 1 1
For every bin that has a binary 0 value in it, just cross out and remove it.
128 64 32 16 8 4 2 1
1 0 0 1 1 0 1 1
CHAPTER 3
Unlike Sequential Logic Circuits whose outputs are dependant on both their present inputs
and their previous output state giving them some form of Memory, the outputs
of Combinational Logic Circuits are only determined by the logical function of their current
input state, logic 0 or logic 1, at any given instant in time.
The result is that combinational logic circuits have no feedback, and any changes to the
signals being applied to their inputs will immediately have an effect at the output. In other
words, in a Combinational Logic Circuit, the output is dependant at all times on the
combination of its inputs. So if one of its inputs condition changes state, from 0-1or 1-0, so
too will the resulting output as by default combinational logic circuits have no memory,
timing or feedback loops within their design.
Combinational Logic
Combinational Logic Circuits are made up from basic logic NAND, NOR or NOT gates
that are combined or connected together to produce more complicated switching circuits.
These logic gates are the building blocks of combinational logic circuits. An example of a
combinational circuit is a decoder, which converts the binary code data present at its input
into a number of different output lines, one at a time producing an equivalent decimal code at
its output.
Combinational logic circuits can be very simple or very complicated and any combinational
circuit can be implemented with only NAND and NOR gates as these are classed as
universal gates.
The three main ways of specifying the function of a combinational logic circuit are:
1. Boolean Algebra This forms the algebraic expression showing the operation of
the logic circuit for each input variable either True or False that results in a logic
1 output.
2. Truth Table A truth table defines the function of a logic gate by providing a
concise list that shows all the output states in tabular form for each possible
combination of input variable that the gate could encounter.
and all three of these logic circuit representations are shown below.
As combinational logic circuits are made up from individual logic gates only, they can also be
considered as decision making circuits and combinational logic is about combining logic
gates together to process two or more signals in order to produce at least one output signal
according to the logical function of each logic gate. Common combinational circuits made up
from individual logic gates that carry out a desired application include Multiplexers, De-
multiplexers, Encoders, Decoders, Full and Half Adders etc.
CHAPTER 4
Complement (NOT)
The complement of a binary value is like finding the exact opposite of everything about it.
The complement function looks at a number and turns every 1 into a 0 and every 0 becomes
a 1. The complement operator is also called NOT.
-------- =
01001010 (decimal 74)
NOT is the only bitwise operator which only operates on a single binary value.
OR
OR takes two numbers and produces the union of them. Heres the process to OR two binary
numbers together: line up each number so the bits match up, then compare each of their bits
that share a position. For each bit comparison, if either or both bits are 1, the value of the
result at that bit-position is 1. If both values have a 0 at that position, the result also gets a 0 at
that position.
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1
For example to find the 10011010 OR 01000110, line up each of the numbers bit-by-bit. If
either or both numbers has a 1 in a column, the result value has a 1 there too:
10011010
OR 01000110
-------- =
11011110
Think of the OR operation as binary addition, without a carry-over. 0 plus 0 is 0, but 1 plus
anything will be 1.
AND
AND takes two numbers and produces the conjunction of them. AND will only produce
a 1 if both of the values its operating on are also 1.
The process of AND'ing two binary values together is similar to that of OR. Line up each
number so the bits match up, then compare each of their bits that share a position. For each
bit comparison, if either or both bits are 0, the value of the result at that bit-position is 0. If
both values have a 1 at that position, the result also gets a 1 at that position.
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
For example, to find the value of 10011010 AND 01000110, start by lining up each value.
The result of each bit-position will only be 1 if both bits in that column are also 1.
10011010
AND 01000110
-------- =
00000010
Think of AND as kind of like multiplication. Whenever you multiply by 0 the result will also
be 0.
XOR
XOR is the exclusive OR. XOR behaves like regular OR, except itll only produce
a 1 if either one or the othernumbers has a 1 in that bit-position.
The four possible XOR combinations, and their outcome are:
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
10011010
XOR 01000110
-------- =
11011100
In this project I have introduced the topic of Digital Logic. First I have given the basic
introduction of digital logic and then proceeded with the main topics. It includes digital
circuitry and programming.
And also covered the topics of conversions and counting as well as combinational logic.
And chapter 4 includes
NOT
OR
AND
XOR
WEBLIOGRAPHY
https://learn.sparkfun.com/tutorials/digital-logic
https://learn.sparkfun.com/tutorials/binary
http://www.electronics-tutorials.ws/combination/comb_1.html