diff --git a/cordic.sv b/cordic.sv index e3629cd..1c39097 100644 --- a/cordic.sv +++ b/cordic.sv @@ -62,7 +62,7 @@ end /* verilator lint_on ALWCOMBORDER */ always_comb - if (i_qph > 16'd65508) o_sin = 16'hFFFF; + if (i_qph > 16'd65508) o_sin = 16'hFFFE; else if (i_qph < 16'd32) o_sin = i_qph + (i_qph >> 1); else o_sin = y[19][17:2]; diff --git a/saw2sin.sv b/saw2sin.sv index c9e753b..c74347d 100644 --- a/saw2sin.sv +++ b/saw2sin.sv @@ -22,8 +22,13 @@ cordic cordic , .o_sin (qsin) ); -always_comb o_sin = invert - ? ~{1'b1, qsin[15:1]} + 1 // Invert - : {1'b1, qsin[15:1]}; // Normal +logic [16:0] sin; +always_comb sin = reverse + ? (invert ? ~{1'b1, qsin[15:0]} // Reverse, Invert + : {1'b1, qsin[15:0]} + 17'd1) // Reverse, Normal + : (invert ? ~{1'b1, qsin[15:0]} + 17'd2 // Normal, Invert + : {1'b1, qsin[15:0]} + 17'd0); // Normal, Normal + +always_comb o_sin = sin[16:1]; endmodule