fhdl.ir: add black-box fragments, fragment parameters, and Instance.

This commit is contained in:
whitequark 2018-12-17 22:55:30 +00:00
parent de6c12af77
commit c7f9386eab
7 changed files with 139 additions and 28 deletions

View file

@ -567,6 +567,16 @@ class _StatementCompiler(xfrm.AbstractStatementTransformer):
def convert_fragment(builder, fragment, name, top):
if fragment.black_box is not None:
port_map = OrderedDict()
for signal in fragment.ports:
port_map["\\{}".format(fragment.port_names[signal])] = signal
return "\\{}".format(fragment.black_box), port_map
else:
assert not fragment.port_names
assert not fragment.parameters
with builder.module(name or "anonymous", attrs={"top": 1} if top else {}) as module:
compiler_state = _ValueCompilerState(module)
rhs_compiler = _RHSValueCompiler(compiler_state)
@ -601,7 +611,7 @@ def convert_fragment(builder, fragment, name, top):
module.cell(sub_name, name=sub_name, ports={
port: compiler_state.resolve_curr(signal, prefix=sub_name)
for port, signal in sub_port_map.items()
})
}, params=subfragment.parameters)
with module.process() as process:
with process.case() as case: