我正在从Chisel 3源代码生成Verilog,并使用UCF文件将Verilog的顶级模块端口映射到FPGA引脚。
我的设计中有一组inout引脚(SDRAM数据引脚),它们在凿线侧必须表示为单独的输入和输出端口。问题是,我不能(AFAIK)然后将Verilog输入端口和输出端口映射到同一个FPGA引脚(如果我直接编写Verilog,这将是一个单一的inout信号,所以这不是一个问题),我不知道如何强制Chisel 3从两个输入/输出Chisel端口产生一个单一的Verilog inout端口。
在Chisel (3)中这通常是如何解决的?
发布于 2016-12-05 11:10:59
我们正在致力于在Chisel 3中对Verilog inout提供一定程度的支持,但在该API完全充实之前,您应该编写一个Verilog包装器,将inout转换为输入、输出和某个方向。
例如,假设我有一个带有inout引脚的Verilog,可以用来设置或读取某些寄存器:
module Inout(
input clock,
input write,
inout [31:0] data
);
reg [31:0] value;
assign data = (write) ? 32'dz : value;
always @(posedge clock) begin
if (write)
value <= data;
else
value <= value;
end
endmodule通过一个简单的包装器,我可以公开一个不使用inout的不同接口:
module InoutWrapper(
input clock,
input write,
input [31:0] dataIn,
output [31:0] dataOut
);
wire [31:0] bus;
assign bus = (write)? dataIn : 32'dz;
assign dataOut = bus;
Inout mod (
.clock(clock),
.write(write),
.data(bus)
);
endmodule此包装器接口可在雕刻板设计中作为BlackBox使用:
class InoutWrapper extends BlackBox {
val io = IO(new Bundle {
val clock = Input(Clock())
val write = Input(Bool())
val dataIn = Input(UInt(32.W))
val dataOut = Output(UInt(32.W))
})
}这里有一个额外的简单的理智测试来证明它是有效的:
class InoutTester extends BasicTester {
val mod = Module(new InoutWrapper)
val (cycle, done) = Counter(true.B, 4)
when (done) { stop(); stop() }
mod.io.clock := this.clock // BlackBoxes require explicit clock assignment
mod.io.write := false.B // default assignments
mod.io.dataIn := "hdeadbeef".U
when (cycle === 1.U) {
mod.io.write := true.B
mod.io.dataIn := 123.U
}
when (cycle === 2.U) {
assert(mod.io.dataOut === 123.U)
}
}如果inout端口位于设计的顶部,则可以为设计的顶部创建类似类型的包装器。
https://stackoverflow.com/questions/40961550
复制相似问题