Jelmer Lap
10/16/2024, 9:55 AMJelmer Lap
10/16/2024, 9:58 AMJelmer Lap
10/16/2024, 10:06 AMRoel Jordans
10/18/2024, 7:51 AMAnton Maurovic (efabless support)
10/18/2024, 5:03 PMuint32_t data = USER_readWord(0);
...with this:
uint32_t data = 123;
And then your test correctly produced this output:
[TEST] read 123
...do I understand that correctly?Anton Maurovic (efabless support)
10/18/2024, 5:10 PMAnton Maurovic (efabless support)
10/18/2024, 5:12 PMwbs_dat_o
as it completes the transaction. I'm unsure if that's right or not. Are you maybe "draining" your FIFO on the wrong clock cycle, and 0x0000DEAD
should carry over for 1 more clock? I actually don't know in a Wishbone read whether that's required or not.Anton Maurovic (efabless support)
10/18/2024, 5:17 PMwbs_dat_o
on the first clock after the ACK pulse. If that's true, it is sampling 0, not 0xDEAD, and therefore you'll need to find out why your FIFO is asserting 0... my guess is you need to make the output 1 more register-delay deep.Anton Maurovic (efabless support)
10/18/2024, 5:32 PMwbs_dat_o
value presented by your slave is being latched by Caravel in this region (which is when the value is 0, instead of 0xDEAD):Anton Maurovic (efabless support)
10/18/2024, 5:33 PMJelmer Lap
10/21/2024, 9:54 AMJelmer Lap
10/21/2024, 9:54 AMJelmer Lap
10/21/2024, 9:55 AMJelmer Lap
10/21/2024, 10:24 AMAnton Maurovic (efabless support)
10/22/2024, 8:52 PMJelmer Lap
10/23/2024, 10:18 AMAnton Maurovic (efabless support)
10/23/2024, 1:00 PMJelmer Lap
10/23/2024, 1:01 PMmake cocotb-verify-test1-rtl
and make cocotb-verify-test1-gl
@Anton Maurovic (efabless support)Anton Maurovic (efabless support)
10/23/2024, 6:18 PMUART.get_int
because the actual error message is:
msg = await uart.get_int()
File "/usr/local/lib/python3.10/dist-packages/caravel_cocotb/interfaces/UART.py", line 49, in get_int
return int(line, 16)
ValueError: invalid literal for int() with base 16: ''
I will try to look into this more, and see if I can offer a workaround until this can be fixed (if it is in fact a caravel_cocotb bug)Anton Maurovic (efabless support)
10/23/2024, 8:20 PMUART_sendInt
will take an int (supporting up to 32 bits) and attempt to send it as a stream of hex characters per each nibble, starting with the lowest nibble first (which means it transmits it in reverse order), and ending with a newline ('\n'
, i.e. ASCII 0x0A)
Thus, if you call UART_sendInt(0x1234ABCD)
then the literal string it sends over UART will be: "DCBA4321\n"
-- The caravel_cocotb function UART.get_int reverses this and converts it back to an integer value.
The problem you're hitting is that the UART_sendInt
function attempts to drop leading zeroes, but if the value itself is 0, then it will send no digits... it'll just send a newline. In this case, UART.get_int attempts to interpret an empty string as though it is a hex integer.
So, aside from that issue, we need to work out why your USER_readWord()
is returning a 0.Anton Maurovic (efabless support)
10/23/2024, 9:09 PM#include <firmware_apis.h> // include required APIs
void main(){
ManagmentGpio_outputEnable();
ManagmentGpio_write(0);
enableHkSpi(0); // disable housekeeping spi
// configure all gpios as user out then chenge gpios from 32 to 37 before loading this configurations
GPIOs_configureAll(GPIO_MODE_MGMT_STD_OUTPUT);
GPIOs_loadConfigs(); // load the configuration
// Enable UART
UART_enableTX(1);
User_enableIF();
ManagmentGpio_write(1); // configuration finished
// writing to any address inside user project address space would reload the counter value
// In theory: Write to fifo, then read result
reg_mprj_datal = 0x5555AAAA;
USER_writeWord(0xABCDEF00,0);
uint32_t data = *((volatile uint32_t*)(0x30000000));
//reg_mprj_datal = data;
UART_sendInt(data);
return;
}
...but if I uncomment the //reg_mprj_datal = data;
line, it works as expected (i.e. correct data is presented at GPIOs, and correct data is sent via UART).Anton Maurovic (efabless support)
10/23/2024, 9:10 PMvolatile
everywhere should not allow this sort of optimization problem to happen. I haven't tried looking into the assembly to see if that's what's really happening, though.Anton Maurovic (efabless support)
10/23/2024, 9:37 PMdata
variable as volatile
also, i.e.
volatile uint32_t data = USER_readWord(0);
Jelmer Lap
10/24/2024, 7:25 AMAnton Maurovic (efabless support)
10/24/2024, 2:17 PMJelmer Lap
10/28/2024, 9:20 AMAnton Maurovic (efabless support)
11/01/2024, 5:18 PMJelmer Lap
11/02/2024, 5:55 PMJelmer Lap
11/04/2024, 12:44 PMJelmer Lap
11/05/2024, 12:13 PMvoid IRQ_enableUser0(bool is_enable)
allows us to enable it in cocotb, but how do we write firmware that reacts to the user interrupt?Anton Maurovic (efabless support)
11/07/2024, 5:42 AMio_oeb
high (to disable output buffers), leave io_out
disconnected, and configure the GPIO with mode GPIO_MODE_USER_STD_ANALOG -- ideally in verilog/rtl/user_defines.v
and without ever changing it in firmware (since you probably wouldn't want to risk contention where a digital output gets enabled and shorts) -- though if you're careful there are ways you could design a solution that handles and even takes advantage of this.
2. I actually don't yet know the correct/preferred way to set up an ISR for IRQs, but I can offer the following advice: RISC-V has an "mtvec" register which is a convention for interrupt/exception addresses (but behaves more like a singular or vectored 'jump' table rather than an address table). Also, if you want a FAST ISR, you would want to make sure both the ISR, and address that mtvec points to, are located entirely in local RAM (i.e. within the limited 1.5kBytes that Caravel has on-chip, or otherwise extend RAM via the Wishbone bus) -- otherwise, when the interrupt triggers, it could take 1,000-2,000 cycles to be serviced because of the flash firmware SPI cache miss. As for an ISR from cocotb... do you mean Python code that runs in response to an IRQ? Or do you just mean supporting a C code ISR via the same cocotb infrastructure (which WILL work).Mitch Bailey
11/07/2024, 6:19 AMio_oeb
and io_out
. With GPIO_MODE_USER_STD_ANALOG
it does not matter whether they are high or low.Anton Maurovic (efabless support)
11/07/2024, 7:03 AMAnton Maurovic (efabless support)
11/07/2024, 6:42 PMmtvec
register.