0% found this document useful (0 votes)
4 views

Bits and Bytes

Uploaded by

metro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Bits and Bytes

Uploaded by

metro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

ФАКУЛТЕТ ЗА ЕЛЕКТРОТЕХНИКА И ИНФОРМАЦИСКИ ТЕХНОЛОГИИ

FACULTY OF COMPUTER SCIENCE AND ENGINEERING

Bits and bytes


10101010101010
10101010101010
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

What is data?
 Data are the facts and statistics collected
together for reference or analysis
 Data is information such as facts and
numbers used to analyze something or
make decisions
 Computer data is information in a form that
can be processed by a computer
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Definition given by ChatGPT


 Data refers to raw facts and figures that can be
processed or analyzed to generate information.
 It can exist in various forms, such as numbers,
text, images, or audio, and serves as the
foundation for decision-making, research, and
various computational processes.
 Data becomes meaningful when organized,
interpreted, or contextualized.
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

What is information?
 The facts provided or learned about something
or someone
 What is conveyed or represented by a particular
arrangement or sequence of things
 Knowledge obtained from investigation, study, or
instruction
 A collection of facts or details that provide
context and relevance, allowing individuals to
understand, analyze, and act upon a specific
situation or topic
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

How is information represented?

 Computers represent, process, store, copy, and


transmit everything as numbers
 hence "digital computer"
 The numbers can represent anything
 not just numbers that you might do arithmetic on
 The meaning depends on context
 as well as what the numbers ultimately represent
 e.g., numbers coming to your computer or phone from
your wi-fi connection could be email, movies, music,
documents, apps, Zoom meeting, ...
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Why binary numbers?


 Some of the first computers, such as ENIAC
from 1946, were using decimal arithmetic units
based on vacuum tubes
 Von Neumann: “Our fundamental unit of memory
is naturally adapted to the binary system since
we do not attempt to measure gradations of
charge at a particular point in the Selectron but
are content to distinguish two states.”
 The first computer Z3, created by Konrad Zuse
and released in 1941 used the binary system
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

How are they used in the


computers?
 Binary is used in computers because it's
easy to make fast, reliable, small devices
that have only two states
 high voltage/low voltage, current flowing/not
flowing (chips)
 electrical charge present/not present (RAM,
flash)
 magnetized this way or that (disks)
 light bounces off/doesn't bounce off (cd-rom,
dvd)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

What’s a bit?
 A bit represents one 2-way decision or a choice
out of two possibilities
 yes / no, true / false, on / off, up / down, north / south,
...
 The abstraction of all of these is represented as
0 or 1
 enough to tell which of TWO possibilities has been
chosen
 a single digit with one of two values
 hence "binary digit“
 hence bit
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

To summarize
 Bit - binary digit, the smallest unit of
storage (like an atom)
 A bit stores just a 0 or 1
 "Computer is all 0's and 1's" ... bits
 Anything with two separate states can store 1
bit
 Chip uses electricity 0/1 states
 Hard drive uses spots North/South magnetism
0/1 states
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Bytes
 Bit too small to be much use
 Group 8 bits into a byte (1 Byte = 8 Bits)
 One byte = grouping of 8 bits
 e.g. 0 1 0 1 1 0 1 0
 One byte can store one letter, e.g. 'b' or 'x‘

 Byte is the unit of information storage


 All storage is measured in bytes, despite
being very different hardware
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

How much can one byte hold?


How many distinct/separate patterns can
be made with 1, 2, or 3 bits?

Number of bits Distinct Patterns


1 01
2 00 01 10 11
3 000 001 010 011
100 101 110 111
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Bits
 In general: add 1 bit, double the number of
patterns
1 bit – 2 patterns 5 bits – 32
 2 bits – 4  6 bits – 64
 3 bits – 8  7 bits – 128
 4 bits – 16  8 bits – 256
 Mathematically: n bits yields 2ⁿ patterns (2 to
the nth power)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

One Byte - 256 Patterns


 1 byte is group of 8 bits
 Introduced by Werner Buchholz in 1956,
when he designed IBM computers
 8 bits can make 256 different patterns
 How to use the 256 patterns?
 How to store a number in a byte?
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

One Byte - 256 Patterns


 Start with 0, go up, one pattern per
number, until run out of patterns (256)
 0, 1, 2, 3, 4, 5, ... 254, 255
 One byte holds an integer number 0..255
 Code: pixel.setRed(n) took a number
0..255. Why?
 Red value stored in one byte
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

SI vs. IEC
 Standard SI (International System of Units) vs.
IEC (International Electrotechnical Commission)
representation
 Hard disk manufacturers use standard SI
notation
 1МB = 1.000.000 B / 80GB = 80.000.000.000 B
 Windows uses IEC notation
 The capacity of 80GB disk is presented as 74,56 GB
 250 GB is presented as 232 GB
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Kibibyte, Мebibyte...
1 kibibyte (KiB) = 1.024 bytes
1 kilobyte (KB) = 1.000 bytes
1 mebibyte (MiB) = 1.048.576 byte
1 megabyte (MB) = 1.000.000 bytes
1 gibibyte (GiB) = 1.073.741.824 bytes
1 gigabyte (GB) = 1.000.000.000 bytes
1 tebibyte (TiB) = 1.099.511.627.776 bytes
1 terabyte (TB) = 1.000.000.000.000 bytes

Learn more about these prefixes from:


https://en.wikipedia.org/wiki/Binary_prefix
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Kilobyte or KB
 One kilobyte (KB) is a
collection of about
1000 bytes. A page of
ordinary roman
alphabetic text takes
about 2 kilobytes to
store (about one byte
per letter). A typical
short email would
also take up just 1 or
2 kilobytes.
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Megabyte or MB (1)
 One old 3½ “ floppy holds 1,44 Megabytes. It
can store one small book
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Megabyte or MB (2)
 100 MB can store several volumes of an
encyclopedia
 650 MB is the capacity of one CD-ROM
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Gigabyte or GB
 1 GB holds almost two CD-ROMs
 1 GB can store several shelves of books
100 GB is sufficient for a home library
 ChatGPT was trained using databases from the
internet that included a massive 570 GB of data
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Terabyte or TB
 3,6 million images, 300 KB each, or 300
hours of video of good quality
 1.000 copies of Encyclopedia Britannica
 In April 2011, U.S. Library of Congress
collected data with a capacity of 235 TB (5
TB a month)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Petabyte or PB
 In 2022, U.S. Library of Congress
managed 21 PB of digital collection
content, comprising 914 million unique
files
 Google processes around 20+ PB of data
every day
 The NSA processes 30+ PB of data every
day
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Positional representation systems

 A numeration system in which a real


number is represented by an ordered set
of characters where the value of a
character depends on its position
 Positional notation
 base (or radix) – positive integer
 vocabulary – symbols for representing digits
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Positional numeration systems

 The most frequently used:


 decimal (base: 10, vocabulary: 0, 1, 2, 3, 4, 5,
6, 7, 8, 9)
 binary (base: 2, vocabulary: 0, 1)
 octal (base: 8, vocabulary: 0, 1, 2, 3, 4, 5, 6,
7)
 Hexadecimal or sexadecimal (base: 16,
vocabulary: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
D, E, F)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Binary notation system


 The reason for the binary notation system
concerns the nature of electricity in computer
circuits.
 Easy to store with bistable elements - relays
 Reliably transmitted on noisy and inaccurate
wires (media)
0 1 0

3.3V
2.8V

0.5V
0.0V
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Conversions
Binary - decimal
101001112 =
1*27 + 0*26 + 1*25 + 0*24 + 0*23 + 1*22 + 1*21 + 1*20 = 16710
Decimal - binary
167/2 = 83 1
83/2 = 41 1
41/2 = 20 1
20/2 = 10 0
10/2 = 5 0
5/2 = 2 1 101001112
2/2 = 1 0
1/2 = 0 1
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Conversion of floating numbers


Binary - decimal
0.1101012 =
1*2-1 + 1*2-2 + 0*2-3 + 1*2-4 + 0*2-5 + 1*2-6 = 0.82812510
Decimal – binary
0.828125*2 = 1.656250
0.656250*2 = 1.312500
0.312500*2 = 0.625000
0.625000*2 = 1.250000
0.250000*2 = 0.500000
0.500000*2 = 1.000000
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Byte in different notations


 Byte = 8 bits 0
1
0
1
0000
0001
 Binary 000000002 ...11111112 2 2 0010
3 3 0011
 Decimal 010 ... 25510 4 4 0100
5 5 0101
 Hexadecimal 0016 ... FF16 6 6 0110
7 7 0111
 ‘0’...‘9’ and ‘A’...‘F’ 8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Binary into octal


 Binary can be easily converted into octal
 Why?
 810 = 10002
 101001112 = ???8
 Let’s present it as triples:
010 100 1112 = 2478
 Was the calculation correct?
2*82 + 4*81 + 7*80 = 2*64 + 4*8 + 7*1 = 167
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Binary into hexadecimal


 Binary can be converted into hexadecimal
 Why?
 1610 = 100002
 101001112 = ???16
 Let’s present it as quadruples:
1010 01112 = A78
 Was the calculation correct?
10*161 + 7*160 = 10*16 + 7*1 = 167
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Floating binary into octal


 0.1101012 = ??? 8
 Let’s again present the bits as triples:
 0. 110 1012 = 0.65 8
 Was the calculation correct?
0.65 8 = 6*8-1 + 5*8-2 =
6*.0125 + 5*0.015625 =
0.75 + 0.078125 = 0.828125
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Floating binary into hexadecimal


 0.1101012 = ??? 16
 Let’s again present the bits as quadruples:
 0. 1101 01002 = 0.D4 16
 Was the calculation correct?
0.D416 = 13*16-1 + 4*16-2 =
13*.0125 + 5*0.015625 =
0.75 + 0.07812500 = 0.82812510
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Numbers and characters in


computers
 One byte works well for individual characters
 Computers are also good at manipulating
numbers
 ASCII is an encoding representing each typed
character by a number
 For example: A is 65, B is 66, a is 96, space is
32
 "Unicode" is an encoding for Cyrillic, typically 2-
bytes per "character“
 It is used for all non-English scripts
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Storing numbers
 Integers are typically stored with either 4
or 8 bytes
2 bytes: -32768 (-215) to 32767 (215-1)
 4 bytes: -2147483648 (-231) to 2147483647
(231-1)
 8 bytes: -9223372036854775808 (-263) to
9223372036854775807 (263-1)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Binary arithmetics
 Adding in binary is just like normal addition with
carrying
0 +0= 0
0+1= 1
1+0= 1
 1 + 1 = 10

 For example:
 1010 1111 + 1000 0001 = 1 0011 0000
 Subtraction, multiplication, division are
analogous
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Integer overflow
 When you run out of bits you can't carry
anymore
 Leftmost bit indicates sign, so carrying to the
leftmost bit changes a number from positive to
negative.
 So, adding 1 to 32767 goes to -32768
 Similarly, adding 1 to 2147483647 goes to
-2147483648
 This is called integer overflow
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Machine words
 Word = group of 2, 3, 4, ... bytes
 In the 1990s, computers used 32-bit
words: address space limited to 4GB
Few for demanding calculations
 Modern general purpose computers and
high-end systems use 64-bit words (8B)
address space ~ 1,8 X 1019B
x86-64 machines support 48B address
space: 256 TB
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

The memory subsystem


32B 64B
words words bytes address

 Addresses specify Addr


0000
0001
byte location =
0000
?? 0002
Addr
 Address of first byte = 0003
is word Addr
0000
?? 0004
= 0005
 Addresses of 0004
?? 0006
successive words 0007
differ by 4 (32-bit) or 0008
Addr
8 (64-bit) = 0009
0008
??
Addr
0010
= 0011
0008
?? 0012
Addr
= 0013
0012
?? 0014
0015
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Basic memory concepts (1)


 How to order bytes within a memory word?
 Conventions for byte ordering:
 Big Endian: Sun, PPC Mac, Internet
 In Big Endian, the most significant byte (MSB) is
stored in the smallest address
 Little Endian: x86
 In Little Endian, the least significant byte (LSB) is
stored in the smallest address
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Basic memory concepts (2)


 Big Endian
 The least significant byte has the biggest address
 Little Endian
 The least significant byte has the biggest address
 Example
 Variable x presented with 4 bytes: 0x01234567
 The address of &x is 0x100

Big Endian 0x100 0x101 0x102 0x103


01 23 45 67
Little Endian 0x100 0x101 0x102 0x103
67 45 23 01
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Data representations
 How much data types occupy in C (in bytes)?
 C Data type Typical 32-bit Intel IA32 x86-64
 char 1 1 1
 short 2 2 2
 int 4 4 4
 long 4 4 8
 long long 8 8 8
 float 4 4 4
 double 8 8 8
 long double 8 10/12 10/16
 char * 4 4 8
* Or any pointer
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Examining Data Representations

 Code to Print Byte Representation of Data


 Casting pointer to unsigned char * creates byte array

typedef unsigned char *pointer;

void show_bytes(pointer start, int len)


{
int i;
for (i = 0; i < len; i++)
printf("0x%p\t0x%.2x\n“, start+i, start[i]);
printf("\n");
}

Printf directives:
%p: Print pointer
%x: Print Hexadecimal
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

show_bytes Execution example

int a = 15213;
printf("int a = 15213;\n");
show_bytes((pointer) &a, sizeof(int));

Result (Linux):
int a = 15213;
0x11ffffcb8 0x6d
0x11ffffcb9 0x3b
0x11ffffcba 0x00
0x11ffffcbb 0x00
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Representing integers
int A = 15213; Decimal: 15213
int B = -15213; Binary: 0011 1011 0110 1101
long int C = 15213;
Hex: 3 B 6 D
IA32, x86-64 A Sun A IA32 C x86-64 C Sun C
6D 00 6D 6D 00
3B 00 3B 3B 00
00 3B 00 00 3B
00 6D 00 00 6D
00
IA32, x86-64 B Sun B 00
00
93 FF
00
C4 FF
FF C4
FF 93 Two’s complement representation
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Let’s subtract by adding


 1312 – 687 = ???
 1312 + 313 = 1 625
 So, 1312 – 678 = 625
 Do you agree?

 Let’s try again:


 2189 – 1932 = ???
 2189 + 8068 = 1 0257
 2189 – 1932 = 257
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

How did we do it?


 1312 – 687 = 1312 – (1000 - 313) =
1312 + 313 – 1000 = 1625 - 1000 = 625
 2189 – 1932 = 2189 – (10000 - 8068) =
2189 + 8068 – 10000 = 10257 – 10000

 313 is a ten’s (decimal) complement of 687


 8068 is a ten’s (decimal) complement of 1932
 312 is a nine’s complement of 687
 8067 is a nine’s complement of 1932
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Two’s complement
 Two’s complement (of a binary number):
 Invertsthe digits. 0 becomes 1, 1 becomes 0 (one’s
complement).
 Adds 1 (two’s complement)

 If the first (leftmost) bit is 0, the number is 0 or


positive
 If the first (leftmost) bit is 1, the number is
negative
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Examples:
 Negative numbers are represented with
their two’s complement (without the sign of
the number)

x  510 x  0  x e  x  00101  510


x  510 x  0  two's complement x e  00101  1  11011
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Working with binary data


 Binary variables take only two possible values,
traditionally termed 0 and 1
 Logical operators work with binary data and binary
variables
 Basic logic operations (bitwise operations):
 AND, OR, NOT
 Logic gates implement logic functions
 Boolean algebra is mathematical basis that encodes
logical functions
 Boolean algebra is the foundation for the design and
analysis of digital systems
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Boolean algebra
 Basic logical operators:
 AND . or &
 OR + or |
 NOT ¯ , ‘ , or (~)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

In C
 AND &&
 OR ||
 NOT !
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Truth tables
 Example: Truth table for basic logical
operators:

AND OR NOT
X Y Z = X·Y X Y Z = X+Y X ZX
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Implementation of logical functions


Parallel switches => OR
 Switches
 Inputs:
 logical 1: closed
 logical 0: open
 Outputs: Serial switches => AND
 logical 1: light is energized
 logical 0: light is not energized
 NOT input:
 logical 1: open
Closed switch => NOT
 logical 0: closed
C
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Logic gates
 In first computers, to build logic systems,
switches were opened and closed using
magnetic field and electric coils in relays
 Afterwards, vacuum tubes replaced relays
 Today, logic gating function and the
amplifying function are performed by
transistors
 The logic is called transistor - transistor
logic (TTL)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Symbols of logic gates


 Logic gates utilize special symbols
X X
Z = X ·Y Z= X+ Y X Z= X
Y Y
AND gate OR gate NOT gate or inverter

 Performance:
X 0 0 1 1

Y 0 1 0 1

(AND) X ·Y 0 0 0 1

(OR) X+ Y 0 1 1 1

(NOT) X 1 1 0 0
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Gate latency
 A standard logic gate does not respond to a change of one of its
inputs instantaneously
 There is, instead, a finite delay between a change on the input and a
change on the output
 The propagation delay of a standard logic gate is tG

Input
1
0 tG tG tG = 0.3 ns

Output 1
0
0 0.5 1 1.5 Time (ns)
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Boolean algebra
 Created by George Boole in 1854
 Algebraic structure defined over set B = {0, 1},
two binary operators (+ and ·) and one unary operation ( )

1. X + 0= X 2. X .1=X Identity for AND


3. X+ 1=1 4. X .0=0 Identity for OR
5. X+X=X 6. X .X = X Idempotent
7. X+X=1 8. X .X = 0 Complement
9. X=X Involution
10. X +Y =Y+ X 11. XY = YX Commutativity
12. (X + Y) + Z = X + (Y + Z) 13. (XY) Z = X(Y Z) Associativity
14. X(Y + Z) = XY + XZ 15. X + YZ = (X + Y) (X + Z) Distributivity
16. X + Y = X . Y 17. X .Y = X + Y De Morgan
ФАКУЛТЕТ ЗА ИНФОРМАТИЧКИ НАУКИ
И КОМПЈУТЕРСКО ИНЖЕНЕРСТВО

Summary
 Data and information
 Bits
 Bytes
 Binary arithmetic
 Working with binary data
 Implementation of binary data

You might also like