Is there a way/example to write to user area wishb...
# shuttle
h
Is there a way/example to write to user area wishbone slave through C? I am just seeing these examples: https://github.com/efabless/caravel-lite/tree/c2943440e278814787f761585b99b9ea3c1f4121/verilog/dv/wb_utests Which instantiate certain modules to test wishbone.
The link here: https://caravel-harness.readthedocs.io/en/latest/memory-mapped-io-summary.html tells the memory map but I am not sure how to actually use it.
a
Copy code
*((volatile uint32_t*)(0x8000000)) = 0x32;
something like that will write 0x32 to the 32-bit register at 0x8000000
t
@User: Per that page (which needs updating and needs a few typos corrected), you can see that the range 0x30000000 to 0x3fffffff is reserved for the user project area. The management SoC will apply a strobe signal (cyc and stb) to the user project area whenever the C program writes in that range. You can create a wishbone module in the user area that responds to addresses in that range. See in the
caravel_user_project
repository the testbench
verilog/dv/wb_port/wb_port.c
. The example project only defines one register which it references by the C definition found in caravel
verilog/dv/caravel/defs.h
defined as "`reg_mprj_slave`" (and is equal to address 0x30000000). The slave module verilog is defined in
caravel_user_project
at
verilog/rtl/user_proj_example.v
. It's rather overly-simple and doesn't even decode the address, so the single register is effectively mapped to every address in the range 0x30000000 to 0x3fffffff.
You can make your own "convenience definitions" for your own C program, so if you define a wishbone module that maps a register to 0x30000004, then you can do
#define reg_mprj_myreg (*(volatile uint32_t *)0x30000004)
and then read/write it simply using
x = reg_mprj_myreg;
or
reg_mprj_myreg = 0x01;
, for example.
๐Ÿ‘ 1
I created an example chip that has such a wishbone slave that you can look at as an example. You can find it at https://github.com/RTimothyEdwards/chaos_automaton.
๐Ÿ‘ 1
h
thanks
m
๐Ÿ‘ 1