Beispiel #1
0
 def test_permute(self):
     s = SPM(self.main, word_size=1, size=1,
             access_time=1, cycle_time=1)
     s.reset(self.machine)
     dist = MemoryDistribution(mocks.MockRandom([0, 1]))
     result = s.permute(dist, 1, 0)
     self.assertEqual(result, False)
     result = s.permute(dist, 10000, 0)
     self.assertEqual(result, True)
Beispiel #2
0
    def test_spm1(self):
        spm = SPM(self.main, word_size=8, size=1024,
                  access_time=1, cycle_time=1)
        spm.reset(self.machine)

        t = spm.process(0, False, 0, 1)
        self.assertEqual(t, 1)
        self.machine.time += t

        t = spm.process(0, False, 1024 - 8, 8)
        self.assertEqual(t, 1)
        self.machine.time += t

        t = spm.process(0, False, 1024, 4)
        self.assertEqual(t, 400)
        self.machine.time += t

        t = spm.process(0, False, 1023, 2)
        self.assertEqual(t, 101)
        self.machine.time += t

        t = spm.process(0, True, 1024, 1)
        self.assertEqual(t, 100)
        self.machine.time += t

        t = spm.process(0, True, 8192, 16)
        self.assertEqual(t, 1600)
        self.machine.time += t
Beispiel #3
0
 def test_path(self):
     spm = SPM(self.main, word_size=2, size=1024,
               access_time=1, cycle_time=1)
     spm.reset(self.machine)
     self.assertEqual(spm.get_path_length(), 2 * self.machine.addr_bits)
Beispiel #4
0
 def test_cost(self):
     spm = SPM(self.main, word_size=8, size=1024,
               access_time=1, cycle_time=1)
     spm.reset(self.machine)
     self.assertEqual(spm.get_cost(), 8 * 1024)
Beispiel #5
0
 def test_simplify(self):
     spm = SPM(self.main, word_size=4, size=1024,
               access_time=1, cycle_time=1)
     simplified = spm.simplify()
     self.assertEqual(spm, simplified)