CSCI 50.01 LT#3

5.0(1)
studied byStudied by 23 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/249

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

250 Terms

1
New cards

Datapath

Hardware components that execute instructions

2
New cards

What does Main Memory contain?

instructions to execute any data (ex. variables)

3
New cards

Give an address to either: ______ or _______

1. Retrieve a line of code/data
- Address specifies location containing instructions & parameters, or contents of variable

2. Overwrite a line of data
- Contents of variable

4
New cards

Address in Program Counter (PC)

  • Passed to instruction memory to fetch next instruction to be executed

<ul><li><p>Passed to instruction <strong><mark data-color="#ffe600" style="background-color: #ffe600; color: inherit">memory </mark></strong>to <strong><mark data-color="#00ff13" style="background-color: #00ff13; color: inherit">fetch next instruction to be executed</mark></strong></p></li></ul><p></p>
5
New cards

Main memory should have at least ____ read port/s and ______ write port/s

2 read ports
1 write port

6
New cards

Program Counter

  • 1 instance of main memory

  • Knowing where you are requires a register (esp for branching or jumping)

7
New cards

Opcode

  • Binary code

  • Represents specific instruction

8
New cards

What is the purpose of assigning opcodes to instructions?

  • to identify instructions for processor to differentiate operations

  • assigned based on functional groups or specific criteria

9
New cards

What pattern is used for arithmetic instructions in the Beta instruction set?

- Using constants have opcode[4] == 1
- Using 2nd register have opcode[4] == 0

10
New cards

What is the opcode significance of branching instructions like BEQ or BNE?

use constant to specify branch target address, so opcode[4] == 1

11
New cards

Control Unit

- Given instruction's opcode
- Sends signals to rest of CPU for instruction execution

<p>- Given <strong><mark data-color="#cdffa4" style="background-color: #cdffa4; color: inherit">instruction's opcode</mark></strong><br>- <strong><mark data-color="#92e8ff" style="background-color: #92e8ff; color: inherit">Sends signals to rest of CPU</mark></strong> for instruction execution</p>
12
New cards

Registers

  • Storage in CPU for temporary variables passed to ALU

  • Includes PC to remember address of next instruction

13
New cards

Register File

- Collection of registers for instruction arguments
- Used for Ra/Rb/Rc arguments in BSim implementation

<p>- <strong><mark data-color="#fff577" style="background-color: #fff577; color: inherit">Collection of registers</mark> </strong>for<strong> <mark data-color="#77edff" style="background-color: #77edff; color: inherit">instruction arguments</mark></strong><br>- Used for <strong><mark data-color="#77ff9f" style="background-color: #77ff9f; color: inherit">Ra/Rb/Rc arguments</mark></strong> in BSim implementation</p>
14
New cards

RFLE

Register File Load Enable (allow write)

15
New cards

OPCODE Fields

Operate: ADD, ADDC

Main memory: LD, ST

Program control: JMP, BEQ

16
New cards

How are Incremental Design datapaths implemented?

  • Implement datapaths for each class individually

  • Merge datapaths (old functionality maintained while adding new functionality)

17
New cards

Instruction Fetch

Process of retrieving next instruction

<p>Process of<strong><mark data-color="#b3ffdc" style="background-color: #b3ffdc; color: inherit"> retrieving next instruction</mark></strong></p>
18
New cards

Instruction Fetch Steps

  1. PC passes address of current instruction to main memory

  2. Default next instruction is in next line (address + 4)

  3. Instruction's opcode passed to control logic

  4. Control logic send signals to execute current instruction

19
New cards

Is it necessary to "save" PC's value?

Yes

20
New cards

Can the system function without a PC register?

No assuming PC is not saved anywhere

21
New cards

Is there another way to remember where we are in the program and to send the appropriate address to main memory for instruction fetch?

Yes only if PC is saved somewhere (doesn't have to be a register) in a device connected to main memory's instruction port's address

22
New cards

What is the role of control logic in a processor?

  • determines what ALU should do

  • controls if overwriting is allowed in register file for current instruction

23
New cards

What input does the register file receive from an instruction?

register addresses specified in instruction

24
New cards

What does the ALU base its operations on?

Instructions from control logic

25
New cards

WERF

  • Write Enable Register File

  • Controls if current instruction can overwrite a register in register file

    1 - can overwrite
    0 - can’t overwrite

26
New cards

Why can't WERF be don't care (1)?

Setting it to 1 (DC) will cause an unspecified overwrite to occur because of how registers function

27
New cards

ALUFN

Arithmetic and Logic Unit FunctioN

28
New cards

ALUFN

Arithmetic and Logic Unit FunctioN

Specifies operation that ALU should perform

29
New cards

How to send A and B inputs to the ALU without using a register file?

A and B inputs sent to ALU directly via connections to main memory instead of register file

30
New cards

What issues arise when sending ALU inputs directly from main memory?

More bits needed to specify memory addresses:
- Register file uses 5 bits (for 32 registers)
- Main memory with 2^20 lines would require 20 bits for address specification

31
New cards

What does BSEL do in ALU operations?

selects either:
- Rb (register file input)
- Constant embedded in the instruction

32
New cards

What must be done to a 16-bit constant before it can be used in ALU operations?

SEXT

sign-extended to 32 bits to match the ALU's input size

33
New cards

How does the current setup support both ALU register-register and register-constant operations?

Can choose between:
- Rb (register input) for register-register
- Constant (from instruction) for register-constant

34
New cards

What role does the multiplexer controlled by BSEL play in ALU operations?

Switches ALU's B input between
- Value from register file (Rb)
- Sign-extended constant from instruction

35
New cards

BSEL

B Selector

36
New cards

WDSEL

  • Write Data SELector

  • Controls source of data written to register file's Rc port

    "What am I supposed to write to register file?

37
New cards

Possible Values of BSEL

0 - need Rb's data to be passed, ignore constant (c[15:0])

1 - need their attached 16-bit constant, ignore Rb

38
New cards

How do you sign-extend a 16-bit value to a 32-bit value?

- Copy most significant bit into rest of the bits
- This preserves the sign

39
New cards

Why do memory and branching instructions have opcode[4] = 1?

They require a constant

EX. for addresses or offsets

40
New cards

What are examples of arithmetic instructions using a second register in the Beta instruction set?

ADD, SUB, and MUL

41
New cards

How are opcodes grouped in Beta instruction set?

Based on functionality, with specific opcode bits (like opcode[4]) indicating if constant or second register

42
New cards

How does BSEL allow Rb[15:11] and c[15:0] to occupy the same space in an instruction?

  • Uses mux to enable either rb[15:11] or c[15:0] as active input

  • Ensure only 1 path is used despite sharing instruction space

43
New cards

What is BSEL for?

Controls what gets passed as ALU's B input

44
New cards

WDSEL Possible Values

0: For BEQ/BNE

1: ALU output

2: Main memory's data read port's data

45
New cards

Wr

Write to memory

46
New cards

What is Wr used for?

- to know if reading or writing to main memory
- Similar to WERF, but specifically for memory writes

47
New cards

Possible Values of Wr

0: No data written to memory

1: Data written to memory.

48
New cards

For LD instructions, what should ALUFN be?

ADD

LD calculates address by adding <Ra> and C using ADDC

49
New cards

For LD instructions, what should BSEL be?

1

LD uses constant as second 2nd operand

50
New cards

For LD instructions, what should WDSEL be?

2

Data is read from main memory and written to register file's Rc

51
New cards

For LD instructions, what should Wr be?

0

LD doesn't write to main memory

52
New cards

RA2SEL

  • Read Address #2 SELector

  • determines which address is used for 2nd register

53
New cards

RA2SEL possible values

0 - Use Rb[15:11]
1 - Use Rc[25:21]

54
New cards

For ST instructions, what should ALUFN be?

ADD

ST calculates memory address by <Ra> + C using ADDC

55
New cards

For ST instructions, what should BSEL be?

1

ST uses constant (C) as second operand for ALU

56
New cards

For ST instructions, what should WERF be?

0

ST doesn't write to register file

57
New cards

For ST instructions, what should WDSEL be?

DC

WDSEL is not used for ST bc WERF = 0

0 default value for WDSEL

58
New cards

For ST instructions, what should Wr be?

1

ST writes data from Rc to main memory[<Ra> + C]

59
New cards

For ST instructions, what should RA2SEL be?

1

ST reads data from Rc[25:21] for writing to memory

60
New cards

What should RA2SEL be for non-ST instructions?

0 - read from Rb[15:11]

DC - don't read from Rb or Rc

61
New cards

Why does ST use Rc[25:21] instead of Rb[15:11]?

Because it needs a constant C[15:0] and can’t use Rb[15:11] simultaneously

62
New cards

PCSEL

Program Counter SELector

63
New cards

What is PCSEL used for?

determines the next instruction address

64
New cards

Possible Values of PCSEL

0 - Use default PC + 4
1 - Use branch address
2 - Use <Ra> for JMP instructions

  • can have 3 or 4 as well (but idk for what)

65
New cards

For JMP instructions, what should WDSEL be?

0

Passes PC + 4 to be written to Rc as return point

66
New cards

For JMP instructions, what should ALUFN be?

Dont care

67
New cards

For JMP instructions, what should BSEL be?

Don’t care

68
New cards

For JMP instructions, what should WERF be?

1

JMP writes PC + 4 to register file (Rc) as return point

69
New cards

What is Z for?

Zero check

1 if <Ra> is 0

0 otherwise

Requires additional circuitry to check if <Ra> is zero

70
New cards

For BEQ instructions, what should PCSEL be?

PCSEL = Z

0 if Z = 0

1 if Z = 1 (branch)

71
New cards

For BNE instructions, what should PCSEL be?

PCSEL = !Z

1 if Z = 0 (branch if <Ra> ≠ 0)
0 if Z = 1 (don't branch).

72
New cards

For both BEQ/BNE instructions:
What should ALUFN be?
What should WDSEL be?
What should WERF be?

ALUFN = DC

WDSEL = 0 (passes <PC>+4 to be written to Rc)

WERF = 1

73
New cards

What is XP (R30) used for?

register for handling Interrupts or Exceptions

74
New cards

Examples of CPU or system-generated faults (synchronous)

- Illegal instruction
- System calls, like "read-a-character"

75
New cards

Examples of externally generated I/O events (asynchronous)

Interrupt Request (IRQ) events like a key being pressed

76
New cards

How Interrupts Work:

1. Interrupt running program
2. Invoke exception handler (Similar to a procedure call)
3. Return to continue execution

77
New cards

What does ILLOP (PCSEL = 3) handle?

Handles illegal operations, like:
- Divide by 0
- Unimplemented instructions

78
New cards

What happens during an illegal instruction?

1. Procedure call is forced
2. CPU branches to illegal operation handler instead of executing illegal instruction
3. <PC+4> is saved to XP (R30)
4. Program resumes at instruction after illegal one

79
New cards

What does XAdr (PCSEL = 4) handle?

Interrupt Requests (IRQs)

80
New cards

What happens during an interrupt request?

1. Procedure call is forced
2. CPU branches to IRQ handler
3. <PC> is saved to XP (R30)
4. Program resumes at instruction that was supposed to execute when interrupt occurred

81
New cards

What is the difference between ILLOP and XAdr in handling events?

ILLOP handles illegal operations, saving <PC+4> to XP (R30)

XAdr handles interrupts, saving <PC> to XP (R30)

82
New cards

What is the primary purpose of a cache in a memory system?

combines high-speed memory access of expensive memory with large size of cheaper, slower main memory

83
New cards

How does a cache improve memory access efficiency?

  • Storing copy of frequently accessed portions of main memory for future use

  • Take advantage of locality of reference

84
New cards

Cache Read Operation

<p></p>
85
New cards

What happens when the processor attempts to read a word of memory?

Check if word is in cache

86
New cards

Cache Hit

- requested word is in cache
- it's delivered to processor

87
New cards

What happens during a cache hit?

- Address & data buffers disabled
- Communication only between processor and cache
- No system bus traffic

88
New cards

Cache Miss

  • Requested word not in cache

  • Desired address loaded onto system bus

  • Data is returned via data buffer to cache & processor

89
New cards

Why does cache load a block of memory instead of requesting the word during a miss?

To take advantage of locality of reference, which predicts that nearby words might be accessed soon

90
New cards

How many addressable words are in main memory?

2n addressable words

each word having a unique n-bit address

91
New cards

What are blocks in main memory?

Main memory is divided into fixed-length blocks, each containing K words

92
New cards

How many blocks (M) are in main memory? (formula)

M blocks in main mem = (2n) / K words

93
New cards

Cache consists of C blocks called ___?

Lines

94
New cards

Each line contains ______ words and additional information like ______ and ______

K words

Tags and Control bits

95
New cards

Tag identifies …?

- Identifies which block is currently being stored
- Equivalent to part of the block's memory address

96
New cards

What additional information is stored in a cache line besides words and tags?

Control bits to indicate if line was modified since being loaded into cache

97
New cards

What is the line size in a cache?

length of a line in cache, excluding tag and control bits

98
New cards

How does number of cache lines C compare to number of main memory blocks M?

lines C < main memory blocks M

99
New cards

A single cache line can hold data from multiple main memory blocks simultaneously

False

100
New cards

True or False: Every block in main memory has a dedicated cache line in the cache.

False