Decode an instruction with a negative immediate
Convert 0xFFF28293 to binary and split it into fields. Give the format, the opcode, the registers, funct3 and the decimal value of the immediate.
0xFFF28293
Practice
All you need is paper and the format table from the RISC-V path.
Convert 0xFFF28293 to binary and split it into fields. Give the format, the opcode, the registers, funct3 and the decimal value of the immediate.
0xFFF28293
Identify the fields of 0x40B50533. Pay attention to funct7: it is what tells add and sub apart.
0x40B50533
Look only at the low 7 bits of each word (the last hex digit and a half) and say which format it belongs to.
Run the program by hand. What are t2 and a0 at the end?
li t0, 7 li t1, 3 sub t2, t0, t1 slli t2, t2, 2 xor a0, t2, t0
What is a0 when the loop exits? How many instructions run in total (counting every iteration)?
li a0, 1 li t0, 4 loop: add a0, a0, a0 addi t0, t0, -1 bnez t0, loop
In the simulator’s 5-stage pipeline, how many cycles does this sequence take with and without forwarding? How many bubbles are there with forwarding?
lw t0, 0(a0) add t1, t0, t0 sub t2, t1, a1
Two instructions load constants and the third adds them. What value ends up in a0?
addi t0, zero, 5 addi t1, zero, 7 add a0, t0, t1
What is a0 at the end and how many instructions run?
li a0, 1 j skip li a0, 2 skip: addi a0, a0, 10
lui loads 0x80000 into the upper 20 bits of t0. What are t1 and t2 in decimal?
lui t0, 0x80000 addi t1, t0, -1 slt t2, t1, t0
The triple routine takes a number in a0 and returns the result in a0. What are a0 and ra at the end?
li a0, 6 jal ra, triple j end triple: add a1, a0, a0 add a0, a1, a0 ret end: nop
In the original order (lw, add, addi, sw) there is a load-use bubble and the sequence takes 9 cycles with forwarding. Here addi has been moved between lw and add. How many cycles does it take now with forwarding, and how many bubbles remain?
lw t0, 0(a0) addi t2, a1, 4 add t1, t0, t0 sw t1, 0(a2)
The simulator resolves branches in EX and treats them as taken. How many cycles does the sequence take with forwarding and how many instructions are discarded?
addi t0, t0, -1 bne t0, zero, loop addi a0, a0, 1 addi a1, a1, 1
Answers are compared with the full truth table, so any equivalent minimal expression is accepted. Review the digital logic path.
Mark the cells of F(A,B,C,D) = Σm(3, 6, 11, 12, 14) on the 4-variable map. Rows are AB and columns are CD, both in Gray code.
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | ||||
| 01 | ||||
| 11 | ||||
| 10 |
On a 4-variable map, which cells are adjacent to m8? Mark all of them: remember that opposite edges also touch.
| AB \ CD | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | ||||
| 01 | ||||
| 11 | ||||
| 10 |
Write a minimal sum of products for F(A,B,C,D) = Σm(1, 3, 7, 11, 15) + d(0, 2, 5). Use A, B, C, D and an apostrophe for NOT (for example A'B).
Syntax: products side by side (AB), sum with +, NOT with an apostrophe (A') or a leading !.
A classmate proposes F = A'B' + BC' + AB for F(A,B,C) = Σm(0, 1, 2, 5, 6, 7). Is it correct? If not, mark a minterm where it fails.
F = A'B' + BC' + AB