Closed Tiwalun closed 4 years ago
Is this a limit of svd2rust
then? These registers do require a 32-bit write, but are only 8-bits wide.
This change is a result of https://github.com/xobs/lxsocdoc/commit/4883e9907ad9e73077b5465a7a2c8733faa454b7
Seems to be the fault of svd2rust, we should probably round the size up in lxsocdoc.
The issue seems to be here, which truncates the number instead of rounding up.
@Tiwalun Pushed the svd (&generated code) with 8 bit multiple register sizes.
Seems to work for me locally, could you verify if it works for you?
@david-sawatzke Seems to work fine now, thanks for the fix!
I'm not sure if declaring the registers as 32 bit would be better. Right now, rustc seems to emit lb
to load the register values, but if they are actually 32 bit register, it might be better to use lw
instructions, i.e. just load the whole word.
@xobs Which kind of load would be better on the vexriscv CPU?
At this point, it actually doesn't matter. From a hardware perspective, the difference between lb
and lw
are which of the SEL
lines are active, and the wishbone2csr
module doesn't even consult the SEL
line: https://github.com/enjoy-digital/litex/blob/master/litex/soc/interconnect/wishbone2csr.py
I tried updating the workshop example in im-tomu/fomu-workshop#94 to use the new version, but it didn't work with the new example.
After looking at the code, it seems that the register sizes in the new fomu.svd file lead to issues in the code generated by
svd2rust
.For example, the new register block for the RGB peripheral looks like this:
Note that the
_reserved
fields have a width of 4 bytes, which means that the offsets are wrong for theCTRL
andRAW
fields. The right size for the reserved fields would be 3 bytes, as one byte is taken up by the actual value itself. In contrast, version v0.0.1 had the following block, where all fields are 32 bit values:The problem seems to be caused by the "strange" bit sizes in the svd, e.g. the register with size 4 here:
The wrong generation of the padding fields seems to be an issue with svd2rust, but I think it might also be better to view these registers as 8 bit registers in the SVD, where only part of the register is used.