chili-chips-ba / openCologne

Spicing up the first and only EU FPGA chip with a flashy new board, loaded with a suite of engaging demos and examples. https://www.chili-chips.xyz/open-cologne
https://nlnet.nl/project/openCologne
BSD 3-Clause "New" or "Revised" License
46 stars 2 forks source link

GHDL-YOSYS-PLUGIN error: cannot find "std" library #24

Closed TarikHamedovic closed 3 months ago

TarikHamedovic commented 4 months ago

Issue 1: Relative Paths in cc-toolchain-linux

When you download and extract cc-toolchain-linux (tested on Linux; untested on Windows but likely the same), you get examples and tools such as yosys, p_r, and openFPGALoader. Running make synth_vhdl for examples like Blinky completes without issues. However, using the paths to yosys (from the extracted folder) in a different directory results in the following error:

warning: ieee library directory '../../bin/yosys/share/ghdl/ieee/v93/' not found
error: cannot find "std" library

This error occurs because the library path is relative, restricting the use of the tools to the cc-toolchain-linux folder. It should be clarified that if users wish to use yosys separately, they need to build it from source and set its path in the Makefile accordingly.

Issue 2: ghdl-yosys-plugin Installation Instructions

Following the GateMate Toolchain Installation Guide for yosys, ghdl, and ghdl-yosys-plugin, it is advisable to use the following commands for make and sudo make install for the ghdl-yosys-plugin to ensure it points to the correct GHDL installation executable. A colleague encountered an issue where sudo make install didn't place the ghdl.so plugin in /usr/local/share/yosys/plugins/, and the commands below resolved it:

git clone https://github.com/ghdl/ghdl-yosys-plugin.git
cd ghdl-yosys-plugin
make GHDL=/usr/local/bin/ghdl
sudo make GHDL=/usr/local/bin/ghdl install

Issue 3: Adding -m ghdl to synth_vhdl

After installing yosys, ghdl, and ghdl-yosys-plugin from source and adding them to your Makefile, running the command make synth_vhdl results in the following error:

Error: No such command ghdl(type 'help' for a command overview)

This problem is fixed by adding -m ghdl to the synth_vhdl command as follows:

$(YOSYS) -ql log/synth.log -m ghdl -p 'ghdl --warn-no-binding -C --ieee=synopsys $(VHDL_SRC) -e $(TOP); synth_gatemate -top $(TOP) -nomx8 -vlog net/$(TOP)_synth.v'

The -m ghdl flag ensures that the ghdl-yosys-plugin, which can be seen here, is correctly loaded. Running just yosys in your terminal and then running ghdl will give the same error, but running yosys -m ghdl will recognize the command. For example, running help ghdl in the yosys command terminal after yosys -m ghdl provides the following:

yosys> help ghdl

    ghdl [options] unit [arch]

Elaborate the already analyzed unit design and import it

    ghdl [options] files... -e [unit]

Analyse files, elaborate unit and import it
If unit is not specified, it is automatically found

Full list of options are described in ghdl documentation.

    --std=(93|08)
        set the vhdl standard.

    -C
        allow UTF-8 in comments.

    --ieee=synopsys
        allow use of ieee.std_logic_arith.

    -fpsl
        parse PSL in comments.

    --top-name=hash
        use hash to encode the top entity name

It should be clarified in the Makefile/Toolchain Installation guide that -m ghdl is required as explained above. Additionally, it is advisable to include a step to test if the ghdl-yosys-plugin is correctly installed by running the command yosys -m ghdl as described for added assurance. A question, out of curiosity, how did you make it work without the -m ghdl flag in your workspace?

Summary

To use make synth_vhdl command in your own workspace you need to: This installation assumes that everything is install in /usr/local/, if you want to change your yosys installation path for instance you need to use ./configure --prefix=<path/to/yosys/installation/you/want>

Install yosys

git clone https://github.com/YosysHQ/yosys.git
cd yosys
make config-clang
git submodule update --init
make -j$(nproc)
sudo make install

Install ghdl

git clone https://github.com/ghdl/ghdl.git
cd ghdl
./configure --prefix=/usr/local
make -j$(nproc)
sudo make install

Install ghdl-yosys-plugin

git clone https://github.com/ghdl/ghdl-yosys-plugin.git
cd ghdl-yosys-plugin
make GHDL=/usr/local/bin/ghdl -j$(nproc)
sudo make GHDL=/usr/local/bin/ghdl install

Check that in your yosys install directory, in this case usr/local/share/yosys/plugins there is ghdl.so Check yosys, ghdl, ghdl-yosys-plugin installation from terminal using which yosys, which ghdl and yosys -m ghdl commands respectively, all independent from another.

Change the synth_vhdl command

You need to add -m ghdl to the synth_vhdl command like this:

$(YOSYS) -ql log/synth.log -m ghdl -p 'ghdl --warn-no-binding -C --ieee=synopsys $(VHDL_SRC) -e $(TOP); synth_gatemate -top $(TOP) -nomx8 -vlog net/$(TOP)_synth.v'
TarikHamedovic commented 3 months ago

Closing this issue, because it is been resolved. And the issue can be used as documentation on how to resolve the GHDL GateMate problem.