在 Verilog 中连接信号 n 次

电器工程 验证日志
2022-01-21 13:53:54

给定一个信号wire [7:0] dummy,我怎样才能将它连接起来n

也就是说,是否有以下符号:

{dummy, ..., dummy} // n times

?

1个回答

这就是我重复和连接 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 

模拟结果: 编辑必须至少为 6 个字符