搜索
您的当前位置:首页正文

SpinalHDL之结构(一)

来源:小奈知识网

本文作为SpinalHDL学习笔记第六十一篇,介绍SpinalHDL的模块和层次(Component and hierarchy)

目录:

1.简介(Introduction)

2.输入/输出定义(Input/output definition)

3.信号剪枝(Pruned signals)

4.参数化硬件电路("Generic"——VHDL, "Parameter"——Verilog)

5.综合模块名(Synthesized component names)

⼀、简介(Introduction)

正如VHDL和Verilog, 你可以在SpinalHDL中定义模块来进⾏层次化设计。然⽽, 在SpinalHDL中, 你不需要在例化的时候分配他们的端⼝。

class AdderCell() extends Component {
//声明外部端⼝, 推荐在Bundle中⽤io命名
val io = new Bundle {
val a, b, cin = in Bool()
val sum, cout = out Bool()
}
//写⼀些逻辑
io.sum := io.a ^ io.b ^ io.cin
io.cout := (io.a & io.b) | (io.a & io.cin) | (io.b & io.cin)
}
class Adder(width: Int) extends Component {
...
//例化两个AdderCell
val cell0 = new AdderCell()
val cell1 = new AdderCell()
cell1.io.cin := cell0.io.cout /

因篇幅问题不能全部显示,请点此查看更多更全内容

Top