27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
from pathlib import Path
|
|
|
|
import numpy as np
|
|
|
|
from galileo_rx.fixed_point.formats import FixedFormat
|
|
from galileo_rx.rtl_model.vector_export import export_complex_hex, export_timed_complex_hex
|
|
|
|
|
|
def test_exported_vector_is_twos_complement(tmp_path: Path) -> None:
|
|
manifest = export_complex_hex(tmp_path, "samples", np.asarray([-1 - 0.5j, 0.5 + 0.25j]), FixedFormat(8, 7))
|
|
assert (tmp_path / "samples_i.hex").read_text().splitlines() == ["80", "40"]
|
|
assert (tmp_path / "samples_q.hex").read_text().splitlines() == ["c0", "20"]
|
|
assert manifest["sample_count"] == 2
|
|
|
|
|
|
def test_exported_timestamps_and_register_metadata(tmp_path: Path) -> None:
|
|
manifest = export_timed_complex_hex(
|
|
tmp_path,
|
|
"timed",
|
|
np.asarray([1 + 2j, 3 + 4j]),
|
|
FixedFormat(8, 0),
|
|
8.0,
|
|
{"ACQ_COHERENT_SAMPLES": 2},
|
|
)
|
|
assert (tmp_path / "timed_timestamps.csv").read_text().splitlines() == ["sample_index,time_s", "0,0", "1,0.125"]
|
|
assert manifest["register_values"]["ACQ_COHERENT_SAMPLES"] == 2
|