Fixed bug in adder/subtracter where code assuming width was the bit width was not updated when moving to the 2**N approach required by the assignment. Updated adder/subtracter testbench to correctly instantiate the asser/subtracter and removed unused variable
This commit is contained in:
2 files changed
+5
-7
No files matched your search
+4
-4
@@ -7,11 +7,11 @@ module asu #(parameter width = 2)(
|
||||
always_comb begin
|
||||
// A + (sub) ? B : -B
|
||||
// Adds an extra bit to all operands to calculate the carry bit. Not optimal for hardware synthesis
|
||||
operand = (B ^ {(width){op}});
|
||||
{COUT, OUT_1} = A + operand + {{(width-1){1'b0}}, op};
|
||||
operand = (B ^ {(2**width){op}});
|
||||
{COUT, OUT_1} = A + operand + {{(2**width-1){1'b0}}, op};
|
||||
end
|
||||
|
||||
// Need to do this outside of the always_comb block because parameter-based bitslicing/indexing isn't supported?
|
||||
// Cin for width-2'th bit to later be xor'ed with COUT to determine if a signed overflow occured for the MIPS architecture
|
||||
assign OUT_CIN = A[width-1] ^ operand[width-1] ^ OUT_1[width-1];
|
||||
// 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];
|
||||
endmodule
|
||||
+1
-3
@@ -10,10 +10,8 @@ module asu_tb #(width=8)();
|
||||
logic [width-1:0] C_exp;
|
||||
logic [0:0] Cout_exp;
|
||||
logic [0:0] Cin_exp; // TODO
|
||||
|
||||
logic [0:0] Signed_overflow;
|
||||
|
||||
asu #(width) dut(op, A, B, C, Cout, Cin);
|
||||
asu #($clog2(width)) dut(op, A, B, C, Cout, Cin);
|
||||
|
||||
integer error_count;
|
||||
initial begin
|
||||
|
||||
Reference in new issue
Block a user