How to get unused global variables into the IMEM as ROM #993
-
I have a header file with test values that I would like to include in my IMEM as ROM. Currently, not all of them are used yet, so the compiler/linker optimizes them away. This is a slight problem because I do want to know how much the ROM image would increase in size if I would include the whole header file. Therefore, i added my own section to the linker script and set it to be kept: Now the .text segment does show an increase in size but the final exe or vhdl image still has the size of the globals not being included? I thought it maybe had something to do with the NEORV32 image_gen.c program, but that seems to contain only packaging software, no actual compilation software... What am I missing?
Meanwhile the main.elf does have the correct size of 2.8 MB |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
This actually made me think about the relationship between IMEM/DMEM and BRAM in general leading to the following more general question: (background) This was related to this discussion on a 64-bit DMA access: #981 (comment)
I was going to copy the data to the external DMEM maybe, but I just realised that might not be possible since it could be >2MB of data and my genesys2 board only has 16 Mbits of BRAM available, so that is only 2 MB that can fit in BRAMS. (background end) Question: If the IMEM/DMEM have an address space of gigabytes, then how can they ever be mapped to BRAMs on an FPGA. There is no FPGA with that much space no? |
Beta Was this translation helpful? Give feedback.
-
What do your test values look like? Just simple constants? const test_a uint32_t = 123;
Good idea! But I think the linker is smart enough to trim all non-referenced symbols (and sections). Therefore, I also think that it would be pointless to use attributes here (e.g. However, you can explicitly tell the linker which symbols you want to keep. For example, if you have this constant (placed in the const char some_array[] = "this is a test!"; // 15 chars + zero-termination = 16 bytes If you compile this and check the
Now if you tell the linker to keep this specific symbol (->
You cannot map the entire address space to BRAMs - but you could map it to external memory (for example by using a DDR memory controller). |
Beta Was this translation helpful? Give feedback.
What do your test values look like? Just simple constants?
Good idea! But I think the linker is smart enough to trim all non-referenced symbols (and sections). Therefore, I also think that it would be pointless to use attributes here (e.g.
__attribute__((unused))
).Howe…