简体   繁体   English

Verilog:不支持程序连续分配注册

[英]Verilog:Procedural Continuous Assignment to register is not supported

    input [31:0] write_data;
    input [4:0]  write_reg;
    reg [31:0] registers [31:0];

always @(*) 
     assign registers[write_reg] = write_data;

I have a 32-bit input write_data , which i want to an assign corresponding index which i get from write reg.Error says you cant do continuous assignment which i think causes by always@(*) but if i remove that 我有一个32位输入write_data,我想分配一个我从write reg。得到的索引。错误说你不能做我认为总是由always @(*)引起的连续分配,但是如果我删除了

It says object "registers" on left-hand side of assignment must have a net type and its another error. 它说分配左侧的对象“寄存器”必须具有网络类型,这是另一个错误。

You need to synchronously assign to registers. 您需要同步分配给寄存器。 Because the synthesizer parses it and routes to a physical register (ie flip-flop) 由于合成器对其进行解析并路由到物理寄存器(即触发器)

always @(posedge clk) 
    my_reg = my_data;

d触发器

assign inside an always block is the procedural assignment . assign的总块里面procedural assignment It is not synthesizable and should not be used. 它是不可合成的,不应使用。 It is there for very special modeling cases. 它用于非常特殊的建模案例。

continuous assignment , or assign outside the always block is there for connecting nets and used all over the places. continuous assignment ,或assign always块是有连接nets和各地使用的地方。 lhs of such an assignment must be a net type, ie wire . 这样的分配必须是网络类型,即wire it cannot be a reg. 它不能是reg。

On the other hand all lhs in always blocks must be of 'reg' type. 另一方面, 始终块中的所有lh 必须为“ reg”类型。

what you had to do in your case was to remove the keyword assign : 在这种情况下,您要做的就是删除关键字assign

input [31:0] write_data;
input [4:0]  write_reg;
reg [31:0] registers [31:0];

always @(*) 
     registers[write_reg] = write_data;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM