Esempio n. 1
0
    def test_multimux_multiway(self):

        one4 = Multi([zero, zero, zero, one])
        zero4 = Multi([zero, zero, zero, zero])

        self.assertEquals(str(multimux_multiway(Multi([one]), m_fifteen, m_fourteen)), str(m_fourteen))
        self.assertEquals(str(multimux_multiway(Multi([one, one]), m_fifteen, m_fourteen, m_zero, m_one)), str(one4))
        self.assertEquals(
            str(multimux_multiway(Multi([zero, one]), m_three, m_zero, m_fifteen, m_fourteen)), str(zero4)
        )
        self.assertEquals(
            str(
                multimux_multiway(
                    Multi([one, zero, zero]), m_zero, m_three, m_fourteen, m_eight, m_one, m_zero, m_fifteen, m_fourteen
                )
            ),
            str(m_eight),
        )
        self.assertEquals(
            str(
                multimux_multiway(
                    Multi([zero, one, zero]), m_zero, m_three, m_fourteen, m_eight, m_one, m_zero, m_fifteen, m_fourteen
                )
            ),
            str(m_fourteen),
        )
Esempio n. 2
0
    def test_multimux_multiway(self):

        one4 = Multi([zero, zero, zero, one])
        zero4 = Multi([zero, zero, zero, zero])

        self.assertEquals(
            str(multimux_multiway(Multi([one]), m_fifteen, m_fourteen)),
            str(m_fourteen))
        self.assertEquals(
            str(
                multimux_multiway(Multi([one, one]), m_fifteen, m_fourteen,
                                  m_zero, m_one)), str(one4))
        self.assertEquals(
            str(
                multimux_multiway(Multi([zero, one]), m_three, m_zero,
                                  m_fifteen, m_fourteen)), str(zero4))
        self.assertEquals(
            str(
                multimux_multiway(Multi([one, zero, zero]), m_zero, m_three,
                                  m_fourteen, m_eight, m_one, m_zero,
                                  m_fifteen, m_fourteen)), str(m_eight))
        self.assertEquals(
            str(
                multimux_multiway(Multi([zero, one, zero]), m_zero, m_three,
                                  m_fourteen, m_eight, m_one, m_zero,
                                  m_fifteen, m_fourteen)), str(m_fourteen))
Esempio n. 3
0
 def __call__(self, multi, load, address, clock):
     inputs = dmux_multiway(Multi([load]), address)
     regs = [
         Multi(pair[0](multi, pair[1], clock))
         for pair in zip(self.reg, inputs)
     ]
     return multimux_multiway(address, *regs)
Esempio n. 4
0
 def __call__(self, multi, load, address, clock):
     input_address = Multi(address[-1:-4:-1])
     reg_address = Multi(address[-4:-(len(address) + 1):-1])
     inputs = dmux_multiway(Multi([load]), input_address)
     regs = [
         Multi(pair[0](multi, pair[1], reg_address, clock))
         for pair in zip(self.reg, inputs)
     ]
     return multimux_multiway(input_address, *regs)
    def test_multimux_multiway(self):
        """Checks that multimux_multiway returns the correct value given an input of 2, 4, or 8 Multi instances 
            and a corresponding selector of 1, 2, or 3 digits"""

        one4 = Multi([zero, zero, zero, one])
        zero4 = Multi([zero, zero, zero, zero])

        self.assertEquals(str(multimux_multiway(Multi([one]), m_fifteen, m_fourteen)), str(m_fourteen))
        self.assertEquals(str(multimux_multiway(Multi([zero]), neg_one, m_fourteen)), str(neg_one))
        self.assertEquals(str(multimux_multiway(Multi([one, one]), m_fifteen, neg_two, m_zero, m_one)), str(one16))
        self.assertEquals(str(multimux_multiway(Multi([zero, one]), m_zero, neg_one, m_two, neg_three)), str(neg_one))
        self.assertEquals(str(multimux_multiway(Multi([one, zero, zero]), m_zero, neg_one, m_fourteen, neg_eight, m_one, m_zero, 
                                                m_fifteen, neg_three)), str(one16))
        self.assertEquals(str(multimux_multiway(Multi([zero, one, zero]), m_zero, m_three, m_fourteen, m_eight, m_one, m_zero, 
                                                      m_fifteen, m_fourteen)), str(m_fourteen))
Esempio n. 6
0
 def __call__(self, multi, load, address, clock):
     inputs = dmux_multiway(Multi([load]), address)
     regs = [Multi(pair[0](multi, pair[1], clock)) for pair in zip(self.reg, inputs)]
     return multimux_multiway(address, *regs)        
Esempio n. 7
0
 def __call__(self, multi, load, address, clock):
     input_address = Multi(address[-1:-4:-1])
     reg_address = Multi(address[-4:-(len(address) + 1):-1])
     inputs = dmux_multiway(Multi([load]), input_address)
     regs = [Multi(pair[0](multi, pair[1], reg_address, clock)) for pair in zip(self.reg, inputs)]        
     return multimux_multiway(input_address, *regs)