TheV360 / toy_mips_emu

A toy MIPS emulator I'm writing. No machine in particular (until I feel like it? idk)
https://thev360.github.io/toy_mips_emu/
1 stars 0 forks source link

Take RAM out of CPU (and make it smaller, too.) #1

Closed TheV360 closed 2 years ago

TheV360 commented 2 years ago

RAM doesn't need to be inside the CPU, contrary to what this comment says:

https://github.com/TheV360/toy_mips_emu/blob/62abb2239d5cfbca05e39bd52ec6a1f810094cd0/src/chip.rs#L112-L117

Plus, this current implementation is Very wasteful. It's the reason the WASM version takes half a second to initialize!! I want to allocate sections of RAM as they're filled in. Maybe that sucks? It will suck for a program that randomly pokes everywhere, but that program is asking to waste time. We'll see.

I'm thinking of taking an approach similar to how CPUs cache things, y'know? They take parts of the memory address and assign them to different buckets. (Or whatever that term is) After this, I could absolutely switch to the "large" memory format MARS uses by default.

TheV360 commented 2 years ago

A while ago (1 or 2 days/weeks ago) I think I went through this same thought process, about the "allocate sections of RAM as they're used" thing.

On one hand:

And on the other:

It'd be cool to take the RAM out of the CPU however -- imagine having two CPUs running on the same RAM! Fun to emulate.

So yeah, conclusion: don't do this, (not even the vec idea??) just maybe uh keep it the way it is, use MARS' compact memory layout for this and limit RAM to like 0x10_0000 or so.

I'll work on this in a bit.