diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-01-21 06:23:46 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-02-20 11:11:17 -0600 |
| commit | f3b18ead59ae02f95dabbf0a1dea40873a816975 (patch) | |
| tree | 8979e50f2a37f66a4cd27e937b480efe60d72cf7 /rtl/core/alu | |
| parent | a8bc5a353ea997f73209b39377ee15a73e471237 (diff) | |
rtl: refactor filenames and directory hierarchy
Diffstat (limited to 'rtl/core/alu')
| -rw-r--r-- | rtl/core/alu/add.sv | 45 | ||||
| -rw-r--r-- | rtl/core/alu/alu.sv | 139 | ||||
| -rw-r--r-- | rtl/core/alu/and.sv | 12 | ||||
| -rw-r--r-- | rtl/core/alu/orr.sv | 12 | ||||
| -rw-r--r-- | rtl/core/alu/xor.sv | 12 |
5 files changed, 0 insertions, 220 deletions
diff --git a/rtl/core/alu/add.sv b/rtl/core/alu/add.sv deleted file mode 100644 index a15a6b6..0000000 --- a/rtl/core/alu/add.sv +++ /dev/null @@ -1,45 +0,0 @@ -module core_alu_add -# -( - parameter W=16, - parameter SUB=0 -) -( - input logic[W - 1:0] a, - b, - input logic c_in, - - output logic[W - 1:0] q, - output logic c, - v -); - - logic sgn_a, sgn_b, sgn_q, maybe_v; - logic[W:0] out; - - /* Quartus infiere dos sumadores si se zero-extendea el cin - * para complacer a Verilator, lo cual es malo para Fmax. - */ -`ifdef VERILATOR - logic[W:0] ext_carry; - assign ext_carry = {{W{1'b0}}, c_in}; -`else - logic ext_carry; - assign ext_carry = c_in; -`endif - - assign v = maybe_v & (sgn_a ^ sgn_q); - assign {c, q} = out; - assign {sgn_a, sgn_b, sgn_q} = {a[W - 1], b[W - 1], q[W - 1]}; - - generate - if(SUB) begin - assign out = {1'b1, a} - {1'b0, b} - ext_carry; - assign maybe_v = sgn_a ^ sgn_b; - end else begin - assign out = {1'b0, a} + {1'b0, b} + ext_carry; - assign maybe_v = sgn_a ~^ sgn_b; - end - endgenerate - -endmodule diff --git a/rtl/core/alu/alu.sv b/rtl/core/alu/alu.sv deleted file mode 100644 index c0ccd32..0000000 --- a/rtl/core/alu/alu.sv +++ /dev/null @@ -1,139 +0,0 @@ -`include "core/uarch.sv" -`include "core/decode/isa.sv" - -module core_alu -#(parameter W=16) -( - input alu_op op, - input logic[W - 1:0] a, - b, - input logic c_in, - c_logic, - - output logic[W - 1:0] q, - output psr_flags nzcv, - output logic v_valid -); - - logic c, v, c_add, c_sub, c_rsb, v_add, v_sub, v_rsb; - logic[W - 1:0] not_b, q_add, q_sub, q_rsb, q_and, q_bic, q_orr, q_xor; - - assign not_b = ~b; - - core_alu_add #(.W(W), .SUB(0)) op_add - ( - .q(q_add), - .c(c_add), - .v(v_add), - .c_in(c_in && !op `FIELD_ALUOP_ADD_CMN && op `FIELD_ALUOP_ADD_NOTCMN_ADC), - .* - ); - - core_alu_add #(.W(W), .SUB(1)) op_sub - ( - .q(q_sub), - .c(c_sub), - .v(v_sub), - .c_in(!c_in && op `FIELD_ALUOP_SUB_SBC), - .* - ); - - core_alu_add #(.W(W), .SUB(1)) op_rsb - ( - .a(b), - .b(a), - .q(q_rsb), - .c(c_rsb), - .v(v_rsb), - .c_in(!c_in && op `FIELD_ALUOP_RSB_RSC), - .* - ); - - core_alu_and #(.W(W)) op_and - ( - .q(q_and), - .* - ); - - core_alu_and #(.W(W)) op_bic - ( - .b(not_b), - .q(q_bic), - .* - ); - - core_alu_orr #(.W(W)) op_orr - ( - .q(q_orr), - .* - ); - - core_alu_xor #(.W(W)) op_xor - ( - .q(q_xor), - .* - ); - - always_comb begin - unique case(op) - `ALU_ADD, `ALU_ADC, `ALU_CMN: - q = q_add; - - `ALU_SUB, `ALU_SBC, `ALU_CMP: - q = q_sub; - - `ALU_RSB, `ALU_RSC: - q = q_rsb; - - `ALU_AND, `ALU_TST: - q = q_and; - - `ALU_BIC: - q = q_bic; - - `ALU_EOR, `ALU_TEQ: - q = q_xor; - - `ALU_ORR: - q = q_orr; - - `ALU_MOV: - q = b; - - `ALU_MVN: - q = not_b; - endcase - - v = 1'bx; - unique case(op) - `ALU_AND, `ALU_EOR, `ALU_TST, `ALU_TEQ, `ALU_ORR, `ALU_MOV, `ALU_BIC, `ALU_MVN: - c = c_logic; - - `ALU_ADD, `ALU_ADC, `ALU_CMN: begin - c = c_add; - v = v_add; - end - - `ALU_SUB, `ALU_SBC, `ALU_CMP: begin - c = c_sub; - v = v_sub; - end - - `ALU_RSB, `ALU_RSC: begin - c = c_rsb; - v = v_rsb; - end - endcase - - unique case(op) - `ALU_AND, `ALU_EOR, `ALU_TST, `ALU_TEQ, `ALU_ORR, `ALU_MOV, `ALU_BIC, `ALU_MVN: - v_valid = 0; - - `ALU_SUB, `ALU_RSB, `ALU_ADD, `ALU_ADC, `ALU_SBC, `ALU_RSC, `ALU_CMP, `ALU_CMN: - v_valid = 1; - endcase - end - - assign nzcv = {q[W - 1], q == 0, c, v}; - -endmodule diff --git a/rtl/core/alu/and.sv b/rtl/core/alu/and.sv deleted file mode 100644 index d119f24..0000000 --- a/rtl/core/alu/and.sv +++ /dev/null @@ -1,12 +0,0 @@ -module core_alu_and -#(parameter W=16) -( - input logic[W - 1:0] a, - b, - - output logic[W - 1:0] q -); - - assign q = a & b; - -endmodule diff --git a/rtl/core/alu/orr.sv b/rtl/core/alu/orr.sv deleted file mode 100644 index 1ee87c2..0000000 --- a/rtl/core/alu/orr.sv +++ /dev/null @@ -1,12 +0,0 @@ -module core_alu_orr -#(parameter W=16) -( - input logic[W - 1:0] a, - b, - - output logic[W - 1:0] q -); - - assign q = a | b; - -endmodule diff --git a/rtl/core/alu/xor.sv b/rtl/core/alu/xor.sv deleted file mode 100644 index f55dfc2..0000000 --- a/rtl/core/alu/xor.sv +++ /dev/null @@ -1,12 +0,0 @@ -module core_alu_xor -#(parameter W=16) -( - input logic[W - 1:0] a, - b, - - output logic[W - 1:0] q -); - - assign q = a ^ b; - -endmodule |
