コード例 #1
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
 def test_clone_wire_same_name_same_block(self):
     a = pyrtl.WireVector(1, 'a')
     with self.assertRaises(pyrtl.PyrtlError) as error:
         pyrtl.clone_wire(a, 'a')
     self.assertEqual(
         str(error.exception),
         "Cannot give a newly cloned wire the same name as an existing wire."
     )
コード例 #2
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
 def test_clone_wire_no_name_same_block(self):
     a = pyrtl.WireVector(1, 'a')
     with self.assertRaises(pyrtl.PyrtlError) as error:
         pyrtl.clone_wire(a)
     self.assertEqual(
         str(error.exception),
         "Must provide a name for the newly cloned wire "
         "when cloning within the same block.")
コード例 #3
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
 def test_same_type(self):
     for ix, cls in enumerate(
         [pyrtl.WireVector, pyrtl.Register, pyrtl.Input, pyrtl.Output]):
         w1 = cls(4, 'w%d' % ix)
         w2 = pyrtl.clone_wire(w1, 'y%d' % ix)
         self.assertIsInstance(w2, cls)
         self.assertEqual(w1.bitwidth, w2.bitwidth)
コード例 #4
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
 def test_clone_wire_different_name_different_block(self):
     a = pyrtl.WireVector(1, 'a')
     b = pyrtl.Block()
     with set_working_block(b):
         w = pyrtl.clone_wire(a, 'w')
     self.assertEqual(a.name, 'a')
     self.assertEqual(w.name, 'w')
     self.assertIs(pyrtl.working_block().wirevector_by_name['a'], a)
     self.assertEqual(pyrtl.working_block().wirevector_set, {a})
     self.assertIs(b.wirevector_by_name['w'], w)
     self.assertEqual(b.wirevector_set, {w})
コード例 #5
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
    def test_clone_wire_no_or_same_name_different_block(self):
        for clone_name in (None, 'a'):
            a = pyrtl.WireVector(1, 'a')
            b = pyrtl.Block()
            with pyrtl.set_working_block(b):
                w = pyrtl.clone_wire(a, name=clone_name)

            self.assertEqual(a.name, 'a')
            self.assertIs(pyrtl.working_block().wirevector_by_name['a'], a)
            self.assertEqual(pyrtl.working_block().wirevector_set, {a})

            self.assertEqual(w.name, 'a')
            self.assertIs(b.wirevector_by_name['a'], w)
            self.assertEqual(b.wirevector_set, {w})
            pyrtl.reset_working_block()
コード例 #6
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
    def test_clone_wire_different_name_same_block(self):
        a = pyrtl.WireVector(1, 'a')
        self.assertEqual(a.name, 'a')
        self.assertEqual(pyrtl.working_block().wirevector_set, {a})
        self.assertIs(pyrtl.working_block().wirevector_by_name['a'], a)

        w = pyrtl.clone_wire(a, name='w')
        self.assertEqual(w.name, 'w')
        self.assertEqual(a.name, 'a')
        self.assertIs(pyrtl.working_block().wirevector_by_name['w'], w)
        self.assertIs(pyrtl.working_block().wirevector_by_name['a'], a)
        self.assertEqual(pyrtl.working_block().wirevector_set, {a, w})

        pyrtl.working_block().remove_wirevector(a)
        self.assertEqual(pyrtl.working_block().wirevector_set, {w})
コード例 #7
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
 def f(wire):
     if wire.name == 'a':
         w = pyrtl.clone_wire(wire, 'w2')
     else:
         w = pyrtl.clone_wire(wire, 'w3')
     return wire, w
コード例 #8
0
ファイル: test_transform.py プロジェクト: UCSBarchlab/PyRTL
 def f(wire):
     w = pyrtl.clone_wire(wire, 'w2')
     return w, wire