1. Memory hierarchy general

//{Processor [Control] [Datapath (Registers)] [On-chip cach]}

Registers - On-chip cache - Second level cache (SRAM) - Main memory (DRAM) - Secondary storage (Disk)


* Principle of locality

Temporal locality: 같은 아이템이 곧 다시 쓰이게 될 거임

Spatial locality: 주위 아이템이 곧 쓰이게 될 거임

-> Memory Hierarchy가 작동할 수 있는 이유는 principle of locality가 있기 때문임!



2. Basics of Cache

Direct mapped cache: lower level에 있는 데이타들이 cache에 있을 곳이 단 한 군데! 정해져 있다. 

즉, 여러 lower level 데이타들이 upper level의 장소를 공유한다.

->캐쉬에 있을 장소 = 블록 주소 % 캐쉬 안에 있는 캐쉬 블록 개수


* Hit vs. Miss

Hit: OK

Miss: Stall the CPU -> fetch block from memory -> deliver to cache -> restart


* Write through (계속 메모리에 저장) vs . Write back (replace될 때만 저장) //아마 따로 정리 예정



3. Improving cache performance

Miss penalty: 캐쉬의 블록을 알맞은 블록으로 replace하는 데 걸리는 시간 + 그 블록을 프로세서에게 전달하는 시간


* 3 placement policies 

1. Direct mapped 

(multiple word direct mapped cache)

장점: spatial locality

단점: miss시 entire block을 가져와야 한다

블록크기가 커지면 miss ratio는 작아지지만 miss penalty는 커진다.

2. Fully Associative

- 캐쉬의 아무 곳에나 block을 넣는다. 데이터를 찾을 때 병렬적으로 모든 캐쉬 태그를 비교

- loww miss rate, but complex HW cost

3. Set Associative

- 메모리 블록 position: (block #) % (# of sets in the cache)

- 위의 두 개의 중간


* Replacement Algorithm

1. Random

2. FIFO - 자주 쓰이는 block을 replace 해 버릴 가능성

3. LRU (Least Recently Used) - Time stamp 필요. 그리고 time stamp 업로드시 오버헤드

4. LFU (Least Frequently Used) - Counter 필요. 가장 최근 거를 replace 해버릴 가능성이 있다.




'나의' 카테고리의 다른 글

Chapter 6. Storage and Other I/O Topics  (0) 2011.03.16
Virtual Memory  (0) 2011.03.14
Chapter 3. Arithmetic for computers  (0) 2011.03.13
캡스톤 - compass sensor / 값 출력  (0) 2011.03.12
Big endian & Little endian  (0) 2011.03.09

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


package com.paad.android.cPreview;

    public void updateWithNewLocation(Location location) {
     String latLongString;
     
     if (location != null) {
      double lat = location.getLatitude();//위도
      double lng = location.getLongitude();//경도
      double altitude = location.getAltitude();//고도
      latLongString = "Lat:" + lat + "\nLong:" + lng + "\nAltitude:" + altitude + "\nHeading:" + (float)comp.getHeading();
     } else {
      latLongString = "No location found" + "\nHeading:" + (float)comp.getHeading();
      location = locationManager.getLastKnownLocation(provider);
     }
     Toast.makeText(getBaseContext(), latLongString, 2000).show();
     
    }//end of updateWithNewLocation
   
}//end of class


이유는 알 수 없지만
저렇게 캐스팅 해 주니 출력이 되었다... -ㅅ-;;; 뭐징 ㅋㅋㅋ

그리고 100% 잘 되는 게 아니다...

음.. 저 latLongString 구문은 화면을 회전할 때마다 출력이 되는데
그 때는 0.0으로 heading이 나오고

새로 gps를 받아올 때에만 heading 값을 0.0 이상의 수로 받아온다.


도대체 무엇이 문제인가 -_-
어떤 문제인가


그리고 gps 부분 클래스로 빼내려고 했는데 잘 되지 않았다 ㅠㅠㅠㅠ
흑흑

'나의' 카테고리의 다른 글

Chapter 5. Large and Fast: Exploiting Memory Hierarchy  (0) 2011.03.13
Chapter 3. Arithmetic for computers  (0) 2011.03.13
Big endian & Little endian  (0) 2011.03.09
Stored Program Concept 폰노이만구조  (0) 2011.03.08
CISC vs. RISC  (0) 2011.03.08

+ Recent posts