class Mem:
 
-    def __init__(self, bytes_per_word=8):
+    def __init__(self, bytes_per_word=8, initial_mem=None):
         self.mem = {}
         self.bytes_per_word = bytes_per_word
         self.word_log2 = math.ceil(math.log2(bytes_per_word))
+        if initial_mem:
+            for addr, (val, width) in initial_mem.items():
+                self.st(addr, val, width)
 
     def _get_shifter_mask(self, width, remainder):
         shifter = ((self.bytes_per_word - width) - remainder) * \
 class ISACaller:
     # decoder2 - an instance of power_decoder2
     # regfile - a list of initial values for the registers
-    def __init__(self, decoder2, regfile, initial_sprs={}, initial_cr=0):
+    def __init__(self, decoder2, regfile, initial_sprs=None, initial_cr=0,
+                       initial_mem=None):
+        if initial_sprs is None:
+            initial_sprs = {}
+        if initial_mem is None:
+            initial_mem = {}
         self.gpr = GPR(decoder2, regfile)
-        self.mem = Mem()
+        self.mem = Mem(initial_mem=initial_mem)
         self.pc = PC()
         self.spr = SPR(decoder2, initial_sprs)
         # TODO, needed here:
 
                     yield from self.iodef.check_cu_outputs(res, pdecode2,
                                                             sim, code)
 
+                    # sigh.  hard-coded.  test memory
+                    if self.funit == Function.LDST:
+                        print ("mem dump", sim.mem.mem)
+
         sim.add_sync_process(process)
 
         name = self.funit.name.lower()
 
         """naming (res) must conform to LDSTFunctionUnit output regspec
         """
 
+        print ("check cu outputs", res)
         # RT
         out_reg_valid = yield dec2.e.write_reg.ok
         if out_reg_valid:
 
         super().__init__(name)
         self.test_name = name
 
-    def run_tst_program(self, prog, initial_regs=None, initial_sprs=None):
-        tc = TestCase(prog, self.test_name, initial_regs, initial_sprs)
+    def run_tst_program(self, prog, initial_regs=None,
+                        initial_sprs=None, initial_mem=None):
+        tc = TestCase(prog, self.test_name, initial_regs, initial_sprs,
+                      mem=initial_mem)
         self.test_data.append(tc)
 
-    def test_load_store(self):
+    def test_1_load(self):
+        lst = ["lwz 3, 0(1)"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0x0004
+        initial_regs[2] = 0x0008
+        initial_mem = {0x0004: (0x1234, 4)}
+        self.run_tst_program(Program(lst), initial_regs,
+                             initial_mem=initial_mem)
+
+    def tst_2_load_store(self):
         lst = ["stw 2, 0(1)",
                "lwz 3, 0(1)"]
         initial_regs = [0] * 32
         initial_regs[2] = 0x0008
         self.run_tst_program(Program(lst), initial_regs)
 
-    def test_ilang(self):
-        pspec = LDSTPipeSpec(id_wid=2)
-        alu = LDSTBasePipe(pspec)
-        vl = rtlil.convert(alu, ports=alu.ports())
-        with open("ldst_pipeline.il", "w") as f:
-            f.write(vl)
-
-
 
 class TestCase:
-    def __init__(self, program, name, regs=None, sprs=None, cr=0):
+    def __init__(self, program, name, regs=None, sprs=None, cr=0, mem=None):
+
         self.program = program
         self.name = name
 
             regs = [0] * 32
         if sprs is None:
             sprs = {}
+        if mem is None:
+            mem = {}
         self.regs = regs
         self.sprs = sprs
         self.cr = cr
-
+        self.mem = mem