Updated ALU and ASU modules to conditionally require seven-segment output logic. Used for the assignment 1 demo and MUST be stripped for assignment 2.

This commit is contained in:
riley committed 2026-09-15 21:27:04 +10:00
1 parent c27a04ef73
commit 19cd7ac177
2 files changed
+34 -7

No files matched your search

+21 -4
View File
@@ -9,13 +9,25 @@
// flags[1:1] = Overflow // flags[1:1] = Overflow
module alu #(parameter width=2)(input logic [3:0] op, module alu #(parameter width=2)(input logic [3:0] op,
input logic [2**width-1:0] A, input logic [2**width-1:0] B, input logic [2**width-1:0] A, input logic [2**width-1:0] B,
output logic [2**width-1:0] OUT_1, output logic[1:0] flags, output logic [2**width-1:0] OUT_1, output logic[1:0] flags
output logic [7:0] out_seg1); `ifdef SYNTHESIS
, output logic [7:0] out_seg1);
`else
);
`endif
logic [0:0] asu_op; logic [0:0] asu_op;
logic [2**width-1:0] asu_out; logic [2**width-1:0] asu_out;
logic [1:0] asu_flags; logic [1:0] asu_flags;
asu #(width) adder_unit(asu_op[op[1]], A, B, asu_out, asu_flags[0], asu_flags[1]); logic [7:0] asu_seven_seg_out;
// NOTE: For demo only
// TODO: Strip this for assignment 2
`ifdef SYNTHESIS
asu #(width) adder_unit(asu_op[op[1]], A, B, asu_out, asu_flags[0], asu_flags[1], asu_seven_seg_out);
`else
asu #(width) adder_unit(asu_op[op[1]], A, B, asu_out, asu_flags[0], asu_flags[1]);
`endif
logic [2**width-1:0] lu_out; logic [2**width-1:0] lu_out;
lu #(width) logic_unit(op[1:0], A, B, lu_out); lu #(width) logic_unit(op[1:0], A, B, lu_out);
@@ -35,6 +47,11 @@ module alu #(parameter width=2)(input logic [3:0] op,
default: begin OUT_1 = {(2**width){1'b0}}; flags = asu_flags; end default: begin OUT_1 = {(2**width){1'b0}}; flags = asu_flags; end
endcase endcase
end end
seven_seg dut(OUT_1, 1, out_seg1);
// NOTE: For demo only
// TODO: Strip this for assignment 2
`ifdef SYNTHESIS
seven_seg dut(OUT_1, 1'b1, out_seg1);
`endif
endmodule endmodule
`endif `endif
+13 -3
View File
@@ -5,8 +5,14 @@
module asu #(parameter width = 2)( module asu #(parameter width = 2)(
input logic [0:0] op, input logic [0:0] op,
input logic[2**width-1:0] A, input logic[2**width-1:0] B, input logic[2**width-1:0] A, input logic[2**width-1:0] B,
output logic[2**width-1:0] OUT_1, output logic[0:0] COUT, output logic[0:0] OUT_CIN, output logic[2**width-1:0] OUT_1, output logic[0:0] COUT, output logic[0:0] OUT_CIN
output logic[7:0] out_seg_1); // Used to switch between demo mode and testbench mode
// TODO: Strip for assignment 2
`ifdef SYNTHESIS
, output logic[7:0] out_seg_1);
`else
);
`endif
logic [2**width-1:0] operand; logic [2**width-1:0] operand;
always_comb begin always_comb begin
@@ -21,6 +27,10 @@ module asu #(parameter width = 2)(
// Cin for final bit in adder to later be xor'ed with COUT to determine if a signed overflow occured for the MIPS architecture // Cin for final bit in adder to later be xor'ed with COUT to determine if a signed overflow occured for the MIPS architecture
assign OUT_CIN = A[2**width-1] ^ operand[2**width-1] ^ OUT_1[2**width-1]; assign OUT_CIN = A[2**width-1] ^ operand[2**width-1] ^ OUT_1[2**width-1];
seven_seg dut(OUT_1, 1, out_seg_1); // Include seven segment visual output for hardware builds only
// TODO: Strip this for assignment 2 outright
`ifdef SYNTHESIS
seven_seg dut(OUT_1, 1'b1, out_seg_1);
`endif
endmodule endmodule
`endif `endif