Skip to content

Commit 2eeba86

Browse files
author
Sarah Mount
committed
Refactor get_printable_location.
1 parent 43b3b81 commit 2eeba86

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exclude_lines =
3232

3333
# Don't complain about code that only executes when translated.
3434
.*we_are_translated.*
35-
def get_location
35+
def get_printable_location
3636
_RevelationByteMemory
3737

3838
# Don't complain about every single status bit.

revelation/sim.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ def new_memory(logger):
2525
return Memory(block_size=2**20, logger=logger)
2626

2727

28+
def get_printable_location(pc, core, coreid, opcode):
29+
hex_pc = pad_hex(pc)
30+
mnemonic, _ = decode(opcode)
31+
return 'Core ID: 0x%x PC: %s Instruction: %s' % (coreid, hex_pc, mnemonic)
32+
33+
2834
class Revelation(Sim):
2935

3036
def __init__(self):
@@ -35,17 +41,12 @@ def __init__(self):
3541
self.arch_name = self.arch_name_human.lower()
3642
self.jit_enabled = True
3743
if self.jit_enabled:
38-
self.jitdriver = JitDriver(greens = ['pc', 'core', 'coreid', 'opcode'],
39-
reds = ['tick_counter',
40-
'halted_cores',
41-
'idle_cores',
42-
'old_pcs',
43-
'memory',
44-
'sim',
45-
'state',
46-
'start_time'],
47-
virtualizables = ['state'],
48-
get_printable_location=self.get_location)
44+
self.jitdriver = JitDriver(
45+
greens = ['pc', 'core', 'coreid', 'opcode'],
46+
reds = ['tick_counter', 'halted_cores', 'idle_cores',
47+
'old_pcs', 'memory', 'sim', 'state', 'start_time'],
48+
virtualizables = ['state'],
49+
get_printable_location=get_printable_location)
4950
self.default_trace_limit = 400000
5051
self.max_insts = 0
5152
self.logger = None
@@ -73,11 +74,6 @@ def __init__(self):
7374
9 : 0x24, # Software-generate user interrupt.
7475
}
7576

76-
@staticmethod
77-
def get_location(pc, core, coreid, opcode):
78-
mnemonic, _ = decode(opcode)
79-
return 'Core ID: %x PC: %x Instruction: %s' % (coreid, pc, mnemonic)
80-
8177
@elidable
8278
def next_core(self, core):
8379
return (core + 1) % (self.rows * self.cols)

0 commit comments

Comments
 (0)