[Libre-soc-dev] Running the libre-soc CPU under cxxsim

Luke Kenneth Casson Leighton lkcl at lkcl.net
Tue Sep 22 12:35:19 BST 2020

On Tue, Sep 22, 2020 at 12:27 PM Cesar Strauss <cestrauss at gmail.com> wrote:
> Em 22/09/2020 07:26, Luke Kenneth Casson Leighton escreveu:
> >> Per discussion above, found a way to conditionally switch to cxxsim,
> >> without losing backwards compatibility with earlier nMigen git versions.
> >
> > fantastic.  i wonder, perhaps that can go into nmutils for now?
> Sure.
> Something like:
>     from nmutil.simulator_alternative import Simulator

yes.  from nmutil.sim_tmp_alternative, something like that.

>     engine = engine_alternative()  # engine name from environment

i was thinking along the lines of:

    from nmigen.something.sim import Simulator as RealSimulator
    detected_new_api = True
except ImportError:
   from nmigen.old.something import Simulator as RealSimulator
   detected_new_api = False

def Simulator(*args, **kwargs):
    if detected_new_api:
          kwargs['engine'] = nmigen_sim_environ_variable
    return RealSimulator(*args, **kwargs)

then everything is "hidden" behind that function, and the if elif elif
etc. inside every single unit test is not needed.

it is something like 70 unit tests that would otherwise need that if elif elif.


More information about the Libre-soc-dev mailing list