Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Hanbat National University Prof. Lee Jaeheung
Computer SystemArchitecture
Computer SystemArchitecture
2Hanbat National University Prof. Lee Jaeheung
데 이 터 표 현
데이터종류
보완
고정소숫점표현
유동소숫점표현
다른 2진표현
에러검출코드
3Hanbat National University Prof. Lee Jaeheung
자 료 표 현
Computer가다루는정보
* 데이터-수치데이터숫자 (정수, 실수)
-수가아닌데이터문자, 기호
* 데이터성분사이의구조-데이터구조
Linear Lists, Trees, Rings, etc
* Program(Instruction)
Data Types
4Hanbat National University Prof. Lee Jaeheung
수치 데이터 표현
R = 10 Decimal number system, R = 2 BinaryR = 8 Octal, R = 16 Hexadecimal
Radix point(.) 완전수의자리와기수의자리를나눈다.
데이타수치자료 -수(정수, 실수)기호자료 -기호, 문자
진법Nonpositional number system
-로마식 표기Positional number system ( 진수 )
-각자리에따라서 값을가지고있다.- Decimal(10진), Octal(8진), Hexadecimal(16진), Binary(2진)
Base (or radix) R number- R은각자리의의미를정확하게부여한다.- Example AR = an-1 an-2 ... a1 a0 .a-1…a-m
- V(AR ) = ∑−
−=
1n
mi
iiRa
Data Types
5Hanbat National University Prof. Lee Jaeheung
왜 디지털 컴퓨터에서는 진수를 사용할까?
중요점은비용과시간이다.-하드웨어설계에드는비용.
Arithmetic and Logic Unit, CPU, Communications-연산에필요한시간.
산술 –수치연산 - 테이블연산* Non-positional Number System
-테이블연산을통해무한히연산가능하다.-->설계가불가능하다.
(설계시매우비싸다.)
* Positional Number System-테이블연산에한계가있다.--> 물리적으로실현할수있다.
-비용때문에작은테이블일수록비용이적게든다.--> 2진수가 10진으로변하기쉽다.
0 10 0 1
1 1 10
0 1 2 3 4 5 6 7 8 90 0 1 2 3 4 5 6 7 8 91 1 2 3 4 5 6 7 8 9 102 2 3 4 5 6 7 8 9 10113 3 4 5 6 7 8 9 1011124 4 5 6 7 8 9 101112135 5 6 7 8 9 10111213146 6 7 8 9 1011121314157 7 8 9 101112131415168 8 9 10111213141516179 9 101112131415161718
Binary Addition Table
Decimal Addition Table
Data Types
6Hanbat National University Prof. Lee Jaeheung
REPRESENTATION OF NUMBERS - POSITIONAL NUMBERS
Decimal Binary Octal Hexadecimal00 0000 00 001 0001 01 102 0010 02 203 0011 03 304 0100 04 405 0101 05 506 0110 06 607 0111 07 708 1000 10 809 1001 11 910 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17 F
Binary, octal, and hexadecimal conversion
1 0 1 0 1 1 1 1 0 1 1 0 0 0 1 11 2 7 5 4 3
A F 6 3
OctalBinaryHexa
Data Types
7Hanbat National University Prof. Lee Jaeheung
진 수 변 환
10진수를변환하기- Separate the number into its integer and fraction parts and convert
each part separately.- Convert integer part into the base R number→ R로연달아나눈후나머지값을정리한다.
- Convert fraction part into the base R number→정수자리를연달아증가시키면서정리(축척) 한다.
십진수의표시
V(A) = Σ ak Rk
A = an-1 an-2 an-3 … a0 . a-1 … a-m
(736.4)8 = 7 x 82 + 3 x 81 + 6 x 80 + 4 x 8-1
= 7 x 64 + 3 x 8 + 6 x 1 + 4/8 = (478.5)10(110110)2 = ... = (54)10(110.111)2 = ... = (6.785)10(F3)16 = ... = (243)10(0.325)6 = ... = (0.578703703 .................)10
Data Types
8Hanbat National University Prof. Lee Jaeheung
EXAMPLE
Convert 41.687510 to base 2.
Integer = 414120 110 05 02 11 00 1
Fraction = 0.68750.6875x 21.3750x 20.7500x 21.5000x 21.0000
(41)10 = (101001)2 (0.6875)10 = (0.1011)2
(41.6875)10 = (101001.1011)2
Convert (63)10 to base 5: (223)5Convert (1863)10 to base 8: (3507)8Convert (0.63671875)10 to hexadecimal: (0.A3)16
Exercise
Data Types
9Hanbat National University Prof. Lee Jaeheung
보 수
R 진법에는두가지방법이있다. - R 보수와 (R-1)보수
(R-1)보수각자리수를 (R-1) .
Example - 9보수 83510는 16410이다.- 1의보수 10102는 01012 이다. (bit by bit complement operation)
R의보수(R-1) 1을더한다.
Example- 10의보수 83510는 16410 + 1 = 16510
- 2의보수 10102는 01012 + 1 = 01102
Complements
10Hanbat National University Prof. Lee Jaeheung
고정 소숫점
Numbers :고정소숫점과유동소숫점.
Fixed Point Representations
2진고정소숫점의표현
X = xnxn-1xn-2 ... x1x0. x-1x-2 ... x-m
Sign Bit(xn): 0 for positive - 1 for negative
Remaining Bits(xn-1xn-2 ... x1x0. x-1x-2 ... x-m)
11Hanbat National University Prof. Lee Jaeheung
부호화된 수부호화된 수
부호절대값표현부호화된 1의보수표현부호화된 2의보수표현
Example+9 와 -9 를 7 bit-binary number로표현시
+9의표현 ==> 0 0010013가지방법에의한 -9 표현
부호절대표현에의해 : 1 001001부호화된 1의보수표현에의해 : 1 110110부호화된 2의보수표현에의해 : 1 110111
일반적으로 컴퓨터에서고정된소숫점은 표현은오직 integer part 로표현되거나 fractional part 로표현된다.
양수음수두자기를모두표현한다.- 3가지표현에따라서
12Hanbat National University Prof. Lee Jaeheung
CHARACTERISTICS OF 3 DIFFERENT REPRESENTATIONS
보완
부호절대값 : 오직기호비트만보수를취한다.부호화된 1의보수 : 모든비트를보수를취한다.부호화된 2의보수 : 모든비트에보수를취한후하위1비트를더한다.
Fixed Point Representations
최대값과최소값는숫자와 0으로나타내어진다.X = xn xn-1 ... x0 . x-1 ... x-m
Signed MagnitudeMax: 2n - 2-m 011 ... 11.11 ... 1Min: -(2n - 2-m) 111 ... 11.11 ... 1Zero: +0 000 ... 00.00 ... 0
-0 100 ... 00.00 ... 0
Signed 1’s ComplementMax: 2n - 2-m 011 ... 11.11 ... 1Min: -(2n - 2-m) 100 ... 00.00 ... 0Zero: +0 000 ... 00.00 ... 0
-0 111 ... 11.11 ... 1
Signed 2’s ComplementMax: 2n - 2-m 011 ... 11.11 ... 1Min: -2n 100 ... 00.00 ... 0Zero: 0 000 ... 00.00 ... 0
13Hanbat National University Prof. Lee Jaeheung
2의 보수의 중요성2의 보수의 중요성
Signed 2’s complement representation follows a “weight”scheme similar to that of unsigned numbers
비트표현은 음수를 가지고 있다.다른 비트는 기존 값을 가진다.
X = xn xn-1 ... x0
V(X) = - xn × 2n + xi × 2i
i = 0Σn-1
14Hanbat National University Prof. Lee Jaeheung
덧 셈 연 산절 대 값 표 현
[1] 부호를비교한다.[2] 만약, 두수의부호가같으면두수를더한다.
-overflow 를주의한다.[3] 같지않다면, 두수의크기를비교하고큰수로부터작은수를뺀다.
--> 덧셈연산을위해필요하다.[4] Determine the sign of the result
6 0110+) 9 100115 1111 -> 01111
9 1001- ) 6 0110
3 0011 -> 00011
9 1001-) 6 0110- 3 0011 -> 10011
6 0110+) 9 1001-15 1111 -> 11111
6 + 9 -6 + 9
6 + (- 9) -6 + (-9)
Overflow 9 + 9 or (-9) + (-9)9 1001
+) 9 1001(1)0010overflow
Fixed Point Representations
15Hanbat National University Prof. Lee Jaeheung
덧 셈 연 산2의 보수
Example 6 0 01109 0 1001
15 0 1111
-6 1 10109 0 10013 0 0011
6 0 0110-9 1 0111-3 1 1101
-9 1 0111-9 1 0111
-18 (1)0 1110
두수를더할때부호비트까지연산하여케리비트를가지고부호를결정한다.– overflow를주의한다.
overflow9 0 10019 0 1001+)
+) +)
18 1 0010
+) +)
2 operands have the same signand the result sign changesxn-1yn-1s’n-1 + x’n-1y’n-1sn-1 = cn-1⊕ cn
x’n-1y’n-1sn-1(cn-1 ⊕ cn)
xn-1yn s’n-1(cn-1 ⊕ cn)
Fixed Point Representations
16Hanbat National University Prof. Lee Jaeheung
덧셈 연산1의 보수 사용
두수의덧셈에부호비트도같이연산한다.-최상의비트를넘는오버플로우비트발생시, 그들의결과값에케리된수를더한다.
6 0 0110-9 1 0110-3 1 1100
-6 1 10019 0 1001
(1) 0(1)00101
3 0 0011
+) +)
+)
end-around carry
-9 1 0110-9 1 0110
(1)0 11001
0 1101
+)
+)
9 0 10019 0 1001
1 (1)0010+)
overflow
Example
not overflow (cn-1 ⊕ cn) = 0
(cn-1 ⊕ cn)
Fixed Point Representations
17Hanbat National University Prof. Lee Jaeheung
COMPARISON OF REPRESENTATIONS
음수변환수월함
S + M > 1’s Complement > 2’s Complement
Hardware
- S+M: Needs an adder and a subtractor for Addition- 1’s and 2’s Complement: Need only an adder
연산속도
2’s Complement > 1’s Complement(end-around C)
Zero의인식
2’s Complement is fast
Fixed Point Representations
18Hanbat National University Prof. Lee Jaeheung
뺄 셈 연 산
뺄셈을보완한다. (Sign bit포함)피감수 sign bits를포함하여덧셈연산을한다.
( ± A ) - ( - B ) = ( ± A ) + B ( ± A ) - B = ( ± A ) + ( - B )
Fixed Point Representations
2의보수를이용한뺄셈연산
19Hanbat National University Prof. Lee Jaeheung
유 동 소 수 점 표 현
The location of the fractional point is not fixed to a certain locationThe range of the representable numbers is wide
F = EM
mn ekek-1 ... e0 mn-1mn-2 … m0 . m-1 … m-m
부호 지수 가수
가수점에의해표시된다. (정수혹은분수에의해)
지수기수에의해서위치를가리키다.
십진표현
V(F) = V(M) * RV(E) M: MantissaE: ExponentR: Radix
Floating Point Representation
20Hanbat National University Prof. Lee Jaeheung
유 동 소 수 점
0 .1234567 0 04sign sign
가수 지수
==> +.1234567 x 10+04
Example
Note:유동소숫점표현에서는, 오직가수(Mantissa(M))와지수Exponent(E)중심으로표현된다.. ( 기수와소숫점은 생략된다. )
Example
2진수 +1001.11는 16-bit 유동소숫점으로밑의표현으로나타내어진다.(6-bit exponent and 10-bit fractional mantissa)
0 0 00100 100111000
0 0 00101 010011100
Exponent MantissaSignor
Floating Point Representation
21Hanbat National University Prof. Lee Jaeheung
유 동 소 수 점 의 특 성 표 현
표준
-같은수일지라도유종소숫점의표현은배우다르다.→ Need for a unified representation in a given computer
-가수의 non-zero digit 점의자리표현은매우중요하다.
Zero의표현
- Zero가수(Mantissa) = 0
- Real ZeroMantissa = 0표현
= 최소화된수표현은00 ... 0← hardware에의해쉽게확인할수있다.
Floating Point Representation
22Hanbat National University Prof. Lee Jaeheung
INTERNAL REPRESENTATION AND EXTERNAL REPRESENTATION
CPUMemory
InternalRepresentation Human
Device
AnotherComputer
ExternalRepresentation
ExternalRepresentation
ExternalRepresentation
23Hanbat National University Prof. Lee Jaeheung
EXTERNAL REPRESENTATIONNumbersMost of numbers stored in the computer are eventually changed
by some kinds of calculations→ Internal Representation for calculation efficiency→ Final results need to be converted to as External Representation
for presentability
Alphabets, Symbols, and some NumbersElements of these information do not change in the course of processing→ No needs for Internal Representation since they are not used
for calculations→ External Representation for processing and presentability
ExampleDecimal Number: 4-bit Binary Code
BCD(Binary Coded Decimal)
Decimal BCD Code0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001
External Representations
24Hanbat National University Prof. Lee Jaeheung
OTHER DECIMAL CODES
Decimal BCD(8421) 2421 84-2-1 Excess-30 0000 0000 0000 00111 0001 0001 0111 01002 0010 0010 0110 01013 0011 0011 0101 01104 0100 0100 0100 01115 0101 1011 1011 10006 0110 1100 1010 10017 0111 1101 1001 10108 1000 1110 1000 10119 1001 1111 1111 1100 d3 d2 d1 d0: symbol in the codes
BCD: d3 x 8 + d2 x 4 + d1 x 2 + d0 x 1⇒ 8421 code.
2421: d3 x 2 + d2 x 4 + d1 x 2 + d0 x 184-2-1: d3 x 8 + d2 x 4 + d1 x (-2) + d0 x (-1)Excess-3: BCD + 3
Note: 8,4,2,-2,1,-1 in this table is the weight associated with each bit position.
BCD: It is difficult to obtain the 9's complement.However, it is easily obtained with the other codes listed above.
→ Self-complementing codes
External Representations
25Hanbat National University Prof. Lee Jaeheung
GRAY CODE
Characterized by having their representations of the binary integers differ in only one digit between consecutive integers
Useful in some applications
Decimalnumber
Gray Binaryg3 g2 g1 g0 b3 b2 b1 b0
0 0 0 0 0 0 0 0 01 0 0 0 1 0 0 0 12 0 0 1 1 0 0 1 03 0 0 1 0 0 0 1 14 0 1 1 0 0 1 0 05 0 1 1 1 0 1 0 16 0 1 0 1 0 1 1 0 7 0 1 0 0 0 1 1 18 1 1 0 0 1 0 0 09 1 1 0 1 1 0 0 1
10 1 1 1 1 1 0 1 011 1 1 1 0 1 0 1 112 1 0 1 0 1 1 0 013 1 0 1 1 1 1 0 114 1 0 0 1 1 1 1 015 1 0 0 0 1 1 1 1
4-bit Gray codes
Other Binary codes
26Hanbat National University Prof. Lee Jaeheung
그레이 코드 - 분석
Letting gngn-1 ... g1 g0 be the (n+1)-bit Gray code for the binary number bnbn-1 ... b1b0
gi = bi ⊕ bi+1 , 0 ≤ i ≤ n-1gn = bn
andbn-i = gn ⊕ gn-1 ⊕ . . . ⊕ gn-ibn = gn
0 0 0 0 00 0 0001 0 1 0 01 0 001
1 1 0 11 0 0111 0 0 10 0 010
1 10 0 1101 11 0 1111 01 0 1011 00 0 100
1 1001 1011 1111 0101 0111 0011 1011 000
그레이코드는 연산되어진결과를반영한다.-연산없이결과테이블을예상하기쉽지다.- for any n: reflect case n-1 about a
mirror at its bottom and prefix 0 and 1to top and bottom halves, respectively
Reflection of Gray codes
Note:
ε
Other Binary codes
27Hanbat National University Prof. Lee Jaeheung
CHARACTER REPRESENTATION ASCII
ASCII (American Standard Code for Information Interchange) Code
Other Binary codes
0123456789ABCDEF
NULSOHSTXETXEOTENQACKBELBSHTLFVTFFCRSOSI
SP!“#$%&‘()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]mn
‘abcdefghIjklmno
Pqrstuvwxyz{|}~DEL
0 1 2 3 4 5 6 7DLEDC1DC2DC3DC4NAKSYNETBCANEMSUBESCFSGSRSUS
LSB(4 bits)
MSB (3 bits)
28Hanbat National University Prof. Lee Jaeheung
CONTROL CHARACTER REPRESENTAION (ACSII)
NUL NullSOH Start of Heading (CC)STX Start of Text (CC)ETX End of Text (CC)EOT End of Transmission (CC)ENQ Enquiry (CC)ACK Acknowledge (CC)BEL BellBS Backspace (FE)HT Horizontal Tab. (FE)LF Line Feed (FE)VT Vertical Tab. (FE)FF Form Feed (FE)CR Carriage Return (FE)SO Shift OutSI Shift InDLE Data Link Escape (CC)
(CC) Communication Control(FE) Format Effector(IS) Information Separator
Other Binary codes
DC1 Device Control 1DC2 Device Control 2DC3 Device Control 3DC4 Device Control 4NAK Negative Acknowledge (CC)SYN Synchronous Idle (CC)ETB End of Transmission Block (CC)CAN CancelEM End of MediumSUB SubstituteESC EscapeFS File Separator (IS)GS Group Separator (IS)RS Record Separator (IS)US Unit Separator (IS)DEL Delete
29Hanbat National University Prof. Lee Jaeheung
에러 검출 코드
Parity System
-에러검색을위해간소화한다. - One parity 비트를이용하여검사한다. -짝수검사기와홀수검사기가있다.
짝수검사기- One bit is attached to the information so that
the total number of 1 bits is an even number
1011001 01010010 1
홀수검사기- One bit is attached to the information so that
the total number of 1 bits is an odd number
1011001 11010010 0
Error Detecting codes
30Hanbat National University Prof. Lee Jaeheung
Parity Bit Generation
For b6b5... b0(7-bit information); even parity bit beven
beven = b6 ⊕ b5 ⊕ ... ⊕ b0
For odd parity bit
bodd = beven ⊕ 1 = beven
PARITY BIT GENERATION
31Hanbat National University Prof. Lee Jaeheung
PARITY GENERATOR AND PARITY CHECKER
Parity Generator Circuit (even parity)
b6b5b4b3b2b1
b0
beven
Parity Checker
b6b5b4b3b2b1
b0
beven
Even Parity error indicator
Error Detecting codes