Amaranth HDL 板定义项目教程
1. 项目的目录结构及介绍
Amaranth HDL 板定义项目的目录结构如下:
amaranth-boards/
├── CONTRIBUTING.txt
├── LICENSE.txt
├── README.md
├── pyproject.toml
├── github/
│ └── workflows/
│ └── amaranth_boards.yml
├── env/
│ └── toolchain/
└── amaranth_boards/
目录介绍
CONTRIBUTING.txt
: 贡献指南文件。LICENSE.txt
: 项目许可证文件,采用 BSD-2-Clause 许可证。README.md
: 项目说明文件。pyproject.toml
: 项目配置文件。github/workflows/
: GitHub Actions 工作流配置文件目录。env/toolchain/
: 环境工具链配置文件目录。amaranth_boards/
: 板定义文件目录。
2. 项目的启动文件介绍
项目的启动文件主要是 pyproject.toml
,这是一个标准的 Python 项目配置文件,用于定义项目的元数据和依赖关系。
pyproject.toml
文件内容示例
[project]
name = "amaranth-boards"
version = "0.0"
description = "Board definitions for Amaranth HDL"
authors = [
{ name="whitequark" }
]
dependencies = [
"amaranth"
]
3. 项目的配置文件介绍
项目的配置文件主要包括 pyproject.toml
和 amaranth_boards/
目录下的板定义文件。
pyproject.toml
配置文件
如上所述,pyproject.toml
文件定义了项目的名称、版本、描述、作者和依赖关系。
板定义文件
amaranth_boards/
目录下包含了具体的板定义文件,这些文件定义了不同开发板的硬件配置和接口信息。每个板定义文件通常包含以下内容:
- 板名称
- 硬件接口定义
- 引脚映射
示例板定义文件内容
from amaranth import *
from amaranth.build import *
class MyBoard(Platform):
def __init__(self):
self.name = "MyBoard"
self.default_clk = "clk"
self.add_resources([
Resource("clk", 0, Pins("1", dir="i"), Clock(100e6), Attrs(IOSTANDARD="LVCMOS33")),
Resource("led", 0, Pins("2", dir="o"), Attrs(IOSTANDARD="LVCMOS33")),
])
以上内容为 Amaranth HDL 板定义项目的简要教程,涵盖了项目的目录结构、启动文件和配置文件的介绍。