Skip to content

Commit

Permalink
More ennui.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Mount committed Aug 10, 2016
1 parent 013653a commit befa805
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions revelation/sim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydgin.debug import Debug, pad, pad_hex
from pydgin.elf import elf_reader
from pydgin.jit import hint, JitDriver, set_param, set_user_param
from pydgin.jit import JitDriver, set_param, set_user_param
from pydgin.sim import Sim, init_sim

from revelation.argument_parser import cli_parser, DoNotInterpretError
Expand All @@ -25,16 +25,16 @@
EXIT_CTRL_C = 130
LOG_FILENAME = 'r_trace.out'
IVT = { # Interrupt vector table.
0 : 0x0, # Sync hardware signal.
1 : 0x4, # Floating-point,invalid instruction or alignment.
2 : 0x8, # Memory protection fault.
3 : 0xc, # Timer0 has expired.
4 : 0x10, # Timer1 has expired.
5 : 0x14, # Message interrupt.
6 : 0x18, # Local DMA channel-0 finished data transfer.
7 : 0x1c, # Local DMA channel-1 finished data transfer.
8 : 0x20, # Wired AND-signal interrupt.
9 : 0x24, # Software-generate user interrupt.
0 : 0x0, # Sync hardware signal.
1 : 0x4, # Floating-point,invalid instruction or alignment.
2 : 0x8, # Memory protection fault.
3 : 0xc, # Timer0 has expired.
4 : 0x10, # Timer1 has expired.
5 : 0x14, # Message interrupt.
6 : 0x18, # Local DMA channel-0 finished data transfer.
7 : 0x1c, # Local DMA channel-1 finished data transfer.
8 : 0x20, # Wired AND-signal interrupt.
9 : 0x24, # Software-generate user interrupt.
}


Expand Down Expand Up @@ -107,23 +107,21 @@ def __init__(self):
if self.jit_enabled:
self.jitdriver = JitDriver(
greens = ['pc', 'core', 'coreid', 'opcode'],
reds = ['tick_counter',
'max_insts',
'halted_cores', 'idle_cores', 'sim',
reds = ['tick_counter', 'halted_cores', 'idle_cores', 'sim',
'state',],
get_printable_location=get_printable_location)
self.default_trace_limit = 400000
self.max_insts = 0
self.logger = None
self.rows = 1
self.cols = 1
self.states = [] # Cores (revelation.machine.State objects).
self.max_insts = 0 # --max-insts.
self.logger = None # --debug output: self.logger.log().
self.rows = 1 # --rows, -r.
self.cols = 1 # --cols, -c.
self.states = [] # revelation.machine.State objects.
self.num_cores = 0
self.first_core = 0x808
self.first_core = 0x808 # --first-core, -f.
self.ext_base = 0x8e000000 # Base address of 'external' memory.
self.ext_size = 32 # Size of 'external' memory in MB.
self.switch_interval = 1 # TODO: currently ignored.
self.user_environment = False # TODO: currently ignored.
self.switch_interval = 1 # --switch. TODO: currently ignored.
self.user_environment = False # Superuser mode. TODO: currently ignored.
self.collect_times = False # --time, -t option.
self.start_time = .0 # --time, -t option.
self.end_time = .0 # --time, -t option.
Expand Down Expand Up @@ -183,7 +181,6 @@ def run(self):
coreid = state.coreid # We save these values so that get_location can
opcode = 0 # print a more meaningful trace in the JIT log.
tick_counter = 0 # Number of instructions executed by all cores.
max_insts = self.max_insts
halted_cores, idle_cores = [], []
old_pc = 0
self.start_time = time.time()
Expand All @@ -194,7 +191,6 @@ def run(self):
coreid=coreid,
opcode=opcode,
tick_counter=tick_counter,
max_insts=max_insts,
halted_cores=halted_cores,
idle_cores=idle_cores,
sim=self,
Expand Down Expand Up @@ -228,15 +224,14 @@ def run(self):
tick_counter += 1
state.num_insts += 1
# Halt if we have reached the maximum instruction count.
if max_insts != 0 and state.num_insts >= max_insts:
print 'Reached the max_insts (%d), exiting.' % max_insts
return EXIT_GENERAL_ERROR, tick_counter
if self.max_insts != 0 and state.num_insts >= self.max_insts:
print 'Reached the max_insts (%d), exiting.' % self.max_insts
break
# Check whether state has halted or become idle.
if not state.running:
halted_cores = hint(halted_cores, promote=True)
halted_cores.append(core)
if len(halted_cores) == self.num_cores:
return EXIT_SUCCESS, tick_counter
break
elif not state.ACTIVE:
idle_cores.append(core)
# Switch cores after every instruction. TODO: Honour switch interval.
Expand All @@ -259,7 +254,6 @@ def run(self):
coreid=coreid,
opcode=opcode,
tick_counter=tick_counter,
max_insts=max_insts,
halted_cores=halted_cores,
idle_cores=idle_cores,
sim=self,
Expand Down

0 comments on commit befa805

Please sign in to comment.