lookuptable / hash table

Apr 15, 2013 at 1:40am
I am doing some work in which i need to simulate, potentially, a large amount of memory, I am reading in from file a memory address (0x0000000 to 0xfffffff) and storing to it a value, also (0x0000000 to 0xfffffff)
I've read so many pages (possibly not the right pages) on the net on look up tables and hash maps but for some reason I can t get my head around it. I understand the basic idea of these structures but not how to implement them.

Currently,I am just using an array of unsigned integers, 1024 in size and a the following function to generate positions in that array

1
2
3
4
5
6
7
8
9
unsigned int cpu::map_it(unsigned int x) 
{
	
    x = ((x >> 16) ^ x) * 0x45d9f3b;
    x = ((x >> 16) ^ x) * 0x45d9f3b;
    x = ((x >> 16) ^ x);
	
    return x%1024;
}


This is working ok for all but one of the test files i'm reading in from. The one that fails is running far far more instructions than the the others so I assume I am getting collisions in my array.

I'm reading in from the file ok, and Ive got the memory address and the associated memory instruction, but I'm at a loss as to how to implement the lookup table or hashmap to store them.

Any advice would be much appreciated.
Apr 15, 2013 at 2:10am
Topic archived. No new replies allowed.