Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Science - Lecture 6

Similar presentations


Presentation on theme: "Introduction to Computer Science - Lecture 6"— Presentation transcript:

1 Introduction to Computer Science - Lecture 6
Boolean Algebra, digital circuits

2 Data processing After previous lectures we know how to encode and store information It is time to consider how to process information

3 Data processing Data processing is the process of inferring new information based on previously known information. An example of data processing is computing the average salary in a company based on the salaries of every employee of the company.

4 Data processing One of the simpler (though not elementary) mechanisms of data processing is adding of two integer numbers. In order to perform this operation, computers make use of digital circuits built of logic gates.

5 Logic gates A logic gate represents an electronic circuit which has one or more input signals and exactly one output signal For technical reasons, these signals are always 0 (interpreted as no signal) or 1 (interpreted as a non-zero signal) Logic gates can be represented by a so called truth table.

6 Logic gates Source:

7 Boolean algebra Logic gates can be combined into more complicated circuits Mathematical model of these operations is the Boolean algebra

8 Boolean algebra Boolean algebra is the following algebraic structure:
BA = (B, ∩,∪,~,0,1) where: B - any set ∩,∪ - two-argument functions ~ - one-argument function 0,1 - selected elements from B

9 Boolean algebra For electronic applications we use: B = {0,1}
∩ - logical product (AND) ∪ - logical sum (OR) ~ - logical negation (NOT)

10 Boolean algebra Logic circuit is every function f:Bn→ Bm built with ∩, ∪ and ~ The letters x,y,z will denote logical variables assuming the values 0 and 1. An example of a logical circuit is the function: f(x,y) = (x ∩ ~y) ∪ ~(~y ∪ ~x)

11 Gray code Let’c consider standard binary 3-bit codes: 000 1 001 2 010
000 1 001 2 010 3 011 4 100 5 101 6 110 7 111

12 Gray code Note that the codes for 3 and 4, despite of being neighbours, differ by 3 bits. In some electronic applications (eg. in Karnaugh optimiziation) it is useful to have a coding in which every two neighbouring codes only differ by one bit. Such code was proposed Frank Gray

13 Gray code Construction of n-bit Gray code with the use of a table:
if n=1, the Gray code is 0,1 n-bit Gray code is constructed by: noting the n-1 bit Gray code and prepending 0 to each code noting the n-1 bit Gray code in reverse and prepending 1 to each code

14 Gray code Finding the i-th number in the n-bit Gray code
Write i in the standard binary code. Fill with zeros if necessary. Write also the same number but shifted right by one bit. The rightmost bit is discarded. On the first position write 0. Perform a bitwise XOR.

15 Adders Let’s consider the following circuit:
Source: M. Pudełko “Urządzenia techniki komputerowej”

16 Adders This is the half adder. It is used to build full adders.

17 Adders A full adder has three inputs: Outpus of the adder are:
Ai - i-th bit of the first number Bi - i-th bit of the second number Ci-1 - carry over bit from the previous position Outpus of the adder are: Si - sum Ci - carry over bit for the next position

18 Adder A full adder:

19 Sources http://zto.ita.pwr.wroc.pl/~luban/uklady_kom/sum/sum.html
M. Pudełko: “Urządzenia techniki komputerowej”

20 Thank you for your attention!


Download ppt "Introduction to Computer Science - Lecture 6"

Similar presentations


Ads by Google