一种用于构建硬件电路的嵌入式dsl

magma-lang的Python项目详细描述


岩浆

Documentation StatusBuild StatusCoverage Status

CHANGELOG

magma是一种嵌入python的硬件设计语言。

岩浆的中心提取是一个回路。 电路是连接在一起的一组功能单元。 岩浆回路对verilog模块是分析性的。 因此,所有的岩浆程序都保证是可合成的。 尽管将模块连接在一起可能看起来很低级, 它鼓励硬件设计师构建可重用的组件, 类似于程序员如何构建库。

Python用于创建岩浆回路。 使用脚本语言进行硬件设计的这种方法 在硬件社区中称为generators。 硬件生成器示例包括 算术单位, 线性反馈移位寄存器, 华莱士树, 以及分类网络。 软件工程师称这种技术为metaprogramming。 脚本语言是一个元程序 从某种意义上说,它是一个创建硬件程序的程序

与verilog相比, python具有强大的元编程功能, 比如decorators和元类。 这使得创造 高级领域特定语言(DSL)。 示例包括 有限状态机, 内存控制器, 图像和信号处理, 甚至处理器

学习岩浆最好的方法是通过例子。这个 magmathon存储库包含 安装magma的说明,以及一组Jupyter Notebooks 引入了这个系统。还有 magma_tutorial包含 一组基本电路和测试,为岩浆提供了一个示例模板 项目。另请参阅 documentation

岩浆的设计受 Chisel, 所以如果你懂凿子,岩浆应该很容易学。 凿子教程中的一些示例已移植到 岩浆可以在these notebooks中找到。 岩浆也有 FIRRTL后端, 我们希望很快通过firrtl展示与cricle的互操作性。

岩浆的作用是 Mantle 它包含一组有用的电路; 和Loam 用来表示零件和板, 并为独立的FPGA板构建应用程序

设置Python

我们建议使用python 3。本节介绍几种常见的方法 为了和Python相处。第一种(推荐)方法是 miniconda支持MacOS和Linux(和Windows,但magma支持 windows尚未测试)我们还提供使用标准的方法 MacOS和UbuntuLinux的包管理器。

通用

miniconda-免费的最小安装程序 康达。Miniconda是一个小型的,引导版本的水蟒,只包括 conda、Python、它们所依赖的包以及其他一些有用的包 包,包括pip、zlib和其他一些包。使用conda install命令 从Continuum存储库安装720多个附加Conda软件包。

从下载操作系统的安装程序 https://conda.io/miniconda.html

以下说明使用最新的MacOSX版本,替换中的链接 操作系统的wget命令。

$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
$ bash Miniconda3-latest-MacOSX-x86_64.sh
# Installing dependencies like matplotlib is typically more reliable with conda than pip
$ conda install matplotlib

MacOS/自制

$ brew install python3

Ubuntu

$ sudo apt-get install python3 python3-pip

用户设置

Magma以PIP软件包的形式提供,请使用以下命令安装最新版本:

pip install magma-lang

开发设置

克隆岩浆库

$ git clone https://github.com/phanrahan/magma
$ cd magma

将magma作为符号包安装

$ pip install -e .

安装测试基础设施并运行测试以验证设置

$ pip install pytest  # note that magma requires pytest version 3.3 or later
$ pytest tests

您应该看到类似

============================= test session starts ==============================
platform darwin -- Python 3.6.1, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: ..../repos/magmacore, inifile:
collected 70 items

tests/test_circuit/test_anon.py .
tests/test_circuit/test_declare.py .
tests/test_circuit/test_define.py .
tests/test_higher/test_braid.py .
tests/test_higher/test_curry.py .
tests/test_higher/test_currylut.py .
tests/test_higher/test_curryrom.py .
tests/test_higher/test_flat.py .
tests/test_higher/test_fork.py .
tests/test_higher/test_higher_compose.py .
tests/test_higher/test_join.py .
tests/test_interface/test_interface.py ....
tests/test_io/test_inout1.py .
tests/test_io/test_inout2.py .
tests/test_io/test_out1.py .
tests/test_io/test_out2.py .
tests/test_ir/test_declaretest.py .
tests/test_ir/test_ir.py .
tests/test_meta/test_class.py .
tests/test_meta/test_creg.py .
tests/test_simulator/test_counter.py .
tests/test_simulator/test_ff.py .
tests/test_simulator/test_logic.py .
tests/test_type/test_anon_type.py .
tests/test_type/test_array.py .
tests/test_type/test_array2d.py .
tests/test_type/test_arrayconstruct.py .
tests/test_type/test_arrayflip.py .
tests/test_type/test_arrayval.py .
tests/test_type/test_awire1.py .
tests/test_type/test_bit.py .
tests/test_type/test_bitflip.py .
tests/test_type/test_bitval.py .
tests/test_type/test_tuple.py .
tests/test_type/test_tupleconstruct.py .
tests/test_type/test_tupleflip.py .
tests/test_type/test_tupleval.py .
tests/test_type/test_twire1.py .
tests/test_type/test_type_errors.py ...
tests/test_type/test_vcc.py .
tests/test_type/test_whole.py .
tests/test_type/test_wire1.py .
tests/test_type/test_wire2.py .
tests/test_type/test_wire3.py .
tests/test_type/test_wire4.py .
tests/test_type/test_wire5.py .
tests/test_verilog/test_verilog.py .
tests/test_wire/test_arg1.py .
tests/test_wire/test_arg2.py .
tests/test_wire/test_array1.py .
tests/test_wire/test_array2.py .
tests/test_wire/test_array3.py .
tests/test_wire/test_call1.py .
tests/test_wire/test_call2.py .
tests/test_wire/test_compose.py .
tests/test_wire/test_const0.py .
tests/test_wire/test_const1.py .
tests/test_wire/test_errors.py ..
tests/test_wire/test_flip.py .
tests/test_wire/test_named1.py .
tests/test_wire/test_named2a.py .
tests/test_wire/test_named2b.py .
tests/test_wire/test_named2c.py .
tests/test_wire/test_pos.py .

========================== 70 passed in 1.45 seconds ===========================

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaGWT:何时使用Lazydemelement?   Java中跟踪消失线程的多线程处理   java Springboot未能配置数据源:“url”,但我没有使用数据库   java为按钮生成随机位置   math Java:包含二项式系数计算的表达式   java通过AsyncTask传递参数   从路径错误创建java文件   高流量网站的性能播放框架、Java、Apache、PostgreSQL、JPA和Hibernate   java将4D矢量转换为长矢量   arraylist Java循环在没有任何错误的情况下终止   java正在制作一个计算器应用程序,希望在第二个片段中更新历史,但无法完成   java将信息从IntentService发送到Activity   java如何在游戏中插入大量实体!工作   javascript如何在ScriptEngineforJava中从数学中获得准确的结果?