Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 744e33f42df5
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a5c71cdd3675
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on May 13, 2019

  1. back.rtlil: assign undriven signals to their reset value.

    Fixes #35.
    whitequark committed May 13, 2019
    Copy the full SHA
    a5c71cd View commit details
Showing with 21 additions and 0 deletions.
  1. +21 −0 nmigen/back/rtlil.py
21 changes: 21 additions & 0 deletions nmigen/back/rtlil.py
Original file line number Diff line number Diff line change
@@ -844,6 +844,27 @@ def convert_fragment(builder, fragment, hierarchy):
wire_curr, wire_next = compiler_state.resolve(signal)
sync.update(wire_curr, wire_next)

# Any signals that are used but neither driven nor connected to an input port always
# assume their reset values. We need to assign the reset value explicitly, since only
# driven sync signals are handled by the logic above.
#
# Because this assignment is done at a late stage, a single Signal object can get assigned
# many times, once in each module it is used. This is a deliberate decision; the possible
# alternatives are to add ports for undriven signals (which requires choosing one module
# to drive it to reset value arbitrarily) or to replace them with their reset value (which
# removes valuable source location information).
for wire in compiler_state.wires:
if wire in compiler_state.driven:
continue
if wire in compiler_state.ports:
port_id, port_kind = compiler_state.ports[wire]
if port_kind == "input":
continue
wire_curr, _ = compiler_state.wires[wire]
module.connect(wire_curr, rhs_compiler(ast.Const(wire.reset, wire.nbits)))

print(compiler_state.wires, compiler_state.ports, compiler_state.driven)

# Finally, collect the names we've given to our ports in RTLIL, and correlate these with
# the signals represented by these ports. If we are a submodule, this will be necessary
# to create a cell for us in the parent module.