if self.funit == Function.LDST:
yield from setup_test_memory(l0, sim)
- index = sim.pc.CIA.value//4
+ pc = sim.pc.CIA.value
+ index = pc//4
msr = sim.msr.value
while True:
print("instr index", index)
# ask the decoder to decode this binary data (endian'd)
yield pdecode2.dec.bigendian.eq(self.bigendian) # le / be?
- yield pdecode2.msr.eq(msr)
+ yield pdecode2.msr.eq(msr) # set MSR "state"
+ yield pdecode2.cia.eq(pc) # set PC "state"
yield instruction.eq(ins) # raw binary instr.
yield Settle()
fn_unit = yield pdecode2.e.do.fn_unit
# call simulated operation
yield from sim.execute_one()
yield Settle()
- index = sim.pc.CIA.value//4
+ pc = sim.pc.CIA.value
+ index = pc//4
msr = sim.msr.value
# get all outputs (one by one, just "because")
print ("extra inputs: so", so)
yield alu.p.data_i.xer_so.eq(so)
- def set_msr(alu, dec2, inp):
- if 'msr' in inp:
- yield alu.p.data_i.msr.eq(inp['msr'])
-
- def set_cia(alu, dec2, inp):
- if 'cia' in inp:
- yield alu.p.data_i.cia.eq(inp['cia'])
-
def set_slow_spr1(alu, dec2, inp):
if 'spr1' in inp:
yield alu.p.data_i.spr1.eq(inp['spr1'])
"""trap. sets new PC, stores MSR and old PC in SRR1 and SRR0
"""
comb = m.d.comb
- msr_i = self.i.msr
+ op = self.i.ctx.op
+ msr_i = op.msr
nia_o, srr0_o, srr1_o = self.o.nia, self.o.srr0, self.o.srr1
# trap address
may change in the future, hence the (unused) trap_addr argument
"""
comb = m.d.comb
- msr_i, msr_o = self.i.msr, self.o.msr
+ op = self.i.ctx.op
+ msr_i, msr_o = op.msr, self.o.msr
comb += msr_o.data.eq(msr_i) # copy msr, first, then modify
comb += msr_o.data[MSR.SF].eq(1)
comb += msr_o.data[MSR.EE].eq(0)
op = self.i.ctx.op
# convenience variables
- a_i, b_i, cia_i, msr_i = self.i.a, self.i.b, self.i.cia, self.i.msr
+ a_i, b_i, cia_i, msr_i = self.i.a, self.i.b, op.cia, op.msr
srr0_i, srr1_i = self.i.srr0, self.i.srr1
o, msr_o, nia_o = self.o.o, self.o.msr, self.o.nia
srr0_o, srr1_o = self.o.srr0, self.o.srr1
('INT', 'rb', '0:63'), # RB/immediate
('FAST', 'fast1', '0:63'), # SRR0
('FAST', 'fast2', '0:63'), # SRR1
- ('FAST', 'cia', '0:63'), # Program counter (current)
- ('FAST', 'msr', '0:63')] # MSR
+ ]
def __init__(self, pspec):
super().__init__(pspec, False)
# convenience
yield from ALUHelpers.set_fast_spr1(alu, dec2, inp) # SPR1
yield from ALUHelpers.set_fast_spr2(alu, dec2, inp) # SPR1
- yield from ALUHelpers.set_cia(alu, dec2, inp)
- yield from ALUHelpers.set_msr(alu, dec2, inp)
+ #yield from ALUHelpers.set_cia(alu, dec2, inp)
+ #yield from ALUHelpers.set_msr(alu, dec2, inp)
return inp
# This test bench is a bit different than is usual. Initially when I
gen = program.generate_instructions()
instructions = list(zip(gen, program.assembly.splitlines()))
+ msr = sim.msr.value
pc = sim.pc.CIA.value
+ print ("starting msr, pc %08x, %08x"% (msr, pc))
index = pc//4
while index < len(instructions):
ins, code = instructions[index]
- print("pc %08x instr: %08x" % (pc, ins & 0xffffffff))
+ print("pc %08x msr %08x instr: %08x" % (pc, msr, ins))
print(code)
if 'XER' in sim.spr:
so = 1 if sim.spr['XER'][XER_bits['SO']] else 0
# ask the decoder to decode this binary data (endian'd)
yield pdecode2.dec.bigendian.eq(bigendian) # little / big?
+ yield pdecode2.msr.eq(msr) # set MSR in pdecode2
+ yield pdecode2.cia.eq(pc) # set CIA in pdecode2
yield instruction.eq(ins) # raw binary instr.
yield Settle()
fn_unit = yield pdecode2.e.do.fn_unit
self.assertEqual(fn_unit, Function.TRAP.value)
alu_o = yield from set_alu_inputs(alu, pdecode2, sim)
- yield pdecode2.msr.eq(alu_o['msr']) # set MSR in pdecode2
yield
opname = code.split(' ')[0]
yield from sim.call(opname)
pc = sim.pc.CIA.value
index = pc//4
print("pc after %08x" % (pc))
+ msr = sim.msr.value
+ print("msr after %08x" % (msr))
vld = yield alu.n.valid_o
while not vld:
layout = (('insn_type', MicrOp),
('fn_unit', Function),
('insn', 32),
+ ('msr', 64), # TODO: "state" in separate Record
+ ('cia', 64), # likewise
('is_32bit', 1),
('traptype', 5), # see trap main_stage.py and PowerDecoder2
('trapaddr', 13),