mirror of
https://github.com/supleed2/cordic.git
synced 2024-12-22 13:45:50 +00:00
Add saw2sin.sv
Handles inversion and reversing to create full sine wave from quarter wave
This commit is contained in:
parent
e00149bb62
commit
44e148de38
29
saw2sin.sv
Normal file
29
saw2sin.sv
Normal file
|
@ -0,0 +1,29 @@
|
|||
`default_nettype none
|
||||
|
||||
module saw2sin
|
||||
( input var [15:0] i_saw
|
||||
, output var [15:0] o_sin
|
||||
);
|
||||
|
||||
logic invert;
|
||||
always_comb invert = i_saw[15];
|
||||
|
||||
logic reverse;
|
||||
always_comb reverse = i_saw[14];
|
||||
|
||||
logic [15:0] qsaw;
|
||||
always_comb qsaw = reverse
|
||||
? {~i_saw[13:0], 2'b01} // Reverse
|
||||
: {i_saw[13:0], 2'b00}; // Normal
|
||||
|
||||
logic [15:0] qsin;
|
||||
cordic cordic
|
||||
( .i_qph (qsaw)
|
||||
, .o_sin (qsin)
|
||||
);
|
||||
|
||||
always_comb o_sin = invert
|
||||
? ~{1'b1, qsin[15:1]} + 1 // Invert
|
||||
: {1'b1, qsin[15:1]}; // Normal
|
||||
|
||||
endmodule
|
Loading…
Reference in a new issue