1. Binary Number Basic
* Possible Representations
- Sign magnitude
- 1's complement
- 2's complement
-> Negating a 2's complement number: 모든 bit을 반대로 바꾸고 + 1
-> 16bit을 32bit으로: sign bit을 복사 (sign extension) *zero extension for logical instruction
* Detecting Overflow
연산 시 결과값의 sign bit이 바뀌면 overflow 발생
양수 더하기 양수가 음수, 음수 더하기 음수가 양수,
양수 빼기 음수가 음수, 음수 빼기 양수가 양수일 경우
2. Building MIPS ALU
ALU: Arithmetic Logic Unit
MUX(Multiplexor) - 컨트롤 인풋에 근거하여 여러 인풋 중 아웃풋으로 내보낼 것을 선택한다.
어떤 게이트의 속도는 그 게이트에 연결된 인풋의 개수에 영향을 받는다.
어떤 회로의 속도는 직렬로 연결된 게이트의 개수에 영향을 받는다.
-> fan-in, fan-out problem
엔간한 칩들은 5v로 동작하는 걸 인식! 2.3v, 2.5v 등이 되었을 때 어떤 결과가 나왔는 지 생각해보기 :)
그렇기 때문에 회로 설계시 하나에 너무 많이 이으면 안 됨 ㅇㅅㅇ 이론과 현실이 다른 부분
3. Multiplication
ex) multiplicand 0010
product 0000 1001
이럼 product의 아래 4bit * multiplicand가 되는 거임. product를 오른쪽으로 shift시키는데
맨 오른쪽 bit가 1일 시 add + shift를 하고, 0일 시 그냥 shift만 한다.
음수곱:
1. 음수를 negate
2. unsigned 곱셈
3. multiplier와 multiplicand가 다를 시 결과 negate.
4. Division
shift left와 subtraction을 반복함.
우선 SLL 후 SUB를 하는데 그 뺀 값의 sign bit가 바뀌었으면 다시 더해서 restore.
그리고 다시 SLL을 하며 sign bit가 바뀌었을 시 restore를 해주며 반복한다.
SLL이 bit수만큼 나올 때까지 반복.
결과값의 앞부분은 Remainder, 뒷부분은 Quotient :)
5. Floating point number arithmetic
* IEEE 754 floating-point standard
(-1)^(sign) * (1 + significand) * 2^(exponent-bias)
bias = 127 for single procision, 1023 for double precision.
ex)
1 bit | 8 bits | 23 bits |
만약 모든 digit이 zero라면 1.0 * 2^(-127)이 아니라 "0"
underflow와 overflow로 표현하지 못하는 수들이 있음
덧셈:
1. Align binary points
2. Add the aligned components
3. Normalize the sum
곱셈:
1. Compute exponents
2. Multiply significands
3. Normalize the product
4. Set sign
'나의' 카테고리의 다른 글
Virtual Memory (0) | 2011.03.14 |
---|---|
Chapter 5. Large and Fast: Exploiting Memory Hierarchy (0) | 2011.03.13 |
캡스톤 - compass sensor / 값 출력 (0) | 2011.03.12 |
Big endian & Little endian (0) | 2011.03.09 |
Stored Program Concept 폰노이만구조 (0) | 2011.03.08 |