A common question in the #nMigen Libera.Chat channel asks how one can include a non-nMigen component—e.g. a library cell or a component from a Verilog design—so it seemed worth writing up a quick note we can link to answer that.
Invoking a Component
The key is to create an nmigen.Instance component, as in the following example:
m.submodules.my_component = Instance("CustomFlipFlop",
# Attributes
a_HasAsyncReset = False,
# Parameters
p_NumberInputs = "1",
p_NumberOutputs = "1",
# Inputs
i_D = my_input_signal,
# Ouptuts
o_Q = my_output_signal,
# Bidirectional / inouts
io_DZ = my_tristate_pin
)
The first parameter to the Instance constructor is the name of the component to be instantiated, which usually matches e.g. your library cell instance, or your Verilog module name. The remaining (keyword) arguments are the inputs and outputs to the Instance. As these inputs/outputs to this function currently lack type information, we’ll need to prefix each name with a short prefix, depending on its type:
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.