Skip to content

Commit 5999f10

Browse files
committed
Merge branch 'dev' into implements-options
2 parents a150ac9 + 29ed35a commit 5999f10

30 files changed

+504
-187
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ name: 'docs'
22

33
on:
44
push:
5+
paths:
6+
- 'docs/**'
57
branches:
6-
# - main
8+
- main
9+
- dev
710

811
jobs:
912
docs:
@@ -19,4 +22,4 @@ jobs:
1922
uses: peaceiris/actions-gh-pages@v4
2023
with:
2124
github_token: ${{ secrets.GITHUB_TOKEN }}
22-
publish_dir: docs/_build/html
25+
publish_dir: docs/build/html

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
.PHONY: docs
44

5+
all: docs lint test
6+
57
docs:
68
cd docs; make html
79

@@ -15,11 +17,7 @@ test:
1517

1618
clean:
1719
py3clean .
18-
cd docs; make clean
19-
rm -fr build .pytest_cache
20-
21-
submodule-init:
22-
git submodule update --init --recursive
23-
24-
submodule-update:
25-
cd examples/resources; git checkout main; git pull
20+
rm -fr docs/build
21+
rm -fr .pytest_cache
22+
rm -fr `find . -name results`
23+
rm -fr `find . -name __pycache__`

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SPHINXOPTS ?=
22
SPHINXBUILD ?= sphinx-build
33
SOURCEDIR = .
4-
BUILDDIR = _build
4+
BUILDDIR = build
55
HELPERS = $(BUILDDIR)/hdl2bit $(BUILDDIR)/prj2bit $(BUILDDIR)/bitprog
66

77
help:

docs/basic.rst

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ Basic usage
44
Project Configuration
55
---------------------
66

7-
The first steps involve importing the necessary module to support the desired tool and instantiating the corresponding *class*:
7+
The first steps involve importing the necessary module to support the desired tool and instantiating the corresponding ``class``:
88

99
.. code-block:: python
1010
1111
from pyfpga.vivado import Vivado
1212
1313
prj = Vivado('PRJNAME', odir='OUTDIR')
1414
15-
In the example, we are using Vivado, specifying the optional parameter *project name* (*tool name* if omitted) and *output directory* (*results* by default).
15+
In the example, we are using Vivado, specifying the optional parameters
16+
``project name`` (``tool name`` if omitted) and ``output directory``
17+
(``results`` by default).
1618

1719
Next step is to specify the target FPGA device:
1820

@@ -32,9 +34,8 @@ HDL source files are added using one of the following methods:
3234
prj.add_vlog('PATH_TO_FILES_GLOB_COMPATIBLE')
3335
prj.add_slog('PATH_TO_FILES_GLOB_COMPATIBLE')
3436
35-
In these methods, you provide a path to the files. The path can include wildcards (like `*.vhdl`), allowing you to match multiple files at once.
36-
37-
For `add_vhdl`, you can also optionally specify a library name where the files will be included.
37+
In these methods, you provide a path to the files. The path can include wildcards (like ``*.vhdl``), allowing you to match multiple files at once.
38+
In case of ``add_vhdl``, you can also optionally specify a library name where the files will be included.
3839

3940
.. note::
4041

@@ -43,6 +44,15 @@ For `add_vhdl`, you can also optionally specify a library name where the files w
4344
.. _glob: https://docs.python.org/3/library/glob.html
4445
.. _Path: https://docs.python.org/3/library/pathlib.html
4546

47+
.. hint::
48+
49+
Files are processed in the order they are added. If a file is specified more than once,
50+
it is removed from its previous position and placed at the end of the list.
51+
This allows you to ensure that a file is processed after others when necessary
52+
(e.g., placing a top-level at the end) or to customize options
53+
(e.g., removing a VHDL library specification in case of a top-level)
54+
when multiple files are added using a wildcard.
55+
4656
Generics/parameters can be specified with:
4757

4858
.. code-block:: python
@@ -82,7 +92,8 @@ After configuring the project, you can run the following to generate a bitstream
8292
8393
prj.make()
8494
85-
By default, this method performs *project creation*, *synthesis*, *place and route*, and *bitstream generation*.
95+
By default, this method performs **project creation**, **synthesis**, **place and route**,
96+
and **bitstream generation**.
8697
However, you can optionally specify both the initial and final stages, as follows:
8798

8899
.. code-block:: python
@@ -100,7 +111,8 @@ However, you can optionally specify both the initial and final stages, as follow
100111

101112
.. note::
102113

103-
After executing this method, you will find the file `<TOOL>.tcl` (or `sh` in some cases) in the output directory.
114+
After executing this method, you will find the file ``<TOOL>.tcl``
115+
(``<TOOL>.sh`` in some cases) in the output directory.
104116
For debugging purposes, if things do not work as expected, you can review this file.
105117

106118
Bitstream programming
@@ -112,13 +124,14 @@ The final step is programming the FPGA:
112124
113125
prj.prog('BITSTREAM', 'POSITION')
114126
115-
Both `BITSTREAM` and `POSITION` are optional.
116-
If `BITSTREAM` is not specified, PyFPGA will attempt to discover it based on project information.
117-
The `POSITION` parameter is not always required (depends on the tool being used).
127+
Both ``BITSTREAM`` and ``POSITION`` are optional.
128+
If ``BITSTREAM`` is not specified, PyFPGA will attempt to discover it based on project information.
129+
The ``POSITION`` parameter is not always required (depends on the tool being used).
118130

119131
.. note::
120132

121-
After executing this method, you will find the file `<TOOL>prog.tcl` (or `sh` in some cases) in the output directory.
133+
After executing this method, you will find the file ``<TOOL>prog.tcl``
134+
(``<TOOL>-prog.sh`` in some cases) in the output directory.
122135
For debugging purposes, if things do not work as expected, you can review this file.
123136

124137
Debugging

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# -- Project information -----------------------------------------------------
99

1010
project = 'PyFPGA'
11-
copyright = '2024, Rodrigo Alejandro Melo'
12-
author = 'Rodrigo Alejandro Melo'
11+
copyright = '2016-2024, PyFPGA Project'
12+
author = 'PyFPGA contributors'
1313

1414
# -- General configuration ---------------------------------------------------
1515

@@ -31,9 +31,9 @@
3131
'repositoy': ('https://github.com/PyFPGA/pyfpga/tree/main/%s', None)
3232
}
3333

34-
exclude_patterns = ['_build', 'wip']
34+
exclude_patterns = ['build']
3535

3636
# -- Options for HTML output -------------------------------------------------
3737

3838
html_theme = 'sphinx_rtd_theme'
39-
html_static_path = ['_static']
39+
html_static_path = ['images']

docs/extending.rst

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,76 @@
11
Extending
22
=========
33

4-
1. Add support for the new tool:
4+
.. note::
55

6-
.. code-block:: python
6+
All <TOOL> classes inherit from ``Project`` (``project.py``).
7+
8+
This is a guide on how to add support for a new TOOL.
9+
10+
Add support for the new tool
11+
----------------------------
12+
13+
.. code-block:: bash
714
815
pyfpga/templates/<NEWTOOL>.jinja
916
pyfpga/templates/<NEWTOOL>-prog.jinja
1017
pyfpga/<NEWTOOL>.py
18+
pyfpga/factory.py # UPDATE
19+
pyfpga/helpers/prj2bit.py # UPDATE
1120
12-
2. Include the new tool on Factory:
21+
Add tests and a tool mock-up
22+
----------------------------
1323

14-
.. code-block:: python
24+
.. code-block:: bash
1525
16-
pyfpga/factory.py
26+
tests/test_tools.py # UPDATE
27+
tests/support.py # UPDATE if exceptions are needed
28+
tests/mocks/<NEWCOMMAND>
1729
18-
3. Add tests and a tool mock-up:
30+
Add examples
31+
------------
1932

20-
.. code-block:: python
33+
.. code-block:: bash
2134
22-
tests/test_tools.py
23-
tests/mocks/<NEWTOOL_EXECUTABLE>
35+
examples/sources/cons/<NEWBOARD>/timing.<EXT>
36+
examples/sources/cons/<NEWBOARD>/clk.<EXT>
37+
examples/sources/cons/<NEWBOARD>/led.<EXT>
38+
examples/projects/<NEWTOOL>.py
39+
examples/projects/regress.sh # UPDATE
40+
examples/helpers/<NEWTOOL>.sh
41+
examples/hooks/<NEWTOOL>.py # OPTIONAL
2442
25-
4. Updated the project's documentation:
43+
Verify the code
44+
---------------
2645

27-
.. code-block:: python
46+
Run it at the root of the repo.
2847

29-
README.md
30-
docs
48+
.. code-block:: bash
3149
32-
5. [OPTIONAL] Add examples:
50+
make docs
51+
make lint
52+
make test
3353
34-
.. code-block:: python
54+
.. tip::
3555

36-
examples/sources/cons/<NEWBOARD>/timing.<EXT>
37-
examples/sources/cons/<NEWBOARD>/clk.<EXT>
38-
examples/sources/cons/<NEWBOARD>/led.<EXT>
39-
examples/projects/<NEWTOOL>.py
40-
examples/hooks/<NEWTOOL>.py
56+
You can simply run ``make`` to perform all the operations.
57+
Running ``make clean`` will remove all the generated files.
58+
59+
Verify the functionality
60+
------------------------
61+
62+
.. code-block:: bash
63+
64+
cd examples/projects/
65+
bash regress.sh <NEWTOOL>
66+
cd ../../tests/
67+
python3 support.py --tool <NEWTOOL>
68+
69+
Updated the documentation
70+
-------------------------
71+
72+
.. code-block:: bash
73+
74+
README.md
75+
docs/intro.rst
76+
docs/tools.rst

docs/helpers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ Helpers
44
hdl2bit
55
-------
66

7-
.. literalinclude:: _build/hdl2bit
7+
.. literalinclude:: build/hdl2bit
88

99
prj2bit
1010
-------
1111

12-
.. literalinclude:: _build/prj2bit
12+
.. literalinclude:: build/prj2bit
1313

1414
bitprog
1515
-------
1616

17-
.. literalinclude:: _build/bitprog
17+
.. literalinclude:: build/bitprog

docs/images/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/make
2+
3+
FILES = $(wildcard *.dot)
4+
FILES := $(basename $(FILES))
5+
FILES := $(addsuffix .svg,$(FILES))
6+
7+
ODIR = .
8+
9+
vpath %.svg $(ODIR)
10+
11+
%.svg: %.dot
12+
@mkdir -p $(ODIR)
13+
dot -Tsvg $< -o $(ODIR)/$@
14+
15+
all: $(FILES)
File renamed without changes.

docs/images/openflow.dot

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
digraph openflow {
2+
graph [ranksep=0.25];
3+
node [shape = doublecircle];
4+
node [shape = rectangle];
5+
GHDL "ghdl-yosys-plugin" Yosys "nextpnr-ice40" "nextpnr-ecp5" icetime icepack iceprog eccpack;
6+
node [shape = note ];
7+
VHDL Verilog;
8+
node [shape = box3d ];
9+
ice40;
10+
node [shape = oval];
11+
"bit-ice40" [label=".bit"];
12+
"bit-ecp5" [label=".bit"];
13+
VHDL -> {GHDL "ghdl-yosys-plugin"};
14+
GHDL -> "ghdl-yosys-plugin";
15+
"ghdl-yosys-plugin" -> Yosys;
16+
Verilog -> Yosys;
17+
Yosys -> ".json";
18+
".json" -> {"nextpnr-ice40" "nextpnr-ecp5"};
19+
"nextpnr-ice40" -> ".asc";
20+
"nextpnr-ecp5" -> ".config";
21+
".asc" -> {icetime icepack};
22+
icepack -> "bit-ice40";
23+
"bit-ice40" -> iceprog;
24+
iceprog -> ice40;
25+
".config" -> eccpack;
26+
eccpack -> "bit-ecp5";
27+
{rank = same; GHDL ; "ghdl-yosys-plugin"; Yosys;}
28+
}

0 commit comments

Comments
 (0)