Skip to content

Commit 43f460e

Browse files
committed
ad_dds_cordic_pipe.v: Optimize for implementation
The present changes make better use of the Carry Chain blocks resulting in fewer FPGA resources being used.
1 parent dc80048 commit 43f460e

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

library/common/ad_dds_cordic_pipe.v

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ module ad_dds_cordic_pipe#(
4545

4646
// interface
4747

48-
input clk,
49-
(* keep = "TRUE" *) input dir,
50-
(* keep = "TRUE" *) input signed [ DW-1:0] dataa_x,
51-
(* keep = "TRUE" *) input signed [ DW-1:0] dataa_y,
52-
(* keep = "TRUE" *) input signed [ DW-1:0] dataa_z,
53-
(* keep = "TRUE" *) input signed [ DW-1:0] datab_x,
54-
(* keep = "TRUE" *) input signed [ DW-1:0] datab_y,
55-
(* keep = "TRUE" *) input signed [ DW-1:0] datab_z,
56-
(* keep = "TRUE" *) output reg signed [ DW-1:0] result_x,
57-
(* keep = "TRUE" *) output reg signed [ DW-1:0] result_y,
58-
(* keep = "TRUE" *) output reg signed [ DW-1:0] result_z,
48+
input clk,
49+
(* keep = "TRUE" *) input dir,
50+
(* keep = "TRUE" *) input [ DW-1:0] dataa_x,
51+
(* keep = "TRUE" *) input [ DW-1:0] dataa_y,
52+
(* keep = "TRUE" *) input [ DW-1:0] dataa_z,
53+
(* keep = "TRUE" *) input [ DW-1:0] datab_x,
54+
(* keep = "TRUE" *) input [ DW-1:0] datab_y,
55+
(* keep = "TRUE" *) input [ DW-1:0] datab_z,
56+
(* keep = "TRUE" *) output reg [ DW-1:0] result_x,
57+
(* keep = "TRUE" *) output reg [ DW-1:0] result_y,
58+
(* keep = "TRUE" *) output reg [ DW-1:0] result_z,
5959
output signed [ DW-1:0] sgn_shift_x,
6060
output signed [ DW-1:0] sgn_shift_y,
6161
input [DELAY_DW:1] data_delay_in,
@@ -66,22 +66,15 @@ module ad_dds_cordic_pipe#(
6666

6767
reg [DELAY_DW:1] data_delay = 'd0;
6868

69+
wire dir_inv = ~dir;
70+
6971
// stage rotation
7072

7173
always @(posedge clk)
7274
begin
73-
case(dir)
74-
1'b0: begin
75-
result_x <= dataa_x - datab_y;
76-
result_y <= dataa_y + datab_x;
77-
result_z <= dataa_z - datab_z;
78-
end
79-
1'b1: begin
80-
result_x <= dataa_x + datab_y;
81-
result_y <= dataa_y - datab_x;
82-
result_z <= dataa_z + datab_z;
83-
end
84-
endcase
75+
result_x <= dataa_x + ({DW{dir_inv}} ^ datab_y) + dir_inv;
76+
result_y <= dataa_y + ({DW{dir}} ^ datab_x) + dir;
77+
result_z <= dataa_z + ({DW{dir_inv}} ^ datab_z) + dir_inv;
8578
end
8679

8780
// stage shift
@@ -100,4 +93,4 @@ module ad_dds_cordic_pipe#(
10093

10194
assign data_delay_out = data_delay;
10295

103-
endmodule
96+
endmodule

0 commit comments

Comments
 (0)