Skip to content

How should the bus configuration in the vexii litex integration be handled? #2401

@cklarhorst

Description

@cklarhorst

Hi @Dolu1990

currently, in litex the pbus addr_width are effectively hard-coded to 32 bits.
This breaks for configurations like: --vexii-args "--physical-width=38 --xlen=64".
All in all, many more bus options are currenlty affected:

  • dma addr width is forced to 32bit (which results in a width converter placed by litex for other main bus configurations)
  • all id sizes are hardcoded
  • pbus data and addr width
  • mbus addr width

I’d like to make a PR to fix this, but I’m not sure what approach you would prefer.

Options I see:

  1. Parse the generated verilog and extract the final interface width (e.g. PBUS address width / data width).
  2. Extend the existing Python config flow (PythonArgsGen) to export these additional values.
  3. Recompute/guess them from the CLI args (e.g. from the Vexii args + LiteX options).

Is there a direction you would prefer?
My personal preference would be a single source of truth.
I think Options 2 and 3 tend to duplicate logic and can drift over time.
But option 1 also feels not ideal.

Question about the current 2-step integration (PythonArgsGen)
May I ask what the original design goal was behind generating an additional python file?
Downsides I see:

  • It limits refactoring of the python vexii core file, because it constrains the naming/placement of things that the generated Python file overrides.
  • It wasn't immediately clear to me which parameters are overridden during the process (I initially tried to set with_rvcbom = True in core.py without realizing most of those values would not survive^^)
  • In the long term, PythonArgsGen may also end up duplicating scala-side logic. For example, for pBusDataWidth it would need to mimic the design logic (32 if axiLiteForce32 else xlen)

So my related idea/question is why not create the resolved config during cpu generation?
For example as an extra meta module in verilog containing only constants: (although I would hate to parse that^^)

module vexii_soc_meta;
  localparam MBUS_WIDTH  = 64;
  localparam PBUS_AW     = 38;
  localparam PBUS_DW     = 64;
  localparam L2_WAYS     = 8;
endmodule

Or as a machine-readable header with (JSON or YAML) one-liner or block:
// DESIGN-META: {"mBusWidth":64,"pBusAddrWidth":38,"pBusDataWidth":64,"l2Ways":8}
Or maybe there's an even better approach.
Maybe a plugin could do that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions