Add .fifo directive
This commit is contained in:
parent
a8fa218e45
commit
3da0f6cea2
2 changed files with 31 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ MOV_DESTINATIONS = ["pins", "x", "y", None, "exec", "pc", "isr", "osr"]
|
|||
MOV_SOURCES = ["pins", "x", "y", "null", None, "status", "isr", "osr"]
|
||||
MOV_OPS = [None, "~", "::", None]
|
||||
SET_DESTINATIONS = ["pins", "x", "y", None, "pindirs", None, None, None]
|
||||
FIFO_TYPES = {"txrx": 0, "tx": 0, "rx": 0, "txput": 1, "txget": 1, "putget": 1}
|
||||
|
||||
|
||||
class Program: # pylint: disable=too-few-public-methods
|
||||
|
|
@ -59,6 +60,13 @@ class Program: # pylint: disable=too-few-public-methods
|
|||
wrap_target = None
|
||||
offset = -1
|
||||
pio_version = 0
|
||||
fifo_type = None
|
||||
|
||||
def require_version(required_version, instruction):
|
||||
if pio_version < required_version:
|
||||
raise RuntimeError(
|
||||
f"{instruction} requires .pio_version {required_version}"
|
||||
)
|
||||
|
||||
for i, line in enumerate(text_program.split("\n")):
|
||||
line = line.strip()
|
||||
|
|
@ -72,6 +80,8 @@ class Program: # pylint: disable=too-few-public-methods
|
|||
program_name = line.split()[1]
|
||||
elif line.startswith(".pio_version"):
|
||||
pio_version = int(line.split()[1], 0)
|
||||
if not 0 <= pio_version <= 1:
|
||||
raise RuntimeError(f"Invalid .pio_version {pio_version}")
|
||||
elif line.startswith(".origin"):
|
||||
offset = int(line.split()[1], 0)
|
||||
elif line.startswith(".wrap_target"):
|
||||
|
|
@ -83,6 +93,12 @@ class Program: # pylint: disable=too-few-public-methods
|
|||
elif line.startswith(".side_set"):
|
||||
sideset_count = int(line.split()[1], 0)
|
||||
sideset_enable = "opt" in line
|
||||
elif line.startswith(".fifo"):
|
||||
fifo_type = line.split()[1]
|
||||
required_version = FIFO_TYPES.get(fifo_type)
|
||||
if required_version is None:
|
||||
raise RuntimeError(f"Invalid fifo type {fifo_type}")
|
||||
require_version(required_version, line)
|
||||
elif line.endswith(":"):
|
||||
label = line[:-1]
|
||||
if label in labels:
|
||||
|
|
@ -262,6 +278,9 @@ class Program: # pylint: disable=too-few-public-methods
|
|||
if wrap_target is not None:
|
||||
self.pio_kwargs["wrap_target"] = wrap_target
|
||||
|
||||
if FIFO_TYPES.get(fifo_type):
|
||||
self.pio_kwargs["fifo_type"] = fifo_type
|
||||
|
||||
self.assembled = array.array("H", assembled)
|
||||
|
||||
self.debuginfo = (linemap, text_program) if build_debuginfo else None
|
||||
|
|
|
|||
|
|
@ -13,3 +13,15 @@ def test_version() -> None:
|
|||
assert_pio_kwargs(".pio_version 0", sideset_enable=0)
|
||||
assert_pio_kwargs(".pio_version 1", pio_version=1, sideset_enable=0)
|
||||
assert_assembly_fails(".pio_version muffin", errtype=ValueError)
|
||||
assert_assembly_fails(".pio_version -1")
|
||||
|
||||
|
||||
def test_fifo() -> None:
|
||||
assert_pio_kwargs(".fifo txrx", sideset_enable=0)
|
||||
assert_assembly_fails(".fifo txput")
|
||||
assert_pio_kwargs(
|
||||
".pio_version 1\n.fifo txput",
|
||||
pio_version=1,
|
||||
sideset_enable=0,
|
||||
fifo_type="txput",
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue