I have been experimenting with custom function units (CFUs) added to VexRiscv (using VexRiscv since it provides a CfuPlugin option, and it's also awesome, although eventually we hope more CPUs support the interface). The CFU connects ONLY to the CPU, not to the system bus, and it has no CSRs of its own. I've been using CPU+CFU in LiteX systems for quite a while now, but I've been hiding the CFU from LiteX --- I make a wrapper containing the CPU+CFU, and the wrapper exports just the normal CPU signals, so LiteX doesn't even know the CFU is there.
But now I think it makes sense to hook up the CFU in LiteX, so I'd like to ask your advice. I've mocked up a couple of ways of doing it. I have the code for connecting the CFU to the VexRiscv in cores/cpu/vexriscv/core.py --- it creates and hooks the signals, creates the CFU instance, and optionally adds the CFU source. But it might make more sense to have the CPU just create its interface when needed, and move the CFU instantiation and CFU<->CPU hookup out of the CPU core.py.
I've had a suggestion to create a Record for the CFU<->CPU connections.
The interface will be fairly stable. It is basically one cmd stream CPU-->CFU with a payload of an opcode and two data arguments, and a rsp stream CFU-->CPU with a payload of one data result and a ok status bit. There will likely also be a context_id field in the cmd payload, although that is still being finalized.
I have been experimenting with custom function units (CFUs) added to VexRiscv (using VexRiscv since it provides a CfuPlugin option, and it's also awesome, although eventually we hope more CPUs support the interface). The CFU connects ONLY to the CPU, not to the system bus, and it has no CSRs of its own. I've been using CPU+CFU in LiteX systems for quite a while now, but I've been hiding the CFU from LiteX --- I make a wrapper containing the CPU+CFU, and the wrapper exports just the normal CPU signals, so LiteX doesn't even know the CFU is there.
But now I think it makes sense to hook up the CFU in LiteX, so I'd like to ask your advice. I've mocked up a couple of ways of doing it. I have the code for connecting the CFU to the VexRiscv in cores/cpu/vexriscv/core.py --- it creates and hooks the signals, creates the CFU instance, and optionally adds the CFU source. But it might make more sense to have the CPU just create its interface when needed, and move the CFU instantiation and CFU<->CPU hookup out of the CPU core.py.
I've had a suggestion to create a Record for the CFU<->CPU connections.
The interface will be fairly stable. It is basically one
cmdstream CPU-->CFU with a payload of an opcode and two data arguments, and arspstream CFU-->CPU with a payload of one data result and aokstatus bit. There will likely also be a context_id field in thecmdpayload, although that is still being finalized.