generated from saji/ecp5-template
fix tests
This commit is contained in:
parent
3187db40ae
commit
e945aa03f2
|
@ -24,9 +24,11 @@ Rgb111Layout = RGBLayout(1, 1, 1)
|
||||||
|
|
||||||
|
|
||||||
class RGBView(data.View):
|
class RGBView(data.View):
|
||||||
|
|
||||||
def bit_depth(self) -> int:
|
def bit_depth(self) -> int:
|
||||||
return max(self.red.shape(), self.green.shape(), self.blue.shape())
|
return max(
|
||||||
|
self.red.shape().width, self.green.shape().width, self.blue.shape().width
|
||||||
|
)
|
||||||
|
|
||||||
def channel_slice(self, bit: int) -> Rgb111Layout:
|
def channel_slice(self, bit: int) -> Rgb111Layout:
|
||||||
"""Select bits from each channel and use it to form an Rgb111Layout.
|
"""Select bits from each channel and use it to form an Rgb111Layout.
|
||||||
This is useful for BCM stuff, since the bits are sliced to form a bitplane.
|
This is useful for BCM stuff, since the bits are sliced to form a bitplane.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from amaranth import Module, Cat, Mux, Print, ShapeLike, Signal, Assert, Array
|
from amaranth import Module, Cat, Mux, ShapeLike, Signal, Assert, Array
|
||||||
from amaranth.build import Platform
|
from amaranth.build import Platform
|
||||||
from amaranth.lib import wiring, data
|
from amaranth.lib import wiring, data
|
||||||
from amaranth.lib.wiring import In, Out
|
from amaranth.lib.wiring import In, Out
|
||||||
|
@ -313,7 +313,6 @@ class Hub75DataDriver(wiring.Component):
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
class Hub75Coordinator(wiring.Component):
|
class Hub75Coordinator(wiring.Component):
|
||||||
"""A shared-control hub75 driver"""
|
"""A shared-control hub75 driver"""
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@ from groovylight.common import Rgb888Layout, Rgb666Layout, RGBView
|
||||||
def test_rgbview():
|
def test_rgbview():
|
||||||
rgb = Rgb888Layout(0xAABBCC)
|
rgb = Rgb888Layout(0xAABBCC)
|
||||||
|
|
||||||
assert rgb.channel_size() == unsigned(8)
|
assert rgb.bit_depth() == 8
|
||||||
|
|
||||||
rgb18 = Rgb666Layout(0x2DEFD)
|
rgb18 = Rgb666Layout(0x2DEFD)
|
||||||
|
|
||||||
slice = rgb.channel_slice(1)
|
slice = rgb.channel_slice(1)
|
||||||
assert isinstance(slice, RGBView), "channel_slice should return another rgbview"
|
assert isinstance(slice, RGBView), "channel_slice should return another rgbview"
|
||||||
|
|
||||||
assert slice.channel_size() == unsigned(1), "channel_slice channel size should be 1"
|
assert slice.bit_depth() == 1, "channel_slice channel size should be 1"
|
||||||
assert isinstance(
|
assert isinstance(
|
||||||
rgb18.channel_slice(5), RGBView
|
rgb18.channel_slice(5), RGBView
|
||||||
), "channel_slice should return another rgbview"
|
), "channel_slice should return another rgbview"
|
||||||
|
|
Loading…
Reference in a new issue