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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
39742b9f
Commit
39742b9f
authored
10 years ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Added tech_ceil_log2() because that is used for FIFO usedw width.
parent
5065c153
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/technology/base/technology_pkg.vhd
+37
-0
37 additions, 0 deletions
libraries/technology/base/technology_pkg.vhd
with
37 additions
and
0 deletions
libraries/technology/base/technology_pkg.vhd
+
37
−
0
View file @
39742b9f
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
LIBRARY
IEEE
;
LIBRARY
IEEE
;
USE
IEEE
.
STD_LOGIC_1164
.
ALL
;
USE
IEEE
.
STD_LOGIC_1164
.
ALL
;
USE
IEEE
.
MATH_REAL
.
ALL
;
PACKAGE
technology_pkg
IS
PACKAGE
technology_pkg
IS
...
@@ -33,6 +34,9 @@ PACKAGE technology_pkg IS
...
@@ -33,6 +34,9 @@ PACKAGE technology_pkg IS
-- Functions
-- Functions
FUNCTION
tech_sel_a_b
(
sel
:
BOOLEAN
;
a
,
b
:
STRING
)
RETURN
STRING
;
FUNCTION
tech_sel_a_b
(
sel
:
BOOLEAN
;
a
,
b
:
STRING
)
RETURN
STRING
;
FUNCTION
tech_true_log2
(
n
:
NATURAL
)
RETURN
NATURAL
;
-- tech_true_log2(n) = log2(n)
FUNCTION
tech_ceil_log2
(
n
:
NATURAL
)
RETURN
NATURAL
;
-- tech_ceil_log2(n) = log2(n), but force tech_ceil_log2(1) = 1
END
technology_pkg
;
END
technology_pkg
;
...
@@ -43,4 +47,37 @@ PACKAGE BODY technology_pkg IS
...
@@ -43,4 +47,37 @@ PACKAGE BODY technology_pkg IS
IF
sel
=
TRUE
THEN
RETURN
a
;
ELSE
RETURN
b
;
END
IF
;
IF
sel
=
TRUE
THEN
RETURN
a
;
ELSE
RETURN
b
;
END
IF
;
END
;
END
;
FUNCTION
tech_true_log2
(
n
:
NATURAL
)
RETURN
NATURAL
IS
-- Purpose: For calculating extra vector width of existing vector
-- Description: Return mathematical ceil(log2(n))
-- n log2()
-- 0 -> -oo --> FAILURE
-- 1 -> 0
-- 2 -> 1
-- 3 -> 2
-- 4 -> 2
-- 5 -> 3
-- 6 -> 3
-- 7 -> 3
-- 8 -> 3
-- 9 -> 4
-- etc, up to n = NATURAL'HIGH = 2**31-1
BEGIN
RETURN
natural
(
integer
(
ceil
(
log2
(
real
(
n
)))));
END
;
FUNCTION
tech_ceil_log2
(
n
:
NATURAL
)
RETURN
NATURAL
IS
-- Purpose: For calculating vector width of new vector
-- Description:
-- Same as tech_true_log2() except tech_ceil_log2(1) = 1, which is needed to support
-- the vector width width for 1 address, to avoid NULL array for single
-- word register address.
BEGIN
IF
n
=
1
THEN
RETURN
1
;
-- avoid NULL array
ELSE
RETURN
tech_true_log2
(
n
);
END
IF
;
END
;
END
technology_pkg
;
END
technology_pkg
;
\ No newline at end of file
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