Skip to content

Commit f9c96a5

Browse files
committed
Update tests and docs. Rename config 'pad-ring' to 'package'
1 parent 15fa563 commit f9c96a5

File tree

10 files changed

+128
-65
lines changed

10 files changed

+128
-65
lines changed

chipflow_lib/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ def _ensure_chipflow_root():
7373
"type": "object",
7474
"required": [
7575
"process",
76-
"pad_ring",
77-
"pads",
76+
"package",
7877
],
7978
"additionalProperties": False,
8079
"properties": {
8180
"process": {
8281
"enum": ["sky130", "gf180", "customer1", "gf130bcd", "ihp_sg13g2"]
8382
},
84-
"pad_ring": {
83+
"package": {
8584
"enum": ["caravel", "cf20", "pga144"]
8685
},
8786
"pads": {"$ref": "#/$defs/pin"},

chipflow_lib/pin_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def lock_pins() -> None:
8282
oldlock = LockFile.model_validate_json(json_string)
8383

8484
print(f"Locking pins: {'using pins.lock' if lockfile.exists() else ''}")
85-
package_name = config["chipflow"]["silicon"]["pad_ring"]
85+
package_name = config["chipflow"]["silicon"]["package"]
8686

8787
if package_name not in PACKAGE_DEFINITIONS:
8888
logger.debug(f"Package '{package_name} is unknown")

chipflow_lib/steps/silicon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def submit(self, rtlil_path, *, dry_run=False):
135135
"dependency_versions": dep_versions,
136136
"silicon": {
137137
"process": self.silicon_config["process"],
138-
"pad_ring": self.silicon_config["pad_ring"],
138+
"package": self.silicon_config["package"],
139139
"pads": pads,
140140
"power": self.silicon_config.get("power", {})
141141
}

docs/chipflow-toml-guide.rst

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Intro to chipflow.toml
2-
======================
1+
Intro to ``chipflow.toml``
2+
==========================
33

44
The ``chipflow.toml`` file provides configuration for your design with the ChipFlow platform.
55

@@ -14,25 +14,55 @@ Let's start with a typical example:
1414
# Assert that example-chipflow.toml matches the current config schema. If
1515
# this test fails, then its likely that the content in this file will need
1616
# to be updated.
17-
from chipflow_lib.cli import _parse_config_file
17+
from chipflow_lib import _parse_config_file
1818
_parse_config_file("docs/example-chipflow.toml")
1919

20-
project_id
21-
===========
20+
``[chipflow]``
21+
--------------
2222

23-
The ``project_id`` is set to the project ID which you can get from the ChipFlow app project page.
23+
.. code-block:: TOML
24+
25+
[chipflow]
26+
project_name = "my_project"
27+
28+
29+
The ``project_name`` is a human-readable identifier for this project. If not set, the tool and library will use the project name configured in ``pyproject.toml``.
30+
31+
``[chipflow.steps]``
32+
--------------------
33+
34+
The ``steps`` section allows overriding or addition to the standard steps available from `chipflow_lib`_.
35+
36+
For example, if you want to override the standard silicon preparation step, you could derive from :ref:`SiliconStep`, add your custom functionality
37+
and add the following to your `chipflow.toml`, with the appropriate Python `qualified name`_ :
38+
39+
.. code-block:: TOML
40+
41+
[chipflow.stepe]
42+
silicon = "my_design.steps.silicon:SiliconStep"
2443
25-
steps
26-
=====
2744
28-
The ``steps`` define the Python class which will be used as an entry point to these parts of the ChipFlow process.
2945
You probably won't need to change these if you're starting from an example repository.
3046

31-
silicon
32-
=======
47+
.. _chipflow_lib: https://github.com/ChipFlow/chipflow-lib]
48+
.. _qualified name: https://docs.python.org/3/glossary.html#term-qualified-name
3349

34-
The ``silicon`` section sets the Foundry ``process`` we are targeting for manufacturing, and the physical ``pad_ring`` we want to place our design inside.
35-
You'll choose the ``process`` and ``pad_ring`` based in the requirements of your design.
50+
51+
``[chipflow.clocks]``
52+
---------------------
53+
54+
``[chipflow.silicon]``
55+
----------------------
56+
57+
.. code-block:: TOML
58+
59+
[chipflow.silicon]
60+
process = "ihp_sg13g2"
61+
package = "pga144"
62+
63+
64+
The ``silicon`` section sets the Foundry ``process`` we are targeting for manufacturing, and the physical ``package`` we want to place our design inside.
65+
You'll choose the ``process`` and ``package`` based in the requirements of your design.
3666

3767
Available processes
3868
-------------------
@@ -56,12 +86,8 @@ Available pad rings
5686
+----------+-----------+--------------------+------------------------------------+
5787
| Pad ring | Pad count | Pad locations | Notes |
5888
+==========+===========+====================+====================================+
59-
|| caravel || TBC || TBC || The `Caravel Harness`_ contains |
60-
|| || || || additional logic which wraps your |
61-
|| || || || design. |
62-
|| || || || It handles its own power pins. |
6389
+----------+-----------+--------------------+------------------------------------+
64-
|| cf20 || 20 || ``N1`` ... ``N7`` || |
90+
|| cf20 || 20 || ``N1`` ... ``N7`` || Bare die package with 20 pins |
6591
|| || || ``S1`` ... ``S7`` || |
6692
|| || || ``E1`` ... ``E3`` || |
6793
|| || || ``W1`` ... ``W3`` || |
@@ -74,10 +100,12 @@ Available pad rings
74100
+----------+-----------+--------------------+------------------------------------+
75101

76102

103+
104+
77105
silicon.pads
78106
============
79107

80-
The ``silicon.pads`` section lists the pads we will be using.
108+
The ``silicon.pads`` section lists special pads. In general you are unlikely to need to add to this.
81109

82110
For each pad, there's a label which is used by our design, and what ``type`` and ``loc`` each pad should be.
83111

@@ -86,8 +114,8 @@ type
86114

87115
The ``type`` for each pad can be set to one of:
88116

89-
clk
90-
External clock.
117+
clock
118+
External clock input.
91119

92120
i
93121
Input.

docs/conf.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
# Add parent folder to path so we can pick up module
55
import os
6+
import sys
7+
sys.path.insert(0, os.path.abspath('../../chipflow_lib'))
8+
69
doctest_path = [os.path.abspath('..')]
710

811
# -- Project information
@@ -22,13 +25,39 @@
2225
'sphinx.ext.autodoc',
2326
'sphinx.ext.autosummary',
2427
'sphinx.ext.intersphinx',
28+
'sphinx.ext.napoleon'
2529
]
2630

31+
html_static_path = ['_static']
32+
html_logo = '_static/chipflow-logo.png'
33+
logo_only = True
34+
html_theme = 'sphinx_book_theme'
35+
36+
html_sidebars = {
37+
'**': [
38+
'relations.html', # needs 'show_related': True theme option to display
39+
'searchbox.html',
40+
]
41+
}
2742
intersphinx_mapping = {
2843
'python': ('https://docs.python.org/3/', None),
2944
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
45+
'chipflow': ('https://docs.chipflow.io/', None),
3046
}
3147
intersphinx_disabled_domains = ['std']
3248

49+
# Napoleon settings
50+
napoleon_google_docstring = True
51+
napoleon_numpy_docstring = True
52+
napoleon_include_init_with_doc = True
53+
napoleon_include_private_with_doc = True
54+
napoleon_include_special_with_doc = True
55+
napoleon_use_admonition_for_examples = False
56+
napoleon_use_admonition_for_notes = False
57+
napoleon_use_admonition_for_references = False
58+
napoleon_use_ivar = False
59+
napoleon_use_param = True
60+
napoleon_use_rtype = True
61+
3362
# -- Options for EPUB output
3463
epub_show_urls = 'footnote'

docs/example-chipflow.toml

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
11
[chipflow]
2-
project_id = 8
2+
project_name = "test-chip"
3+
4+
[chipflow.top]
5+
soc = "my_design.design:MySoC"
36

47
[chipflow.steps]
5-
sim = "my_design.steps.sim:MySimStep"
6-
board = "my_design.steps.board:MyBoardStep"
7-
silicon = "my_design.steps.silicon:MySiliconStep"
8-
software = "my_design.steps.software:MySoftwareStep"
8+
silicon = "chipflow_lib.steps.silicon:SiliconStep"
9+
10+
[chipflow.clocks]
11+
default = 'sys_clk'
12+
13+
[chipflow.resets]
14+
default = 'sys_rst_n'
915

1016
[chipflow.silicon]
11-
process = "sky130"
12-
pad_ring = "caravel"
17+
process = "gf130bcd"
18+
package = "pga144"
1319

1420
[chipflow.silicon.pads]
15-
sys_clk = { type = "clk", loc = "0" }
16-
sys_rstn = { type = "i", loc = "1" }
17-
uart_tx = { type = "o", loc = "2" }
18-
uart_rx = { type = "i", loc = "3" }
19-
flash_clk = { type = "o", loc = "4" }
20-
flash_csn = { type = "o", loc = "5" }
21-
flash_d0 = { type = "io", loc = "6" }
22-
flash_d1 = { type = "io", loc = "7" }
23-
flash_d2 = { type = "io", loc = "8" }
24-
flash_d3 = { type = "io", loc = "9" }
25-
gpio_0 = { type = "io", loc = "10" }
26-
gpio_1 = { type = "io", loc = "11" }
27-
gpio_2 = { type = "io", loc = "12" }
28-
gpio_3 = { type = "io", loc = "13" }
29-
gpio_4 = { type = "io", loc = "14" }
30-
gpio_5 = { type = "io", loc = "15" }
31-
gpio_6 = { type = "io", loc = "16" }
32-
gpio_7 = { type = "io", loc = "17" }
33-
btn_0 = { type = "io", loc = "18" }
34-
btn_1 = { type = "io", loc = "19" }
35-
jtag_tck = { type = "i", loc = "33" }
36-
jtag_tms = { type = "i", loc = "34" }
37-
jtag_tdi = { type = "i", loc = "35" }
38-
jtag_tdo = { type = "o", loc = "36" }
21+
# System
22+
sys_clk = { type = "clock", loc = "114" }
23+
sys_rst_n = { type = "reset", loc = "115" }
24+
25+
[chipflow.silicon.power]
26+
dvss0 = { type = "source", loc = "1" }
27+
dvdd0 = { type = "drain", loc = "9" }
28+
vss0 = { type = "source", loc = "17" }
29+
vdd0 = { type = "drain", loc = "25" }
30+
dvss1 = { type = "source", loc = "33" }
31+
dvdd1 = { type = "drain", loc = "41" }
32+
vss1 = { type = "source", loc = "49" }
33+
vdd1 = { type = "drain", loc = "57" }
34+
dvss2 = { type = "source", loc = "65" }
35+
dvdd2 = { type = "drain", loc = "73" }
36+
vss2 = { type = "source", loc = "81" }
37+
vdd2 = { type = "drain", loc = "89" }
38+
dvss3 = { type = "source", loc = "97" }
39+
dvdd3 = { type = "drain", loc = "105" }
40+
vss3 = { type = "source", loc = "113" }
41+
vdd3 = { type = "drain", loc = "121" }
42+
dvss4 = { type = "source", loc = "129" }
43+
dvdd4 = { type = "drain", loc = "137" }

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies = [
2727
"requests>=2.30.0",
2828
"python-dotenv>=1.0.1",
2929
"pydantic>=2.10.6",
30+
"sphinx-book-theme>=1.1.3",
3031
]
3132

3233
[project.scripts]
@@ -61,7 +62,7 @@ test-cov.cmd = "pytest --cov=chipflow_lib --cov-report=html"
6162
test.cmd = "pytest"
6263
test-docs.cmd = "sphinx-build -b doctest docs/ docs/_build"
6364
lint.cmd = "ruff check"
64-
document.cmd = "sphinx-build docs/ docs/_build/ -W --keep-going"
65+
docs.cmd = "sphinx-build docs/ docs/_build/ -W --keep-going"
6566

6667

6768
[dependency-groups]

tests/fixtures/mock.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ project_name = "proj-name"
55
silicon = "chipflow_lib.steps.silicon:SiliconStep"
66

77
[chipflow.silicon]
8-
process = "test"
9-
pad_ring = "cf20"
8+
process = "ihp_sg13g2"
9+
package = "pga144"
1010

1111
[chipflow.clocks]
1212
default = 'sys_clk'

tests/test_silicon_platform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SiliconPlatformTestCase(unittest.TestCase):
1717
def setUp(self):
1818
os.environ["CHIPFLOW_ROOT"] = os.path.dirname(os.path.dirname(__file__))
1919
current_dir = os.path.dirname(__file__)
20-
customer_config = f"{current_dir}/fixtures/chipflow-flexic.toml"
20+
customer_config = f"{current_dir}/fixtures/mock.toml"
2121
with open(customer_config, "rb") as f:
2222
self.config = tomli.load(f)
2323

tests/test_silicon_step.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import tomli
66
import unittest
77
from contextlib import redirect_stdout
8+
from pprint import pformat
89
from unittest.mock import patch
910

1011
from chipflow_lib.steps.silicon import SiliconStep
@@ -43,7 +44,7 @@ def setUp(self):
4344
@patch('dotenv.load_dotenv')
4445
@patch('requests.post', side_effect=mocked_requests_post)
4546
def test_submit_happy_path(self, mock_requests_post, mock_dotenv):
46-
customer_config = f"{current_dir}/fixtures/chipflow-flexic.toml"
47+
customer_config = f"{current_dir}/fixtures/mock.toml"
4748
with open(customer_config, "rb") as f:
4849
config_dict = tomli.load(f)
4950

@@ -73,10 +74,10 @@ def test_submit_happy_path(self, mock_requests_post, mock_dotenv):
7374
"amaranth-orchard", "amaranth-vexriscv",
7475
], "We have entries for the the dependency versions"
7576

77+
print(pformat(config))
7678
assert config["silicon"] == {
77-
'process': 'customer1',
78-
'pad_ring':
79-
'cf20',
79+
'process': 'ihp130',
80+
'package': 'pga144',
8081
'pads': {},
8182
'power': {
8283
'vss': {'loc': 'N1'},

0 commit comments

Comments
 (0)