Executable Processor Modules Flashcards

1
Q

List the 6 types of RISC-V instruction

A
  1. R-type
  2. I-type
  3. S-type
  4. B-type
  5. U-type
  6. J-type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Draw the encoding of an R-type instruction

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Draw the encoding of an I-type instruction

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Draw the encoding of an S-type instruction

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Draw the encoding of an B-type instruction

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Draw the encoding of an U-type instruction

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Draw the encoding of an J-type instruction

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which fields is the instruction function encoded in?

A

opcode, funct3, funct7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why can there be more R-type than U-type instructions?

A

R-type instructions have more bits taken up by opcode, funct3 and funct7 (U-type instructions do not have funt3 or funct7 fields), which are the fields the instruction function is encoded in, so there are more possible function encodings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

List the 4 addressing modes, used to address the operands

A
  1. Register
  2. Immediate
  3. Base
  4. PC-relative
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does it mean to sign extend?

A

Duplicate the leftmost bit as many times as needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which type of operations are R-type?

A

register-to-register

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

List R type instructions

A

ADD, SUB
XOR, OR, AND
SLL (shift left logical) - zeros shifted in
rf[rd] = rf[rs1] &laquo_space;rf[rs2]
SRL (shift right logical) - zeros shifted in
rf[rd] = unsigned(rf[rs1]&raquo_space; rf[rs2])
SRA (shift right arithmetic) - sign extended
rf[rd] = signed(rf[rs1]&raquo_space; rf[rs2])
SLT - rf[rd] = (rf[rs1] < rf[rs2]) ? 1 : 0
SLTU (unsigned version of SLT)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List R type shift immediate instructions

A

rs2 = shift amount
SLLI = logical shift left (zeros shifted into the botton bits)
SRLI = logical shift right (zeroes shifted into the top bits)
SRAI = arithmetic shift right (the original sign bit shifted into the vacated bits)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

List I-type arithmetic/shift instructions

A

ADDI, ORI, XORI, ANDI
SLTI - rf[rd] = (rf[rs1]<imm) ? 1 : 0
SLTIU - unsigned version of SLTI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are I-type arithmetic/shift operations?

A

Arithmetic operations where one operand is a constant provided by a 12-bit sign extended immediate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List I-type load instructions

A

LW = load 32 bit word
LB = load byte (read sign extended into rf[rd])
LH = load half word (2 bytes) (read sign extended into rf[rd])
LBU, LHU = read unsigned versions of the ones above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are I-type load operations?

A

address = rf[rs1] + imm
The immediate specifies the offset from the register to be read from memory

18
Q

What are S-type instructions?

A

Store instructions. Note that normally the register order in instructions is destination, source but in store instructions it is the opposite way round

address = rf[rs1] + imm
Write rf[rs2] to memory: memory[address] = rf[rs2]

19
Q

List S-type store instructions

A

SB = store byte
SH = store half-word
SW = store word (lower 4 bytes)

20
Q

What are B-type branch instructions?

A

if(condition), pc = pc + imm

21
Q

List B-type branch instructions

A

BEQ rf[rs1] == rf[rs2]
BNE
BLT
BGE
BLTU and BGEU - unsigned versions

22
Q

What are U-type instructions used for?

A

Forming large constants

23
Q

What is an LUI instruction?

A

Load upper immediate U-type
Constant is formed with the upper 20 bits from the immediate and the bottom 12 bits are zero. Use ADDI to add in the bottom 12 bits to form a 32-bit constant
rf[rd] = U_immediate

24
List U-type instructions
1. LUI 2. AUIPC
24
What is an AUIPC instruction?
Add upper immediate to PC for far jumps U-type rf[rd] = pc + U_immediate Combine with JALR to provide bottom 12 bits and perform jump
25
25
What is a JALR instruction?
I-type jump to subroutine Jump and link register rf[rd] = pc + 4 pc = rf[rs1] + imm rd = ra for subroutines, rd = 0 for a plain jump
26
How long does each RISC-V instruction take to execute?
1 clock cycle, good for pipelining
27
What are pseudo assembler instructions?
Instructions that are more human readable and map to instructions in the ISA
28
List the 6 steps in executing an instruction
1. Instruction fetch 2. Decode 3. Execute 4. Branch 5. Memory access 6. Writeback
29
Explain what happens in Instruction Fetch
instruction_register = memory[pc] pc = pc + 4
30
Explain what happens in Decode
Unpack the machine code instruction: read opcode, determine what kind of instruction, extract relevant fields, send to register file read ports, fetch operands from register file
31
What does the opcode field determine?
Either the instruction to be performed or the class of instruction to be performed (in which case funct fields determine the exact instruction)
32
Explain what happens in Execute
Operands are fed into ALU. Function code (ALU opcode) selects the function. The result is produced together with status eg. zero, overflow
33
Explain what happens in Branch
Modify PC to change control flow Conditional branches are B-type - 12 bit immediate shifted left one bit and sign extended before being added to PC Unconditional jumps are I-type - 20 bit immediate shifter left one bit and sign extended before being added to PC
34
Explain what happens in memory access
An address will have been computed during execute. Send this to memory and receive the data returned. Can be time consuming due to latency in the memory hierarchy
35
Explain what happens in writeback
A result from execute or memory access is written back to the destination register if required
36
What is ISA-level simulation? What is it used for?
Program that interprets machine code to emulate a processor. It is used to bring up software before the hardware is available
37
Look at example fib program in assembly language
.
38
What is tandem verification?
Method of verifying[processor models. Run two models or implementations of processors and compare them side-by-side
39
Why is a golden model needed in tandem verification?
Can get divergent behaviour due to interrupts or subtle differences in I/O models - this can be fixed by sending information to the golden model and using it as a checker
40
Draw a diagram of tandem verification
.
41
What interface does an ISA provide?
Hardware and software