hdl.ast: deprecate Signal.{range,enum}.

Although constructor methods can improve clarity, there are many
contexts in which it is useful to use range() as a shape: notably
Layout, but also Const and AnyConst/AnyValue. Instead of duplicating
these constructor methods everywhere (which is not even easily
possible for Layout), use casting to Shape, introduced in 6aabdc0a.

Fixes #225.
This commit is contained in:
whitequark 2019-10-11 13:07:42 +00:00
parent 6aabdc0a73
commit 706bfaf5e1
10 changed files with 66 additions and 59 deletions

View file

@ -15,7 +15,7 @@ class UARTReceiver(Elaboratable):
def elaborate(self, platform):
m = Module()
ctr = Signal.range(self.divisor)
ctr = Signal(range(self.divisor))
stb = Signal()
with m.If(ctr == 0):
m.d.sync += ctr.eq(self.divisor - 1)

View file

@ -7,7 +7,7 @@ cd_por = ClockDomain(reset_less=True)
cd_sync = ClockDomain()
m.domains += cd_por, cd_sync
delay = Signal.range(256, reset=255)
delay = Signal(range(256), reset=255)
with m.If(delay != 0):
m.d.por += delay.eq(delay - 1)
m.d.comb += [

View file

@ -31,9 +31,9 @@ class UART(Elaboratable):
def elaborate(self, platform):
m = Module()
tx_phase = Signal.range(self.divisor)
tx_phase = Signal(range(self.divisor))
tx_shreg = Signal(1 + self.data_bits + 1, reset=-1)
tx_count = Signal.range(len(tx_shreg) + 1)
tx_count = Signal(range(len(tx_shreg) + 1))
m.d.comb += self.tx_o.eq(tx_shreg[0])
with m.If(tx_count == 0):
@ -54,9 +54,9 @@ class UART(Elaboratable):
tx_phase.eq(self.divisor - 1),
]
rx_phase = Signal.range(self.divisor)
rx_phase = Signal(range(self.divisor))
rx_shreg = Signal(1 + self.data_bits + 1, reset=-1)
rx_count = Signal.range(len(rx_shreg) + 1)
rx_count = Signal(range(len(rx_shreg) + 1))
m.d.comb += self.rx_data.eq(rx_shreg[1:-1])
with m.If(rx_count == 0):