31 attributes[
"sym_name"] = StringAttr.get(name)
32 attributes[
"initialState"] = StringAttr.get(initial_state)
36 for (i, (_, port_type))
in enumerate(input_ports):
37 input_types.append(port_type)
39 for (i, (_, port_type))
in enumerate(output_ports):
40 output_types.append(port_type)
42 attributes[
"function_type"] = TypeAttr.get(
43 FunctionType.get(inputs=input_types, results=output_types))
47 self.build_generic(attributes=attributes,
61 def instantiate(self, name: str, loc=
None, ip=
None, **kwargs):
62 """ FSM Instantiation function"""
63 in_names = support.attribute_to_var(self.attributes[
'in_names'])
64 inputs = [kwargs[port].value
for port
in in_names]
71 clock = support.BackedgeBuilder().create(
72 IntegerType.get_signed(1),
73 StringAttr(self.attributes[
'clock_name']).value, self)
74 reset = support.BackedgeBuilder().create(
75 IntegerType.get_signed(1),
76 StringAttr(self.attributes[
'reset_name']).value, self)
78 op = fsm.HWInstanceOp(outputs=self.
type.results,
80 sym_name=StringAttr.get(name),
81 machine=FlatSymbolRefAttr.get(self.sym_name.value),
83 reset=reset.result
if reset
else None,
88 def set_OpOperand(name, backedge):
90 for i, operand
in enumerate(op.operands):
91 if operand == backedge.result:
94 assert index
is not None
95 op_operand = support.OpOperand(op, index, op.operands[index], op)
96 setattr(op, f
'_{name}_backedge', op_operand)
97 op.backedges[i] = backedge
99 set_OpOperand(
'clock', clock)
101 set_OpOperand(
'reset', reset)
106@_ods_cext.register_operation(_Dialect, replace=True)