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

Cours Struct M Chapitre1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Cours Struct M Chapitre1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

‫اﻟـﺟﻣﮭــورﯾﺔ اﻟــﺟزاﺋرﯾﺔ اﻟـدﯾﻣﻘراطــﯾﺔ اﻟـﺷــﻌﺑﯾﺔ‬

‫وزارة اﻟﺗﻌﻠﯾم اﻟﻌﺎﻟﻲ واﻟﺑﺣث اﻟﻌﻠﻣﻲ‬


Ministry of Higher Education and Scientific Research

Computer structure
1

2020/2021 Abdelmadjid Boukra 1


Teacher presentation

• Mr BOUKRA Abdelmadjid
• Teacher-researcher at the university of sciences
• and technology Houari Boumediene (USTHB)

Email : [email protected]

2020/2021 Abdelmadjid Boukra 2


Course outline
• Chapter 1 number systems and information
• representation

• Chapter 2 Boolean algebra and logic circuits

• Chapter 3 Combinatorial circuits

2020/2021 Abdelmadjid Boukra 3


•Chaptre 1
Number systems and
information
representation
Chapter 1
Number Systems and information
representation
1. Concept of number systems
In common use, a number N written in the form
N=1962
Can be written as
N = 1. 103 + 9.102 + 6.101 + 2.100

The number 10 intervenes through its different powers


103 =1000, 102=100, 101=10 et 100=1

2020/2021 Abdelmadjid Boukra 5


• The number 10 is the base B in the decimal number system.
• It allows you to express any number in the following way

• 𝑵𝑵 = ∑𝒏𝒏𝒊𝒊=𝟎𝟎 𝒂𝒂𝒊𝒊 . 𝟏𝟏𝟏𝟏𝒊𝒊


• where 𝟎𝟎 ≤ 𝒂𝒂𝒊𝒊 < 𝟏𝟏𝟏𝟏

We say that 1962 is the implicit form and that


N = 1. 103 + 9.102 + 6.101 + 2.100 is the explicit form
Generally speaking, a number N can be written in a base B as
𝑁𝑁𝐵𝐵 = 𝑎𝑎𝑛𝑛 . 𝐵𝐵𝑛𝑛 + 𝑎𝑎𝑛𝑛−1 . 𝐵𝐵𝑛𝑛−1 + ⋯ + 𝑎𝑎0 . 𝐵𝐵0 0 ≤ 𝑎𝑎𝑖𝑖 < 𝐵𝐵

Most Significant Digit (MSD) Least Significant Digit (LSD)


Abdelmadjid Boukra
6
• For fractional numbers, for example,
• N= 1962,31
will be written in the form:

N = 1. 103 + 9.102 + 6.101 + 2.100 + 3.10-1 + 1.10-2

In general, a fractional number N in base B will be written in the form:

𝑵𝑵𝑩𝑩 = 𝒂𝒂𝒏𝒏 . 𝑩𝑩𝒏𝒏 + 𝒂𝒂𝒏𝒏−𝟏𝟏 . 𝑩𝑩𝒏𝒏−𝟏𝟏 + ⋯ + 𝒂𝒂𝟎𝟎 . 𝑩𝑩𝟎𝟎 + 𝒂𝒂−𝟏𝟏 . 𝑩𝑩−𝟏𝟏 + 𝒂𝒂−𝟐𝟐 . 𝑩𝑩−𝟐𝟐 …

𝟎𝟎 ≤ 𝒂𝒂𝒊𝒊 < 𝑩𝑩

2020/2021 Abdelmadjid Boukra 7


2. Some number systems used
a) Octal system
B=8 𝒏𝒏

𝑵𝑵𝟖𝟖 = � 𝒂𝒂𝒊𝒊 . 𝟖𝟖𝒊𝒊 0 ≤ 𝑎𝑎𝑖𝑖 < 8


𝒊𝒊=𝟎𝟎
b) Hexadecimal system
B=16 𝒏𝒏

𝑵𝑵𝟏𝟏𝟏𝟏 = � 𝒂𝒂𝒊𝒊 . 𝟏𝟏𝟏𝟏𝒊𝒊 𝑎𝑎𝑖𝑖 𝜖𝜖 {0,1,2,3,4,5,6,7,8,9, 𝐴𝐴, 𝐵𝐵, 𝐶𝐶, 𝐷𝐷, 𝐸𝐸, 𝐹𝐹}
𝒊𝒊=𝟎𝟎
c) Binary system
B=2 𝒏𝒏

𝑵𝑵𝟐𝟐 = � 𝒂𝒂𝒊𝒊 . 𝟐𝟐𝒊𝒊 0 ≤ 𝑎𝑎𝑖𝑖 < 2


𝒊𝒊=𝟎𝟎

2020/2021 Abdelmadjid Boukra 8


3. base change (conversion)
• A change of base consists in writing a number N, written in base B1,
in another base B2.
• 3.1 Conversion From base B to base 10
• To convert from base B to base 10, simply write the number NB
using its explicit expression, then perform the calculation.
• Example:
• Write the number N=(763)8 in base 10

• (763)8= 7.82 + 6. 81 + 3.80 =(499)10=499

2020/2021 Abdelmadjid Boukra 9


• 3.2 conversion from base 10 to any base B.
• For the integer part
• Simply make a succession of divisions by B. The first remainder is the
first digit to the right of the number in base B.
• Example: convert 1227 to base 8
• 1227 / 8 = 153 remainder 3
• 153/ 8 = 19 remainder 1
• 19/8 = 2 remainder3
• 2/8 = 0 remainder 2

• 1227= (2 3 1 3)8

2020/2021 Abdelmadjid Boukra 10


• For the fractional part
• All you have to do is multiply by the base B (we'll see how to do this with
an example).
• Example: convert 0,47 to base 2
• 0,47= 0, 0 1 1 1 1

• 0,47 x 2 = 0,94 a-1=0


• 0,94 x 2 = 1,88 a-2=1
• 0,88 x 2= 1,76 a-3=1
• 0,76 x 2 = 1,52 a-4=1
• 0,52 x 2 = 1,04 a-5=1

2020/2021 Abdelmadjid Boukra 11


• Note: if a number is made up of an integer part and a fractional part,
apply the first method to the integer part, apply the second method
to the fractional part and then concatenate the two results,
separated by a comma.

• Conversion from Base B1 to Base B2

• B1 B2

• 10

2020/2021 Abdelmadjid Boukra 12


3.3 Conversion binary – octal
• Conversion rule
• Starting from the decimal point, group the bits in blocks of three,
going left and right for the fractional part, then write the decimal
equivalent of each group.
• Example:
• N= (110 111 011 , 001 101)2 = (6 7 3 , 1 5)8
• 6 7 3 1 5

2020/2021 Abdelmadjid Boukra 13


• Reverse conversion rule
• Write the binary value of each digit of the number in blocks of three
bits.
• Example: convert (567,315)8 into binary
• (5 6 7 , 3 1 5)8

• (101 110 111 011 001 101)2
• Note: If you want to convert a number from decimal to binary, you
can go through octal, then from octal to binary, using the previous
method. In this way, fewer operations are required.
• 3.4 Conversion binary – Hexadecimal
• Conversion Rule
• This is the same rule as for octal, but groupings are made by 04 bits.
2020/2021 Abdelmadjid Boukra 14
4. Binary arithmetic
• The arithmetic operation algorithms applied in decimal are the
same in any base
• Binary Addition
•0+0=0
•0+1=1
•1+0=1
• 1 + 1 = 0 Carry 1
• The carry occurs as soon as the sum reaches the value of the base in
any numbering system
• Example: 1 11 11 01 1 0 1

• + 1 0 1 100
• = 11 0 0 001
2020/2021 Abdelmadjid Boukra 15
Binary subtraction
0-0=0
0 - 1 = 1 carry 1
1-0=1
1-1=0
Example
11 01 01 11 0 1 1
- 1 0 1 111
= 0 0 1 1 100

2020/2021 Abdelmadjid Boukra 16


• The binary multiplication
•0x0=0
•0x1=0
•1x0=0
•1x1=1
• Example:
• 101101
• x 101
• 101101
• 101101 . .
• 11100001

2020/2021 Abdelmadjid Boukra 17


• The binary division
• Example
1 011101110 110
110
0 1011 1111101
110
0 1010
110
01001
110
00111
110
00110
110
2020/2021
000 Abdelmadjid Boukra 18
5. The Complementation
• One ‘s Complement
• We form the one's complement (denoted as C1) of a binary number
by subtracting 1 from each bit of that number.
• Example
• Let's calculate the one's complement of 1011
• 1111
• - 1011 Therefore C1(1011)=0100
• = 0 100
• Note 1: To calculate the one's complement of a binary number,
simply complement each bit of that number.
• Note 2: The sum of a binary number and its one's complement is a
number composed entirely of 1s.
2020/2021 Abdelmadjid Boukra 19
• Two’s Complement
• Finding the 2's complement (C2) of a binary number means
subtracting it from the next higher power of 2.
• Example: Let's calculate the C2(1101)
• 10000
• - 1101
• = 0011 Donc C2(1101) = 0011
• A second method consists in calculating the 1's complement of the
number and then adding '1'.
• Example: to calculate C2(1101), we compute C1(1101)=0010 then
add '1', which gives 0011

2020/2021 Abdelmadjid Boukra 20


• A third method is to keep all the bits, from the right up to and including
the first '1', and then complement the rest.
• Example: C2(010100) = (101100)
C2(010011) = (101101)

6. Notion of Code.
The computer only recognizes 0 and 1, so to manipulate the user's objects
(number, character, image, etc.), coding is necessary.
6.1 Some existing codes
Natural binary code
To represent integers, we can use the natural binary code, which is the
binary equivalent of the integer.

2020/2021 Abdelmadjid Boukra 21


• For example, to represent numbers from 0 to 20, we'll use a string of
05 bits. The coding will be as follows:
Nombre Code binaire
naturel
0 00000
1 00001
2 00010
.
.
20 10100

• The number of bits to be used depends on the greatest number to


be represented

2020/2021 Abdelmadjid Boukra 22


• Gray's code or reflected binary
• In this code, there is only one bit that changes its value from one
0 0 0 0
0 0 0 1
number to the next.
0 0 1 1
• Gray’s code Construction (04 bits). 0 0 1 0
Remarque : 0 1 1 0
0 1 1 1
Direct arithmetic manipulation is not possible. 0 1 0 1
It is possible to use binary to perform the operation. 0 1 0 0
1 1 0 0
1 1 0 1
1 1 1 1
1 1 1 0
1 0 1 0
1 0 1 1
1 0 0 1
2020/2021 Abdelmadjid Boukra 1 0 0 0 23
• Switching from Gray's code to binary
• Let G=g1…gn a numbre represented in Gray
• let B=b1…bn the same number represented in binary
• b1=g1
Let 𝑺𝑺𝒏𝒏 = ∑𝒏𝒏−𝟏𝟏
𝒊𝒊=𝟏𝟏 𝒈𝒈𝒊𝒊 (mod 2)
• If Sn=1 (n≠ 1) then bn=gn
• else bn=gn
Explanation: if the number of bits equal to 1 from g1 to gn-1 is odd.
then bn=gn
else bn=gn
• Example G=1 0 1 1 1 b1=g1=1, b2=1, b3=0, b4=1, et b5=0
• B=1 1 0 1 0
2020/2021 Abdelmadjid Boukra 24
• Switching from binary to Gray code
• Let B be a number written in binary as B=b1..bn. We'd like to find
its Gray representation G=g1..gn
• g1 =b1
• If bn-1=1 then gn=bn
• else gn=bn
• Example B = 1 1 0 0
• g1=b1=1
• b1=1 g2=0
• b2=1 g3=1 G=1 0 1 0
• b3=0 g4=0

2020/2021 Abdelmadjid Boukra 25


• How to create a Gray number from the previous one
• If the number of 1 is even, reverse the last bit.
• If the number of 1 is odd, invert the bit to the left of the first
rightmost 1,
• Example
1 1 1 1 1 0 1 (Number of 1's is even) 1111100

• 1 0 1 1 1 1 0 (Number of 1's is odd) 1011 010

• 1 1 0 0 1 0 0 (Number of 1's is odd) 1101100

2020/2021 Abdelmadjid Boukra 26


The BCD code (Binary-coded decimal)
• In this code, each decimal digit is assigned its 04-bit binary
equivalent.
• Example: Decimal number : 8 6 3 6 7

Numbre in BCD: 1000 0110 0011 0110 0111


Arithmetic operations are more complicated than in binary.
The Excess3 code
This code is the code BCD + 3. It was introduced to simplify arithmetic
operations, which are complicated in BCD.
0 will be coded 0011 instead of 0000, 1 will be coded 0100 instead of
0001, etc

2020/2021 Abdelmadjid Boukra 27


7. Information representation
7.1 Signed numbers representation
A signed number is represented by a binary string of length n, 𝑛𝑛 𝜖𝜖
{8,16,32,64} we speak of a representation of signed numbers on 8 bits,
16 bits, 32 bits or 64 bits.
Module and sign representation (MS)
The number is represented by a string of n bits (bn-1...b0)Where bn-1
represents the sign of the number (0 for + and 1 for -)*
Bn-2...B0 represents module of the number.
Example + 33 will be represented on 8 bits by 00100001
- 33 will be represented on 8 bits by 10100001

2020/2021 Abdelmadjid Boukra 28


• Note: 0 has two representations
• 00000000 represents +0
• 10000000 represents -0

Range of representable signed numbers


If N is represented on n bits
-(2𝑛𝑛−1 − 1) ≤ 𝑁𝑁 ≤ +(2𝑛𝑛−1 − 1)

• For 8 bits -127≤ N ≤ +127


• The code has bad arithmetic properties.

2020/2021 Abdelmadjid Boukra 29


Representation in “Ones’ Complement” Code
We can represent negative binary numbers through ones’ complement (C1).
The positive numbers are coded in pure binary, leaving the most significant digit at 0.
The negatives are the C1 of the corresponding positive number
In the following table, we see an example for 4-bit numbers..
The carry “outside” the number format
should be added to the LSB of the result.
CP denotes the carry to the MSB and CS
the carry outside the MSB
• Let’s consider the sum of two numbers Q + N.
• the table below shows us the values of CP and CS for all the combinations
of the signs of addends and result, when the sum is correct, i.e., when the
number’s format is able to contain the result:

If CP and CS are different, there is an overflow error, and we can detect it as


OVF = CP ⊕ CS. Here is an example of an overflow error:
Representation in “Two’s Complement” Code

In this representation,
A positive number +N is represented by its n-bit binary value,
A negative number -N is represented by the two's complement of its
positive equivalent +N.
The most significant bit is the sign bit (0 +) (1 -).
For example, let's represent +33 and - 33 in the 2's complement
representation.
+33 is positive, so its 8-bit representation is 00100001
-33 is negative, we calculate C2(00100001)=11011111.
so -33 will be represented in the 2’s complement representation by
11011111

2020/2021 Abdelmadjid Boukra 34


Arithmetic Properties

Concerning the (CP) and the (CS), the same considerations for
representation in C1 also hold for C2. When adding two numbers Q and N,
the table used for checking the carries for overflow errors still holds:

As before, there is overflow when CP and CS are different: OVF = CP ⊕ CS

C2 code allows us to execute additions regardless of the sign of the addends by using a normal binary adder
with no need to make corrections to the result (unlike with C1).
• Remarks
• We have only one representation of the 0 00000000
• Range of representable signed numbers
• If N is represented on n bits
• -(2𝑛𝑛−1 ) ≤ 𝑁𝑁 ≤ +(2𝑛𝑛−1 − 1)

• For 8 bits
• -128≤ N ≤ +127
• In this representation, we can transform a subtraction into an
addition because A-B is equivalent to A+C2(B)

2020/2021 Abdelmadjid Boukra 36


Representation of real numbers
Fixed-point representation.
• In this representation, part of the bits are reserved for coding the
integer part and part for the decimal part (plus a sign bit).
• This makes it very easy to perform operations.
• However, this is restrictive, as it is highly probable that memory
space will be lost by such a representation.
• For example, numbers strictly less than 1 have their integer part set
to zero, so the space used to store the integer part could be used to
represent more decimals and thus achieve greater precision.
7.2 Floating-point representation
• General principle
• A number N is written in floating point in a base B if it is written in
the form N= ± m1,m2 . B±c
Where m1,m2 is the mantissa
c, is the exponent or caracteristic

A number N written in floating point is normalized if it is written in


the following form: : N= ± 0,m . B±c where m is a number whose
rightmost digit is not zero.
Example: let N=12,352 105 Its normalized form is 0,12352 107

2020/2021 Abdelmadjid Boukra 38


• The IEEE 754 norm
• This norm unifies the representation of floating-point numbers by
proposing a standardized format. It offers a 32-bit single-precision
format and a 64-bit double-precision format.
• 32-bit single-precision format.
• 1bit 8 bits 23 bits
S C M in base 2 with a hiden bit
• 32 bits
• 64-bit double-precision format
• 1bit 11 bits 52 bits

2020/2021 Abdelmadjid Boukra 39


• The sign of the number is coded by the most significant bit
• (0 + , 1 -).
• The characteristic C is internally coded at the value C', which is always
positive thanks to an eccentricity value K added to C
• The mantissa is normalized as ± 1,M . 2 ±c . M is called pseudo
mantissa
• The 1 preceding the decimal point, known as the hidden bit, is not
coded
• M is binary coded.
• Eccentricity constant k applied to the exponent::
• For double-precision format k=127
• For simple-precision format k=1023
The internally coded exponent c' is equal to c + 127 or c + 1023

2020/2021 Abdelmadjid Boukra 40


• Example Let's represent the number N= -10.125 using the IEEE 745
norm
• Write N in binary N=- (1010,001)2
Write N in normalized form: N= - (1,010001)2 . 23
The number N is negative the sign bit =1
The exponent C=3 C’= C + 127=130 = (10000010)2
Pseudo mantissaM= 010001
The coding of N according to the IEEE norm is
1 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Hexadecimal writing (C1220000)16

2020/2021 Abdelmadjid Boukra 41


• Remarque:
The 0 value is represented with
an exponent C= -127 and
a mantissa = 0
The sign is arbitrary, there is a positive zero and a negative zero.
+∞ and -∞ are represented with
• an exponent C=+128 and
• A mantissa = 0
• The sign is a function of the infinity represented.

2020/2021 Abdelmadjid Boukra 42


8 Representation of characters
• Each character is associated with a binary string.
• The number of characters that can be coded depends on the length of
the binary string.
• The characters to be represented are:
• uppercase and lowercase letters, punctuation marks, mathematical
signs, etc. (these are editable characters).
• Characters reserved for specific computer functions. These are non-
editable characters.

2020/2021 Abdelmadjid Boukra 43


• 8.1 Main character codes
• The ASCII code (American Standard Code For Information Interchange)
• ASCII uses 7 bits.
We can therefore represent128 caracters.

The codes are given by a


table with two entries.
Example: Character A has
ASCII code (41)16 or (100
0001)2

2020/2021 Abdelmadjid Boukra 44


• The EBCDIC code (Extended Binary Coded Decimal Interchange Code)

• The EBCDIC code uses 8 bits. It encodes 256 characters.

The codes are given by a two-


entry table
Example
Character A has EBCDIC code
(C1)16 or (1100 0001)2

2020/2021 Boukra
Abdelmadjid
Abdelmadjid
Boukra
(USTHB) 45
• The UNICODE code (Universal code)
• UNICODE uses 16 bits. It can therefore code 65 536 characters
Unicode adopts the ASCII coding for the main characters, using 16
bits.

Thus character A is coded by


(0041)16

2020/2021 Boukra
Abdelmadjid
Abdelmadjid
Boukra
(USTHB) 46

You might also like