Professional Documents
Culture Documents
1. Consider three different processors P1, P2, and P3 executing the same instruction set.
P1 has a 3 GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a CPI of 1.0.
P3 has a 4.0 GHz clock rate and has a CPI of 2.2.
a. Which processor has the highest performance expressed in instructions per second?
IPS of P1 = Cycles per s/CPI = Fclk/CPI = 3GHz/1.5 = 2 x 109 IPS
IPS of P2 = 2.5GHz/1 = 2.5 x 109 IPS
IPS of P3 = 2.5GHz/1 = 2.5 x 109 IPS
b. If the processors each execute a program in 10 seconds, find the number of cycles and
the number of instructions.
# of cycles = Cycles per second x time (in seconds)
Cycles of P1: 3 GHz x 10 s = 30 B cycles
Cycles of P2: 2.5GHz x 10 s = 25 B cycles
Cycles of P3: 4 GHz x 10s = 40 B cycles
c. We are trying to reduce the execution time by 30%, but this leads to an increase of 20%
in the CPI. What clock rate should we have to get this time reduction?
• Lower execution time trades off with higher CPI & higher FCLK
• Assuming 30% reduction in execution time requires 20% higher CPI
# Instructions x CPI_new / ET_new = Fclk_new
Fclk_new P1 = 20 B x 1.8 / 7s = 5.14 GHz
Fclk_new P2 = 25 B x 1.2 / 7s = 4.28 GHz
Fclk_new P1 = 18.18 B x 2.6 / 7s = 6.75 GHz
2. Find a short sequence of RISC-V instructions that extracts bits 23 down to 8 from
register x7 and uses the bitwise inverted value of this field to replace bits 31 down to
16 in register x8 without changing any of the bits of registers x7 or any of the bits in
the less significant half word of x8 (bits 15:0).
We can shift 0x5F left 5 places (BD016), then add 0x5F shifted left 4 places (5F016), then
add 0x5F shifted left 3 places (2F816) and then add 0x5F shifted once (0x?)
5F x 25
=5F shifted left 5 places: 0101 1111 shifted left 5 places = 1011 1110 0000 = BD016
5F x 24
=5F shifted left 4 places: 0101 1111 shifted left 4 places = 0101 1111 0000 = 5F016
5F x 23
=5F shifted left 3 places: 0101 1111 shifted left 3 places = 0010 1111 1000 = 2F816
5F x 21
=5F shifted left 1 places: 0101 1111 shifted left 1 places = 0000 1011 1110 = 0BD16
4 shifts, 3 adds.
4. Write the RISC-V assembly code that creates the 64-bit constant
0x112233445566778816 and stores that value to register x10.
lui x10, 0x11223 // loads the 5 hex numbers 11223 into the upper 20 bits of x10
// note that each hex number corresponds to 4 bits, so loading the
// upper 20 bits with lui can only permit exactly 5 hex numbers.
// Hence the choice of ‘11223’ into the upper 20 bits
addi x10, x10, 0x344 // we can extend the above string of 11223 by adding the immediate
// value of 3 hex numbers of ‘344’ in the lower 12 bits to the
// above string of ‘11223’ to get ‘11223344’ into x10
slli x10, x10, 32 // moves the 8 hex numbers ‘11223344’ to the upper half of the 64
// bit double word
lui x5, 0x55667 // loads the MSBs of the lower half of the desired double word with
// the 5 hex numbers ‘55667’
addi x5, x5, 0x788 // just as we did previously, these 5 hex numbers are added to 3
// hex numbers ‘788’ to produce the lower half string: ‘55667788’
add x10, x10, x5 // this added to the upper half string yields the full desired
// string of ‘1122334455667788’ loaded into the double word
5. Assuming a single precision IEEE 754 Floating Point representation
(b) Write down the Decimal value of the Floating Point Number represented by the following
32 bit Single Precision IEEE 754 standard
(a)
-0.1562510 = -0.001012 = -1.01 x 2-3
Sign bit = 1
Value of exponent = EXP field – bias
-3 = EXP field – 127
EXP field = 127-3 = 124 or 01111100
Fractional Field: 010 0000 0000 0000 0000 0000
(b)
Fractional Field = .0011
EXP field = 011011102 = 11010
Value of exponent = EXP field – bias = 110 – 127 = -17
Number is + 1.0011 x 2-17