Skip to content

Commit 0020899

Browse files
committed
Moving cordic files from free-ip.com to github
Move
1 parent c19fecd commit 0020899

39 files changed

+1990
-0
lines changed

cla.rca/hdl/BitMux21.v

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
//----------------------------------------------------------------------------
3+
//----------------------------------------------------------------------------
4+
//-- The Free IP Project
5+
//-- Verilog Free-CORDIC Core
6+
//-- (c) 2000, The Free IP Project and Rohit Sharma ([email protected])
7+
//--
8+
//--
9+
//-- FREE IP GENERAL PUBLIC LICENSE
10+
//-- TERMS AND CONDITIONS FOR USE, COPYING, DISTRIBUTION, AND MODIFICATION
11+
//--
12+
//-- 1. You may copy and distribute verbatim copies of this core, as long
13+
//-- as this file, and the other associated files, remain intact and
14+
//-- unmodified. Modifications are outlined below.
15+
//-- 2. You may use this core in any way, be it academic, commercial, or
16+
//-- military. Modified or not.
17+
//-- 3. Distribution of this core must be free of charge. Charging is
18+
//-- allowed only for value added services. Value added services
19+
//-- would include copying fees, modifications, customizations, and
20+
//-- inclusion in other products.
21+
//-- 4. If a modified source code is distributed, the original unmodified
22+
//-- source code must also be included (or a link to the Free IP web
23+
//-- site). In the modified source code there must be clear
24+
//-- identification of the modified version.
25+
//-- 5. Visit the Free IP web site for additional information.
26+
//-- http://www.free-ip.com
27+
//--
28+
//----------------------------------------------------------------------------
29+
//----------------------------------------------------------------------------
30+
module BitMux2_1 (out,a,b,select);
31+
output out;
32+
input a,b,select;
33+
reg out;
34+
35+
always @ (select or a or b)
36+
case (select)
37+
1'b0: out <= a;
38+
1'b1: out <= b;
39+
default: out <= b;
40+
endcase
41+
endmodule //BitMux2_1
42+

cla.rca/hdl/BusMux21.v

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
//----------------------------------------------------------------------------
3+
//----------------------------------------------------------------------------
4+
//-- The Free IP Project
5+
//-- Verilog Free-CORDIC Core
6+
//-- (c) 2000, The Free IP Project and Rohit Sharma ([email protected])
7+
//--
8+
//--
9+
//-- FREE IP GENERAL PUBLIC LICENSE
10+
//-- TERMS AND CONDITIONS FOR USE, COPYING, DISTRIBUTION, AND MODIFICATION
11+
//--
12+
//-- 1. You may copy and distribute verbatim copies of this core, as long
13+
//-- as this file, and the other associated files, remain intact and
14+
//-- unmodified. Modifications are outlined below.
15+
//-- 2. You may use this core in any way, be it academic, commercial, or
16+
//-- military. Modified or not.
17+
//-- 3. Distribution of this core must be free of charge. Charging is
18+
//-- allowed only for value added services. Value added services
19+
//-- would include copying fees, modifications, customizations, and
20+
//-- inclusion in other products.
21+
//-- 4. If a modified source code is distributed, the original unmodified
22+
//-- source code must also be included (or a link to the Free IP web
23+
//-- site). In the modified source code there must be clear
24+
//-- identification of the modified version.
25+
//-- 5. Visit the Free IP web site for additional information.
26+
//-- http://www.free-ip.com
27+
//--
28+
//----------------------------------------------------------------------------
29+
//----------------------------------------------------------------------------
30+
module BusMux2_1(out,data0,data1,select);
31+
output [`REG_SIZE:0] out;
32+
input [`REG_SIZE:0] data0,data1;
33+
input select;
34+
35+
reg [`REG_SIZE:0] out;
36+
37+
always @ (select or data0 or data1)
38+
case (select)
39+
1'b0: out <= data0;
40+
1'b1: out <= data1;
41+
default: out <= data1;
42+
endcase
43+
44+
endmodule //Mux2_1 delay : delay of BitMux2_1
45+
46+

cla.rca/hdl/adder.v

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
//----------------------------------------------------------------------------
3+
//----------------------------------------------------------------------------
4+
//-- The Free IP Project
5+
//-- Verilog Free-CORDIC Core
6+
//-- (c) 2000, The Free IP Project and Rohit Sharma ([email protected])
7+
//--
8+
//--
9+
//-- FREE IP GENERAL PUBLIC LICENSE
10+
//-- TERMS AND CONDITIONS FOR USE, COPYING, DISTRIBUTION, AND MODIFICATION
11+
//--
12+
//-- 1. You may copy and distribute verbatim copies of this core, as long
13+
//-- as this file, and the other associated files, remain intact and
14+
//-- unmodified. Modifications are outlined below.
15+
//-- 2. You may use this core in any way, be it academic, commercial, or
16+
//-- military. Modified or not.
17+
//-- 3. Distribution of this core must be free of charge. Charging is
18+
//-- allowed only for value added services. Value added services
19+
//-- would include copying fees, modifications, customizations, and
20+
//-- inclusion in other products.
21+
//-- 4. If a modified source code is distributed, the original unmodified
22+
//-- source code must also be included (or a link to the Free IP web
23+
//-- site). In the modified source code there must be clear
24+
//-- identification of the modified version.
25+
//-- 5. Visit the Free IP web site for additional information.
26+
//-- http://www.free-ip.com
27+
//--
28+
//----------------------------------------------------------------------------
29+
//----------------------------------------------------------------------------
30+
/********************************Test Case ***************
31+
`include "header.v"
32+
`include "cla.v"
33+
`include "BusMux21.v"
34+
`include "compl.v"
35+
36+
module test ;
37+
38+
39+
reg [`REG_SIZE:0] A, B;
40+
reg Asgn, AS;
41+
wire [`REG_SIZE:0] S;
42+
43+
Adder testit ( S, sgn, Asgn, A, B, AS ) ;
44+
45+
initial
46+
begin
47+
AS <= 0; Asgn <= 0 ;
48+
A <= 12; B<= 65534 ;
49+
$stop ;
50+
$monitor ( "Sum=%d sign=%d ASign=%b A=%d B=%d AS=%d", S, sgn, Asgn, A, B, AS ) ;
51+
end
52+
endmodule
53+
54+
********************************Test Case ***************/
55+
56+
module Adder (S, sign, Asign, A, B, AS);
57+
output [`REG_SIZE:0] S;
58+
output sign;
59+
input [`REG_SIZE:0] A,B;
60+
input Asign,AS;
61+
62+
wire [`REG_SIZE:0] Atemp,Btemp,Btemp1,Stemp;
63+
reg [`REG_SIZE:0] CIN;
64+
wire Y_1,Y_2,Y_3,Y_4;
65+
66+
assign Y_1 = (~AS) & Asign;
67+
68+
BusMux2_1 MUX_0 (Atemp,A,B,Y_1); // xchange A & B
69+
BusMux2_1 MUX_1 (Btemp,B,A,Y_1);
70+
71+
assign Y_2 = Asign ^ AS;
72+
73+
integer i;
74+
always @ (Y_2)
75+
begin
76+
for(i=0;i<`REG_SIZE+1;i=i+1)
77+
CIN[i] <= Y_2;
78+
end
79+
assign Btemp1 = Btemp ^ CIN;
80+
81+
CLA Add1 (Stemp[`CLA_SIZE:0],W_1,Atemp[`CLA_SIZE:0],Btemp1[`CLA_SIZE:0],Y_2);
82+
83+
CLA Add2 (Stemp[((`CLA_SIZE + 1)*2 - 1):(`CLA_SIZE + 1)],W_2,Atemp[((`CLA_SIZE + 1)*2 - 1):(`CLA_SIZE + 1)],Btemp1[((`CLA_SIZE + 1)*2 - 1):(`CLA_SIZE + 1)],W_1);
84+
85+
CLA Add3 (Stemp[((`CLA_SIZE + 1)*3 - 1):((`CLA_SIZE + 1)*2)],W_3,Atemp[((`CLA_SIZE + 1)*3 - 1):((`CLA_SIZE + 1)*2)],Btemp1[((`CLA_SIZE + 1)*3 - 1):((`CLA_SIZE + 1)*2)],W_2);
86+
87+
CLA Add4 (Stemp[`REG_SIZE:(`CLA_SIZE + 1)*3],Y_3,Atemp[`REG_SIZE:(`CLA_SIZE + 1)*3],Btemp1[`REG_SIZE:(`CLA_SIZE + 1)*3],W_3);
88+
89+
assign Y_4 = (~Y_3) & (Asign ^ AS);
90+
91+
complement Compl (S,Stemp,Y_4); // 2's Complement if result neg.
92+
assign sign = (~Y_3 & AS) | (~Y_3 & Asign) | (AS & Asign);
93+
94+
endmodule // Adder

cla.rca/hdl/cla.v

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
//----------------------------------------------------------------------------
3+
//----------------------------------------------------------------------------
4+
//-- The Free IP Project
5+
//-- Verilog Free-CORDIC Core
6+
//-- (c) 2000, The Free IP Project and Rohit Sharma ([email protected])
7+
//--
8+
//--
9+
//-- FREE IP GENERAL PUBLIC LICENSE
10+
//-- TERMS AND CONDITIONS FOR USE, COPYING, DISTRIBUTION, AND MODIFICATION
11+
//--
12+
//-- 1. You may copy and distribute verbatim copies of this core, as long
13+
//-- as this file, and the other associated files, remain intact and
14+
//-- unmodified. Modifications are outlined below.
15+
//-- 2. You may use this core in any way, be it academic, commercial, or
16+
//-- military. Modified or not.
17+
//-- 3. Distribution of this core must be free of charge. Charging is
18+
//-- allowed only for value added services. Value added services
19+
//-- would include copying fees, modifications, customizations, and
20+
//-- inclusion in other products.
21+
//-- 4. If a modified source code is distributed, the original unmodified
22+
//-- source code must also be included (or a link to the Free IP web
23+
//-- site). In the modified source code there must be clear
24+
//-- identification of the modified version.
25+
//-- 5. Visit the Free IP web site for additional information.
26+
//-- http://www.free-ip.com
27+
//--
28+
//----------------------------------------------------------------------------
29+
//----------------------------------------------------------------------------
30+
/********************************Test Case ***************
31+
32+
module test ;
33+
34+
35+
reg [`CLA_SIZE:0] A, B;
36+
reg CI;
37+
wire [`CLA_SIZE:0] S;
38+
39+
CLA testit ( S, CO, A, B, CI );
40+
41+
initial
42+
begin
43+
CI <= 0;
44+
A <= 12; B<= 4095 ;
45+
$monitor ( "CI=%d A=%d B=%d S=%d CO=%d",CI,A,B,S,CO);
46+
end
47+
endmodule
48+
49+
********************************Test Case ***************/
50+
51+
52+
module CLA ( s, co, a, b, ci );
53+
54+
input ci;
55+
input [`CLA_SIZE:0] a, b;
56+
output [`CLA_SIZE:0] s;
57+
output co;
58+
59+
reg [`CLA_SIZE:0] carrychain;
60+
integer i;
61+
62+
wire [`CLA_SIZE:0] p = a ^ b;
63+
wire [`CLA_SIZE:0] g = a & b;
64+
wire [`CLA_SIZE+1:0] shiftedcarry = {carrychain, ci};
65+
wire [`CLA_SIZE:0] s = p ^ shiftedcarry[`CLA_SIZE:0];
66+
wire co = shiftedcarry[`CLA_SIZE+1];
67+
68+
always @ (a or b or ci or g or p)
69+
begin
70+
carrychain[0] = g[0] | (p[0] & ci);
71+
for ( i = 1; i <= `CLA_SIZE; i = i + 1)
72+
carrychain[i] = g[i] | (p[i] & carrychain[i-1]);
73+
end
74+
75+
endmodule
76+

cla.rca/hdl/compl.v

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
//----------------------------------------------------------------------------
3+
//----------------------------------------------------------------------------
4+
//-- The Free IP Project
5+
//-- Verilog Free-CORDIC Core
6+
//-- (c) 2000, The Free IP Project and Rohit Sharma ([email protected])
7+
//--
8+
//--
9+
//-- FREE IP GENERAL PUBLIC LICENSE
10+
//-- TERMS AND CONDITIONS FOR USE, COPYING, DISTRIBUTION, AND MODIFICATION
11+
//--
12+
//-- 1. You may copy and distribute verbatim copies of this core, as long
13+
//-- as this file, and the other associated files, remain intact and
14+
//-- unmodified. Modifications are outlined below.
15+
//-- 2. You may use this core in any way, be it academic, commercial, or
16+
//-- military. Modified or not.
17+
//-- 3. Distribution of this core must be free of charge. Charging is
18+
//-- allowed only for value added services. Value added services
19+
//-- would include copying fees, modifications, customizations, and
20+
//-- inclusion in other products.
21+
//-- 4. If a modified source code is distributed, the original unmodified
22+
//-- source code must also be included (or a link to the Free IP web
23+
//-- site). In the modified source code there must be clear
24+
//-- identification of the modified version.
25+
//-- 5. Visit the Free IP web site for additional information.
26+
//-- http://www.free-ip.com
27+
//--
28+
//----------------------------------------------------------------------------
29+
//----------------------------------------------------------------------------
30+
/************************Test Case *****************
31+
32+
module test ;
33+
34+
reg [`REG_SIZE:0] datain ;
35+
wire [`REG_SIZE:0] dataout ;
36+
reg enable ;
37+
38+
initial
39+
begin
40+
enable = 1 ;
41+
datain = 12'b110011001100;
42+
$monitor ( "datain = %b \t dataout = %b", datain, dataout );
43+
#10 enable = 0 ;
44+
$display ( "datain = %b \t dataout = %b", datain, dataout );
45+
end
46+
47+
complement testc (dataout, datain, enable);
48+
49+
endmodule
50+
51+
************************Test Case *****************/
52+
53+
54+
module complement (dataout, datain, enable);
55+
output [`REG_SIZE:0] dataout;
56+
input [`REG_SIZE:0] datain;
57+
input enable;
58+
59+
60+
reg [`REG_SIZE:0] Co, dataout, Enable;
61+
reg Cin;
62+
integer i,j;
63+
64+
always @ (enable)
65+
begin
66+
for(j=0;j<`REG_SIZE+1;j=j+1)
67+
Enable[j] = enable;
68+
end
69+
70+
wire [`REG_SIZE:0] A = datain ^ Enable;
71+
72+
73+
always @ (enable)
74+
begin
75+
case (enable)
76+
1'b0: Cin <= 1'b0;
77+
1'b1: Cin <= 1'b1;
78+
default: Cin <= 1'b1;
79+
endcase
80+
end
81+
82+
83+
84+
always @ (A or Cin )
85+
begin
86+
dataout[0] = A[0] ^ Cin;
87+
Co[0] = A[0] & Cin;
88+
for(i = 1; i <=`REG_SIZE; i = i + 1)
89+
begin
90+
dataout[i] = A[i] ^ Co[i-1];
91+
Co[i] = A[i] & Co[i-1];
92+
end
93+
end
94+
95+
endmodule // 2compl delay : BitMux2_1 delay + 12 * HA1 dalay
96+

0 commit comments

Comments
 (0)