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

Learning VHDL with GHDL #1291

Open
eine opened this issue May 8, 2020 · 25 comments
Open

Learning VHDL with GHDL #1291

eine opened this issue May 8, 2020 · 25 comments
Labels
Documentation: General General documentation issues. Documentation: Wiki Related to documentation written in the Wiki

Comments

@eine
Copy link
Collaborator

eine commented May 8, 2020

The documentation of GHDL contains a brief Quick Start Guide to introduce GHDL's CLI interface to users, but it does not contain an introduction to VHDL. There are many examples scattered in the repos:

  • The testsuite of the main repo contains hundreds of reproducible examples. These are mostly undocumented, but most of them are small and are related to some public discussion.
  • The examples and testsuite of ghdl-yosys-plugin contain tens of examples too. These use the plugin along with open source P&R and programming tools, such as nextpnr, icestorm, openocd, etc.
  • Documented co-simulation examples about VPI and VHPIDIRECT are available in ghdl.github.io/ghdl-cosim.

However, since many users learn about both VHDL, GHDL and sometimes digital design at the same time, previous resources might be too harsh. The purpose of this document is to gather references to open/free (as in free beer) tutorials, guides, books, blog post, repositories, etc. which use VHDL (and optionally GHDL).

See also Talks, presentations and other communications about GHDL and Target projects for synthesis.

Moreover, the following repositories (in case insensitive alphabetical order) might be useful for searching solutions to common designs/problems:

@Xiretza
Copy link
Contributor

Xiretza commented May 8, 2020

@Domipheus' VHDL CPU series comes to mind; it started out as a custom ISA CPU called TPU and was later spun off into a RISC-V CPU called RPU, complete with an Arty-S7 based SoC. The source repos haven't been updated with the blog in a while unfortunately, but they still contain a lot of great reference designs.

It's based entirely on Vivado, but at least the CPU should be fairly easy to port to ghdl if it doesn't work OOTB anyway.

@tgingold
Copy link
Member

tgingold commented May 8, 2020 via email

@eine
Copy link
Collaborator Author

eine commented May 8, 2020

@tgingold, on the one hand, there is no "discussion" feature in the wiki. Hence, I thought that it would be good to have an issue for that purpose, regardless of the main message being later moved elsewhere. On the other hand, if we create ghdl/ghdl-examples, this can be the first README.

@Xiretza, thanks for the references. I added them above.

@eine eine added Documentation: General General documentation issues. Documentation: Wiki Related to documentation written in the Wiki labels May 8, 2020
@tgingold
Copy link
Member

tgingold commented May 9, 2020 via email

@eine
Copy link
Collaborator Author

eine commented May 9, 2020

Is it possible to submit a PR for a wiki page ? I don't think so, so having a list in a file would be simpler for updates.

The wiki is a git repo: https://github.com/ghdl/ghdl.wiki

However, there is no GUI to handle PRs. We would need to create a separate repo and keep it in sync with the wiki here. Anyway, I think that the wiki is currently open for anyone to edit, not just for maintainers/contributors.

create ghdl/ghdl-examples (or should it be ghdl/ghdl-tutorial ?)

I think it should be ghdl-examples, because I'd expect it to contain different types of resources:

  • VHDL tutorials
  • Specific guides about e.g. how to read binary files or code coverage
  • PSL examples would be in-between a guide and a tutorial
  • Makefiles, build script and assets for multiple P&R tools (nextpnr, Vivado, Quartus...)

Some examples might be elaborated as tutorials, but many others might be contributed as code sources only. Overall, I'd expect to put in ghdl-examples all the MWEs that are not just tests for ghdl or ghdl-yosys-plugin. Nonetheless, ghdl or ghdl-yosys-plugin can use ghdl-examples as part of their test suites.

@tgingold
Copy link
Member

tgingold commented May 9, 2020 via email

@brimdavis
Copy link

@eine I have some examples with simple self-contained testbenches on github that might be of use for this.

Combinatorial bit counting and testbench with simple makefile (mcode) flow:
https://github.com/brimdavis/fpga_stuff/tree/master/bit_count

The following pieces of my homebrew RISC processor repo were written long ago for a Windows box (originally VHDL Simili 1.5, later GHDL) and use a simple .bat file flow for an mcode simulator.

UART with self-checking testbench:
https://github.com/brimdavis/yard-1/tree/master/hdl/cores/m_uart

Switch debouncer:
https://github.com/brimdavis/yard-1/tree/master/hdl/common/debounce

-Brian

p.s. probably off-topic for 'starter' examples, but the YARD-1 processor instruction verification tests use an simple yet effective technique in which small assembly test programs including 'verify' directives are simulated on the processor and post-processed to implement simulation time assertions regarding processor state, as described here back in 2001:
https://groups.io/g/fpga-cpu/message/660
I'd probably implement the verification testbench differently now than 20 years ago, but it still gets the job done...
https://github.com/brimdavis/yard-1/tree/master/verify

@eine
Copy link
Collaborator Author

eine commented May 12, 2020

@brimdavis, nice to meet you and thanks a lot! I added your references to the list above. When repo ghdl-examples is created, I might further copy your previous message almost as is. I cannot learn each resource to write an accurate description myself, but I'd like to briefly describe the resources whose authors do step by. Precisely, your comments about some of the resources being written 20 years ago are very relevant, because they allow users to understand the context and which language features were available at that time.

Furthermore, the purpose is to gather resources for learning VHDL, which can be optionally and preferredly used with GHDL. However, neither do all resources need to be starters nor do all of them need to work with GHDL out of the box. With VHDL and GHDL one can never stop learning, so examples about 'intermediate' and 'advanced' features are much welcome too. Precisely, it is relatively easy to simulate any design (small or huge) with GHDL. However, we are lacking friendly resources related to other features: advanced verification methodologies/frameworks, formal verification, mixed-language synthesis, mixed-language simulation, mixed-signal simulation, code coverage, etc. Hence, your verification solution is very interesting for users to evaluate how to and how not to do it in 2020.

@kost
Copy link

kost commented May 22, 2020

I have lot of basic GHDL examples already available here:

https://github.com/kost/ulx3s-ghdl-examples

Feel free to take them. If there's any way I can make it more available for your needs - do let me know!

@eine
Copy link
Collaborator Author

eine commented May 22, 2020

@kost, thanks! I added it to the list above.

Feel free to take them. If there's any way I can make it more available for your needs - do let me know!

IMHO, it would be useful to have some minimal CI workflow that executes the examples. That allows new users to see what output they should expect when they execute them locally. There are multiple examples about how to setup GHDL in CI, with or without docker containers. Please, let us know if you want to discuss implementation alternatives.

@hackfin
Copy link

hackfin commented Jul 10, 2020

I forked some GHDL specifics off a Python/Jupyter notebook based playground (with Python being the general HDL), more or less for documentation purposes:

https://github.com/hackfin/hdlplayground

It's runnable as virtual machine in the pretty awesome mybinder.org service (hopefully for a while).
There's some MyHDL based Cosimulation framework in there to help with post-synth(map) simulation through yosys and test the GHDL yosys plugin.

From the current research it appears that the Binder approach of running HDL/synthesis from the browser is not too popular, but I think beginners might pick up on it, as one reads how-to instructions and executable example code 'inline (interactive step by step). So it can be used as a linear IDE. Plus there's kinda built-in testing framework to ensure that the examples reproduce.

However it's far from complete and there's not much activity expected to happen on this end, but plans are to move 'stable' examples into the notebooks for the future for better documentation/presentation.

@eine
Copy link
Collaborator Author

eine commented Aug 1, 2020

I added a couple of references to hackaday projects by Yann Guidon in the list above. Nonetheless, at ygdes.com users will find many VHDL related projects: CPUs (F-CPU, YASEP, YGREC), co-simulation extensions (http://ygdes.com/GHDL)...

@eine
Copy link
Collaborator Author

eine commented Sep 1, 2020

I added references to some blogs posts about "Learning FPGA programming, key points for a software developer":

@targeted, how did you draw all those nice diagrams?

@targeted
Copy link

targeted commented Sep 1, 2020

@eine
Thank you !
The tool I used is https://excalidraw.com/

@diogratia
Copy link

Peter Ashenden wrote an 82 page tutorial on VHDL to go with an Elsevier book on computer design in 2004 also found as a companion material for another book.

The VHDL Tutorial (PDF) is also found on the Internet Archive where it should remain available even should the book(s) become unavailable.

@eine
Copy link
Collaborator Author

eine commented Nov 21, 2020

I added the folowing references:

I don't know a word of czech, so I mostly guessed that the book itself is not open/public (but it is rather cheap, ~15€), however, there are dozens of references for learning VHDL and a bunch of open source IP cores. I'd be glad if anyone could confirm.

@targeted
Copy link

@eine

I don't know a word of czech, so I mostly guessed that the book itself is not open/public (but it is rather cheap, ~15€), however, there are dozens of references for learning VHDL and a bunch of open source IP cores. I'd be glad if anyone could confirm.

From the pure similarity between Czech and Russian, this here https://datacipy.cz/
"E-book je dostupný pod volnou licencí CC jako PDF • EPUB • MOBI"
says that the e-book is available for download under free CC license.

Also in the book itself:
"Toto autorské dílo podléhá licenci Creative Commons BY-ND 3.0 CZ"

And from https://github.com/datacipy/VHDL
"Vše pod otevřenými licencemi MIT, pokud není uvedeno jinak (např. CC nebo GPL). "
Says that all the utilities that accompany the book are available under open MIT licenses, unless otherwise noted.

@eine
Copy link
Collaborator Author

eine commented Nov 23, 2020

@targeted, thanks so much for explaining. I added the links to PDF, EPUB and MOBI above. I'm glad I misunderstood the openness of the book 😅

@maly, congratulations on that very nice work!

@maly
Copy link

maly commented Nov 23, 2020

@eine Thank you a lot. And I, as the author, have to say @targeted is right: The whole book content is under the CC-BY-ND license. The code examples I wrote (published at https://github.com/datacipy/VHDL) are under the MIT license. Some libraries or entities are from other authors - like T80 - and they're licensed under their own licenses (mostly MIT / BSD / GPL / LGPL).

Let me say it is my third book (an "electronics trilogy"). The first one was about the gates, transistors, volts, sensors, etc. The second one was about the "computer building" (illustrated on the 8bit single board computers, based on CPUs 8085, 6502, and 6809) and "programming in assembler". And the whole trilogy is under the CC-BY-ND, all constructions and software are under MIT or CERN OHL...

Thank you, guys, for awesome work with the GHDL! It is a great tool, which allows me not to focus only on the Quartus IDE and embedded Multisim, but on the VHDL code and its testing itself.

@eine
Copy link
Collaborator Author

eine commented Feb 4, 2021

I added @rodrigomelo9's "Fundamentals of VHDL (Hardware Description Language)" (slides, video) at the Joint ICTP-IAEA School on FPGA-based SoC and its Applications for Nuclear and Related Instrumentation. Find other talks: http://indico.ictp.it/event/9443/other-view?view=ictptimetable.

@rodrigomelo9
Copy link
Contributor

Thanks @eine. Today, I will give the second part, related to simulation and of course, GHDL :-D. Slides are already available.

Regards

@JC-LL
Copy link

JC-LL commented Feb 4, 2021

Maybe you could add this marvelous tool, based on GHDL in the list.

https://gitlab.ensta-bretagne.fr/bollenth/ghdl-vpi-virtual-board

It allows to quickly play with a GHDL-based virtual board : LEDs, switches, buttons, seven segments.

Regards

@umarcor
Copy link
Member

umarcor commented Feb 5, 2021

@JC-LL, such an interesting reference! Congratulations to Théotime for that nice work! I added it to https://ghdl.github.io/ghdl-cosim/vpi/examples/other.html and https://github.com/dbhi/vboard.

@umarcor
Copy link
Member

umarcor commented Sep 19, 2021

Added a ref to xupgit/VHDL (Open Hardware 2015: TU Crete; Game of Life), authored by @nkyparissas. Also to nkyparissas/Cellular_Automata_FPGA, by the same author.

@umarcor
Copy link
Member

umarcor commented Sep 24, 2021

Added a ref to a tutorial about GHDL and OpenLane based on the adder from the Quick Start Guide: britovski/adder (translation of staydh/adder).

/cc @britovski @staydh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: General General documentation issues. Documentation: Wiki Related to documentation written in the Wiki
Projects
None yet
Development

No branches or pull requests