
Although a dir="oe" pin is generally equivalent to dir="io" pin with the i* signal(s) disconnected, they are not equivalent, because some pins may not be able to support input buffers at all, either because there are no input buffers, or because the input buffers are consumed by some other resource. E.g. this can happen on iCE40 when the input buffer is consumed by a PLL.
179 lines
5.4 KiB
Python
179 lines
5.4 KiB
Python
from .tools import *
|
|
from ..hdl.ast import *
|
|
from ..hdl.rec import *
|
|
from ..lib.io import *
|
|
|
|
|
|
class PinLayoutCombTestCase(FHDLTestCase):
|
|
def test_pin_layout_i(self):
|
|
layout_1 = pin_layout(1, dir="i")
|
|
self.assertEqual(layout_1.fields, {
|
|
"i": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="i")
|
|
self.assertEqual(layout_2.fields, {
|
|
"i": ((2, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_o(self):
|
|
layout_1 = pin_layout(1, dir="o")
|
|
self.assertEqual(layout_1.fields, {
|
|
"o": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="o")
|
|
self.assertEqual(layout_2.fields, {
|
|
"o": ((2, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_oe(self):
|
|
layout_1 = pin_layout(1, dir="oe")
|
|
self.assertEqual(layout_1.fields, {
|
|
"o": ((1, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="oe")
|
|
self.assertEqual(layout_2.fields, {
|
|
"o": ((2, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_io(self):
|
|
layout_1 = pin_layout(1, dir="io")
|
|
self.assertEqual(layout_1.fields, {
|
|
"i": ((1, False), DIR_NONE),
|
|
"o": ((1, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="io")
|
|
self.assertEqual(layout_2.fields, {
|
|
"i": ((2, False), DIR_NONE),
|
|
"o": ((2, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
|
|
class PinLayoutSDRTestCase(FHDLTestCase):
|
|
def test_pin_layout_i(self):
|
|
layout_1 = pin_layout(1, dir="i", xdr=1)
|
|
self.assertEqual(layout_1.fields, {
|
|
"i": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="i", xdr=1)
|
|
self.assertEqual(layout_2.fields, {
|
|
"i": ((2, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_o(self):
|
|
layout_1 = pin_layout(1, dir="o", xdr=1)
|
|
self.assertEqual(layout_1.fields, {
|
|
"o": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="o", xdr=1)
|
|
self.assertEqual(layout_2.fields, {
|
|
"o": ((2, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_oe(self):
|
|
layout_1 = pin_layout(1, dir="oe", xdr=1)
|
|
self.assertEqual(layout_1.fields, {
|
|
"o": ((1, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="oe", xdr=1)
|
|
self.assertEqual(layout_2.fields, {
|
|
"o": ((2, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_io(self):
|
|
layout_1 = pin_layout(1, dir="io", xdr=1)
|
|
self.assertEqual(layout_1.fields, {
|
|
"i": ((1, False), DIR_NONE),
|
|
"o": ((1, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="io", xdr=1)
|
|
self.assertEqual(layout_2.fields, {
|
|
"i": ((2, False), DIR_NONE),
|
|
"o": ((2, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
|
|
class PinLayoutDDRTestCase(FHDLTestCase):
|
|
def test_pin_layout_i(self):
|
|
layout_1 = pin_layout(1, dir="i", xdr=2)
|
|
self.assertEqual(layout_1.fields, {
|
|
"i0": ((1, False), DIR_NONE),
|
|
"i1": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="i", xdr=2)
|
|
self.assertEqual(layout_2.fields, {
|
|
"i0": ((2, False), DIR_NONE),
|
|
"i1": ((2, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_o(self):
|
|
layout_1 = pin_layout(1, dir="o", xdr=2)
|
|
self.assertEqual(layout_1.fields, {
|
|
"o0": ((1, False), DIR_NONE),
|
|
"o1": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="o", xdr=2)
|
|
self.assertEqual(layout_2.fields, {
|
|
"o0": ((2, False), DIR_NONE),
|
|
"o1": ((2, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_oe(self):
|
|
layout_1 = pin_layout(1, dir="oe", xdr=2)
|
|
self.assertEqual(layout_1.fields, {
|
|
"o0": ((1, False), DIR_NONE),
|
|
"o1": ((1, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="oe", xdr=2)
|
|
self.assertEqual(layout_2.fields, {
|
|
"o0": ((2, False), DIR_NONE),
|
|
"o1": ((2, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
def test_pin_layout_io(self):
|
|
layout_1 = pin_layout(1, dir="io", xdr=2)
|
|
self.assertEqual(layout_1.fields, {
|
|
"i0": ((1, False), DIR_NONE),
|
|
"i1": ((1, False), DIR_NONE),
|
|
"o0": ((1, False), DIR_NONE),
|
|
"o1": ((1, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
layout_2 = pin_layout(2, dir="io", xdr=2)
|
|
self.assertEqual(layout_2.fields, {
|
|
"i0": ((2, False), DIR_NONE),
|
|
"i1": ((2, False), DIR_NONE),
|
|
"o0": ((2, False), DIR_NONE),
|
|
"o1": ((2, False), DIR_NONE),
|
|
"oe": ((1, False), DIR_NONE),
|
|
})
|
|
|
|
|
|
class PinTestCase(FHDLTestCase):
|
|
def test_attributes(self):
|
|
pin = Pin(2, dir="io", xdr=2)
|
|
self.assertEqual(pin.width, 2)
|
|
self.assertEqual(pin.dir, "io")
|
|
self.assertEqual(pin.xdr, 2)
|