ECEN3100 - Digital Logic

Lab 10: Implementing the Swap Processor

2 lab periods

This lab assignment is to implement the simple "Swap" processor described in Fig. 7.60 of your textbook. The buttons are used to control the register transfers, and the overall functionality of the module should be asfollows:

Pictoral representation of on-board resources utilized in this project

Required functionality:

Optional functionality (good idea for debugging):

You may use this file, and here's the swap code from the text to help you get started:

module swap (Data, Resetn, w, Clock, Extern, RinExt, BusWires);

input [7:0] Data;
input Resetn, w, Clock, Extern;
input [1:3] RinExt;
output [7:0] BusWires;
tri [7:0] BusWires;
wire [1:3] Rin, Rout, Q;
wire [7:0] R1, R2, R3;
    shiftr control (Resetn, w, Clock, Q);
    defparam control.m = 3;
    assign Rin[1] = RinExt[1] | Q[3];
    assign Rin[2] = RinExt[2] | Q[2];
    assign Rin[3] = RinExt[3] | Q[1];
    assign Rout[1] = Q[2];
    assign Rout[2] = Q[1];
    assign Rout[3] = Q[3];
    regn reg_1 (BusWires, Rin[1], Clock, R1);
    regn reg_2 (BusWires, Rin[2], Clock, R2);
    regn reg_3 (BusWires, Rin[3], Clock, R3);
    trin tri_ext (Data, Extern, BusWires);
    trin tri_1 (R1, Rout[1], BusWires);
    trin tri_2 (R2, Rout[2], BusWires);
    trin tri_3 (R3, Rout[3], BusWires);

Here's the sign-off sheet, and the pin assignments file.

For additional practice and a little extra credit (no more than 5%), modify your TA-approved working design to implement a fourth register. HEX1 and HEX0 should display its' current value, and KEY[3] should swap the values of R1 and the new R4. There's more than one way to implement this functionality, but here's a hint: when you assert the 'w'; signal, store the value of KEY[3].

For even more practice and even more extra credit (no more than 5%), change the behavior of KEY[3] such that it adds the values of R1 and R2, and stores the result in R4. Here's a hint: first copy the value from R1 and write it to a new register, ADD1, then copy the value from R2 and write it to another new register, ADD2, then finally copy the value from a third new register called ADDRESULT and write it to R4. Also, you might want to consider implementing some way to directly view these new registers for debugging purposes (you have a lot of unused switches and LEDs available... use them!).