verilog - 我无法将输出分配给 Verilog 中的值
问题描述
我正在尝试分配ADDR
,pcOut
但ADDR
显示为xxxxxxxx
GTKWave。
这是我的代码:
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:这是controlUnit
模块的代码:
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
解决方案
您controlUnit
似乎没有附加任何逻辑memAddr
,但memAddr
仍然是controlUnit
. 在顶层,您将映射移植ADDR
到.memAddr
,并且您也将assign ADDR = pcOut
. 您正试图ADDR
在两个不同的位置开车。
推荐阅读
- terraform - Terraform - 在变量默认值中使用数据源输出
- qlikview - QlikView 中的饼图
- ruby-on-rails - Rails API 子集响应
- javascript - jQuery文件中的toggleClass和执行顺序
- javascript - 如何删除选定的输入值
- gradle - 在进行 Gradle Clean 构建时在 Spring Boot 应用程序中收到警告
- android - 如何使用 pybluez 构建 Android 蓝牙服务器应用程序处理从 Raspberry Pi 发送的数据
- node.js - npm 安装权限被拒绝 (macOS)
- tensorflow - Tensorflow - 如果主要更新偏差有什么问题?
- java - 编写 SharedPreferences 后更新布局?