├── .gitattributes ├── .github └── workflows │ ├── difftest-selfhost.yml │ └── difftest.yml ├── .gitignore ├── .idea ├── .gitignore ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── file.template.settings.xml ├── fileTemplates │ ├── Chisel Bundle.scala │ ├── Chisel Enum.scala │ └── Chisel Module.scala ├── inspectionProfiles │ └── Project_Default.xml ├── modules.xml └── scala_settings.xml ├── .mill-version ├── .scalafmt.conf ├── .vscode └── settings.json ├── Makefile ├── README.md ├── build.sc ├── docs ├── chiplab.md └── design.pdf ├── env.example ├── millw ├── millw.bat ├── scripts ├── modify_verilog.sh └── refresh_branch.sh ├── src ├── src │ ├── ComplexCoreCpuTop.scala │ ├── Elaborate.scala │ ├── SimpleCoreCpuTop.scala │ ├── axi │ │ ├── Arbiter.scala │ │ ├── Axi3x1Crossbar.scala │ │ ├── AxiCrossbar.scala │ │ ├── AxiCrossbarAddr.scala │ │ ├── AxiCrossbarRead.scala │ │ ├── AxiCrossbarWrite.scala │ │ ├── AxiMaster.scala │ │ ├── AxiRegisterRead.scala │ │ ├── AxiRegisterWrite.scala │ │ ├── BetterAxiMaster.scala │ │ ├── PriorityEncoder.scala │ │ ├── SetClrReg.scala │ │ ├── bundles │ │ │ ├── ArChannel.scala │ │ │ ├── AwChannel.scala │ │ │ ├── AxiMasterInterface.scala │ │ │ ├── BChannel.scala │ │ │ ├── MasterCrossbar.scala │ │ │ ├── MasterRead.scala │ │ │ ├── MasterRegisterRead.scala │ │ │ ├── MasterRegisterWrite.scala │ │ │ ├── MasterWrite.scala │ │ │ ├── RChannel.scala │ │ │ ├── SlaveCrossbar.scala │ │ │ ├── SlaveRead.scala │ │ │ ├── SlaveWrite.scala │ │ │ └── WChannel.scala │ │ └── types │ │ │ └── RegType.scala │ ├── common │ │ ├── BaseStage.scala │ │ ├── CombBaseStage.scala │ │ ├── DistributedQueue.scala │ │ ├── DistributedQueuePlus.scala │ │ ├── LookupQueue.scala │ │ ├── MultiBaseStage.scala │ │ ├── MultiQueue.scala │ │ ├── NoSavedInBaseStage.scala │ │ ├── NoSavedInMultiBaseStage.scala │ │ ├── Pc.scala │ │ ├── RegFile.scala │ │ ├── SimpleMultiBaseStage.scala │ │ ├── bundles │ │ │ ├── AxiMasterPort.scala │ │ │ ├── BackendRedirectPcNdPort.scala │ │ │ ├── BaseStagePort.scala │ │ │ ├── MultiBaseStagePort.scala │ │ │ ├── PassThroughPort.scala │ │ │ ├── RfAccessInfoNdPort.scala │ │ │ ├── RfReadPort.scala │ │ │ └── RfWriteNdPort.scala │ │ └── enums │ │ │ └── ReadWriteSel.scala │ ├── control │ │ ├── Csr.scala │ │ ├── CsrScoreboard.scala │ │ ├── StableCounter.scala │ │ ├── bundles │ │ │ ├── BadVAddrSetBundle.scala │ │ │ ├── BranchFlushInfo.scala │ │ │ ├── CsrReadPort.scala │ │ │ ├── CsrValuePort.scala │ │ │ ├── CsrWriteNdPort.scala │ │ │ ├── CuToCsrNdPort.scala │ │ │ ├── DifftestTimerNdPort.scala │ │ │ ├── EcodeBundle.scala │ │ │ ├── LLBitSetBundle.scala │ │ │ ├── PipelineControlNdPort.scala │ │ │ └── StableCounterReadPort.scala │ │ ├── csrRegsBundles │ │ │ ├── AsidBundle.scala │ │ │ ├── BadvBundle.scala │ │ │ ├── CpuidBundle.scala │ │ │ ├── CrmdBundle.scala │ │ │ ├── CsrSaveBundle.scala │ │ │ ├── DmwBundle.scala │ │ │ ├── EcfgBundle.scala │ │ │ ├── EentryBundle.scala │ │ │ ├── EraBundle.scala │ │ │ ├── EstatBundle.scala │ │ │ ├── EuenBundle.scala │ │ │ ├── LlbctlBundle.scala │ │ │ ├── PgdBundle.scala │ │ │ ├── PgdhBundle.scala │ │ │ ├── PgdlBundle.scala │ │ │ ├── PrmdBundle.scala │ │ │ ├── TcfgBundle.scala │ │ │ ├── TiclrBundle.scala │ │ │ ├── TidBundle.scala │ │ │ ├── TlbehiBundle.scala │ │ │ ├── TlbeloBundle.scala │ │ │ ├── TlbidxBundle.scala │ │ │ ├── TlbrentryBundle.scala │ │ │ └── TvalBundle.scala │ │ └── enums │ │ │ └── ExceptionPos.scala │ ├── execution │ │ ├── Clz.scala │ │ ├── Div.scala │ │ ├── Mul.scala │ │ └── bundles │ │ │ ├── AluInstNdPort.scala │ │ │ ├── AluResultNdPort.scala │ │ │ └── MulDivInstNdPort.scala │ ├── frontend │ │ ├── FetchTargetQueue.scala │ │ ├── Frontend.scala │ │ ├── InstFetch.scala │ │ ├── InstFetchStage.scala │ │ ├── NaiiveFetchStage.scala │ │ ├── PreDecoder.scala │ │ ├── SimpleFetchStage.scala │ │ ├── bpu │ │ │ ├── BPU.scala │ │ │ ├── RAS.scala │ │ │ ├── TagePredictor.scala │ │ │ ├── bundles │ │ │ │ ├── BpuFtqMetaNdPort.scala │ │ │ │ ├── FtqBranchMetaEntry.scala │ │ │ │ └── TagePredictorUpdateInfoPort.scala │ │ │ ├── components │ │ │ │ ├── BasePredictor.scala │ │ │ │ ├── Bundles │ │ │ │ │ ├── FtbEntryNdPort.scala │ │ │ │ │ └── TageMetaPort.scala │ │ │ │ ├── FTB.scala │ │ │ │ └── TaggedPreditor.scala │ │ │ └── utils │ │ │ │ ├── CsrHash.scala │ │ │ │ └── DebugCsrHash.scala │ │ ├── bundles │ │ │ ├── BpuFtqPort.scala │ │ │ ├── BranchTakenMetaBundle.scala │ │ │ ├── CommitFtqTrainNdPort.scala │ │ │ ├── ExeFtqPort.scala │ │ │ ├── FetchCsrNdPort.scala │ │ │ ├── FtqBlockBundle.scala │ │ │ ├── FtqBpuMetaPort.scala │ │ │ ├── FtqIFNdPort.scala │ │ │ ├── ICacheAccessPort.scala │ │ │ ├── ICacheRequestHandshakePort.scala │ │ │ ├── ICacheRequestNdPort.scala │ │ │ ├── InstMemResponseNdPort.scala │ │ │ └── PredecoderResultNdPort.scala │ │ └── fetch │ │ │ ├── InstAddrTransStage.scala │ │ │ ├── InstPreDecodeStage.scala │ │ │ ├── InstReqStage.scala │ │ │ └── InstResStage.scala │ ├── memory │ │ ├── BRam.scala │ │ ├── DCache.scala │ │ ├── ICache.scala │ │ ├── LutRam.scala │ │ ├── SimpleRam.scala │ │ ├── Tlb.scala │ │ ├── UncachedAgent.scala │ │ ├── VBRam.scala │ │ ├── bundles │ │ │ ├── CacheMaintenanceControlNdPort.scala │ │ │ ├── CacheMaintenanceHandshakePort.scala │ │ │ ├── CacheMaintenanceNdPort.scala │ │ │ ├── ICacheStatusTagBundle.scala │ │ │ ├── MemAccessPort.scala │ │ │ ├── MemRequestHandshakePort.scala │ │ │ ├── MemResponseNdPort.scala │ │ │ ├── SimpleRamReadPort.scala │ │ │ ├── SimpleRamWriteNdPort.scala │ │ │ ├── StatusTagBundle.scala │ │ │ ├── TlbCompareEntryBundle.scala │ │ │ ├── TlbCsrWriteNdPort.scala │ │ │ ├── TlbEntryBundle.scala │ │ │ ├── TlbMaintenanceNdPort.scala │ │ │ ├── TlbTransEntryBundle.scala │ │ │ ├── TlbTransPort.scala │ │ │ └── TransExceptionCsrNdPort.scala │ │ └── enums │ │ │ ├── DCacheState.scala │ │ │ ├── ICacheState.scala │ │ │ ├── TlbInstType.scala │ │ │ ├── TlbMemType.scala │ │ │ └── UncachedAgentState.scala │ ├── pipeline │ │ ├── common │ │ │ ├── bundles │ │ │ │ ├── CacheMaintenanceInstNdPort.scala │ │ │ │ ├── DifftestLoadNdPort.scala │ │ │ │ ├── DifftestStoreNdPort.scala │ │ │ │ ├── DifftestTlbFillNdPort.scala │ │ │ │ ├── FetchInstInfoBundle.scala │ │ │ │ ├── FtqInfoBundle.scala │ │ │ │ ├── InstQueueEnqNdPort.scala │ │ │ │ ├── MemCsrNdPort.scala │ │ │ │ ├── MemRequestNdPort.scala │ │ │ │ ├── PcInstBundle.scala │ │ │ │ └── RobQueryPcPort.scala │ │ │ └── enums │ │ │ │ ├── AddrTransType.scala │ │ │ │ ├── CacheMaintenanceTargetType.scala │ │ │ │ ├── MemSizeType.scala │ │ │ │ ├── RegDataLocateSel.scala │ │ │ │ ├── RegDataState.scala │ │ │ │ ├── RobDistributeSel.scala │ │ │ │ └── RobInstState.scala │ │ ├── complex │ │ │ ├── Cu.scala │ │ │ ├── bundles │ │ │ │ ├── CommitFtqInfoBundle.scala │ │ │ │ ├── InstInfoNdPort.scala │ │ │ │ └── RobInstStoreBundle.scala │ │ │ ├── commit │ │ │ │ └── CommitStage.scala │ │ │ ├── dataforward │ │ │ │ ├── DataForwardStage.scala │ │ │ │ └── bundles │ │ │ │ │ └── ReadPortWithValid.scala │ │ │ ├── dispatch │ │ │ │ ├── DispatchStage.scala │ │ │ │ ├── RenameStage.scala │ │ │ │ ├── bundles │ │ │ │ │ ├── IssueInfoWithValidBundle.scala │ │ │ │ │ ├── PreExeInstNdPort.scala │ │ │ │ │ ├── RenameRequestNdPort.scala │ │ │ │ │ ├── RenameResultNdPort.scala │ │ │ │ │ ├── ReservationStationBundle.scala │ │ │ │ │ └── ScoreboardChangeNdPort.scala │ │ │ │ ├── enums │ │ │ │ │ ├── IssueStageState.scala │ │ │ │ │ ├── PrfState.scala │ │ │ │ │ └── ScoreboardState.scala │ │ │ │ └── rs │ │ │ │ │ ├── BaseReservationStation.scala │ │ │ │ │ ├── InOrderReservationStation.scala │ │ │ │ │ ├── OoOReservationStation.scala │ │ │ │ │ └── SimpleOoOReservationStation.scala │ │ │ ├── execution │ │ │ │ ├── Alu.scala │ │ │ │ ├── ExePassWbStage.scala │ │ │ │ └── bundles │ │ │ │ │ └── JumpBranchInfoNdPort.scala │ │ │ ├── memory │ │ │ │ ├── AddrTransStage.scala │ │ │ │ ├── ExeForMemStage.scala │ │ │ │ ├── MemReqStage.scala │ │ │ │ ├── MemResStage.scala │ │ │ │ └── bundles │ │ │ │ │ └── StoreInfoBundle.scala │ │ │ ├── pmu │ │ │ │ ├── Pmu.scala │ │ │ │ └── bundles │ │ │ │ │ ├── PmuBranchMisPredictExeNdPort.scala │ │ │ │ │ ├── PmuBranchPredictNdPort.scala │ │ │ │ │ ├── PmuCacheNdPort.scala │ │ │ │ │ ├── PmuDispatchBundle.scala │ │ │ │ │ ├── PmuNdPort.scala │ │ │ │ │ └── PmuStoreQueueNdPort.scala │ │ │ ├── queue │ │ │ │ ├── MultiInstQueue.scala │ │ │ │ ├── bundles │ │ │ │ │ ├── DecodeOutNdPort.scala │ │ │ │ │ └── DecodePort.scala │ │ │ │ └── decode │ │ │ │ │ ├── Decoder.scala │ │ │ │ │ ├── Decoder_2R.scala │ │ │ │ │ ├── Decoder_2RI12.scala │ │ │ │ │ ├── Decoder_2RI14.scala │ │ │ │ │ ├── Decoder_2RI16.scala │ │ │ │ │ ├── Decoder_3R.scala │ │ │ │ │ ├── Decoder_4R.scala │ │ │ │ │ └── Decoder_special.scala │ │ │ └── rob │ │ │ │ ├── Rob.scala │ │ │ │ ├── bundles │ │ │ │ ├── InstWbNdPort.scala │ │ │ │ ├── RobDistributeBundle.scala │ │ │ │ ├── RobIdDistributePort.scala │ │ │ │ ├── RobMatchBundle.scala │ │ │ │ ├── RobReadRequestNdPort.scala │ │ │ │ └── RobReadResultNdPort.scala │ │ │ │ └── lvt │ │ │ │ ├── LiveValueTable.scala │ │ │ │ ├── LutRam.scala │ │ │ │ ├── LvtLastValidTable.scala │ │ │ │ └── bundles │ │ │ │ ├── LvtReadPort.scala │ │ │ │ └── LvtWriteNdPort.scala │ │ └── simple │ │ │ ├── AddrTransStage.scala │ │ │ ├── CommitStage.scala │ │ │ ├── Cu.scala │ │ │ ├── MainExeStage.scala │ │ │ ├── MemReqStage.scala │ │ │ ├── MemResStage.scala │ │ │ ├── RegMatchTable.scala │ │ │ ├── Rob.scala │ │ │ ├── SimpleExeStage.scala │ │ │ ├── bundles │ │ │ ├── CommitFtqInfoBundle.scala │ │ │ ├── FtqPredictInfoBundle.scala │ │ │ ├── FtqStoreInfoBundle.scala │ │ │ ├── InstInfoNdPort.scala │ │ │ ├── MainExeBranchInfoBundle.scala │ │ │ ├── PreExeInstNdPort.scala │ │ │ ├── RSBundle.scala │ │ │ ├── RegMatchBundle.scala │ │ │ ├── RegOccupyNdPort.scala │ │ │ ├── RegReadPort.scala │ │ │ ├── RegWakeUpNdPort.scala │ │ │ ├── RobInstStoreBundle.scala │ │ │ ├── RobRequestPort.scala │ │ │ └── WbNdPort.scala │ │ │ ├── decode │ │ │ ├── BaseDecoder.scala │ │ │ ├── Decoder_2R.scala │ │ │ ├── Decoder_2RI12.scala │ │ │ ├── Decoder_2RI14.scala │ │ │ ├── Decoder_2RI16.scala │ │ │ ├── Decoder_3R.scala │ │ │ ├── Decoder_special.scala │ │ │ └── bundles │ │ │ │ ├── DecodeOutNdPort.scala │ │ │ │ └── DecodePort.scala │ │ │ ├── execution │ │ │ └── Alu.scala │ │ │ ├── id │ │ │ ├── BaseIssueQueue.scala │ │ │ ├── CompressIssueQueue.scala │ │ │ ├── CompressUnit3IssueQueue.scala │ │ │ ├── DecodeStage.scala │ │ │ ├── DecodeUnit.scala │ │ │ ├── IssueQueue.scala │ │ │ ├── OoOIssueQueue.scala │ │ │ ├── SimpleInstQueue.scala │ │ │ ├── Unit3IssueQueue.scala │ │ │ └── rs │ │ │ │ ├── IoReservationStation.scala │ │ │ │ └── OoOReservationStation.scala │ │ │ └── pmu │ │ │ ├── Pmu.scala │ │ │ └── bundles │ │ │ ├── PmuBranchMisPredictExeNdPort.scala │ │ │ ├── PmuBranchPredictNdPort.scala │ │ │ ├── PmuCacheNdPort.scala │ │ │ └── PmuDispatchInfoBundle.scala │ ├── spec │ │ ├── Csr.scala │ │ ├── ExeInst.scala │ │ ├── Inst.scala │ │ ├── Param.scala │ │ └── package.scala │ └── utils │ │ ├── BiCounter.scala │ │ ├── BiPriorityMux.scala │ │ ├── MinFinder.scala │ │ ├── MultiCounter.scala │ │ └── MultiMux.scala └── test │ └── src │ ├── BaseStageSpec.scala │ ├── ComponentSpec.scala │ ├── DCacheMaintenanceSpec.scala │ ├── DCacheSpec.scala │ ├── DCacheWritebackSpec.scala │ ├── DataForwardSpec.scala │ ├── ExeStageSpecs │ └── testClz.scala │ ├── ICacheSpec.scala │ ├── InstQueueSpec.scala │ ├── MultiMuxSpec.scala │ ├── SimpleCpuSpec.scala │ └── enums │ └── TestEnum.scala ├── utils ├── firtool ├── firtool.exe ├── firtool_darwin ├── firtool_darwin_x86_64 └── firtool_ubuntu2004 └── verilog ├── arbiter.v ├── axi_3x1_crossbar.v ├── axi_crossbar.v ├── axi_crossbar_addr.v ├── axi_crossbar_rd.v ├── axi_crossbar_wr.v ├── axi_register_rd.v ├── axi_register_wr.v ├── cpu_top.v ├── mycpu_top.v ├── priority_encoder.v ├── simpledual_readfirst_bram.v ├── single_readfirst_bram.v └── truedual_readfirst_bram.v /.gitattributes: -------------------------------------------------------------------------------- 1 | firtool text eol=lf 2 | millw text eol=lf -------------------------------------------------------------------------------- /.github/workflows/difftest-selfhost.yml: -------------------------------------------------------------------------------- 1 | name: Self-hosted Difftest 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | rand_test: 12 | runs-on: self-hosted 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Clone Chiplab Repo 18 | uses: actions/checkout@v3 19 | with: 20 | repository: Invalid-Syntax-NSCSCC/min-chiplab 21 | lfs: true 22 | token: ${{ secrets.DIFFTEST_ACCESS_TOKEN }} 23 | path: chiplab 24 | 25 | - name: Prepare Environment 26 | run: | 27 | echo "`pwd`/chiplab/toolchains/loongarch32r-linux-gnusf-2022-05-20/bin" >> $GITHUB_PATH 28 | 29 | - name: Use Cache 30 | uses: coursier/cache-action@v6 31 | 32 | - name: Elaborate CPU 33 | run: make 34 | 35 | - name: Move to Chiplab 36 | run: | 37 | export CHIPLAB_HOME=`pwd`/chiplab 38 | make chiplab 39 | 40 | - name: Test 41 | run: | 42 | export CHIPLAB_HOME=`pwd`/chiplab 43 | cd ./chiplab/sims/verilator/run_random 44 | make 45 | if [[ -s fail.log || -s nopass.log ]]; then 46 | exit 1 47 | fi 48 | 49 | func_test: 50 | runs-on: self-hosted 51 | 52 | steps: 53 | - uses: actions/checkout@v3 54 | 55 | - name: Clone Chiplab Repo 56 | uses: actions/checkout@v3 57 | with: 58 | repository: Invalid-Syntax-NSCSCC/min-chiplab 59 | lfs: true 60 | token: ${{ secrets.DIFFTEST_ACCESS_TOKEN }} 61 | path: chiplab 62 | 63 | - name: Prepare Environment 64 | run: | 65 | echo "`pwd`/chiplab/toolchains/loongarch32r-linux-gnusf-2022-05-20/bin" >> $GITHUB_PATH 66 | 67 | - name: Use Cache 68 | uses: coursier/cache-action@v6 69 | 70 | - name: Elaborate CPU 71 | run: make 72 | 73 | - name: Move to Chiplab 74 | run: | 75 | export CHIPLAB_HOME=`pwd`/chiplab 76 | make chiplab 77 | 78 | - name: Test 79 | run: | 80 | export CHIPLAB_HOME=`pwd`/chiplab 81 | cd ./chiplab/sims/verilator/run_prog 82 | ./configure.sh --run func/func_lab19 --threads 4 --tail-waveform --tail-simu-trace --waveform-tail-size 200 --trace-tail-size 200 83 | make -j`nproc` > make_log.txt 2>&1 84 | sed -i '/RUN simulation/,$!d' make_log.txt 85 | cat make_log.txt 86 | if ! grep -q 'Reached test end PC' make_log.txt; then 87 | exit 1 88 | fi 89 | 90 | - name: Upload Result 91 | uses: actions/upload-artifact@v3 92 | with: 93 | name: difftest-log 94 | path: | 95 | ./chiplab/sims/verilator/run_prog/make_log.txt 96 | ./chiplab/sims/verilator/run_prog/log/**/simu_trace.* 97 | ./chiplab/sims/verilator/run_prog/obj/**/obj/test.s 98 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/file.template.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |