Trying to iterate through entire memory space, resetting the address variable too soon

0

I have a C program that needs to scan through memory from 0xC0000000 to 0xC0001FFF. Before the scanner loop begins there is a subroutine that fills the memory with 0xFFFFFFFF and this successfully goes through the entire memory space. When the main loop begins, however, the addr variable is resetting at 0xC00003e0 rather than 0xC0001FFF. Any ideas why this might be happening? Let me know if I need to include anything else. This program is running on a Basys3 FPGA using a Microblaze soft processor.

Currently the primary subroutines live in a while loop, while(addr <= MEM_TOP_ADDR) [checks if addr is less than or equal to the end of the address space]. My previous method was if(addr >= MEM_TOP_ADDR), both of these result in the same behavior.

while(1){ //The main loop

        while(addr <= MEM_TOP_ADDR){
        LFSR_runtime();
        MEM_SCANNER();
        MEM_SCANNER_1();
        addr += 4;
        addr_1 += 4;
        if(addr_1 >= MEM_1_TOP_ADDR){
            addr_1 = MEM_1_BASE_ADDR;
        }
        }
        addr = MEM_BASE_ADDR;

    }
addr = MEM_BASE_ADDR;

In the programs current space, it can count up to 0xC00003e0 and then the while loop exits. It should count up to 0xC0001FFF before exiting the while loop

c
memory
hex
microblaze
asked on Stack Overflow Apr 25, 2019 by NeedlessBird • edited Apr 25, 2019 by 1201ProgramAlarm

1 Answer

0

This was solved by moving the address variables into the MEM_SCANNER() function as opposed to having them as global variables.

answered on Stack Overflow Apr 25, 2019 by NeedlessBird

User contributions licensed under CC BY-SA 3.0