fhdl.dsl: use less error-prone Switch/Case two-level syntax.

This commit is contained in:
whitequark 2018-12-13 07:11:06 +00:00
parent f70ae3bac5
commit 932f1912a2
3 changed files with 234 additions and 74 deletions

View file

@ -12,14 +12,15 @@ class ParMux:
def get_fragment(self, platform):
m = Module()
with m.Case(self.s, "--1"):
m.d.comb += self.o.eq(self.a)
with m.Case(self.s, "-1-"):
m.d.comb += self.o.eq(self.b)
with m.Case(self.s, "1--"):
m.d.comb += self.o.eq(self.c)
with m.Case(self.s):
m.d.comb += self.o.eq(0)
with m.Switch(self.s):
with m.Case("--1"):
m.d.comb += self.o.eq(self.a)
with m.Case("-1-"):
m.d.comb += self.o.eq(self.b)
with m.Case("1--"):
m.d.comb += self.o.eq(self.c)
with m.Case():
m.d.comb += self.o.eq(0)
return m.lower(platform)