Skip to content

interconnect/stream: Switch Converter to LiteXModule - #2757

Closed
rohanmathew05 wants to merge 1 commit into
enjoy-digital:masterfrom
rohanmathew05:stream-converter-litexmodule
Closed

rohanmathew05 wants to merge 1 commit into
enjoy-digital:masterfrom
rohanmathew05:stream-converter-litexmodule

Conversation

@rohanmathew05

Copy link
Copy Markdown

Resolves the # FIXME: Switch to LiteXModule. on stream.Converter.

Problem with a one-word switch
Changing only Module -> LiteXModule makes Converter inherit AutoCSR/AutoDoc.
Converter.cls stores the converter class itself (e.g. _DownConverter), not an
instance. When a parent module collects its CSRs (e.g. VideoFrameBuffer, which holds
self.conv = stream.Converter(...)), the gatherer finds get_csrs on that class and
calls it without an instance:

TypeError: gatherer() missing 1 required positional argument: 'self'

So any SoC with a video framebuffer would fail to build.

Fix
Exclude cls from collection with autocsr_exclude = {"cls"} and
autodoc_exclude = {"cls"} (AutoCSR and AutoDoc each have their own exclude set).

Tests

  • New test_converter_in_autocsr_parent (a parent module with a CSR and a Converter):

    • master: passes
    • Module -> LiteXModule only: fails with the TypeError above
    • this PR: passes
  • test_stream, test_stream_pipeline, test_byte_enable, test_video,
    test_video_terminal: OK.

  • Elaborated with --no-compile and compared the generated Verilog with master:

    • litex_sim (VexRiscv, SDRAM, Ethernet, video framebuffer, SD card)
    • KC705 (Ethernet, PCIe)
    • KCU105 (Ethernet, PCIe, SD card)

    Logic identical; only the hierarchy-tree comment order differs, which also
    varies between two runs of master.

  • Elaboration only, no hardware.

Written with help from Claude Code (AI agent), reviewed and supervised by me.

@enjoy-digital

Copy link
Copy Markdown
Owner

Thanks @rohanmathew05, this looks good. I'll just wait a bit before merging to see if we should make the error more explicit and avoid this silent potential issue in the future.

@enjoy-digital

Copy link
Copy Markdown
Owner

Thanks @rohanmathew05 for the analysis and the fix. Closing this one in favor of #2763, which fixes the root cause in the gatherers instead of working around it here: AutoCSR/AutoDoc/CSRBankArray now skip class references (so the autocsr_exclude/autodoc_exclude lines are no longer needed), and CSRs held by a plain Migen Module without AutoCSR now raise an explicit error instead of being silently dropped. #2763 also includes the Converter switch to LiteXModule and your test scenario (credited in the PR). Thanks again!

@rohanmathew05

Copy link
Copy Markdown
Author

Yes, I agree. Fixing it in the gatherers makes more sense. I'll keep that in mind for the future. Thanks!

s070388s pushed a commit to s070388s/litex that referenced this pull request Nov 7, 2026
Resolves the FIXME: now that the gatherers skip class references, the self.cls attribute no longer
needs an autocsr/autodoc exclude. Add a test gathering CSRs/Docs of a parent holding a Converter
(scenario from enjoy-digital#2757).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants