From 0b7dd7bdce9606c90c78f8791e5d0fb051b560cb Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 23 Nov 2012 13:40:46 +0100 Subject: [PATCH] pytholite/io: fix Wishbone writes + support sel attribute --- migen/pytholite/io.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/migen/pytholite/io.py b/migen/pytholite/io.py index f81dbca1..bf40a70d 100644 --- a/migen/pytholite/io.py +++ b/migen/pytholite/io.py @@ -94,9 +94,18 @@ def _gen_wishbone_io(compiler, modelname, model, to_model, from_model, bus): ] if model == TWrite: - state.append(bus.we.eq(1)) if from_model: raise TypeError("Attempted to read from write transaction") + state += [ + bus.we.eq(1), + bus.dat_w.eq(compiler.ec.visit_expr(to_model["data"])) + ] + sel = to_model["sel"] + if isinstance(sel, ast.Name) and sel.id == "None": + nbytes = (len(bus.dat_w) + 7)//8 + state.append(bus.sel.eq(2**nbytes-1)) + else: + state.append(bus.sel.eq(compiler.ec.visit_expr(sel))) else: state.append(bus.we.eq(0)) ec = _BusReadExprCompiler(compiler.symdict, modelname, bus.dat_r) -- 2.30.2