Add always_ff in saw2sin to fix glitches

This commit is contained in:
Aadi Desai 2023-06-04 14:14:05 +01:00
parent 6d670dc903
commit aac2ad4c62
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View file

@ -46,7 +46,8 @@ always_comb triangle = saw[15] ? {~saw[14:0], 1'b1} : {saw[14:0], 1'b0}; // Tria
logic [15:0] sine;
saw2sin m_saw2sin // Instantiate saw2sin module
( .i_saw(saw)
( .i_clk(i_clk48)
, .i_saw(saw)
, .o_sin(sine)
);

View file

@ -1,7 +1,8 @@
`default_nettype none
module saw2sin
( input var [15:0] i_saw
( input var i_clk
, input var [15:0] i_saw
, output var [15:0] o_sin
);
@ -23,7 +24,7 @@ cordic cordic
);
logic [16:0] sin;
always_comb sin = reverse
always_ff @(posedge i_clk) 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