Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using yowasp when yosys is not available. #283

Merged

Conversation

antoinevg
Copy link
Member

While YosysHQ's OSS CAD Suite distribution is readily available it can be somewhat overwhelming to install for beginners.

To make it easier for readers of our gateware tutorials this PR adds support to LUNA for using YoWASP's WASM-based packages for Yosys and NextPNR if there aren't any other Amaranth-supported toolchains available.

The logic works as follows:

  1. Check if platform has all required tools with platform.has_required_tools(). If it has, do nothing further and continue to the build.
  2. Otherwise, start by setting the problem count to 0 and then:
  3. Check if the following Python modules can be imported, incrementing the problem count if it cannot.
  • yowasp_yosys
  • yowasp_nextpnr-<target> where <target> is obtained from platform.required_tools.
  1. Check if the tool binaries are abailable on the system PATH:
  • If it is found, set the environment variable for TOOL_NAME to yowasp-tool-name so that Amaranth will use the YoWASP binary instead of he Yosys binary.
  • Otherwise, increment the problem count.
  1. If the problem count is zero, return and continue to the build.
  2. If the problem count is non-zero output a helpful message and continue to the build anyway. (The build could still succeed anyway if someone is using a strange or unusual toolchain.)

@antoinevg antoinevg merged commit ff0b1db into greatscottgadgets:main Dec 17, 2024
8 checks passed
@whitequark
Copy link

Nice!

You could further make this more robust by using {sys.executable} -m yowasp_yosys instead of yowasp-yosys. Now it does not depend on PATH at all, and works when launched out of a virtualenv that is not activated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants