Processor and memory overview
도입됨
5:52
컴퓨터 시스템의 기초
This course follows a program from a single bit to a running process. The first two units are the alphabet: how bits encode data, and how logic gates compute…
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| English | 의미 |
|---|---|
| instruction/ɪnˈstrʌkʃn/ | |
| memory/ˈmeməri/ | Circuits that store data, such as registers, RAM and ROM. |
| fetch-decode-execute cycle/fetʃ dɪˈkəʊd ˈeksɪkjuːt ˈsaɪkl/ | Fetch-Decode-Execute 사이클 |
| program counter/ˈprəʊɡræm ˈkaʊntə/ | 프로그램 카운터 |
| instruction register/ɪnˈstrʌkʃn ˈredʒɪstə/ | 인스트럭션 레지스터 |
| register/ˈredʒɪstə/ | 레지스터 |
| arithmetic logic unit/əˈrɪθmətɪk ˈlɒdʒɪk ˈjuːnɪt/ | 算术逻辑单元 (ALU) |
| memory hierarchy/ˈmeməri ˈhaɪərɑːki/ | 메모리 계층 구조 |
| cache/kæʃ/ | 캐시 |
| locality/ləʊˈkælɪti/ | 국소성 |
| cache line/kæʃ laɪn/ | 캐시 라인 |
Same work, ten times slower
- Two loops add up every number in a large table. They do the same additions, yet one runs many times slower than the other.
- The clock speed is the same, and so is the instruction count. The difference is how each loop uses memory 存储器, and this lesson explains why.
The fetch-decode-execute cycle
- The processor repeats one loop, the fetch-decode-execute cycle 取指-译码-执行周期. Fetch: the program counter 程序计数器 (PC) gives an address, and the instruction there goes into the instruction register 指令寄存器 (IR).
- Decode turns the instruction into control signals; execute uses the ALU, memory or the PC. With 4-byte instructions the PC then moves on by 4, and a branch writes a new address into it.

Put one pass of the processor's cycle in order.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
Fetch, decode, execute, then the PC moves on (or a branch sets it).
In fetch-decode-execute, the instruction register (IR) is loaded during —
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Fetch reads memory at the PC into the IR; decode then interprets it.
The PC holds 1000 and every instruction is 4 bytes. After three instructions with no branch, what does the PC hold?
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
1000 + 3 × 4 = 1012.
Registers and the ALU
- Registers 寄存器 are a few dozen very fast storage places inside the processor. They hold the values the program is working on right now.
- The arithmetic logic unit 算术逻辑单元 (ALU) adds, compares and does logic on register values. Results go back into a register.
The memory hierarchy
- The memory hierarchy 存储层次: registers, then L1, L2 and L3 cache 高速缓存, then DRAM main memory (about 100 ns), then SSD. Each layer is bigger and slower than the one above.
- The reason is cost: fast memory is expensive per byte, and big memory is slow. No single technology is both large and fast.
The memory hierarchy exists because —
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
It is a physical trade-off, solved by stacking layers and using locality.
Match each layer to its rough size and speed.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Each step down is bigger and slower.
Locality makes it work
- Programs show locality 局部性. Temporal locality: data used now is likely to be used again soon. Spatial locality: nearby addresses are likely to be used next.
- So a small fast cache can hold most of what the program touches, and most accesses never reach DRAM.
Reading array elements one after another in address order uses spatial locality.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Neighbouring addresses come in the same cache line, so the next reads are hits.
Cache lines and data layout
- A cache miss does not fetch one value. It fetches a whole cache line 缓存行, usually 64 adjacent bytes.
- For a large table stored in row-major order, walking row by row uses adjacent values in each cache line. Walking column by column may use only one value per line before moving on, causing many more misses.
For a large row-major array, a row-by-row loop can beat a column-by-column loop at the same operation count because —
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Consecutive bytes share one line, so layout can beat arithmetic.
Worked example: three instructions
- Memory at address R2 holds 7.
LOAD R1, 0(R2)makes R1 = 7;ADD R3, R1, R1makes R3 = 14;STORE R3, 0(R2)writes 14 back. - Each instruction 指令 moves the PC on by 4, so after the three the PC is 12 bytes further on.
Worked example: average access time
- 95% of accesses hit the cache 高速缓存 at 1 ns; the other 5% go to DRAM at 100 ns.
- Average $= 0.95 \times 1 + 0.05 \times 100 = 5.95$ ns. The rare misses cost more than all the hits together.
90% of accesses hit the cache at 1 ns and 10% go to DRAM at 100 ns. What is the average access time in ns?
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
0.9 × 1 + 0.1 × 100 = 0.9 + 10 = 10.9 ns.
Three common slips
- Mixing up the PC and the IR. The PC holds an address; the IR holds the instruction itself.
- Treating memory time as fixed. A cache 高速缓存 hit and a DRAM miss differ about a hundred times.
- Thinking the CPU sees physical addresses. Virtual memory sits in between (lesson 0305).
Recap
- Fetch (PC to IR), decode (control signals), execute (ALU, memory or PC); then PC + 4 or a branch.
- Each layer is bigger, slower and cheaper per byte:
| Layer | Size | Access time |
|---|---|---|
| Registers | a few dozen values | under 1 ns |
| L1 cache | tens of KB | about 1 ns |
| DRAM | gigabytes | about 100 ns |
| SSD | terabytes | tens of µs |
- Locality and 64-byte cache lines 缓存行 make the hierarchy work, so data layout can matter more than the clock.
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.