From 2c6e5066a710cf8ab495915513d357ea9a2b5de3 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 7 Feb 2020 14:52:53 +0100 Subject: [PATCH] soc: move SoCController from soc_core to soc --- litex/soc/integration/soc.py | 29 +++++++++++++++++++++++++++ litex/soc/integration/soc_core.py | 33 +------------------------------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index f513777d..7d43efaa 100755 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -9,6 +9,7 @@ import datetime from migen import * +from litex.soc.interconnect.csr import * from litex.soc.interconnect import wishbone # TODO: @@ -424,6 +425,34 @@ class SoCIRQHandler(SoCLocHandler): r = r[:-1] return r +# SoCController ------------------------------------------------------------------------------------ + +class SoCController(Module, AutoCSR): + def __init__(self): + self._reset = CSRStorage(1, description=""" + Write a ``1`` to this register to reset the SoC.""") + self._scratch = CSRStorage(32, reset=0x12345678, description=""" + Use this register as a scratch space to verify that software read/write accesses + to the Wishbone/CSR bus are working correctly. The initial reset value of 0x1234578 + can be used to verify endianness.""") + self._bus_errors = CSRStatus(32, description=""" + Total number of Wishbone bus errors (timeouts) since last reset.""") + + # # # + + # Reset + self.reset = Signal() + self.comb += self.reset.eq(self._reset.re) + + # Bus errors + self.bus_error = Signal() + bus_errors = Signal(32) + self.sync += \ + If(bus_errors != (2**len(bus_errors)-1), + If(self.bus_error, bus_errors.eq(bus_errors + 1)) + ) + self.comb += self._bus_errors.status.eq(bus_errors) + # SoC ---------------------------------------------------------------------------------------------- class SoC(Module): diff --git a/litex/soc/integration/soc_core.py b/litex/soc/integration/soc_core.py index 1f71098f..55ec3b87 100644 --- a/litex/soc/integration/soc_core.py +++ b/litex/soc/integration/soc_core.py @@ -22,10 +22,9 @@ from litex.build.tools import deprecated_warning from litex.soc.cores import identifier, timer, uart from litex.soc.cores import cpu -from litex.soc.interconnect.csr import * from litex.soc.interconnect import wishbone, csr_bus, wishbone2csr from litex.soc.integration.common import * -from litex.soc.integration.soc import SoCRegion, SoC +from litex.soc.integration.soc import SoCRegion, SoC, SoCController __all__ = [ "mem_decoder", @@ -38,36 +37,6 @@ __all__ = [ "soc_mini_argdict", ] -# SoCController ------------------------------------------------------------------------------------ - -class SoCController(Module, AutoCSR): - def __init__(self): - self._reset = CSRStorage(1, description=""" - Write a ``1`` to this register to reset the SoC.""") - self._scratch = CSRStorage(32, reset=0x12345678, description=""" - Use this register as a scratch space to verify that software read/write accesses - to the Wishbone/CSR bus are working correctly. The initial reset value of 0x1234578 - can be used to verify endianness.""") - self._bus_errors = CSRStatus(32, description=""" - Total number of Wishbone bus errors (timeouts) since last reset.""") - - # # # - - # reset - self.reset = Signal() - self.comb += self.reset.eq(self._reset.re) - - # bus errors - self.bus_error = Signal() - bus_errors = Signal(32) - self.sync += \ - If(bus_errors != (2**len(bus_errors)-1), - If(self.bus_error, - bus_errors.eq(bus_errors + 1) - ) - ) - self.comb += self._bus_errors.status.eq(bus_errors) - # SoCCore ------------------------------------------------------------------------------------------ class SoCCore(SoC): -- 2.30.2