blob: 86ddfabd65e0f81a4cea98aba1c3eedf09b5fc7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
use isa;
use binary::{Binary};
use memory::{Memory};
pub struct Simulator {
binary: Binary,
num_cores: usize,
memory: Memory,
}
#[derive(Clone)]
struct Core {
pc: usize,
}
struct RegisterFile {
registers: [u32; 32],
}
impl Simulator {
pub fn new(num_cores: usize, binary: Binary) -> Simulator {
Simulator {
binary: binary,
num_cores: num_cores,
memory: Memory::new(0x20000),
}
}
pub fn run(&mut self) {
let mut cores = vec![Core { pc: 0x10000, }; self.num_cores];
// TODO: set up memory, cache, devices
// TODO: map binary into RAM
loop {
for core in cores.iter_mut() {
self.step_core(core);
}
}
}
fn step_core(&mut self, core: &mut Core) {
if let Some(inst) = self.memory.read_instruction(core.pc) {
match inst.opcode() {
isa::opcodes::Branch => {
}
isa::opcodes::IntegerImmediate => {
}
_ => {
}
}
}
else {
// trap
}
}
}
|