Livt packages
Livt.Math
Version 1.7.2
Reusable integer and fixed-point arithmetic, complex numbers, trigonometry, and statistics for FPGA applications written in Livt.
Published files (90)
- CordicAtan2MagnitudeQ15LifecycleTb.vhd
- CordicSinCosQ15LifecycleTb.vhd
- CordicSinCosQ15SynthesisTop.vhd
- cordic_q15_oracle.py
- cordic_vectoring_q15_oracle.py
- IntegerDivisionResetTb.vhd
- measure_cordic_ice40.py
- special_functions_oracle.py
- test_cordic_sincos_q15.py
- test_cordic_structure.py
- test_cordic_vectoring_lifecycle.py
- test_cordic_vectoring_structure.py
- test_special_function_structure.py
- test_wide_pipeline.py
- WideArithmeticResetTb.vhd
tests/rtl/test_cordic_vectoring_structure.py
"""Synthesize the vectoring CORDIC and enforce its arithmetic structure."""
from pathlib import Path
import re
import subprocess
APP = Path(__file__).resolve().parents[2]
WORK = APP / "out" / "cordic-vectoring-structure-test"
ENTITY = "livt_math_trigonometry_cordicatan2magnitudeq15primitive"
def main() -> None:
WORK.mkdir(parents=True, exist_ok=True)
sources = [
APP / "out/debug/lib/Livt.Lang.Package.vhd",
APP / "out/debug/lib/Livt.Lang.IContext.Package.vhd",
APP / "src/trigonometry/CordicAtan2MagnitudeQ15Primitive.vhd",
]
subprocess.run(["ghdl", "-a", "--std=08", *map(str, sources)], cwd=WORK, check=True)
synthesized = subprocess.run(
["ghdl", "--synth", "--std=08", "--out=verilog", ENTITY],
cwd=WORK,
check=True,
text=True,
capture_output=True,
).stdout
logic = re.sub(r"/\*.*?\*/", "", synthesized, flags=re.DOTALL)
logic = re.sub(r"//.*", "", logic)
variable_shifts = len(re.findall(r">>>\s+[A-Za-z_]", logic))
multipliers = len(re.findall(r"\s\*\s", logic))
dividers = len(re.findall(r"\s/\s", logic))
assert variable_shifts == 2, variable_shifts
assert multipliers == 0, multipliers
assert dividers == 0, dividers
print(
"vectoring structure: two shared variable shifters, "
"no multiplier, no divider"
)
if __name__ == "__main__":
main()