⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 risc8_control.v

📁 这是一篇关于8位RISC CPU设计的文章
💻 V
📖 第 1 页 / 共 2 页
字号:
     else if(div_reg) 
      begin
      next_int_type = 2'b10;
      decode = {`ST5, `ALUtha, `CRYp, `NIb, `ADRspl, `ADRpch, `ADRpcl, `Nrg, `ASRC1, `BSRCp, `FLclie, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPint};
      end
     else 
      begin
      next_int_type = 2'b11;
      decode = {`ST5, `ALUtha, `CRYp, `NIb, `ADRspl, `ADRpch, `ADRpcl, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPack, `ADOPint};
      end
     end
     3'b101: begin
     next_int_processing = 0; 
      next_int_type = int_type;
     decode = {`ST0, `ALUtha, `CRYp, `NIb, `ADRspl, `ADRpch, `ADRpch, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC11001, `DAOPno, `ADOPnul};
     end
     endcase
     end

    else if(opcode_valid)
     begin 
     case(opcode[7:3]) 
     `OPadd:  decode = {`ST0, `ALUadd, `CRY0, `NIb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPadc:  decode = {`ST0, `ALUadd, `CRYc, `NIb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul}; 
     `OPsub:  decode = {`ST0, `ALUadd, `CRY1, `INb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPsbc:  decode = {`ST0, `ALUadd, `CRYn, `INb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPinc:  decode = {`ST0, `ALUadd, `CRY1, `NIb, operan,  `ADRpvb, operan, `Wrg, `ASRC0, `BSRC1, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPdec:  decode = {`ST0, `ALUadd, `CRY0, `INb, operan,  `ADRpvb, operan, `Wrg, `ASRC0, `BSRC1, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPcmp:  decode = {`ST0, `ALUadd, `CRY1, `INb, `ADRr0,  operan, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPsbr:  decode = {`ST0, `ALUadd, `CRY1, `INb, operan,  `ADRr0, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzcnv, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPand:  decode = {`ST0, `ALUand, `CRYc, `NIb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzn,   `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPor:   decode = {`ST0, `ALUor , `CRYc, `NIb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzn,   `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul}; 
     `OPxor:  decode = {`ST0, `ALUxor, `CRYc, `NIb, `ADRr0,  operan, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLzn,   `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPnot:  decode = {`ST0, `ALUnot, `CRYc, `NIb, operan,  `ADRpvb, operan, `Wrg, `ASRC0, `BSRCp, `FLzn,   `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPshl:  decode = {`ST0, `ALUshl, `CRYc, `NIb, operan,  `ADRpvb, operan, `Wrg, `ASRC0, `BSRCp, `FLzcn,  `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPshr:  decode = {`ST0, `ALUshr, `CRYc, `NIb, operan,  `ADRpvb, operan, `Wrg, `ASRC0, `BSRCp, `FLzcn,  `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPspecial0:  // wrps, rdps, nop1, nop2
      casex(opcode[2:0])
      3'b000: decode = {`ST0, `ALUtha, `CRYc, `PIb, `ADRr0,  `ADRpvb, `ADRpsw, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      3'b001: decode = {`ST0, `ALUtha, `CRYc, `PIb, `ADRpsw, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      3'b01?: decode = {`ST0, `ALUpre, `CRYc, `PIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRCp, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      3'b1??: decode = {`ST0, `ALUpre, `CRYc, `PIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRCp, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      endcase
     `OPspecial1: begin // jmp,  ret, ror, rorc, asr
      if(!opcode[2])
       begin
        case(state[0]) // jmp an
        1'b0: decode = {`ST1, `ALUtha, `CRYc, `NIb, operan1, `ADRpvb, `ADRpcl, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10000, `DAOPno, `ADOPldl};
        1'b1: decode = {`ST0, `ALUtha, `CRYc, `NIb, operan2, `ADRpvb, `ADRpch, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC11000, `DAOPno, `ADOPldh};
        endcase
        end
      if(opcode[2])
       begin
        case(opcode[1:0]) // ret, ror, rorc, asr
        2'b00: 
         case({state[2:0]}) // ret
         3'b000: decode = {`ST1, `ALUadd, `CRY0, `INb, `ADRspl, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC10110, `DAOPno, `ADOPldl};
         3'b001: decode = {`ST2, `ALUadd, `CRYs, `INb, `ADRsph, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPrd, `ADOPldh};
         3'b010: decode = {`ST3, `ALUpre, `CRYp, `NIb, `ADRsph, `ADRpvb, `ADRpch, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPrd, `ADOPdec};
         3'b011: decode = {`ST4, `ALUpre, `CRYp, `NIb, `ADRsph, `ADRpvb, `ADRpcl, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPrd, `ADOPdec};
         3'b100: decode = {`ST5, `ALUpre, `CRYp, `NIb, `ADRsph, `ADRpvb, `ADRpsw, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPrd, `ADOPdec};
         3'b101: decode = {`ST6, `ALUtha, `CRYp, `NIb, `ADRpcl, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPldlssp};
         3'b110: decode = {`ST0, `ALUtha, `CRYp, `NIb, `ADRpch, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC11001, `DAOPno, `ADOPldh};
         endcase
       2'b01: decode = {`ST0, `ALUror,  `CRYc, `PIb, `ADRr0, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLzcn, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
       2'b10: decode = {`ST0, `ALUrorc, `CRYc, `PIb, `ADRr0, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLzcn, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
       2'b11: decode = {`ST0, `ALUasr,  `CRYc, `PIb, `ADRr0, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLzcn, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
       endcase
       end
       end
     `OPjmpr:  // jmpr #8-bit
      casex({condition, queue_count_gt0, state[1:0]})  
      4'b??00: decode = {`ST1, `ALUpre, `CRY0, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDnul, `PC1, `OPC00111, `DAOPno, `ADOPnul};
      4'b0001: decode = {`ST1, `ALUpre, `CRY0, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      4'b0101: decode = {`ST0, `ALUpre, `CRY0, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      4'b1001: decode = {`ST1, `ALUpre, `CRY0, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPnul};
      4'b1101: decode = {`ST2, `ALUadd, `CRY0, `NIb, `ADRpva, `ADRpcl, `ADRpcl, `Wrg, `ASRC1, `BSRC0, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPldl};
      4'b??10: decode = {`ST0, `ALUadd, `CRYs, `NIb, `ADRpch, `ADRpvb, `ADRpch, `Wrg, `ASRC0, `BSRC2, `FLnul, `MDnul, `PC0, `OPC11001, `DAOPno, `ADOPldh};
      endcase
     `OPjmpa:  // jmpa #16-bit
      casex({condition, queue_count_gt1, queue_count_gt0, state[1:0]})  
      5'b???00: decode = {`ST1, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC3, `OPC00111, `DAOPno, `ADOPnul};
      5'b00001: decode = {`ST1, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      5'b0?101,
      5'b01?01: decode = {`ST2, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00101, `DAOPno, `ADOPnul};
      5'b00010: decode = {`ST2, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      5'b01?10,
      5'b0?110: decode = {`ST0, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPnul};
      5'b10001: decode = {`ST1, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpcl, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      5'b10101: decode = {`ST1, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpcl, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPnul};
      5'b11?01: decode = {`ST2, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpcl, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPldl};
      5'b1??10: decode = {`ST0, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpch, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC11001, `DAOPno, `ADOPldh};
      endcase
     `OPjmps: // jmps #16-bit
      casex({condition, queue_count_gt1, queue_count_gt0, state[2:0]})  
      6'b???000: decode = {`ST1, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC3, `OPC00111, `DAOPno, `ADOPnul};
      6'b000001: decode = {`ST1, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      6'b0?1001, 
      6'b01?001: decode = {`ST2, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00101, `DAOPno, `ADOPnul};
      6'b000010: decode = {`ST2, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      6'b0?1010,
      6'b01?010: decode = {`ST0, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPnul};
      6'b100001: decode = {`ST1, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      6'b101001: decode = {`ST1, `ALUpre, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPnul};
      6'b11?001: decode = {`ST2, `ALUpre, `CRYp, `NIb, `ADRspl, `ADRr0,  `ADRspl, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPwr, `ADOPrsp};
      6'b1??010: decode = {`ST3, `ALUpre, `CRYp, `NIb, `ADRspl, `ADRpsw, `ADRspl, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPwr, `ADOPinc};
      6'b???011: decode = {`ST4, `ALUpre, `CRYp, `NIb, `ADRspl, `ADRpcl, `ADRspl, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPwr, `ADOPinc};
      6'b???100: decode = {`ST5, `ALUpre, `CRYp, `NIb, `ADRspl, `ADRpch, `ADRspl, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPwr, `ADOPinc};
      6'b???101: decode = {`ST6, `ALUtha, `CRYp, `NIb, `ADRspl, `ADRpch, `ADRpcl, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC10100, `DAOPno, `ADOPldlisp};
      6'b???110: decode = {`ST0, `ALUtha, `CRYp, `NIb, `ADRspl, `ADRpch, `ADRpch, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC11001, `DAOPno, `ADOPldh};
      endcase
     `OPwrr0:  decode = {`ST0, `ALUtha, `CRYc, `PIb, operan, `ADRpvb, `ADRr0, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPrdr0:  decode = {`ST0, `ALUtha, `CRYc, `PIb, `ADRr0, `ADRpvb, operan, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
     `OPmovsp:  // mov SP An & mov An SP; move to/from sp
      case({opcode[2], state[0]})
      2'b00: decode = {`ST1, `ALUtha, `CRYc, `PIb, operan1, `ADRpvb, `ADRspl, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      2'b01: decode = {`ST0, `ALUtha, `CRYc, `PIb, operan2, `ADRpvb, `ADRsph, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul}; 
      2'b10: decode = {`ST1, `ALUtha, `CRYc, `PIb, `ADRspl, `ADRpvb, operan1, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPno, `ADOPnul}; 
      2'b11: decode = {`ST0, `ALUtha, `CRYc, `PIb, `ADRsph, `ADRpvb, operan2, `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul}; 
      endcase 
     `OPincdec16: // 16 bit inc/ dec
      case({opcode[2], state[0]})
      2'b00: decode = {`ST1, `ALUadd, `CRY1, `NIb, operan1, `ADRpvb, operan1, `Wrg, `ASRC0, `BSRC1, `FLzcn,  `MDnul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      2'b01: decode = {`ST0, `ALUadd, `CRYc, `NIb, operan2, `ADRpvb, operan2, `Wrg, `ASRC0, `BSRC1, `FLwzcn, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul}; 
      2'b10: decode = {`ST1, `ALUadd, `CRY0, `INb, operan1, `ADRpvb, operan1, `Wrg, `ASRC0, `BSRC1, `FLzcn,  `MDnul, `PC0, `OPC00000, `DAOPno, `ADOPnul}; 
      2'b11: decode = {`ST0, `ALUadd, `CRYc, `INb, operan2, `ADRpvb, operan2, `Wrg, `ASRC0, `BSRC1, `FLwzcn, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul}; 
      endcase
     `OPldi: // 16 bit inc/ dec
      casex({queue_count_gt0, state[0]})
      2'b?0: decode = {`ST1, `ALUtha, `CRYc, `PIb, `ADRpva, `ADRpvb, operan, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00111, `DAOPno, `ADOPnul};
      2'b01: decode = {`ST1, `ALUtha, `CRYc, `PIb, `ADRpva, `ADRpvb, operan, `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPnul};
      2'b11: decode = {`ST0, `ALUtha, `CRYc, `PIb, `ADRpva, `ADRpvb, operan, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      endcase
     `OPmul: 
      case(state)
      `ST0: decode = {`ST1, `ALUtha, `CRY0, `NIb, `ADRr0,  `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDini, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST1: decode = {`ST2, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST2: decode = {`ST3, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST3: decode = {`ST4, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST4: decode = {`ST5, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST5: decode = {`ST6, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST6: decode = {`ST7, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST7: decode = {`ST8, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST8: decode = {`ST9, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDmul, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST9: decode = {`STa, `ALUtha, `CRY0, `NIb, `ADRpva, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLnul, `MDsv0, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `STa: decode = {`ST0, `ALUtha, `CRY0, `NIb, `ADRpva, `ADRpvb, operan,  `Wrg, `ASRC0, `BSRC0, `FLnul, `MDsv1, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      endcase
     `OPdiv: begin
      case(state)
      `ST0: decode = {`ST1, `ALUthb, `CRY0, `NIb, `ADRr0,  operan, `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDini, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST1: begin
       if(divide_by_0)
        decode = {`ST0, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC1, `OPC00001, `DAOPno, `ADOPnul};
       else
        decode = {`ST2, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
       end
      `ST2: decode = {`ST3, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST3: decode = {`ST4, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST4: decode = {`ST5, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST5: decode = {`ST6, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST6: decode = {`ST7, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST7: decode = {`ST8, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST8: decode = {`ST9, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDdiv, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `ST9: decode = {`STa, `ALUadd, `CRY0, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC0, `BSRC0, `FLnul, `MDres, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `STa: decode = {`STb, `ALUtha, `CRY0, `NIb, `ADRpva, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRC0, `FLnul, `MDsv0, `PC0, `OPC00000, `DAOPno, `ADOPnul};
      `STb: decode = {`ST0, `ALUtha, `CRY0, `NIb, `ADRpva, `ADRpvb, operan,  `Wrg, `ASRC0, `BSRC0, `FLnul, `MDsv1, `PC1, `OPC00001, `DAOPno, `ADOPnul};
      endcase
      end
     `OPldstr:  // ldr (An)/ Str (An)
      case({opcode[2],state[1:0]})
      3'b000: decode = {`ST1, `ALUtha, `CRYc, `NIb, operan1, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPno, `ADOPldlsv};
      3'b001: decode = {`ST2, `ALUtha, `CRYc, `NIb, operan2, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPrd, `ADOPldh};
      3'b010: decode = {`ST0, `ALUtha, `CRYc, `NIb, `ADRpva, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPrec};
      3'b100: decode = {`ST1, `ALUtha, `CRYc, `NIb, operan1, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPno, `ADOPldlsv};
      3'b101: decode = {`ST2, `ALUtha, `CRYc, `NIb, operan2, `ADRr0,  `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPwr, `ADOPldh};
      3'b110: decode = {`ST0, `ALUtha, `CRYc, `NIb, operan2, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC1, `OPC00001, `DAOPno, `ADOPrec};
      endcase
     `OPpsh:  // psh
      case({state[0]})
      1'b0: decode = {`ST1, `ALUadd, `CRY1, `NIb, `ADRspl, operan,  `ADRspl, `Wrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC1, `OPC00000, `DAOPwr, `ADOPrsp};
      1'b1: decode = {`ST0, `ALUadd, `CRYs, `NIb, `ADRsph, `ADRpvb, `ADRsph, `Wrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPrec};
      endcase
     `OPpop: // pop
      case({state[1:0]})
      2'b00: decode = {`ST1, `ALUadd, `CRY0, `INb, `ADRspl, `ADRpvb, `ADRspl, `Wrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC1, `OPC00000, `DAOPno, `ADOPldlsv};
      2'b01: decode = {`ST2, `ALUadd, `CRYs, `INb, `ADRsph, `ADRpvb, `ADRsph, `Wrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC00000, `DAOPrd, `ADOPldh};
      2'b10: decode = {`ST0, `ALUadd, `CRYs, `NIb, `ADRsph, `ADRpvb, operan,  `Wrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPrec};
      endcase
     `OPldsto:  // ldo (An + 8-bit offset)/ Sto (An + 8-bit offset)
      case({opcode[2], queue_count_gt0, state[1:0]})
      4'b0000,
      4'b0100: decode = {`ST1, `ALUadd, `CRY0, `NIb, `ADRpva, operan1, `ADRpvw, `Nrg, `ASRC1, `BSRC0, `FLnul, `MDnul, `PC1, `OPC00111, `DAOPno, `ADOPldlsv};
      4'b0001: decode = {`ST1, `ALUadd, `CRY0, `NIb, `ADRpva, operan1, `ADRpvw, `Nrg, `ASRC1, `BSRC0, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPldl};
      4'b0101: decode = {`ST2, `ALUadd, `CRYs, `NIb, operan2, `ADRpvb, `ADRpvw, `Nrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPrd, `ADOPldh};
      4'b0010,
      4'b0110: decode = {`ST0, `ALUadd, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRr0,  `Wrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPrec};
      4'b1000,
      4'b1100: decode = {`ST1, `ALUadd, `CRY0, `NIb, `ADRpva, operan1, `ADRpvw, `Nrg, `ASRC1, `BSRC0, `FLnul, `MDnul, `PC1, `OPC00111, `DAOPno, `ADOPldlsv};
      4'b1001: decode = {`ST1, `ALUadd, `CRY0, `NIb, `ADRpva, operan1, `ADRpvw, `Nrg, `ASRC1, `BSRC0, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPldl};
      4'b1101: decode = {`ST2, `ALUadd, `CRYs, `NIb, operan2, `ADRr0,  `ADRpvw, `Nrg, `ASRC0, `BSRC1, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPwr, `ADOPldh};
      4'b1010,
      4'b1110: decode = {`ST0, `ALUadd, `CRYp, `NIb, operan2, `ADRr0,  `ADRpvw, `Nrg, `ASRC0, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPrec};
      endcase
     `OPlda:  // lda (16-bit absolute)
      casex({queue_count_gt1, state[1:0]})
      3'b?00: decode = {`ST1, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC3, `OPC00111, `DAOPno, `ADOPldlsv};
      3'b001: decode = {`ST1, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPldl};
      3'b101: decode = {`ST2, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00101, `DAOPrd, `ADOPldh};
      3'b?10: decode = {`ST0, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, operan,  `Wrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPrec};
      endcase
     `OPsta: // Sta ( + 16-bit absolute)
      casex({queue_count_gt1, state[1:0]})
      3'b?00: decode = {`ST1, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC3, `OPC00111, `DAOPno, `ADOPldlsv};
      3'b001: decode = {`ST1, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00100, `DAOPno, `ADOPldl};
      3'b101: decode = {`ST2, `ALUtha, `CRYp, `NIb, `ADRpva, operan,  `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00101, `DAOPwr, `ADOPldh};
      3'b?10: decode = {`ST0, `ALUtha, `CRYp, `NIb, `ADRpva, `ADRpvb, `ADRpvw, `Nrg, `ASRC1, `BSRCp, `FLnul, `MDnul, `PC0, `OPC00001, `DAOPno, `ADOPrec};
      endcase
     endcase 
     end
    end 

endmodule 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -