ghdl-yosys-plugin compilation failed - yosys

I am about to test GHDL and Yosys as a replacement of EDA proprietary design flows, for my students. My point is about VHDL synthesis.
I have a fresh install of several tools : trellis (ECP5), yosys, nexpnr, fujprog (ulx3s).
GHDL is also installed for a longer time but it is supposed to include synthesis also (--synth option works).
ghdl -v
GHDL 1.0-dev (v0.37.0-208-g2c66a8bd) [Dunoon edition]
Compiled with GNAT Version: Community 2019 (20190517-83)
llvm code generator
It seems that I also need ghdl-yosys-plugin. However, the install does not work for me.
I get a bunch of error messages :
make GHDL=/opt/ghdl/bin/ghdl
yosys-config --exec --cxx -c --cxxflags -o ghdl.o src/ghdl.cc -fPIC -DYOSYS_ENABLE_GHDL -I/opt/ghdl/include -O
src/ghdl.cc:361:2: error: unknown type name 'Attribute'
Attribute attr = get_first_attribute (inst);
^
src/ghdl.cc:361:19: error: use of undeclared identifier 'get_first_attribute'
Attribute attr = get_first_attribute (inst);
^
src/ghdl.cc:379:7: error: use of undeclared identifier 'Id_Posedge'; did you mean 'Id_Edge'?
case Id_Posedge:
^~~~~~~~~~
Id_Edge
etc
I am missing something. Can someone help ?
Thanks in advance
JCLL

As I suspected (despite versioning that seemed correct), a fresh new install of GHDL fixed the issue.

i did some investigating: ghdl has undergone some restructuring, for proper FHS compliance. for example this commit https://github.com/ghdl/ghdl/commit/66cd5e0aa897b947533d269535fde4c0852472c2 and further commits show some renaming which ensures compliance with FHS conventions. files that used to be installed as /usr/local/include/ghdhsynth.h are now in /usr/local/include/ghdl
however because there are two completely separate pieces of software involved here (ghdl and yosys-ghdl-plugin) you have to (a) keep them in sync and (b) ensure that prior-installed ghdl headers are manually cleared out HOWEVER
manually deleting the installed files in /usr/local/include and reinstalling may not help if you cross over the threshold of commits from stable to developer releases on one but not the other, because older versions of yosys-ghdl-plugin were also not FHS convention-compliant. or, if you don't get them exactly right (i had to check the git log commit timestamps for both ghdl and ghdl-yosys-plugin in order to get a match), you get the general idea
if you really want to use a mis-matched version of ghdl and ghdl-yosys-plugin (YMMV here) then there are a few solutions:
manually copy the files in /usr/local/include/ghdl into /usr/local/include. this is a really dreadful hack that will need repeating each time you re-install ghdl.
modify the yosys-ghdl-plugin Makefile to include "-I/usr/local/include/ghdl" in CFLAGS or ALL_CFLAGS
in ghdl/synth.h and anywhere you see ghdl/synth.h used replace it with just "synth.h", likewise with synth_gates.h.
bear in mind that all of these are absolutely awful, totally not guaranteed to work, and you are way better off making sure that the versions being used are properly in sync.
it also does not help that some things from yosys latest master are also being removed, on which yosys-ghdl-plugin relies, to compile! as of writing i have found that tag yosys-1.13, ghdl-plugin commit c9b05e481423c, and ghdl commit 263c843ed49 will compile and work. however if i update to latest ghdl master (0e46300) microwatt fails to build, so i am sticking with 263c843 for now.
YMMV, hopefully however that gives you some insights rather than considering these complex and fantastically useful pieces of interlinked software to be opaque black boxes.

Related

NIST Round 3 Classic McEliece Missing Libkeccek.a.headers/SimpleFIPS202.h

I am attempting to build the KAT's for the round 3 submission for Classic McEliece, based off the reference implementation on this site:
https://csrc.nist.gov/Projects/post-quantum-cryptography/post-quantum-cryptography-standardization/round-3-submissions
When I try and build it, I get the error:
libkeccak.a.headers/SimpleFIPS202.h
I have attempted to build XKCP by cloning this repo: https://github.com/XKCP/XKCP
and running: make generic64/libXKCP.a
I can see that this builds, and I get a directory within the repo ./bin/generic64/libXKCP.a.headers
Has the name of this project changed since the round 3 submissions were released, or should I be looking for a different repository?
If this is correct, I still cannot build Classic McEliece, even if I change all references from libkeccak.a.headers/SimpleFIPS202.h to libXKCP.a.headers/SimpleFIPS202.h
Do I need to move this directory: ./bin/generic64/libXKCP.a.headers somewhere to allow gcc to find it? (I am on wsl)
Managed to fix it myself.
This question helped me: C++ Using Keccak Library
I had to clone those repos to the correct spot.
Then you need to change the include from libkeccak.a.headers/SimpleFIPS202.h to libXKCP.a.headers/SimpleFIPS202.h , as I guessed.
After that, you also need to change one of the flags in compilation from -lkeccak to -lXKCP (I couldnt find a reference anywhere, so this was a guess, but it worked.)

Generate Lint targets using cmake (Flexelint/Linux)

I am working on a C/C++ product that only builds in the Linux environment. It is a massive code base and generating lint targets manually is going to be incredibly painful. I know that you can link Lint into cmake so cmake generates these targets for you while it builds the code. Cmake has a macro called add_pc_lint (https://cmake.org/Wiki/PC-Lint) which does this for you. I wanted to know if there is something similar that could be used for Flexelint?
I currently have a PC-Lint license and wanted to ask this question before spending $998 on a Flexelint license. Thanks!
FlexeLint and PC-lint share the same manual so I'm pretty sure they are fully compatible on the command line. You should be able to use the same make files for both, or with minor changes. Otherwise they do offer a 30-day money-back guarantee.
Another option might be to run PC-lint under Wine. I tried this once and I got it working, but then I never used it much so I'm not sure how well it worked.
So I did get a FlexeLint license yesterday and now I am trying to integrate it into my CMakeLists. I am looking at the source code of cmake's add_pc_lint function and trying to modify it to work for FlexeLint. If anyone has played around with it before, please comment. The FlexeLint manual is not at all helpful.

How can a modified Julia package be used natively?

So, there is this cool package I've found but it leaves a lot to be desired. Since it made more sense to modify it, rather than build a new one myself, I changed the code in the corresponding source directory (C:\Users[my username].julia\v0.4[package name]\src). I made sure to modify not just the base.jl file, but also the [name of package].jl one so that there are no issues with dependencies or the new functions I added. I tried running the package several times to ensure that Julia doesn't spit out any errors or exceptions (the original package had some deprecated stuff, which I also remedied). Still, I fail to use the additional functionality of the package that I augmented. Any help would be greatly appreciated.
I'm using Julia ver 0.4.2, on a Windows 7 machine. As an IDE I use Notepad++. Thanks
I'm not exactly sure what you tried, but here's a guess as to what's going on: if you've already loaded the package in your julia session, edits to the source files won't take effect unless you explicitly reload the package. There are some good workflow tips here, and more explanation of the module system here.
However, for a newbie the easiest thing might be to quit julia and restart.
As far as making changes to a package, as Gnumic commented, your best approach is to make a branch and commit your changes there. Once you become convinced your changes represent an improvement, consider sharing your changes with the rest of the world.

Elixir: lint for confirming that every function has type sepcification

Is there a lint for Elixir (like for Javascript) which checks that every function has a type specification?
There is an Erlang compiler switch, +warn_missing_spec, which does this, but I'm having trouble getting it to work with Elixir at the moment, I think there is a bug with it's parsing of the ELIXIR_ERL_OPTS environment variable which is converting +warn_missing_spec into -warn_missing_spec which isn't a valid compiler option. I'm going to open an issue on the tracker, but thought you might like to know that this does indeed exist.
EDIT: As José mentioned below, the correct flag is ERL_COMPILER_OPTIONS. You can enable the missing spec warning during compilation by doing the following:
ERL_COMPILER_OPTIONS="warn_missing_spec" mix compile
Keep in mind you may get superfluous warnings from Elixir itself, for functions like __MODULE__. It should still be useful though. One last thing to note, I discovered this morning that there is a problem using this flag with mix compile, and that it's currently only warning about mix.exs. This is being fixed, and may even be fixed by the time you see this, but it's something to be aware of.

PC Lint for incremental build - with error from latest code

I am having a CI setup with incremental build. As part of the static checking, I am planning to configure a incremental PC Lint report - This report ignoring all other previous Lint report should provide the errors induced in the new code only. Is there any tool which would do this?
Any hint on the relative area to explore would help us.
I tried report diff'ing. But since the line number would vary from last check-in, would not get the actual incremental error introduced.
I am using Linux for my project build, and using Windows for PC Lint report generation.
Regards,
Wouldn't it be easier to just fix all the reported errors, and have a strict policy against creating new ones? That way you don't need to worry about diffs which by the nature of the problem is going to be hard to impossible.
You could write a script that takes the warnings from lint, removes the line numbers and adds a few lines from the source code around where the warning occurs. Diffing this would show all new lint warnings. One flaw in this, is that it would also show any warnings where source was modified near an existing warning without fixing the warning. On the other hand, this might actually be useful.
Years ago, I saw a utility on BDS Unix that would take your compiler errors and stuff them into your source code as comments. Which might be useful for this exercise. Unfortunately I can't remember what it was called.