I only got a few minutes to look at your patches today. They all seem to have the same simplebus changes in them? Am I suppose to be using just one of them, or? Maybe pushing to GitHub would make it easier to see what is going on.
Regarding the bus, pretty much everything in LiteX is memory mapped IO. The SoC has two busses inside it, a wishbone and CSR.
* The wishbone bus is 32bits wide that both CPU's instruction and data interfaces are connected to (Von Neumann arch).
- The wishbone bus looks like memory from the CPU's point of view, things on it are accessed via load/store operations (through the MMU).
- The CPU is not the only master on the wishbone bus, other things like DMA engines can also access this bus but *don't* go through the MMU and are totally transparent to the CPU (except sometimes making load/store operations appear to stall for a while).
- The bus can only be accessed on 32bit boundaries (is that a word?), I'm unclear if the CPU "fixes up" unaligned accesses?
* The CSR bus is bridge into the wishbone bus with a 1:1 mapping.
- All the control registers for peripherals in the LiteX universe are attached to the CSR bus.
- Every CSR "word" takes up one aligned 32bit address location in the wishbone space. However, the CSR word size is normally only 8bits, so you end up with 8bits in CSR space taking up 32bits in wishbone space.
- CSR registers can be wider than a single word but are "rounded up" to the next full word size.
For example;
* A 1 bit CSR register would take up one word in CSR space (8bits) and one word in wishbone space (32bits).
* A 9 bit CSR register would take up two words in CSR space (16bits) and one word in wishbone space (64bits).
- CSRs can be an arbitrary number of bits in size which are mapped to words. A 9bit CSR register would take up two 32bit words in the wishbone space. This is why you get weird things
like this.
- Generally CSR registers are write or read. The FIFO in the UART is bit of a legacy thing and these days would be two separate CSR registers.
- IRQs are handled via a thing called "Event Manger" which provides a couple of CSR registers for determining their current state, if they have fired since last been cleared and ability to clear the fired state.
* Sometimes we might have a non-LiteX peripheral on the wishbone bus. No guarantees about how that would work but it would still be accessed from the CPU via load/stores.
If we are required to have a bus, then simplebus makes a lot of sense. It is unclear to me if there is an advantage to Linux knowing about our internal CSR bus? I guess it could be useful to let us configure the CSR word size?
Tim 'mithro' Ansell