soc/cores: fix vivado issue with SPIRegister (at least with Vivado 2017.x+, mosi was not generated correctly), create cs_n signal if pads does not exists
This commit is contained in:
parent
04646b24ed
commit
c02de1632b
|
@ -45,18 +45,19 @@ class SPIRegister(Module):
|
||||||
self.o.eq(Mux(self.lsb, self.data[0], self.data[-1])),
|
self.o.eq(Mux(self.lsb, self.data[0], self.data[-1])),
|
||||||
]
|
]
|
||||||
self.sync += [
|
self.sync += [
|
||||||
If(self.shift,
|
If(self.lsb,
|
||||||
If(self.lsb,
|
If(self.shift,
|
||||||
self.data[:-1].eq(self.data[1:]),
|
self.data[:-1].eq(self.data[1:])
|
||||||
).Else(
|
),
|
||||||
self.data[1:].eq(self.data[:-1]),
|
If(self.sample,
|
||||||
|
self.data[0].eq(self.i)
|
||||||
)
|
)
|
||||||
),
|
).Else(
|
||||||
If(self.sample,
|
If(self.shift,
|
||||||
If(self.lsb,
|
self.data[1:].eq(self.data[:-1]),
|
||||||
self.data[-1].eq(self.i),
|
),
|
||||||
).Else(
|
If(self.sample,
|
||||||
self.data[0].eq(self.i),
|
self.data[0].eq(self.i)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -317,14 +318,17 @@ class SPIMasterCore(Module):
|
||||||
]
|
]
|
||||||
|
|
||||||
# I/O
|
# I/O
|
||||||
if hasattr(pads, "cs_n"):
|
if not hasattr(pads, "cs_n"):
|
||||||
cs_n_t = TSTriple(len(pads.cs_n))
|
self.cs_n = Signal()
|
||||||
self.specials += cs_n_t.get_tristate(pads.cs_n)
|
else:
|
||||||
self.comb += [
|
self.cs_n = pads.cs_n
|
||||||
cs_n_t.oe.eq(~self.config.offline),
|
cs_n_t = TSTriple(len(self.cs_n))
|
||||||
cs_n_t.o.eq((cs & Replicate(machine.cs, len(cs))) ^
|
self.specials += cs_n_t.get_tristate(self.cs_n)
|
||||||
Replicate(~self.config.cs_polarity, len(cs))),
|
self.comb += [
|
||||||
]
|
cs_n_t.oe.eq(~self.config.offline),
|
||||||
|
cs_n_t.o.eq((cs & Replicate(machine.cs, len(cs))) ^
|
||||||
|
Replicate(~self.config.cs_polarity, len(cs))),
|
||||||
|
]
|
||||||
|
|
||||||
clk_t = TSTriple()
|
clk_t = TSTriple()
|
||||||
self.specials += clk_t.get_tristate(pads.clk)
|
self.specials += clk_t.get_tristate(pads.clk)
|
||||||
|
@ -342,6 +346,7 @@ class SPIMasterCore(Module):
|
||||||
machine.reg.i.eq(Mux(self.config.half_duplex, mosi_t.i,
|
machine.reg.i.eq(Mux(self.config.half_duplex, mosi_t.i,
|
||||||
getattr(pads, "miso", mosi_t.i))),
|
getattr(pads, "miso", mosi_t.i))),
|
||||||
]
|
]
|
||||||
|
self.mosi_t = mosi_t
|
||||||
|
|
||||||
|
|
||||||
class SPIMaster(Module, AutoCSR):
|
class SPIMaster(Module, AutoCSR):
|
||||||
|
|
Loading…
Reference in New Issue