aboutsummaryrefslogtreecommitdiffstats
path: root/machxo2/examples/write_fasm.py
diff options
context:
space:
mode:
authorWilliam D. Jones <thor0505@comcast.net>2020-06-27 17:40:35 -0400
committergatecat <gatecat@ds0.me>2021-02-12 10:36:59 +0000
commit78880e1fdf1721a460c7e4e813f91f427106d3b7 (patch)
tree141a481404383e31cb52dc7d09c630552ad00904 /machxo2/examples/write_fasm.py
parent539651609cf82ab8e05cac636aee997e831b4d29 (diff)
downloadnextpnr-78880e1fdf1721a460c7e4e813f91f427106d3b7.tar.gz
nextpnr-78880e1fdf1721a460c7e4e813f91f427106d3b7.tar.bz2
nextpnr-78880e1fdf1721a460c7e4e813f91f427106d3b7.zip
machxo2: Remove pybindings unneeded files from examples and update README.md and scripts accordingly. Delete resources directory.
Diffstat (limited to 'machxo2/examples/write_fasm.py')
-rw-r--r--machxo2/examples/write_fasm.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/machxo2/examples/write_fasm.py b/machxo2/examples/write_fasm.py
deleted file mode 100644
index ede8f16b..00000000
--- a/machxo2/examples/write_fasm.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from collections import namedtuple
-
-"""
- write: set to True to enable writing this parameter to FASM
-
- numeric: set to True to write this parameter as a bit array (width>1) or
- single bit (width==1) named after the parameter. Otherwise this
- parameter will be written as `name.value`
-
- width: width of numeric parameter (ignored for non-numeric parameters)
-
- alias: an alternative name for this parameter (parameter name used if alias
- is None)
-"""
-ParameterConfig = namedtuple('ParameterConfig', 'write numeric width alias')
-
-# FIXME use defaults= once Python 3.7 is standard
-ParameterConfig.__new__.__defaults__ = (False, True, 1, None)
-
-
-"""
-Write a design as FASM
-
- ctx: nextpnr context
- paramCfg: map from (celltype, parametername) -> ParameterConfig describing how to write parameters
- f: output file
-"""
-def write_fasm(ctx, paramCfg, f):
- for nname, net in sorted(ctx.nets, key=lambda x: str(x[1].name)):
- print("# Net %s" % nname, file=f)
- for wire, pip in sorted(net.wires, key=lambda x: str(x[1])):
- if pip.pip != "":
- print("%s" % pip.pip, file=f)
- print("", file=f)
- for cname, cell in sorted(ctx.cells, key=lambda x: str(x[1].name)):
- print("# Cell %s at %s" % (cname, cell.bel), file=f)
- for param, val in sorted(cell.params, key=lambda x: str(x)):
- cfg = paramCfg[(cell.type, param)]
- if not cfg.write:
- continue
- fasm_name = cfg.alias if cfg.alias is not None else param
- if cfg.numeric:
- if cfg.width == 1:
- if int(val) != 0:
- print("%s.%s" % (cell.bel, fasm_name), file=f)
- else:
- # Parameters with width >32 are direct binary, otherwise denary
- print("%s.%s[%d:0] = %d'b%s" % (cell.bel, fasm_name, cfg.width-1, cfg.width, val), file=f)
- else:
- print("%s.%s.%s" % (cell.bel, fasm_name, val), file=f)
- print("", file=f) \ No newline at end of file