--- /dev/null
+from migen.fhdl.structure import *
+from migen.bus.asmibus import *
+from migen.sim.generic import Simulator, TopLevel
+from migen.sim.icarus import Runner
+
+from milkymist.asmicon.bankmachine import *
+
+from common import sdram_geom, sdram_timing, CommandLogger
+
+def my_generator():
+ for x in range(10):
+ t = TWrite(x)
+ yield t
+ for x in range(10):
+ t = TWrite(x + 2200)
+ yield t
+
+class Completer:
+ def __init__(self, hub, cmd):
+ self.hub = hub
+ self.cmd = cmd
+
+ def get_fragment(self):
+ sync = [
+ self.hub.call.eq(self.cmd.stb & self.cmd.ack & (self.cmd.is_read | self.cmd.is_write)),
+ self.hub.tag_call.eq(self.cmd.tag)
+ ]
+ return Fragment(sync=sync)
+
+def main():
+ hub = Hub(12, 128, 2)
+ initiator = Initiator(hub.get_port(), my_generator())
+ hub.finalize()
+
+ dut = BankMachine(sdram_geom, sdram_timing, 2, 0, hub.get_slots())
+ logger = CommandLogger(dut.cmd, True)
+ completer = Completer(hub, dut.cmd)
+
+ def end_simulation(s):
+ s.interrupt = initiator.done
+
+ fragment = hub.get_fragment() + initiator.get_fragment() + \
+ dut.get_fragment() + logger.get_fragment() + completer.get_fragment() + \
+ Fragment(sim=[end_simulation])
+ sim = Simulator(fragment, Runner(), TopLevel("my.vcd"))
+ sim.run()
+
+main()
+from fractions import Fraction
+from math import ceil
+
from migen.fhdl.structure import *
from migen.sim.generic import Proxy
+from milkymist import asmicon
+
+MHz = 1000000
+clk_freq = (83 + Fraction(1, 3))*MHz
+
+clk_period_ns = 1000000000/clk_freq
+def ns(t, margin=True):
+ if margin:
+ t += clk_period_ns/2
+ return ceil(t/clk_period_ns)
+
+sdram_geom = asmicon.GeomSettings(
+ bank_a=2,
+ row_a=13,
+ col_a=10
+)
+sdram_timing = asmicon.TimingSettings(
+ tRP=ns(15),
+ tRCD=ns(15),
+ tWR=ns(15),
+ tREFI=ns(7800, False),
+ tRFC=ns(70),
+
+ CL=3,
+ rd_delay=4,
+
+ slot_time=16,
+ read_time=32,
+ write_time=16
+)
+
class CommandLogger:
- def __init__(self, cmd):
+ def __init__(self, cmd, rw=False):
self.cmd = cmd
+ self.rw = rw
def do_simulation(self, s):
elts = ["@" + str(s.cycle_counter)]
print("\t".join(elts))
def get_fragment(self):
- return Fragment(sim=[self.do_simulation])
+ if self.rw:
+ comb = [self.cmd.ack.eq(1)]
+ else:
+ comb = []
+ return Fragment(comb, sim=[self.do_simulation])
class SlotsLogger:
def __init__(self, slicer, slots):
from migen.sim.generic import Simulator, TopLevel
from migen.sim.icarus import Runner
-from milkymist import asmicon
from milkymist.asmicon.bankmachine import _AddressSlicer, _Selector, _Buffer
-from common import SlotsLogger
-
-sdram_geom = asmicon.GeomSettings(
- bank_a=2,
- row_a=13,
- col_a=10
-)
+from common import SlotsLogger, sdram_geom
def my_generator(dt, offset):
for t in range(dt):