A
You may use the strlen function to count the length of a string in the C programming language. For this function to be implemented in RISC-V, please fill out the following.
Pseduoinstructions MUST NOT be used.
- A01 = ?
- A02 = ?
- A03 = ?
- A04 = ?
B
Write a RISC-V function that returns 0
if the 32-bit float input is an infinite value and a non-zero value otherwise. As usual, a0
will be used to hold the input and output. Pseduoinstructions MUST NOT be used.
- B01 = ?
- B02 = ?
- B03 = ?
C
The following circuit has a delay of 3 ns for NOT gates, 7 ns for AND and OR gates, and 8 ns for the "Black Box" logic component. The registers have setup times of 5 ns and a clk-to-q latency of 6ns.
What is the maximum allowable hold time of the registers? __ C01 __ ns
- C01 = ?
What is the minimum acceptable clock period for this circuit? __ C02 __ ns
- C02 = ?
D
The circuit seen below can be made simpler. Please write the circuit's origin boolean expression and then simplify it using the fewest possible two-input logic gates. __ D01 __
- D01 = ?
E
All logic gates in the circuit below have a delay of 5 ns, RegC has a setup time of 6 ns, and RegA and RegB have setup, hold, and clk-to-q durations of 4 ns.
What is the maximum allowable hold time for RegC? __ E01 __ ns
- E01 = ?
What is the minimum acceptable clock cycle time for this circuit (E02 ns), and clock frequency does it correspond to (E03 MHz)?
- E02 = ?
- E03 = ?
F
Look at the RISC-V function below, whose start address is in a0
and length is in a1, which sorts a word array in-place.
Please disassemble machine code marked #p1
and #p2
above to RISC-V instructions. (Please use register names, e.g., s0
, s1
, etc., NOT x8
, x9
, etc.)
0x00259493 # p1
: __ F01 __
- F01 = ?
0x00032383 # p2
: __ F02 __
- F02 = ?
li x1, 0xDCBAABCD
is also a pseudo instruction. Below it is expanded to 2 normal instructions. Please fill in the blanks and translate each of them to machine code.
Assembly | Machine code |
---|---|
lui x1, 0x __ F03 __ | 0x __ F04 __ |
addi x1, __ F05 __ , __ F06 __ | 0x __ F07 __ |
- F03 = ?
- F04 = ?
- F05 = ?
- F06 = ?
- F07 = ?
G
Assume that all input originates from a register and that no hold time laws have been broken. What is the highest frequency at which you can run this circuit's clock such that it operates properly? __ G01 __
Using these variables, formulate your response as a mathematical expression (you may also use min()
, max()
, abs()
, and other simple operations if necessary):
- G01 = ?
H
The fabs
instruction in the x86 architecture returns a floating-point number's absolute value. Compared to utilizing branches, this command is quicker.
Complete the following C code that mimics this instruction without ternary operators or if-else
statements. Assume that int and float are of equal size. (The x86 architecture makes use of the IEEE 754).
- H01 = ?
- H02 = ?
Can we use the same method to get the absolute value of a single-precision 32-bit HFP number? __ H03 __ (Yes or No) Why? __ H04 __
- H03 = ?
- H04 = ?
J
We wish to develop a new ISA while we work on a new processor for an embedded application. We choose to include only one, the X-type instruction, because we are tired of the several RISC-V instruction types. Let's say we want to include the instructions below:
The new stw instruction stores the contents of rs3 into both rs1 + offset1
and rs1 + offset2
.
We want to do away with the funct3
and funct7
fields and only use an opcode. If we only wish to support the instructions listed above, what is the minimum number of bits the opcode field can be? __ J01 __ bit(s)
- J01 = ?
We want to be able to jump up to 64 KiB in either direction with a single instruction. How many bits are necessary to encode an immediate that would allow us to do this? __ J02 __ bit(s) Assume that, just like RV32, the least significant bit is an implicit 0 and is not stored in the instruction.
- J02 = ?
Then, we switch to a 32-bit machine, and finalize our instruction format to have 4 bits for each of the immediate fields, 4 bits for each register, and 4 bits for the opcode. Convert the instruction stw x8, 0, 4 (x5)
into machine code. Leave your answer in binary (don’t forget the prefix!). If a field is not used, fill in the field with x
s. __ J03 __
- J03 = ?
K
A bloom filter is a very clever data structure for effectively and probabilistically storing a set. It does two functions: insert and check. The fundamental principle of checking is to hash your search term many times. Each hash identifies a specific bit that has to be set or checked. So, to verify, you check to see if the bit is set. You do this repeatedly, with each iteration's count of repetitions being included in the hash (so each hash is different). The element does not exist in the bloom filter if not all bits are set. The element PROBABLY occurs in the bloom filter if all bits are set. Similar to that, you just set an element as present when using a bloom filter.
Similar to that, you just set all those bits to 1 to indicate that an element is present in a bloom filter.
A flexible and portable bloom filter design is what we are aiming for. Therefore, we create the structure below.
On a 32-bit architecture that requires word alignment for 32-bit integers and pointers, what is sizeof(struct BloomFilter)
? __ K01 __ bytes
- K01 = ?
And now we have the insert
function. For this we need to set the appropriate bit for each iteration.
- K02 = ?
- K03 = ?