我对以下代码有一些问题:
module register_window(port_A, port_B, PD, CWP, A, B, C, loadRF, clk);
output reg[4:0] port_A;
output reg[4:0] port_B;
input [31:0] PD;
input [1:0] CWP;
input [4:0] A;
input [4:0] B;
input [4:0] C;
input loadRF;
input clk;
reg ld; //enable
wire [3:0] t;
decoder_2x4 decoder2by4(CWP, t, loadRF);
wire [31:0] bitDecoder1;
decoder_5x32 decoder0(C, bitDecoder1, t[0]);
wire [31:0] bitDecoder2;
decoder_5x32 decoder1(C, bitDecoder2, t[1]);
wire[31:0] globalReg0;
assign ld = (bitDecoder1[0] == 32'b0 ||bitDecoder2[0] == 32'b0||bitDecoder3[0] == 32'b0||bitDecoder4[0] == 32'b0);
registers g0(globalReg0, PD, ld, clk);
// G1
wire[31:0] globalReg1;
assign ld = (bitDecoder1[1]== 32'b0||bitDecoder2[1]== 32'b0||bitDecoder3[1]== 32'b0||bitDecoder4[1]== 32'b0);
registers g1(globalReg1, PD, ld, clk);
wire[31:0] globalReg2;
assign ld = (bitDecoder1[2]== 32'b0||bitDecoder2[2]== 32'b0||bitDecoder3[2]== 32'b0||bitDecoder4[2]== 32'b0);
registers g2(globalReg2, PD, ld, clk);
基本上我的代码试图做的是设置wire t
为二进制解码器的输出以及其他 5x32 解码器的输入(这里省略了一些)。然后,根据解码器的值,它为 ld 分配一个值,该值基本上只是一个启用信号(如果任何解码器位为 1,则启用为 1,否则为 0)。然后这些值进入一个寄存器,并由电线(globalReg1
、、globalReg2
等)输出。如果重要的话,他们都使用相同的时钟。
我得到的编译错误是
testbench.sv:37:错误:未解决的 net/uwire ld 不能有多个驱动程序。
在分配的每一行中;assign ld = (bitDecoder1[1]== 32'b0||bitDecoder2[1]== 32'b0||bitDecoder3[1]== 32'b0||bitDecoder4[1]== 32'b0);
我还尝试将上面的行放在always @(*) begin
andend
语句之间(因为我认为您总是必须在代码的逻辑部分之间这样做),但这只会给我一个错误:
testbench.sv:33:错误:ld 无法分配给未解析的电线。
如果有人能指出我正确的方向,我将永远感激不尽。谢谢!