Verilog 中自定义模块阵列的单输入
因此,我有一个由 4 个 RAM 模块组成的数组,我希望能够根据两个不同的选择器信号对其进行读/写。现在,我正在使用中间信号实例化 RAM:
genvar i;
generate
for (i = 0; i < regnum; i=i+1) begin: regs
rfram_generic rf (clk,rst,ce_a_int[i],addr_a_int[i],do_a_int[i],
ce_b_int[i],addr_b_int[i],do_b_int[i],
ce_w_int[i],we_w_int[i],addr_w_int[i],
di_w_int[i]);
end
endgenerate
并且我想使用 head
或 tail
信号(2 位向量)来选择要使用的 RAM。有什么想法如何做到这一点?
So I have an array of 4 RAM modules that I want to be able to read/write to based on two different selector signals. Right now I'm instantiating the RAM using intermediary signals:
genvar i;
generate
for (i = 0; i < regnum; i=i+1) begin: regs
rfram_generic rf (clk,rst,ce_a_int[i],addr_a_int[i],do_a_int[i],
ce_b_int[i],addr_b_int[i],do_b_int[i],
ce_w_int[i],we_w_int[i],addr_w_int[i],
di_w_int[i]);
end
endgenerate
And I want to select the RAM to use using either head
or tail
signals (2-bit vectors). Any ideas how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我是新来的,还不能评论问题,但回应 Marty:大多数 FPGA 综合工具都会尽可能将具有三态值的内部多源信号转换为类似 MUX 的逻辑。例如,请参见:旧的三态到逻辑行为的描述对我来说听起来很准确。
作为对 Adam 的建议,您最好通过自己执行屏蔽而不是使用三态来在代码中明确说明这一点。这将提高可移植性,为您提供更可预测的结果,并在有人需要重新访问您的代码时作为自我文档。
但是,根据您的解决方案进行一些猜测,简单地屏蔽写入端口上的时钟使能并复用读取端口的输出可能是有意义的。例如:
这可能会导致比您的解决方案更简单的逻辑(即,更好的面积和延迟)。
I'm new here and can't comment on questions yet, but in response to Marty: most FPGA synthesis tools will translate internal multisource signals with tristate values into MUX-like logic, where possible. See, for instance: a description of old tristate-to-logic behaviour that sounds accurate to me.
As a recommendation to Adam, you're probably better off making this explicit in your code by performing the masking yourself rather than using the tristates. This will improve portability, give you more predictable results, and serve as self-documentation if anybody ever has to revisit your code.
However, making some guesses based on your solution, it would probably make sense to simply mask off the clock enable on the write port and mux the output of the read port. For instance:
This will probably result in less complex logic (i.e., better area and delay) than your solution.
我想我已经弄清楚了,必须使用生成语句:
I think I figured it out, gotta use a generate statement:
很高兴听到您找到了问题的解决方案。我必须承认我没有完全理解你在做什么,但是有一点评论,你也可以在生成语句中使用 if ,从而实例化不同的模块或使用依赖于 genvar 的不同信号,例如:
glad to hear you found a solution for your problem. I must admit I didn't fully understand what you were up to, but one comment, you can also use
if
inside generate statements and thus instantiate different modules or use different signals dependent on thegenvar
, e.g.: