Git Product home page Git Product logo

Comments (4)

themperek avatar themperek commented on August 23, 2024

Try :
compile_args = ["-f", "/home/cmds.f"]

Should probably split this in code before passing to subprocess.

from cocotb-test.

gretzteam avatar gretzteam commented on August 23, 2024

This worked fine, thanks!

Related to this, would it make sense to add a default cmds.f file with decent timescale directive? I believe Icarus is mostly not usable as it is for most people and they will all have to figure out the funny way to set the timescale...

Something along those lines, but I'm sure there is a better way.

class icarus_custom(Icarus):
    def compile_command(self):
        if '-f' in self.compile_args:
            print('A command file is already provided.')
        else:
            print('Override default icarus timescale to 1ns/1ns. Create cmds.f file and add to compile_args')
            with open(self.sim_dir+"/cmds.f", 'w') as f:
                f.write("+timescale+1ns/1ns")  
            self.compile_args.extend(["-f", self.sim_dir+"/cmds.f"])

        cmd_compile = (
            ["iverilog", "-o", self.sim_file, "-D", "COCOTB_SIM=1", "-s", self.toplevel, "-g2012"]
            + self.get_define_commands(self.defines)
            + self.get_include_commands(self.includes)
            + self.compile_args
            + self.verilog_sources
        )

        return cmd_compile

from cocotb-test.

themperek avatar themperek commented on August 23, 2024

I am closing it.
In case it is still an issue please reopen.

from cocotb-test.

shuckc avatar shuckc commented on August 23, 2024

This is one of the things I imagine every Icarus user has to solve when moving from cocotb to cocotb-test - why is Icarus now complaining about timescales?

The Cocotb Makefile takes care of writing a default timescale to cmds.f file and including it here: https://github.com/cocotb/cocotb/blob/master/cocotb/share/makefiles/simulators/Makefile.icarus#L69
When cocotb-test invokes icarus it has no equivalent to set timescale https://github.com/themperek/cocotb-test/blob/master/cocotb_test/simulator.py#L421

Setting compile_args on every test is clunky, and it's not obvious how to replace SIM=icarus pytest . with a custom Icarus subclass (like icarus_custom above) without losing the ability to switch simulators from the command line. Here is one way:

from cocotb_test.simulator import run, Icarus
from cocotb_test import simulator

class IcarusAutoTimescale(Icarus):
    def compile_command(self):
        with open(self.sim_dir+"/cmds.f", 'w') as f:
            f.write("+timescale+1ns/1ns\n")
        self.compile_args.extend(["-f", self.sim_dir+"/cmds.f"])
        return super().compile_command()

simulator.Icarus = IcarusAutoTimescale

def test_fen_decode():
    run(
        verilog_sources=["hw/fen_decode.sv", "hw/ascii_int_to_bin.sv", "hw/onehot_to_bin.v"],
        toplevel="fen_decode",
        module="cocotb_fen_decode"
    )

It's especially odd given all the support to handle Icarus.waves = True which writes a custom modules and adds a new top level.

from cocotb-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.