RICSC16 Lab 1 2 - BEAMS-EE/ELECH473 GitHub Wiki

Hints for RiSC16 Labs 1 and 2

  1. What happens to the value (in base 10) of a number when you shift it to the left? What's 4<<1? 5<<1?

  2. You need to use a mask to select a bit, don't forget you can use MOVI at any point in your code, and also remember that NAND is magic!

  3. Can't you use the previous questions to do that?

  4. Use your previous answers to compute the carry, how does the carry of an addition work? Which are the bits of the operands and the result that fully determine the value of the carry bit? Look at the following examples on 2 bits (with the carry bit between parenthesis), especially the highlighted bits.

10 + 10 = (1)00

01 + 01 = (0)1

11 + 01 = (1)00

10 + 01 = (0)11

  1. Like other previous questions, use your previous answers.

  2. How does multiplication work? Are there multiple ways to carry a multiplication?

Frequently Asked Questions

The example file on the UV does not pass the online simulator tests, why is that?

The online simulator is only for questions 4 through 9 (1.x, during the first lab). The example code given on the UV and the handout is not supposed to be tested online.

What is a test vector?

Test vectors mean all the operands that you may want to test to assess if your code is working properly, e.g. if you make a program that shifts to the left, with what input values will you test it so that you are confident that it works as intended? In the context of this first lab, the online simulator is doing the tests for you, by changing the first few lines into values.

How can we use logical operations (such as OR, AND and NOT) if we only have a NAND?

The NAND operation is functionally complete, you can use it to represent any other boolean operation.

Can we assume the register 0 always contains de value 0 ?

Yes.

What is the TGT signal?

TGT = target. It specifies the address where the result has to be written.

BEQ being limited to +63/-64 lines jump, how can we jump farther using a label?

If you want to jump more than 63 lines, you can either have an intermediate BEQ, meaning you put a beq 0,0 somewhere so that it first jumps there and then to your actual value. Otherwise you would have to use jalr, and put the memory address in a register before jumping, you cannot use a label because it would require that you use movi to put a label in a register, which is not implemented.

Does the cycle count in the online simulator influence de grade of the assignment?

Yes, the maximum cycle count, online, is 10^6. For the grading, we will increase this limit if it is not sufficient for your code. However, note that the time complexity of your code is very important for the grading, if your code needs that much instruction it is probably not efficient and you will loose a good amount of points because of that

As a rule of thumb: less instruction cycles => more points.