Skip to content

Commit

Permalink
Refactor get_printable_location.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Mount committed Jul 29, 2016
1 parent 8fd837d commit d1a6744
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exclude_lines =

# Don't complain about code that only executes when translated.
.*we_are_translated.*
def get_location
def get_printable_location
_RevelationByteMemory

# Don't complain about every single status bit.
Expand Down
28 changes: 12 additions & 16 deletions revelation/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def new_memory(logger):
return Memory(block_size=2**20, logger=logger)


def get_printable_location(pc, core, coreid, opcode):
hex_pc = pad_hex(pc)
mnemonic, _ = decode(opcode)
return 'Core ID: 0x%x PC: %s Instruction: %s' % (coreid, hex_pc, mnemonic)


class Revelation(Sim):

def __init__(self):
Expand All @@ -35,17 +41,12 @@ def __init__(self):
self.arch_name = self.arch_name_human.lower()
self.jit_enabled = True
if self.jit_enabled:
self.jitdriver = JitDriver(greens = ['pc', 'core', 'coreid', 'opcode'],
reds = ['tick_counter',
'halted_cores',
'idle_cores',
'old_pcs',
'memory',
'sim',
'state',
'start_time'],
virtualizables = ['state'],
get_printable_location=self.get_location)
self.jitdriver = JitDriver(
greens = ['pc', 'core', 'coreid', 'opcode'],
reds = ['tick_counter', 'halted_cores', 'idle_cores',
'old_pcs', 'memory', 'sim', 'state', 'start_time'],
virtualizables = ['state'],
get_printable_location=get_printable_location)
self.default_trace_limit = 400000
self.max_insts = 0
self.logger = None
Expand Down Expand Up @@ -73,11 +74,6 @@ def __init__(self):
9 : 0x24, # Software-generate user interrupt.
}

@staticmethod
def get_location(pc, core, coreid, opcode):
mnemonic, _ = decode(opcode)
return 'Core ID: %x PC: %x Instruction: %s' % (coreid, pc, mnemonic)

@elidable
def next_core(self, core):
return (core + 1) % (self.rows * self.cols)
Expand Down

0 comments on commit d1a6744

Please sign in to comment.