输出端口上的Verilog语句
我目前正在为单个周期RISCV处理器设计一个指令解码器。 从代码中可以看到,我定义了R型指令的所有部分以提高可读性。但是,在这种情况下,分配语句给出了错误,因为并发分配或输出端口连接应为净类型。
如何分配输出端口的一部分以提高可读性?
该代码在下面看到为:
module instruction_decoder(
input [31:0] instruction_memory,
output [32:0] control_word
);
///////////// CONTROL WORD /////////////
reg bc, jb, pl;
assign bc = control_word[0];
assign jb = control_word[1];
assign pl = control_word[2];
reg mw, rw, md;
assign mw = control_word[3];
assign rw = control_word[4];
assign md = control_word[5];
reg [10:0] fs;
assign fs = control_word[16:6];
reg mb;
assign mb = control_word[17];
reg [4:0] ba, aa, da;
assign ba = control_word[18:22];//rs2
assign aa = control_word[23:27];//rs1
assign da = control_word[28:32];//rd
/////////////////////////////////////////
////////////////////////INSTRUCTION WORD ////////////////////////
/////////R-TYPE/////////
wire [6:0] opcode;
assign opcode = instruction_memory[6:0];
wire [4:0] rd;
assign rd = instruction_memory[11:7];
wire [2:0] funct3;
assign funct3 = instruction_memory[14:12];
wire [4:0] rs1;
assign rs1 = instruction_memory[19:15];
wire [4:0] rs2;
assign rs2 = instruction_memory[24:20];
wire [6:0] funct7;
assign funct7 = instruction_memory[31:25];
/////////////////////////
////////////////////////////////////////////////////////////////
always @(opcode)
begin
case(opcode)
7'b0110011: //Function-unit operations using registers => R-TYPE INSTRUCTIONS
begin
da = rd;
aa = rs1;
ba = rs2;
mb = 0;
md = 0;
rw = 1;
mw = 0;
pl = 0;
end
endcase
end
endmodule
I am currently designing an instruction decoder for a single cycle RISCV processor.
As you can see from the code, I defined all the parts of the r-type instruction to increase the readability. But, in this situation, assign statements gives an error as concurrent assignment or output port connection should be a net type.
How can I assign the part of output port to increase readability?
The code is seen below as:
module instruction_decoder(
input [31:0] instruction_memory,
output [32:0] control_word
);
///////////// CONTROL WORD /////////////
reg bc, jb, pl;
assign bc = control_word[0];
assign jb = control_word[1];
assign pl = control_word[2];
reg mw, rw, md;
assign mw = control_word[3];
assign rw = control_word[4];
assign md = control_word[5];
reg [10:0] fs;
assign fs = control_word[16:6];
reg mb;
assign mb = control_word[17];
reg [4:0] ba, aa, da;
assign ba = control_word[18:22];//rs2
assign aa = control_word[23:27];//rs1
assign da = control_word[28:32];//rd
/////////////////////////////////////////
////////////////////////INSTRUCTION WORD ////////////////////////
/////////R-TYPE/////////
wire [6:0] opcode;
assign opcode = instruction_memory[6:0];
wire [4:0] rd;
assign rd = instruction_memory[11:7];
wire [2:0] funct3;
assign funct3 = instruction_memory[14:12];
wire [4:0] rs1;
assign rs1 = instruction_memory[19:15];
wire [4:0] rs2;
assign rs2 = instruction_memory[24:20];
wire [6:0] funct7;
assign funct7 = instruction_memory[31:25];
/////////////////////////
////////////////////////////////////////////////////////////////
always @(opcode)
begin
case(opcode)
7'b0110011: //Function-unit operations using registers => R-TYPE INSTRUCTIONS
begin
da = rd;
aa = rs1;
ba = rs2;
mb = 0;
md = 0;
rw = 1;
mw = 0;
pl = 0;
end
endcase
end
endmodule
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复编译错误的一种方法是将单个信号分配给
control_word
net。更改:到:
One way to fix the compile errors is to assign individual signals to the
control_word
net. Change:to: