Verilog 如何在凿子3中将单个钻头复制到UInt?
我正在寻找一种凿子方法来完成以下工作:Verilog 如何在凿子3中将单个钻头复制到UInt?,verilog,bit,chisel,Verilog,Bit,Chisel,我正在寻找一种凿子方法来完成以下工作: wire [3:0] word; wire bit; assign word = {4{bit}}; 我现在是这样做的: val word=WireUInt4.W val位=线布尔 字:=Catbit,bit,bit,bit 然而,当我需要一个更大的数字时,这个解决方案不是很整洁: val bigWord=WireUInt32.W bigWord:=猫,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特
wire [3:0] word;
wire bit;
assign word = {4{bit}};
我现在是这样做的:
val word=WireUInt4.W
val位=线布尔
字:=Catbit,bit,bit,bit
然而,当我需要一个更大的数字时,这个解决方案不是很整洁:
val bigWord=WireUInt32.W
bigWord:=猫,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特,比特
io.out:=传唤_cthulhu
有更好的方法吗?像Verilog assign bigWord={32{bit}}?的评论是正确的。使用是正确的方法
要使其具体化,请使用以下凿子:
进口许可证3_
导入3.3.3实验性多IOmodule
导入3.util.Fill
类foodModulen:Int=32扩展多IOmodule{
val a:UInt=IOInputBool
val b:UInt=IOOutputUIntn.W
b:=菲尔恩,a
}
生成以下Verilog:
module FooModule(
input clock,
input reset,
input a,
output [31:0] b
);
assign b = a ? 32'hffffffff : 32'h0;
endmodule
module BarModule(
input clock,
input reset,
input a,
output [31:0] b
);
wire [9:0] _T_8;
wire [18:0] _T_17;
wire [27:0] _T_26;
wire [30:0] _T_29;
assign _T_8 = {a,a,a,a,a,a,a,a,a,a};
assign _T_17 = {_T_8,a,a,a,a,a,a,a,a,a};
assign _T_26 = {_T_17,a,a,a,a,a,a,a,a,a};
assign _T_29 = {_T_26,a,a,a};
assign b = {_T_29,a};
endmodule
请注意,在填充宽度为1的对象的特殊情况下,填充将使用mux。否则,这将在树中进行显式连接
另一方面,如果您选择显式地进行连接,FIRRTL实际上有一个名为CombineCats的专用转换,它将尝试为您清理这个问题。在下文中,创建了备选示例n-1临时表,其中每个位都显式连接:
类BarModulen:Int=32扩展多IOmodule{
val a:UInt=IOInputBool
val b:UInt=IOOutputUIntn.W
b:=顺序填充na.asUInt.reduce\u_
}
您将获得以下Verilog:
module FooModule(
input clock,
input reset,
input a,
output [31:0] b
);
assign b = a ? 32'hffffffff : 32'h0;
endmodule
module BarModule(
input clock,
input reset,
input a,
output [31:0] b
);
wire [9:0] _T_8;
wire [18:0] _T_17;
wire [27:0] _T_26;
wire [30:0] _T_29;
assign _T_8 = {a,a,a,a,a,a,a,a,a,a};
assign _T_17 = {_T_8,a,a,a,a,a,a,a,a,a};
assign _T_26 = {_T_17,a,a,a,a,a,a,a,a,a};
assign _T_29 = {_T_26,a,a,a};
assign b = {_T_29,a};
endmodule
但是,在树结构中,您将无法获得连接的好处。如果改为使用UInt32.W作为输入,后者的效率会低得多。基于此,您可以使用Fill操作符。