From 45797f9132b9e1a3d81f510ef908b029af778ffb Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 16 May 2013 17:45:21 +0200 Subject: [PATCH] framebuffer: saturate instead of overflow --- milkymist/framebuffer/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/milkymist/framebuffer/__init__.py b/milkymist/framebuffer/__init__.py index d8f0cddd..4161d6fb 100644 --- a/milkymist/framebuffer/__init__.py +++ b/milkymist/framebuffer/__init__.py @@ -75,10 +75,14 @@ class Blender(PipelinedActor, AutoCSR): for component in ["r", "g", "b"]: incomps = [getattr(pix, component) for pix in inpixs] outcomp = getattr(outpix, component) - outcomp_full = Signal(18) + outcomp_full = Signal(19) self.comb += [ outcomp_full.eq(sum(incomp*factor for incomp, factor in zip(incomps, factors))), - outcomp.eq(outcomp_full[8:]) + If(outcomp_full[18], + outcomp.eq(2**10 - 1) # saturate on overflow + ).Else( + outcomp.eq(outcomp_full[8:18]) + ) ] pipe_stmts = [] @@ -90,7 +94,7 @@ class Blender(PipelinedActor, AutoCSR): self.comb += self.source.payload.eq(outval) class MixFramebuffer(Module, AutoCSR): - def __init__(self, pads, *asmiports, blender_latency=4): + def __init__(self, pads, *asmiports, blender_latency=5): pack_factor = asmiports[0].hub.dw//(2*bpp) packed_pixels = structuring.pack_layout(pixel_layout, pack_factor) -- 2.30.2