"""
def __init__(self, bus=None, features=None, name=None):
+ self.enable = Signal(reset=1) # enable signal, defaults to 1
if features is None:
features = frozenset()
if bus is None:
m.submodules += sram
sram.attrs['blackbox'] = 1
- # wishbone is active if cyc and stb set
- wb_active = Signal()
- m.d.comb += wb_active.eq(self.bus.cyc & self.bus.stb)
+ with m.If(self.enable): # in case of layout problems
+ # wishbone is active if cyc and stb set
+ wb_active = Signal()
+ m.d.comb += wb_active.eq(self.bus.cyc & self.bus.stb)
- # generate ack (no "pipeline" mode here)
- m.d.sync += self.bus.ack.eq(wb_active)
+ # generate ack (no "pipeline" mode here)
+ m.d.sync += self.bus.ack.eq(wb_active)
- with m.If(wb_active):
+ with m.If(wb_active):
- # address
- m.d.comb += a.eq(self.bus.adr)
+ # address
+ m.d.comb += a.eq(self.bus.adr)
- # read
- m.d.comb += self.bus.dat_r.eq(q)
+ # read
+ m.d.comb += self.bus.dat_r.eq(q)
- # write
- m.d.comb += d.eq(self.bus.dat_w)
- with m.If(self.bus.we):
- m.d.comb += we.eq(self.bus.sel)
+ # write
+ m.d.comb += d.eq(self.bus.dat_w)
+ with m.If(self.bus.we):
+ m.d.comb += we.eq(self.bus.sel)
return m
# create DMI2JTAG (goes through to dmi_sim())
self.dmi = self.add_dmi(ircodes=[8, 9, 10])
- # use this for enable/disable of parts of the ASIC
- self.sr_en = self.add_shiftreg(ircode=11, length=2)
+ # use this for enable/disable of parts of the ASIC.
+ # NOTE: increase length parameter when adding new enable signals
+ self.sr_en = self.add_shiftreg(ircode=11, length=3)
self.wb_icache_en = Signal(reset=1)
self.wb_dcache_en = Signal(reset=1)
+ self.wb_sram_en = Signal(reset=1)
def elaborate(self, platform):
m = super().elaborate(platform)
m.d.comb += self.sr.i.eq(self.sr.o) # loopback as part of test?
- # provide way to enable/disable wishbone caches just in case of issues
+ # provide way to enable/disable wishbone caches and SRAM
+ # just in case of issues
# see https://bugs.libre-soc.org/show_bug.cgi?id=520
- en_sigs = Cat(self.wb_icache_en, self.wb_dcache_en)
+ en_sigs = Cat(self.wb_icache_en, self.wb_dcache_en,
+ self.wb_sram_en)
with m.If(self.sr_en.oe):
m.d.sync += en_sigs.eq(self.sr_en.o)
# also make it possible to read the enable/disable current state
"""
from nmigen import (Elaboratable, Module, Signal, ClockSignal, ResetSignal,
- ClockDomain, DomainRenamer, Mux)
+ ClockDomain, DomainRenamer, Mux, Const)
from nmigen.cli import rtlil
from nmigen.cli import main
import sys
# honestly probably not.
pspec.wb_icache_en = self.jtag.wb_icache_en
pspec.wb_dcache_en = self.jtag.wb_dcache_en
+ self.wb_sram_en = self.jtag.wb_sram_en
+ else:
+ self.wb_sram_en = Const(1)
# add 4k sram blocks?
- self.sram4x4k = (hasattr(pspec, "sram4x4kblock") and
+ self.sram4x4k = (hasattr(pspec, "sram4x4kblock") and
pspec.sram4x4kblock == True)
if self.sram4x4k:
self.sram4k = []
if self.sram4x4k:
for i, sram in enumerate(self.sram4k):
m.submodules["sram4k_%d" % i] = sram
+ comb += sram.enable.eq(self.wb_sram_en)
# XICS interrupt handler
if self.xics:
unittest.main(exit=False)
suite = unittest.TestSuite()
# suite.addTest(TestRunner(HelloTestCases.test_data))
- suite.addTest(TestRunner(DivTestCases().test_data))
+ #suite.addTest(TestRunner(DivTestCases().test_data))
# suite.addTest(TestRunner(AttnTestCase.test_data))
- suite.addTest(TestRunner(GeneralTestCases.test_data))
- suite.addTest(TestRunner(LDSTTestCase().test_data))
- suite.addTest(TestRunner(CRTestCase().test_data))
- suite.addTest(TestRunner(ShiftRotTestCase().test_data))
+ #suite.addTest(TestRunner(GeneralTestCases.test_data))
+ #suite.addTest(TestRunner(LDSTTestCase().test_data))
+ #suite.addTest(TestRunner(CRTestCase().test_data))
+ #suite.addTest(TestRunner(ShiftRotTestCase().test_data))
suite.addTest(TestRunner(LogicalTestCase().test_data))
- suite.addTest(TestRunner(ALUTestCase().test_data))
+ #suite.addTest(TestRunner(ALUTestCase().test_data))
# suite.addTest(TestRunner(BranchTestCase.test_data))
# suite.addTest(TestRunner(SPRTestCase.test_data))