我无法在Verilog中将输出分配给值
我试图将我无法在Verilog中将输出分配给值,verilog,Verilog,我试图将ADDR分配给pcOut,但ADDR在GTKWave中显示为xxxxxxxx 这是我的密码: module processor ( input CLK, // Memory input [31:0] DATAOUT, // Memory data out output [31:0] DATAIN, // Memory data in output [31:0] ADDR, // Memory address output WE // Me
ADDR
分配给pcOut
,但ADDR
在GTKWave中显示为xxxxxxxx
这是我的密码:
module processor (
input CLK,
// Memory
input [31:0] DATAOUT, // Memory data out
output [31:0] DATAIN, // Memory data in
output [31:0] ADDR, // Memory address
output WE // Memory write enable
);
wire [3:0] aluSel;
wire [4:0] regSel1, regSel2, regDataSel;
wire regLoad, aluEnable, pcLoad, pcNext;
wire [31:0] regDataIn, regDataOut1, regDataOut2, aluOut, pcOut, pcIn, aluA, aluB;
assign ADDR = pcOut;
controlUnit controlUnit (
.CLK(CLK), // Clock
// Outputs
.memDataOut(DATAOUT),
.regDataOut1(regDataOut1),
.regDataOut2(regDataOut2),
.aluOut(aluOut),
.pcOut(pcOut),
// Load and enable
.pcLoad(pcLoad),
.regLoad(regLoad),
.aluEnable(aluEnable),
.pcNext(pcNext),
// Selects
.aluSel(aluSel),
.regSel1(regSel1),
.regSel2(regSel2),
.regDataSel(regDataSel),
// Inputs
.pcIn(pcIn),
.regDataIn(regDataIn),
.aluA(aluA),
.aluB(aluB),
.memDataIn(DATAIN),
.memAddr(ADDR)
);
datapath datapath (
.pcNext(pcNext),
// Load and enable
.pcLoad(pcLoad),
.regLoad(regLoad),
.aluEnable(aluEnable),
// Selects
.aluSel(aluSel),
.regSel1(regSel1),
.regSel2(regSel2),
.regDataSel(regDataSel),
// Inputs
.regDataIn(regDataIn),
.pcIn(pcIn),
.aluA(aluA),
.aluB(aluB),
// Outputs
.regDataOut1(regDataOut1),
.regDataOut2(regDataOut2),
.aluOut(aluOut),
.pcOut(pcOut)
);
endmodule
有人能帮忙吗?
提前谢谢
编辑:
pcOut
正在输出正确的值,但没有将ADDR
设置为相同的值
编辑2:
以下是控制单元
模块的代码:
module controlUnit (
input CLK,
input [31:0] memDataOut, regDataOut1, regDataOut2, aluOut, pcOut,
output reg [0:0] pcLoad, regLoad, aluEnable, pcNext,
output reg [3:0] aluSel,
output reg [4:0] regSel1, regSel2, regDataSel,
output reg [31:0] pcIn, regDataIn, aluA, aluB, memDataIn, memAddr
);
reg cycle = 0;
wire [10:0] opcode;
wire [4:0] rs1, rs2, rd;
decoder decoder (
.cycle(cycle),
.instruction(memDataOut),
.rs1(rs1),
.rs2(rs2),
.rd(rd),
.opcode(opcode)
);
always @(posedge CLK) begin
case (cycle)
1'b0: begin
regLoad <= 0;
aluEnable <= 0;
pcNext <= 0;
end
1'b1: begin
pcNext <= 1;
case (opcode)
11'b00000110011: begin // Add
regSel1 <= rs1;
regSel2 <= rs2;
regDataSel <= rd;
aluSel <= 0;
aluEnable <= 1;
regDataIn <= aluOut;
regLoad <= 1;
end
11'b10000110011: begin // Sub
end
endcase
end
endcase
cycle <= !cycle;
end
endmodule
模块控制单元(
输入时钟,
输入[31:0]memDataOut、regDataOut1、regDataOut2、alout、pcOut、,
输出寄存器[0:0]pcLoad,regLoad,aluEnable,pcNext,
输出寄存器[3:0]aluSel,
输出寄存器[4:0]regSel1、regSel2、regDataSel、,
输出寄存器[31:0]pcIn,regDataIn,aluA,aluB,memDataIn,memAddr
);
reg周期=0;
wire[10:0]操作码;
电线[4:0]rs1,rs2,rd;
译码器(
.循环(循环),
.指令(memDataOut),
.rs1(rs1),
.rs2(rs2),
.rd(rd),
.opcode(操作码)
);
始终@(posedge CLK)开始
案例(周期)
1'b0:开始
regLoad您的controlUnit
似乎没有任何逻辑附加到memAddr
,但是memAddr
仍然是controlUnit
的输出。在顶层,您可以将ADDR映射到.memAddr
,还可以分配ADDR=pcOut
。您试图在两个不同的位置驾驶ADDR
。您的controlUnit
似乎没有任何逻辑连接到memAddr
,但memAddr
仍然是controlUnit
的输出。在顶层,您可以将ADDR映射到.memAddr
,还可以分配ADDR=pcOut
。您试图在两个不同的位置驱动ADDR
。控制单元模块上的//输出注释是控制单元模块的输入<代码>pcOut
仅由数据路径
模块驱动。很抱歉造成混淆,这是因为我的评论不好。看起来你的ADDR本身是由层次更高的某个地方的多个源驱动的,此处未显示。我已经看了一眼,我不认为ADDR
是在其他任何地方驱动的。显示controlUnit
模块的代码。//对controlUnit
模块的//输出
注释是controlUnit
模块的输入<代码>pcOut
仅由数据路径
模块驱动。很抱歉造成混淆,这是因为我的评论不好。看起来您的ADDR本身是由更高层次的某个地方的多个源驱动的,这里没有显示。我看了一下,我不认为ADDR
是在其他地方驱动的。显示controlUnit
模块的代码。