Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
51928ae8
Commit
51928ae8
authored
7 years ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Added function common_math_create_look_up_table_phasor().
parent
bb725a4d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/base/common/src/vhdl/common_math_pkg.vhd
+33
-3
33 additions, 3 deletions
libraries/base/common/src/vhdl/common_math_pkg.vhd
with
33 additions
and
3 deletions
libraries/base/common/src/vhdl/common_math_pkg.vhd
+
33
−
3
View file @
51928ae8
...
@@ -45,9 +45,7 @@ PACKAGE common_math_pkg IS
...
@@ -45,9 +45,7 @@ PACKAGE common_math_pkg IS
-- . +round(ampl) is the maximum integer value and -round(ampl) the minimum integer value
-- . +round(ampl) is the maximum integer value and -round(ampl) the minimum integer value
-- . freq is the number of periods in N samples
-- . freq is the number of periods in N samples
-- . phi is phase offset in radials
-- . phi is phase offset in radials
-- Phasor: exp(j*angle) = cos(angle) + j*sin(angle)
-- . use common_math_create_look_up_table_phasor() to create a complex phasor look up table
-- A complex FFT of N points has N bins or channels: ch = -N/2:0:N/2-1.
-- To create an FFT input phasor with frequency in the middle of a channel use FREQ = ch.
FUNCTION
common_math_create_look_up_table_cos
(
N
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_nat_integer_arr
;
FUNCTION
common_math_create_look_up_table_cos
(
N
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_nat_integer_arr
;
FUNCTION
common_math_create_look_up_table_sin
(
N
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_nat_integer_arr
;
FUNCTION
common_math_create_look_up_table_sin
(
N
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_nat_integer_arr
;
...
@@ -68,6 +66,20 @@ PACKAGE common_math_pkg IS
...
@@ -68,6 +66,20 @@ PACKAGE common_math_pkg IS
-- Function to concat Im & Re values in the lookup table, output = (hi << W) + lo
-- Function to concat Im & Re values in the lookup table, output = (hi << W) + lo
FUNCTION
common_math_concat_look_up_table
(
table_hi
,
table_lo
:
t_nat_integer_arr
;
W
:
POSITIVE
)
RETURN
t_nat_integer_arr
;
FUNCTION
common_math_concat_look_up_table
(
table_hi
,
table_lo
:
t_nat_integer_arr
;
W
:
POSITIVE
)
RETURN
t_nat_integer_arr
;
-- Function to concat Im & Re values of phasor in the lookup table, output = (imag << W) + real
-- . N is number of samples in the lookup table, [0:N-1] = [0:N> = [0:2pi*FREQ>
-- . +round(ampl) is the maximum integer value and -round(ampl) the minimum integer value
-- full scale = 2**(W-1)
-- max = full_scale - 1 = 2**(W-1)-1
-- use AMPL <= max to avoid wrapping
-- . freq is the number of periods in N samples
-- . phi is phase offset in radials
-- Phasor: exp(j*angle) = cos(angle) + j*sin(angle)
-- A complex FFT of N points has N bins or channels: ch = -N/2:0:N/2-1.
-- To create an FFT input phasor with frequency in the middle of a channel use FREQ = ch.
FUNCTION
common_math_create_look_up_table_phasor
(
N
,
W
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_nat_integer_arr
;
FUNCTION
common_math_create_look_up_table_phasor
(
N
,
W
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_slv_32_arr
;
-- range 0 TO N-1
END
common_math_pkg
;
END
common_math_pkg
;
...
@@ -149,5 +161,23 @@ PACKAGE BODY common_math_pkg IS
...
@@ -149,5 +161,23 @@ PACKAGE BODY common_math_pkg IS
RETURN
v_table
;
RETURN
v_table
;
END
;
END
;
FUNCTION
common_math_create_look_up_table_phasor
(
N
,
W
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_nat_integer_arr
IS
CONSTANT
c_cos_arr
:
t_nat_integer_arr
:
=
common_math_create_look_up_table_cos
(
N
,
AMPL
,
FREQ
,
PHI
);
CONSTANT
c_sin_arr
:
t_nat_integer_arr
:
=
common_math_create_look_up_table_sin
(
N
,
AMPL
,
FREQ
,
PHI
);
CONSTANT
c_exp_arr
:
t_nat_integer_arr
:
=
common_math_concat_look_up_table
(
c_sin_arr
,
c_cos_arr
,
W
);
BEGIN
RETURN
c_exp_arr
;
-- Concatenated W bit sin imag part & W bit cos real part
END
;
FUNCTION
common_math_create_look_up_table_phasor
(
N
,
W
:
POSITIVE
;
AMPL
,
FREQ
,
PHI
:
REAL
)
RETURN
t_slv_32_arr
IS
CONSTANT
c_exp_arr
:
t_nat_integer_arr
:
=
common_math_create_look_up_table_phasor
(
N
,
W
,
AMPL
,
FREQ
,
PHI
);
VARIABLE
v_exp_arr
:
t_slv_32_arr
(
0
TO
N
-1
);
BEGIN
FOR
I
IN
0
TO
N
-1
LOOP
v_exp_arr
(
I
)
:
=
TO_SVEC
(
c_exp_arr
(
I
),
32
);
END
LOOP
;
RETURN
v_exp_arr
;
END
;
END
common_math_pkg
;
END
common_math_pkg
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment