我正在尝试使用SystemVerilog中的标准化存储器接口制作一个模块(在我的情况下是一个DSP),并希望模块中的变量根据所连接接口中的总线宽度自动调整大小.我的理由:这使得代码更容易移植,允许它自动调整到任何连接的接口,而不是要求HDL编码器传递参数,告诉模块将连接到它的所有接口总线的宽度(不是这将是可怕的,没有参数,它似乎更清洁).
但是,我似乎无法让它工作.这是一个说明问题的例子; 以下在Quartus II 12.1中进行综合:
// Top level module with some 15-bit ports
module top ( input [14:0] data_in,
output [14:0] data_out1, data_out2,
data_out3, data_out4 );
test_interface my_interface(); // Initialize the interface
test_module my_module(.*); // Initialize & connect module
endmodule
// Define a simple interface:
interface test_interface ();
logic [8:0] my_port;
endinterface
// Define the module:
module test_module ( input [14:0] data_in,
test_interface my_interface,
output [14:0] data_out1, data_out2,
data_out3, data_out4 );
localparam width1 = $size(data_in); // should be 15
localparam …Run Code Online (Sandbox Code Playgroud)