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:
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 = RinExt | Q; assign Rin = RinExt | Q; assign Rin = RinExt | Q; assign Rout = Q; assign Rout = Q; assign Rout = Q; regn reg_1 (BusWires, Rin, Clock, R1); regn reg_2 (BusWires, Rin, Clock, R2); regn reg_3 (BusWires, Rin, Clock, R3); trin tri_ext (Data, Extern, BusWires); trin tri_1 (R1, Rout, BusWires); trin tri_2 (R2, Rout, BusWires); trin tri_3 (R3, Rout, BusWires); endmodule
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 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.
For even more practice and even more extra credit (no more than 5%), change the behavior of KEY 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!).