给定一个信号wire [7:0] dummy
,我怎样才能将它连接起来n
?
也就是说,是否有以下符号:
{dummy, ..., dummy} // n times
?
给定一个信号wire [7:0] dummy
,我怎样才能将它连接起来n
?
也就是说,是否有以下符号:
{dummy, ..., dummy} // n times
?
这就是我重复和连接 n 次所做的:
{n{VARIABLE}}
例子:
module concat_n(dummy,super_dummy,clk);
input [7:0] dummy;
input clk;
output [23:0] super_dummy;
wire [7:0] dummy;
reg [23:0] super_dummy;
always @(posedge clk)
super_dummy <= {3{dummy}};
endmodule
模拟:
module test;
initial begin
$dumpfile("test.vcd");
$dumpvars(0,test);
dummy_in = 8'b10101111;
#10 dummy_in = 8'b10101010;
#10 dummy_in = 8'b11110001;
#10 dummy_in = 8'b01010011;
#10 dummy_in = 8'b00111100;
#10 dummy_in = 8'b00110011;
# 1 $finish;
end
reg clk = 0;
always #1 clk = !clk;
wire [23:0] super_dummy_out;
reg [7:0] dummy_in;
concat_n concat_3 (dummy_in, super_dummy_out, clk);
initial
$monitor("At time %d, dummy_in = 0x%h, super_dummy_out = 0x%h ",
$time, dummy_in, super_dummy_out);
endmodule
模拟结果: