From 75e9310097d9d09879a140fadf7b49f798b41fc3 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 8 Jun 2019 17:30:49 +0800 Subject: [PATCH] simplesoc_ecp5: add simulation --- examples/simplesoc_ecp5.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/examples/simplesoc_ecp5.py b/examples/simplesoc_ecp5.py index 277bdc1..a92a377 100644 --- a/examples/simplesoc_ecp5.py +++ b/examples/simplesoc_ecp5.py @@ -2,7 +2,7 @@ import argparse import struct from nmigen import * -from nmigen.back import rtlil +from nmigen.back import rtlil, pysim from heavycomps import uart, wishbone from minerva.core import Minerva @@ -27,8 +27,9 @@ class SimpleWishboneSerial(Elaboratable): class Top(Elaboratable): - def __init__(self, firmware): - self.clk100 = Signal() + def __init__(self, firmware, create_clock): + if create_clock: + self.clk100 = Signal() self.led = Signal() self.serial_tx = Signal() self.firmware = firmware @@ -36,9 +37,10 @@ class Top(Elaboratable): def elaborate(self, platform): m = Module() - cd_sync = ClockDomain(reset_less=True) - m.domains += cd_sync - m.d.comb += cd_sync.clk.eq(self.clk100) + if hasattr(self, "clk100"): + cd_sync = ClockDomain(reset_less=True) + m.domains += cd_sync + m.d.comb += cd_sync.clk.eq(self.clk100) counter = Signal(27) m.d.sync += counter.eq(counter + 1) @@ -64,23 +66,31 @@ def read_firmware(file): word = f.read(4) if len(word) < 4: break - firmware.append(struct.unpack(">I", word)[0]) + firmware.append(struct.unpack("