📄 or1200_ctrl.v
字号:
sel_imm <= #1 1'b0; // l.rfe `OR1200_OR32_RFE: sel_imm <= #1 1'b0; // l.mfspr `OR1200_OR32_MFSPR: sel_imm <= #1 1'b0; // l.mtspr `OR1200_OR32_MTSPR: sel_imm <= #1 1'b0; // l.sys, l.brk and all three sync insns `OR1200_OR32_XSYNC: sel_imm <= #1 1'b0; // l.mac/l.msb`ifdef OR1200_MAC_IMPLEMENTED `OR1200_OR32_MACMSB: sel_imm <= #1 1'b0;`endif // l.sw `OR1200_OR32_SW: sel_imm <= #1 1'b0; // l.sb `OR1200_OR32_SB: sel_imm <= #1 1'b0; // l.sh `OR1200_OR32_SH: sel_imm <= #1 1'b0; // ALU instructions except the one with immediate `OR1200_OR32_ALU: sel_imm <= #1 1'b0; // SFXX instructions `OR1200_OR32_SFXX: sel_imm <= #1 1'b0;`ifdef OR1200_OR32_CUST5 // l.cust5 instructions `OR1200_OR32_CUST5: sel_imm <= #1 1'b0;`endif // l.nop `OR1200_OR32_NOP: sel_imm <= #1 1'b0; // All instructions with immediates default: begin sel_imm <= #1 1'b1; end endcase endend//// Decode of except_illegal//always @(posedge clk or posedge rst) begin if (rst) except_illegal <= #1 1'b0; else if (!ex_freeze & id_freeze | flushpipe) except_illegal <= #1 1'b0; else if (!ex_freeze) begin case (id_insn[31:26]) // synopsys parallel_case `OR1200_OR32_J, `OR1200_OR32_JAL, `OR1200_OR32_JALR, `OR1200_OR32_JR, `OR1200_OR32_BNF, `OR1200_OR32_BF, `OR1200_OR32_RFE, `OR1200_OR32_MOVHI, `OR1200_OR32_MFSPR, `OR1200_OR32_XSYNC,`ifdef OR1200_MAC_IMPLEMENTED `OR1200_OR32_MACI,`endif `OR1200_OR32_LWZ, `OR1200_OR32_LBZ, `OR1200_OR32_LBS, `OR1200_OR32_LHZ, `OR1200_OR32_LHS, `OR1200_OR32_ADDI, `OR1200_OR32_ADDIC, `OR1200_OR32_ANDI, `OR1200_OR32_ORI, `OR1200_OR32_XORI,`ifdef OR1200_MULT_IMPLEMENTED `OR1200_OR32_MULI,`endif `OR1200_OR32_SH_ROTI, `OR1200_OR32_SFXXI, `OR1200_OR32_MTSPR,`ifdef OR1200_MAC_IMPLEMENTED `OR1200_OR32_MACMSB,`endif `OR1200_OR32_SW, `OR1200_OR32_SB, `OR1200_OR32_SH, `OR1200_OR32_ALU, `OR1200_OR32_SFXX,`ifdef OR1200_OR32_CUST5 `OR1200_OR32_CUST5,`endif `OR1200_OR32_NOP: except_illegal <= #1 1'b0; // Illegal and OR1200 unsupported instructions default: except_illegal <= #1 1'b1; endcase endend//// Decode of alu_op//always @(posedge clk or posedge rst) begin if (rst) alu_op <= #1 `OR1200_ALUOP_NOP; else if (!ex_freeze & id_freeze | flushpipe) alu_op <= #1 `OR1200_ALUOP_NOP; else if (!ex_freeze) begin case (id_insn[31:26]) // synopsys parallel_case // l.j `OR1200_OR32_J: alu_op <= #1 `OR1200_ALUOP_IMM; // j.jal `OR1200_OR32_JAL: alu_op <= #1 `OR1200_ALUOP_IMM; // l.bnf `OR1200_OR32_BNF: alu_op <= #1 `OR1200_ALUOP_NOP; // l.bf `OR1200_OR32_BF: alu_op <= #1 `OR1200_ALUOP_NOP; // l.movhi `OR1200_OR32_MOVHI: alu_op <= #1 `OR1200_ALUOP_MOVHI; // l.mfspr `OR1200_OR32_MFSPR: alu_op <= #1 `OR1200_ALUOP_MFSR; // l.mtspr `OR1200_OR32_MTSPR: alu_op <= #1 `OR1200_ALUOP_MTSR; // l.addi `OR1200_OR32_ADDI: alu_op <= #1 `OR1200_ALUOP_ADD; // l.addic `OR1200_OR32_ADDIC: alu_op <= #1 `OR1200_ALUOP_ADDC; // l.andi `OR1200_OR32_ANDI: alu_op <= #1 `OR1200_ALUOP_AND; // l.ori `OR1200_OR32_ORI: alu_op <= #1 `OR1200_ALUOP_OR; // l.xori `OR1200_OR32_XORI: alu_op <= #1 `OR1200_ALUOP_XOR; // l.muli`ifdef OR1200_MULT_IMPLEMENTED `OR1200_OR32_MULI: alu_op <= #1 `OR1200_ALUOP_MUL;`endif // Shift and rotate insns with immediate `OR1200_OR32_SH_ROTI: alu_op <= #1 `OR1200_ALUOP_SHROT; // SFXX insns with immediate `OR1200_OR32_SFXXI: alu_op <= #1 `OR1200_ALUOP_COMP; // ALU instructions except the one with immediate `OR1200_OR32_ALU: alu_op <= #1 id_insn[3:0]; // SFXX instructions `OR1200_OR32_SFXX: alu_op <= #1 `OR1200_ALUOP_COMP;`ifdef OR1200_OR32_CUST5 // l.cust5 instructions `OR1200_OR32_CUST5: alu_op <= #1 `OR1200_ALUOP_CUST5;`endif // Default default: begin alu_op <= #1 `OR1200_ALUOP_NOP; end endcase endend//// Decode of mac_op//`ifdef OR1200_MAC_IMPLEMENTEDalways @(posedge clk or posedge rst) begin if (rst) mac_op <= #1 `OR1200_MACOP_NOP; else if (!ex_freeze & id_freeze | flushpipe) mac_op <= #1 `OR1200_MACOP_NOP; else if (!ex_freeze) case (id_insn[31:26]) // synopsys parallel_case // l.maci `OR1200_OR32_MACI: mac_op <= #1 `OR1200_MACOP_MAC; // l.nop `OR1200_OR32_MACMSB: mac_op <= #1 id_insn[1:0]; // Illegal and OR1200 unsupported instructions default: begin mac_op <= #1 `OR1200_MACOP_NOP; end endcase else mac_op <= #1 `OR1200_MACOP_NOP;end`elseassign mac_op = `OR1200_MACOP_NOP;`endif//// Decode of shrot_op//always @(posedge clk or posedge rst) begin if (rst) shrot_op <= #1 `OR1200_SHROTOP_NOP; else if (!ex_freeze & id_freeze | flushpipe) shrot_op <= #1 `OR1200_SHROTOP_NOP; else if (!ex_freeze) begin shrot_op <= #1 id_insn[`OR1200_SHROTOP_POS]; endend//// Decode of rfwb_op//always @(posedge clk or posedge rst) begin if (rst) rfwb_op <= #1 `OR1200_RFWBOP_NOP; else if (!ex_freeze & id_freeze | flushpipe) rfwb_op <= #1 `OR1200_RFWBOP_NOP; else if (!ex_freeze) begin case (id_insn[31:26]) // synopsys parallel_case // j.jal `OR1200_OR32_JAL: rfwb_op <= #1 `OR1200_RFWBOP_LR; // j.jalr `OR1200_OR32_JALR: rfwb_op <= #1 `OR1200_RFWBOP_LR; // l.movhi `OR1200_OR32_MOVHI: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // l.mfspr `OR1200_OR32_MFSPR: rfwb_op <= #1 `OR1200_RFWBOP_SPRS; // l.lwz `OR1200_OR32_LWZ: rfwb_op <= #1 `OR1200_RFWBOP_LSU; // l.lbz `OR1200_OR32_LBZ: rfwb_op <= #1 `OR1200_RFWBOP_LSU; // l.lbs `OR1200_OR32_LBS: rfwb_op <= #1 `OR1200_RFWBOP_LSU; // l.lhz `OR1200_OR32_LHZ: rfwb_op <= #1 `OR1200_RFWBOP_LSU; // l.lhs `OR1200_OR32_LHS: rfwb_op <= #1 `OR1200_RFWBOP_LSU; // l.addi `OR1200_OR32_ADDI: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // l.addic `OR1200_OR32_ADDIC: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // l.andi `OR1200_OR32_ANDI: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // l.ori `OR1200_OR32_ORI: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // l.xori `OR1200_OR32_XORI: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // l.muli`ifdef OR1200_MULT_IMPLEMENTED `OR1200_OR32_MULI: rfwb_op <= #1 `OR1200_RFWBOP_ALU;`endif // Shift and rotate insns with immediate `OR1200_OR32_SH_ROTI: rfwb_op <= #1 `OR1200_RFWBOP_ALU; // ALU instructions except the one with immediate `OR1200_OR32_ALU: rfwb_op <= #1 `OR1200_RFWBOP_ALU;`ifdef OR1200_OR32_CUST5 // l.cust5 instructions `OR1200_OR32_CUST5: rfwb_op <= #1 `OR1200_RFWBOP_ALU;`endif // Instructions w/o register-file write-back default: begin rfwb_op <= #1 `OR1200_RFWBOP_NOP; end endcase endend//// Decode of pre_branch_op//always @(posedge clk or posedge rst) begin if (rst) pre_branch_op <= #1 `OR1200_BRANCHOP_NOP; else if (flushpipe) pre_branch_op <= #1 `OR1200_BRANCHOP_NOP; else if (!id_freeze) begin case (if_insn[31:26]) // synopsys parallel_case // l.j `OR1200_OR32_J: pre_branch_op <= #1 `OR1200_BRANCHOP_BAL; // j.jal `OR1200_OR32_JAL: pre_branch_op <= #1 `OR1200_BRANCHOP_BAL; // j.jalr `OR1200_OR32_JALR: pre_branch_op <= #1 `OR1200_BRANCHOP_JR; // l.jr `OR1200_OR32_JR: pre_branch_op <= #1 `OR1200_BRANCHOP_JR; // l.bnf `OR1200_OR32_BNF: pre_branch_op <= #1 `OR1200_BRANCHOP_BNF; // l.bf `OR1200_OR32_BF: pre_branch_op <= #1 `OR1200_BRANCHOP_BF; // l.rfe `OR1200_OR32_RFE: pre_branch_op <= #1 `OR1200_BRANCHOP_RFE; // Non branch instructions default: begin pre_branch_op <= #1 `OR1200_BRANCHOP_NOP; end endcase endend//// Generation of branch_op//always @(posedge clk or posedge rst) if (rst) branch_op <= #1 `OR1200_BRANCHOP_NOP; else if (!ex_freeze & id_freeze | flushpipe) branch_op <= #1 `OR1200_BRANCHOP_NOP; else if (!ex_freeze) branch_op <= #1 pre_branch_op;//// Decode of lsu_op//always @(posedge clk or posedge rst) begin if (rst) lsu_op <= #1 `OR1200_LSUOP_NOP; else if (!ex_freeze & id_freeze | flushpipe) lsu_op <= #1 `OR1200_LSUOP_NOP; else if (!ex_freeze) begin case (id_insn[31:26]) // synopsys parallel_case // l.lwz `OR1200_OR32_LWZ: lsu_op <= #1 `OR1200_LSUOP_LWZ; // l.lbz `OR1200_OR32_LBZ: lsu_op <= #1 `OR1200_LSUOP_LBZ; // l.lbs `OR1200_OR32_LBS: lsu_op <= #1 `OR1200_LSUOP_LBS; // l.lhz `OR1200_OR32_LHZ: lsu_op <= #1 `OR1200_LSUOP_LHZ; // l.lhs `OR1200_OR32_LHS: lsu_op <= #1 `OR1200_LSUOP_LHS; // l.sw `OR1200_OR32_SW: lsu_op <= #1 `OR1200_LSUOP_SW; // l.sb `OR1200_OR32_SB: lsu_op <= #1 `OR1200_LSUOP_SB; // l.sh `OR1200_OR32_SH: lsu_op <= #1 `OR1200_LSUOP_SH; // Non load/store instructions default: begin lsu_op <= #1 `OR1200_LSUOP_NOP; end endcase endend//// Decode of comp_op//always @(posedge clk or posedge rst) begin if (rst) begin comp_op <= #1 4'd0; end else if (!ex_freeze & id_freeze | flushpipe) comp_op <= #1 4'd0; else if (!ex_freeze) comp_op <= #1 id_insn[24:21];end//// Decode of l.sys//always @(posedge clk or posedge rst) begin if (rst) sig_syscall <= #1 1'b0; else if (!ex_freeze & id_freeze | flushpipe) sig_syscall <= #1 1'b0; else if (!ex_freeze) begin`ifdef OR1200_VERBOSE// synopsys translate_off if (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b000}) $display("Generating sig_syscall");// synopsys translate_on`endif sig_syscall <= #1 (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b000}); endend//// Decode of l.trap//always @(posedge clk or posedge rst) begin if (rst) sig_trap <= #1 1'b0; else if (!ex_freeze & id_freeze | flushpipe) sig_trap <= #1 1'b0; else if (!ex_freeze) begin`ifdef OR1200_VERBOSE// synopsys translate_off if (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b010}) $display("Generating sig_trap");// synopsys translate_on`endif sig_trap <= #1 (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b010}) | du_hwbkpt; endendendmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -