ECE 449 Assignment 5

  1. Write an assembly language program to do the following:

    1. Use movi to load the date 05-03-2008 (hex 0x05032008) into r3. Then write your birthdate (in hex) into r4 using ori and orhi.

    2. Set r5 = -1 using addi.

    3. Set r5 = 0xFFFF0000 by using xori.

    4. Set r5 = 0xFFFF by using nor (with r0).

    5. Eliminate the upper 16 bits of r2 and r3 (leaving just the year) by anding them with r5.

    6. Subtract r4 from r3 to generate your "age". Why does this "fail"?

    7. Try again, using decimal numbers for 2008 and your birthyear.

    8. Use the existing instructions to do a logical "not" of a register and a logical "nand" of two registers. Try to do each of these with just two instructions.

    9. Write code to calculate 15 + 30 - 18 using both immediate and register format instructions

    Run your program within the Nios II Command shell, producing the usual text files and generate a MIF of your program.

  2. Modify the risc processor started in the last assignment by adding an ALU. I am providing you with rformat and iformat look-up tables and the ALU input multiplexer. Setup your DE2 project so that it displays the results of each instruction on the DE-2 board. Download de2risc2 for a version based on the last assignment. Demonstrate that your project runs the assembly language program from the previous problem.

  3. Use the Nios II with timer project (or use mine) from assignment 3. Write a C program to find the time required for
    1. multiplication of two integers
    2. division of two integers
    3. addition of two integers
    4. multiplication of two doubles
    5. division of two doubles
    6. addition of two doubles
    7. sqrt()
    8. sin()

    You will need to "fool" the compiler into thinking you really want the results (maybe by saving them to an array that you then sum). Otherwise the compiler may "optimize" them away and never do the calculation.

  4. Modify the audio program to do "Karoke" by making the output equal to the difference of the two input channels. This will often eliminate the vocal track (depending on the recording). You could improve on simple subtraction by adjusting the relative contribution of each channel. I suggest a combinational calculation of the type: out = right + u*(left-right)/64 where u varies from 0 to 64 (start with 32). Note that division by 64 is just a shift operation.

    Use KEY3 to increase u and KEY2 to decrease u. Use SW0 to enable Karoke mode. If SW0 is off, just pass the input to the output. Display u on the seven-segment display.


Maintained by John Loomis, last updated 14 Feb 2008