class ALUTestCase(FHDLTestCase):
- def run_tst(self, program, initial_regs):
+ def run_tst(self, program, initial_regs, initial_sprs):
m = Module()
comb = m.d.comb
instruction = Signal(32)
comb += alu.p.data_i.ctx.op.eq_from_execute1(pdecode2.e)
comb += alu.p.valid_i.eq(1)
comb += alu.n.ready_i.eq(1)
- simulator = ISA(pdecode2, initial_regs)
+ simulator = ISA(pdecode2, initial_regs, initial_sprs)
comb += pdecode2.dec.raw_opcode_in.eq(instruction)
sim = Simulator(m)
gen = program.generate_instructions()
sim.run()
return simulator
- def run_tst_program(self, prog, initial_regs=[0] * 32):
- simulator = self.run_tst(prog, initial_regs)
+ def run_tst_program(self, prog, initial_regs=[0] * 32, initial_sprs={}):
+ simulator = self.run_tst(prog, initial_regs, initial_sprs)
simulator.gpr.dump()
return simulator
class SPR(dict):
- def __init__(self, dec2):
+ def __init__(self, dec2, initial_sprs={}):
self.sd = dec2
dict.__init__(self)
+ self.update(initial_sprs)
def __getitem__(self, key):
# if key in special_sprs get the special spr, otherwise return key
class ISACaller:
# decoder2 - an instance of power_decoder2
# regfile - a list of initial values for the registers
- def __init__(self, decoder2, regfile):
+ def __init__(self, decoder2, regfile, initial_sprs={}):
self.gpr = GPR(decoder2, regfile)
self.mem = Mem()
self.pc = PC()
- self.spr = SPR(decoder2)
+ self.spr = SPR(decoder2, initial_sprs)
# TODO, needed here:
# FPR (same as GPR except for FP nums)
# 4.2.2 p124 FPSCR (definitely "separate" - not in SPR)
'CR': self.cr,
'undefined': self.undefined,
'mode_is_64bit': True,
+ 'SO': XER_bits['SO']
}
- self.namespace.update(XER_bits)
# field-selectable versions of Condition Register TODO check bitranges?
self.crl = []
self.namespace[name] = SelectableInt(val, sig.width)
self.namespace['XER'] = self.spr['XER']
+ self.namespace['CA'] = self.spr['XER'][XER_bits['CA']].value
def handle_carry(self, inputs, outputs):
inv_a = yield self.dec2.invert_a
class DecoderTestCase(FHDLTestCase):
- def run_tst(self, generator, initial_regs):
+ def run_tst(self, generator, initial_regs, initial_sprs={}):
m = Module()
comb = m.d.comb
instruction = Signal(32)
pdecode = create_pdecode()
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- simulator = ISA(pdecode2, initial_regs)
+ simulator = ISA(pdecode2, initial_regs, initial_sprs)
comb += pdecode2.dec.raw_opcode_in.eq(instruction)
sim = Simulator(m)
gen = generator.generate_instructions()
classes = ', '.join(['ISACaller'] + self.pages_written)
f.write('class ISA(%s):\n' % classes)
- f.write(' def __init__(self, dec, regs):\n')
- f.write(' super().__init__(dec, regs)\n')
+ f.write(' def __init__(self, dec, regs, sprs):\n')
+ f.write(' super().__init__(dec, regs, sprs)\n')
f.write(' self.instrs = {\n')
for page in self.pages_written:
f.write(' **self.%s_instrs,\n' % page)