esynr3z / corsair

Control and Status Register map generator for HDL projects
https://corsair.readthedocs.io
MIT License
99 stars 35 forks source link

Verilog waccess not aligned with output data #59

Open sinill57 opened 8 months ago

sinill57 commented 8 months ago

Problem:

When generating an AXI-lite interface, the internal output interface for a bitfield with hardware: oa option, the signal csr_*_out is one clock cycle behind csr_*_waccess.

This prevents from using waccess as a data_valid input for downstream modules.

Screenshot 2024-03-19 at 14 42 59

Solution:

In the Verilog template corsair/templates/regmap_verilog.j2 we can change the combinatorial assignment assign {{ port_bf_waccess(reg, bf) }} = wready && {{ sig_csr_wen(reg) }}; to a registered one.

Is this behaviour a bug or done on purpose? If latter, what are the expected uses of this signal?

esynr3z commented 1 month ago

Well, as far as I remember this was done intentionally. Idea was to notify hardware as early as possible about ongoing read/write on the selected register. Then hardware can FF it if required or not. I can't remember, but for some design this non-registered hint was useful.

Anyway, registered version can be introduced, it is quite easy to implement as you found already.