3 个版本
使用旧 Rust 2015
0.1.3 | 2020年1月22日 |
---|---|
0.1.2 | 2019年7月7日 |
0.1.1 | 2019年5月14日 |
0.1.0 |
|
#275 在 硬件支持
110KB
2.5K SLoC
VeRuGent
该工具是一个用于使用 Rust 编程语言构建 Verilog AST 的 DSL 库。
使用 Rust 编程语言构建 Verilog HDL 代码的 DSL 库
版权 (C) 2019, K.Takano
许可证
Apache 许可证(版本 2.0)
https://apache.ac.cn/licenses/LICENSE-2.0
什么是 VeRuGent?(VeRuGent 是什么?)
VeRuGent 代表 "从 Rust 生成 Verilog : 工具包"
它是一个用于在 Rust 中构建 Verilog HDL 源代码的开源库。
VeRuGent 是 "Verilog from Rust : Generation Toolkits" 的缩写。
这是一个用于使用 Rust 构建 Verilog HDL 代码的库。
VeRuGent 不进行源代码的合成。(当然,它也不进行高级合成)
它只生成 Verilog 代码。
本工具不执行逻辑合成。(高位合成也不在考虑范围内)
生成的只是构建的 Verilog 代码。
VeRuGent 提供了一种简化的 Verilog HDL AST 构建方法。
您可以通过使用 Rust 的高安全性检查功能来减少 Verilog HDL 设计中的故障。
(目前,此功能和安全性尚不充分。因此,更新此工具是未来的任务。)
提供了一种简化的 Verilog HDL AST 构建技术。通过利用 Rust 拥有的高度安全检查功能,可以实现故障较少的硬件代码设计。
(目前,由于功能或安全性方面存在一些不确定性,因此将其作为未来的任务…)
要求(推荐环境)
Rust 1.27.0 稳定版(或更高版本)
-
rustc 1.27.0(3eda71b00 2018-06-19)(或更高版本)
-
cargo 1.27.0(1e95190e5 2018-05-27)(或更高版本)
-
安装(导入)
使用原始代码
1. 将核心文件放在与源代码相同的目录中。
请将核心文件放在与源代码相同的目录中。
2. 添加模块
添加模块
3. 在要使用的块中声明核心和宏的使用。
mod Verugent;
请声明库和宏的使用。
使用库
#[macro_use]
use Verugent::core::*;
1. 使用 Cargo 的功能生成项目文件夹。
并在 cargo.toml 文件中添加此代码。
使用 Cargo 的项目生成功能创建项目文件夹。
然后,在 cargo.toml 文件中添加以下内容。
2. 在要使用的块中声明核心和宏的使用。
[dependencies]
Verugent = "0.1.3"
在 main 文件中添加以下代码以声明库和宏的使用。
It's only.
#[macro_use]
extern crate Verugent;
use Verugent::core::*;
仅此而已!
たったこれだけ!
入门
您可以在本存储库的 "example" 目录中找到一些示例。
您可以在本存储库的 "example" 目录中找到示例。
让我们以 LED 照明电路为例,使用 Verugent。
让我们以这个 LED 照明电路的示例为例,使用 Verugent。
如果您想查看用 Rust 编写的 LED 电路代码的内容,请阅读 led.rs 文件。
如果您想查看 LED 回路的代码,请参阅 led.rs 文件。
执行命令是:cargo run --example led。
执行命令为 "cargo run --example led"。
#[macro_use]
extern crate verugent;
use verugent::vcore::*;
fn main() {
led();
}
・
・
・
如果您构建并运行此代码,您可以看到作为结果的输出Verilog代码。
代码执行后,将输出Verilog代码。
module LED (
input CLK,
input RST,
input BTN1,
input BTN2,
output [7:0] LED
);
localparam IDLE = 0;
localparam RUN = 1;
localparam END = 2;
reg [31:0] State;
reg [31:0] State_Next;
assign LED = (State==RUN)? 8: 0;
always@(posedge CLK or posedge RST) begin
if (RST == 1) begin
State <= IDLE;
end
else begin
State <= State_Next
end
end
always@(posedge CLK) begin
case(State)
IDLE : begin
if(BTN1==1&&RST!=1)
State_Next <= RUN;
end
RUN : begin
if(BTN2==1)
State_Next <= END;
end
END : begin
State_Next <= IDLE;
end
endcase
end
endmodule
方法速查表
wire、register、输入和输出端口设置方法
Input(&str, Box<E> or i32) Input port
Output(&str, Box<E> or i32) Output port
Reg_Output(&str, Box<E> or i32) Output port(register)
Inout(&str, Box<E> or i32) Inout port
Param(&str, i32) Global parameter
LParam(&str, i32) Local parameter
Wire(&str, Box<E> or i32) Wire setting
Reg(&str, Box<E> or i32) Register setting
Mem(&str, Box<E> or i32, Box<E> or i32) Array register setting
控制块方法
Always(Always-AST struct) Always block setting
Function(Function-AST struct) Function block setting
Assign(Assign-AST struct) Assign block setting
块内AST
Always:
--Drive edge setting--
Posedge(Box<E>) Drive always block(positive edge)
Negedge(Box<E>) Drive always block(negative edge)
Nonedge() Non drive signal
--Substitution setting--
non() Nonblocking substitution
block() Blocking substitution
Function:
func(&str, i32) Generate function
Input(&str, i32) Function input setting
own() Function name AST generate(using build function AST)
Assign:
_e(Box<E>) Assign AST setting
FSM(Finite State machine):
Clock_Reset(Box<E>, Box<E>) Clock and Reset signal setting for FSM to drive
State(&str) State register name setting
AddState(&str) Add new state
goto(&str) Designation of state transition destination
from(&str) Transition to current state
Current(&str) Change current state
Param(&str) Get parameter AST in fsm
Branch Method:
--if - else--
If(Box<E>, Vec<Box<E>>) If AST setting(if)
Else_If(Box<E>, Vec<Box<E>>) If AST setting(else if)
Else(Vec<Box<E>>) If AST setting(else)
--case--
Case(Box<E>) Case block setting
S(Box<E>, Vec<Box<E>>) Process for each "case label"
Common Items:
--method--
Form(Box<E>) In block formula
--Macro--
F!( Formula ) Operator syntax that
could not be implemented with overloading.
Formula --> = : Substitution
==: Equal
!=: Not equal
<=: More and equal
>=: Less and equal
< : More than
> : Less than
func_args!( (Box<E>)* ) Pass the coated argment in Box.
更新历史
2017/09/20:开发开始
2017/11/18:添加公式宏
2018/01/20:添加FSM制作方法
2018/06/30:添加语法分解和输出功能
2018/07/27:在GitHub上发布第一个产品
2018/09/15:修复FSM函数的bug
2019/04/30:添加AXI Slave Lite接口生成器和代码生成器
2019/07/07:小范围bug修复
2019/08/31:AXI-Lite端口生成器的bug修复
2019/09/03:"函数"生成器的调整
2020/01/22:添加AXI Slave Full接口生成器