I am using a version of the TINIm400 and the TINIs400 reference design with an FPGA connected to CE3 and CE4.
I wish to access the registers I have placed in the FPGA but am wondering how to do it. I assume by default the FPGA is effectively at 0x60 0000 (for CE3) but how do I place a variable at this address so I can access with a C instruction.
Apologies if it's very obvious.
Didn't find your answer? Ask the community — no account required.
C
Casey
Fred said
Well, you could just set up a suitable structure pointer to that location along the lines of this:
typedef struct { short int register_for_this; short int register_for_that; unsigned char register_for_8_bit_stuff; } FPGA_REGS;
on the command line: sdcc -c -mds400 --model-flat24 --stack-10bit --no-xinit-opt main.c
I get this error: main.c:13 error: illegal cast of LITERAL value to 'generic' pointer from type 'literal-long-int' to type 'struct __00010000 generic* '
which essentially doesn't like: regs = (FPGA_REGS *)(0x600000);
Although I have written a fair amount of code I am not that knowledgable of how to assign a varaible to a location and compilers sometimes treat things differently. This request is perhaps unusual for a 8051 processor which has a 24 bit linear addressing mode.
C
Casey
Fred said
The 8051 family addressing can be a pain ... you probably need to qualify the type of pointer being created. Your FPGA is probably in xdata memory space.
I've never used the SDCC compiler, but you probably need to do something like this to explain that you're creating a pointer to xdata (far) memory:
If you don't want your pointer as a stack variable for the function, you could move it outside the function and put the pointer itself in xdata space:
xdata FPGA_REGS * xdata regs;
I did a quick lookup of the SDCC storage classes at:
formatting link
If you haven't already, you might take a look at this app note as well:
formatting link
Casey
A
Anthony Fremont
Try this: xdata at 0x60000 volatile FPGA_REGS * regs;
A
Anthony Fremont
After looking at it, that might not work. You may have to specify the size of the regs item. Like this: xdata at 0x600000 volatile UC regs[put size here];
F
Fred
Many thanks for the help. This is what I used in the end
xdata at 0x600000 unsigned char sdram_reset_reg;
which work such that I can read and write at this "location" in the FPGA using CS3.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.