From 8668bdc4042f0fe91e95e0f70caca201d04955a2 Mon Sep 17 00:00:00 2001 From: uvok Date: Sun, 25 Jan 2026 16:22:21 +0100 Subject: eater: Set ALU flags --- eater_cpu/eater_alu.sv | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'eater_cpu') diff --git a/eater_cpu/eater_alu.sv b/eater_cpu/eater_alu.sv index d8748a4..fc54fc1 100644 --- a/eater_cpu/eater_alu.sv +++ b/eater_cpu/eater_alu.sv @@ -17,8 +17,10 @@ module eater_alu ( output wire AluFlags flags_out ); +wire [8:0] full_result /* verilator public */; wire [7:0] result /* verilator public */; -assign result = subtract_n_add_in ? (A_in - B_in) : (A_in + B_in); +assign full_result = subtract_n_add_in ? (A_in - B_in) : (A_in + B_in); +assign result = full_result[7:0]; // wire [7:0] xormask = {8{subtract_n_add_in}}; // wire [7:0] B_neg_if = B_in ^ xormask; // wire [7:0] result2 = A_in + B_neg_if + subtract_n_add_in; @@ -29,4 +31,8 @@ zbuffer buffer ( .data_out(bus_out) ); +assign flags_out.Zero = (result == 0); +assign flags_out.Carry = full_result[8] == 1; +assign flags_out.reserved = 'b0; + endmodule -- cgit v1.2.3