From 15e584d8805c02ced84102515ba9512a438f1745 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 20 Sep 2018 12:20:48 +0200 Subject: [PATCH] targets/sim: generate analyzer.csv --- litex/boards/targets/sim.py | 6 ++++- litex/build/sim/verilator.py | 51 ++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/litex/boards/targets/sim.py b/litex/boards/targets/sim.py index df0264ea..7291274f 100755 --- a/litex/boards/targets/sim.py +++ b/litex/boards/targets/sim.py @@ -174,6 +174,7 @@ def main(): sim_config.add_module("ethernet", "eth", args={"interface": "tap0", "ip": "192.168.1.100"}) if args.with_etherbone: sim_config.add_module('ethernet', "eth", args={"interface": "tap1", "ip": "192.168.1.101"}) + soc = SimSoC( with_sdram=args.with_sdram, with_ethernet=args.with_ethernet, @@ -182,7 +183,10 @@ def main(): **soc_kwargs) builder_kwargs["csr_csv"] = "csr.csv" builder = Builder(soc, **builder_kwargs) - builder.build(sim_config=sim_config) + vns = builder.build(run=False, sim_config=sim_config) + if args.with_analyzer: + soc.analyzer.export_csv(vns, "analyzer.csv") + builder.build(build=False, sim_config=sim_config) if __name__ == "__main__": diff --git a/litex/build/sim/verilator.py b/litex/build/sim/verilator.py index 07840b82..1e6176ea 100644 --- a/litex/build/sim/verilator.py +++ b/litex/build/sim/verilator.py @@ -145,35 +145,40 @@ def _run_sim(build_name, as_root=False): class SimVerilatorToolchain: def build(self, platform, fragment, build_dir="build", build_name="dut", - toolchain_path=None, serial="console", run=True, verbose=True, + toolchain_path=None, serial="console", build=True, run=True, verbose=True, sim_config=None): + os.makedirs(build_dir, exist_ok=True) os.chdir(build_dir) - if not isinstance(fragment, _Fragment): - fragment = fragment.get_fragment() - platform.finalize(fragment) - - v_output = platform.get_verilog(fragment, name=build_name) - named_sc, named_pc = platform.resolve_signals(v_output.ns) - v_output.write(build_name + ".v") - - include_paths = [] - for source in platform.sources: - path = os.path.dirname(source[0]).replace("\\", "\/") - if path not in include_paths: - include_paths.append(path) - include_paths += platform.verilog_include_paths - _generate_sim_h(platform) - _generate_sim_cpp(platform) - _generate_sim_variables(include_paths) - if sim_config: - _generate_sim_config(sim_config) - _build_sim(platform, build_name, verbose) + if build: + if not isinstance(fragment, _Fragment): + fragment = fragment.get_fragment() + platform.finalize(fragment) + + v_output = platform.get_verilog(fragment, + name=build_name, dummy_signal=False, regular_comb=False, blocking_assign=True) + named_sc, named_pc = platform.resolve_signals(v_output.ns) + v_output.write(build_name + ".v") + + include_paths = [] + for source in platform.sources: + path = os.path.dirname(source[0]).replace("\\", "\/") + if path not in include_paths: + include_paths.append(path) + include_paths += platform.verilog_include_paths + _generate_sim_h(platform) + _generate_sim_cpp(platform) + _generate_sim_variables(include_paths) + if sim_config: + _generate_sim_config(sim_config) + + _build_sim(platform, build_name, verbose) if run: _run_sim(build_name, as_root=sim_config.has_module("ethernet")) - os.chdir("..") + os.chdir("../../") - return v_output.ns + if build: + return v_output.ns \ No newline at end of file -- 2.30.2