From 1102449d38ae171cb61c707a1ae7f4246e7de464 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 24 Apr 2018 19:05:01 +0200 Subject: [PATCH] Made plugin call configurable --- cycles.txt | 1728 +++++++++++++++++++++ dbt-core | 2 +- etc/dbt-riscv Debug hello w plugin.launch | 34 + etc/dbt-riscv dhrystone.launch | 4 +- riscv/incl/iss/arch/riscv_hart_msu_vp.h | 2 +- riscv/src/main.cpp | 63 +- riscv/src/plugin/cycle_estimate.cpp | 10 +- riscv/src/plugin/instruction_count.cpp | 4 +- 8 files changed, 1821 insertions(+), 26 deletions(-) create mode 100644 cycles.txt create mode 100644 etc/dbt-riscv Debug hello w plugin.launch diff --git a/cycles.txt b/cycles.txt new file mode 100644 index 0000000..2f86175 --- /dev/null +++ b/cycles.txt @@ -0,0 +1,1728 @@ +{ + "RV32GC" : [ + { + "name" : "LUI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AUIPC", + "size" : 32, + "delay" : 1 + }, + { + "name" : "JAL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "JALR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "BEQ", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BNE", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BLT", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BGE", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BLTU", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BGEU", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "LB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LH", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LBU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LHU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SH", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADDI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTIU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "XORI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ORI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ANDI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLLI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRLI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRAI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SUB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLT", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "XOR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRA", + "size" : 32, + "delay" : 1 + }, + { + "name" : "OR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AND", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FENCE", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FENCE_I", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ECALL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "EBREAK", + "size" : 32, + "delay" : 1 + }, + { + "name" : "URET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "MRET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "WFI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SFENCE.VMA", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRS", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRC", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRWI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRSI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRCI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "MUL", + "size" : 32, + "delay" : 5 + }, + { + "name" : "MULH", + "size" : 32, + "delay" : 5 + }, + { + "name" : "MULHSU", + "size" : 320, + "delay" : 5 + }, + { + "name" : "MULHU", + "size" : 32, + "delay" : 5 + }, + { + "name" : "DIV", + "size" : 32, + "delay" : 10 + }, + { + "name" : "DIVU", + "size" : 32, + "delay" : 10 + }, + { + "name" : "REM", + "size" : 32, + "delay" : 10 + }, + { + "name" : "REMU", + "size" : 32, + "delay" : 10 + }, + { + "name" : "LR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SC.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOSWAP.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOADD.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOXOR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOAND.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOOR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMIN.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAX.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMINU.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAXU.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "C.ADDI4SPN", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LW", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SW", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ADDI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.NOP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.JAL", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LUI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ADDI16SP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SRLI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SRAI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ANDI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SUB", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.XOR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.OR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.AND", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.J", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.BEQZ", + "size" : 16, + "delay" : [1, 3] + }, + { + "name" : "C.BNEZ", + "size" : 16, + "delay" : [1, 3] + }, + { + "name" : "C.SLLI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LWSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.MV", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.JR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ADD", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.JALR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.EBREAK", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SWSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "DII", + "size" : 16, + "delay" : 1 + }, + { + "name" : "FLW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMADD.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMSUB.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FNMADD.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FNMSUB.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FADD.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSUB.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMUL.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FDIV.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSQRT.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSGNJ.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSGNJN.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSGNJX.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMIN.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMAX.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.W.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.WU.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FEQ.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FLT.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FLE.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCLASS.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.S.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.S.WU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMV.X.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMV.W.X", + "size" : 32, + "delay" : 1 + }, + { + "name" : "C.FLW", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.FSW", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.FLWSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.FSWSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "FLD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMADD.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMSUB.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FNMADD.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FNMSUB.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FADD.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSUB.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMUL.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FDIV.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSQRT.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSGNJ.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSGNJN.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FSGNJX.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMIN.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FMAX.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.S.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.D.S", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FEQ.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FLT.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FLE.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCLASS.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.W.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.WU.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.D.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FCVT.D.WU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "C.FLD", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.FSD", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.FLDSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.FSDSP", + "size" : 16, + "delay" : 1 + } + ], + "RV32IMAC" : [ + { + "name" : "LUI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AUIPC", + "size" : 32, + "delay" : 1 + }, + { + "name" : "JAL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "JALR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "BEQ", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BNE", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BLT", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BGE", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BLTU", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BGEU", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "LB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LH", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LBU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LHU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SH", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADDI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTIU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "XORI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ORI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ANDI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLLI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRLI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRAI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SUB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLT", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "XOR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRA", + "size" : 32, + "delay" : 1 + }, + { + "name" : "OR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AND", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FENCE", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FENCE_I", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ECALL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "EBREAK", + "size" : 32, + "delay" : 1 + }, + { + "name" : "URET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "MRET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "WFI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SFENCE.VMA", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRS", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRC", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRWI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRSI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRCI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "MUL", + "size" : 32, + "delay" : 5 + }, + { + "name" : "MULH", + "size" : 32, + "delay" : 5 + }, + { + "name" : "MULHSU", + "size" : 32, + "delay" : 5 + }, + { + "name" : "MULHU", + "size" : 32, + "delay" : 5 + }, + { + "name" : "DIV", + "size" : 32, + "delay" : 10 + }, + { + "name" : "DIVU", + "size" : 32, + "delay" : 10 + }, + { + "name" : "REM", + "size" : 32, + "delay" : 10 + }, + { + "name" : "REMU", + "size" : 32, + "delay" : 10 + }, + { + "name" : "LR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SC.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOSWAP.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOADD.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOXOR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOAND.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOOR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMIN.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAX.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMINU.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAXU.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "C.ADDI4SPN", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LW", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SW", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ADDI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.NOP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.JAL", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LUI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ADDI16SP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SRLI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SRAI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ANDI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SUB", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.XOR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.OR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.AND", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.J", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.BEQZ", + "size" : 16, + "delay" : [1, 3] + }, + { + "name" : "C.BNEZ", + "size" : 16, + "delay" : [1, 3] + }, + { + "name" : "C.SLLI", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.LWSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.MV", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.JR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.ADD", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.JALR", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.EBREAK", + "size" : 16, + "delay" : 1 + }, + { + "name" : "C.SWSP", + "size" : 16, + "delay" : 1 + }, + { + "name" : "DII", + "size" : 16, + "delay" : 1 + } + ], + "RV64IA" : [ + { + "name" : "LWU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLLI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRLI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRAI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADDIW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLLIW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRLIW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRAIW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADDW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SUBW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLLW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRLW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRAW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LUI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AUIPC", + "size" : 32, + "delay" : 1 + }, + { + "name" : "JAL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "JALR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "BEQ", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BNE", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BLT", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BGE", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BLTU", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "BGEU", + "size" : 32, + "delay" : [1, 3] + }, + { + "name" : "LB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LH", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LBU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LHU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SH", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADDI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTIU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "XORI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ORI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ANDI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ADD", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SUB", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLT", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SLTU", + "size" : 32, + "delay" : 1 + }, + { + "name" : "XOR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRA", + "size" : 32, + "delay" : 1 + }, + { + "name" : "OR", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AND", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FENCE", + "size" : 32, + "delay" : 1 + }, + { + "name" : "FENCE_I", + "size" : 32, + "delay" : 1 + }, + { + "name" : "ECALL", + "size" : 32, + "delay" : 1 + }, + { + "name" : "EBREAK", + "size" : 32, + "delay" : 1 + }, + { + "name" : "URET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SRET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "MRET", + "size" : 32, + "delay" : 1 + }, + { + "name" : "WFI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SFENCE.VMA", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRW", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRS", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRC", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRWI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRSI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "CSRRCI", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LR.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SC.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOSWAP.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOADD.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOXOR.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOAND.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOOR.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMIN.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAX.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMINU.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAXU.D", + "size" : 32, + "delay" : 1 + }, + { + "name" : "LR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "SC.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOSWAP.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOADD.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOXOR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOAND.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOOR.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMIN.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAX.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMINU.W", + "size" : 32, + "delay" : 1 + }, + { + "name" : "AMOMAXU.W", + "size" : 32, + "delay" : 1 + } + ] +} \ No newline at end of file diff --git a/dbt-core b/dbt-core index 555bff0..393c374 160000 --- a/dbt-core +++ b/dbt-core @@ -1 +1 @@ -Subproject commit 555bff0a20cfbf775994ed74b188b9af480df883 +Subproject commit 393c374cac4950e629036dda1615abedf866961f diff --git a/etc/dbt-riscv Debug hello w plugin.launch b/etc/dbt-riscv Debug hello w plugin.launch new file mode 100644 index 0000000..f46628e --- /dev/null +++ b/etc/dbt-riscv Debug hello w plugin.launch @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/dbt-riscv dhrystone.launch b/etc/dbt-riscv dhrystone.launch index a00fc10..a666818 100644 --- a/etc/dbt-riscv dhrystone.launch +++ b/etc/dbt-riscv dhrystone.launch @@ -12,7 +12,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/riscv/incl/iss/arch/riscv_hart_msu_vp.h b/riscv/incl/iss/arch/riscv_hart_msu_vp.h index dede9de..9e820ce 100644 --- a/riscv/incl/iss/arch/riscv_hart_msu_vp.h +++ b/riscv/incl/iss/arch/riscv_hart_msu_vp.h @@ -55,7 +55,7 @@ namespace arch { enum { tohost_dflt = 0xF0001000, fromhost_dflt = 0xF0001040 }; -enum csr_name { +enum riscv_csr { /* user-level CSR */ // User Trap Setup ustatus = 0x000, diff --git a/riscv/src/main.cpp b/riscv/src/main.cpp index a241da0..f3132a9 100644 --- a/riscv/src/main.cpp +++ b/riscv/src/main.cpp @@ -66,7 +66,8 @@ int main(int argc, char *argv[]) { ("dump-ir", "dump the intermediate representation") ("elf", po::value>(), "ELF file(s) to load") ("mem,m", po::value(), "the memory input file") - ("isa", po::value()->default_value("rv32imac"), "isa to use for simulation"); + ("plugin,p", po::value>(), "plugin to activate") + ("isa", po::value()->default_value("rv32gc"), "isa to use for simulation"); // clang-format on auto parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); try { @@ -97,30 +98,55 @@ int main(int argc, char *argv[]) { LOG_OUTPUT(connection)::stream() = f; } + std::vector plugin_list; + auto res=0; try { // application code comes here // iss::init_jit(argc, argv); bool dump = clim.count("dump-ir"); // instantiate the simulator std::unique_ptr vm{nullptr}; + std::unique_ptr cpu{nullptr}; std::string isa_opt(clim["isa"].as()); -// iss::plugin::instruction_count ic_plugin("riscv/gen_input/src-gen/rv32imac_cyles.txt"); -// iss::plugin::cycle_estimate ce_plugin("riscv/gen_input/src-gen/rv32imac_cyles.txt"); - if (isa_opt.substr(0, 4)=="rv64") { - iss::arch::rv64ia* cpu = new iss::arch::riscv_hart_msu_vp(); - vm = iss::create(cpu, clim["gdb-port"].as()); - } else if (isa_opt.substr(0, 5)=="rv32i") { - iss::arch::rv32imac* cpu = new iss::arch::riscv_hart_msu_vp(); - vm = iss::create(cpu, clim["gdb-port"].as()); - //vm->register_plugin(ce_plugin); - } else if (isa_opt.substr(0, 5)=="rv32g") { - iss::arch::rv32gc* cpu = new iss::arch::riscv_hart_msu_vp(); - vm = iss::create(cpu, clim["gdb-port"].as()); - //vm->register_plugin(ce_plugin); + if (isa_opt=="rv64ia") { + iss::arch::rv64ia* lcpu = new iss::arch::riscv_hart_msu_vp(); + vm = iss::create(lcpu, clim["gdb-port"].as()); + cpu.reset(lcpu); + } else if (isa_opt=="rv32imac") { + iss::arch::rv32imac* lcpu = new iss::arch::riscv_hart_msu_vp(); + vm = iss::create(lcpu, clim["gdb-port"].as()); + cpu.reset(lcpu); + } else if (isa_opt=="rv32gc") { + iss::arch::rv32gc* lcpu = new iss::arch::riscv_hart_msu_vp(); + vm = iss::create(lcpu, clim["gdb-port"].as()); + cpu.reset(lcpu); } else { LOG(ERROR) << "Illegal argument value for '--isa': " << clim["isa"].as() << std::endl; return 127; } + if (clim.count("plugin")) { + for (std::string opt_val : clim["plugin"].as>()){ + auto plugin_name{opt_val}; + std::string filename{"cycles.txt"}; + std::size_t found = opt_val.find('='); + if (found!=std::string::npos){ + plugin_name=opt_val.substr(0, found); + filename=opt_val.substr(found+1, opt_val.size()); + } + if(plugin_name=="ic"){ + auto* ic_plugin= new iss::plugin::instruction_count(filename); + vm->register_plugin(*ic_plugin); + plugin_list.push_back(ic_plugin); + } else if(plugin_name=="ce"){ + auto* ce_plugin= new iss::plugin::cycle_estimate(filename); + vm->register_plugin(*ce_plugin); + plugin_list.push_back(ce_plugin); + } else { + LOG(ERROR) << "Unknown plugin name: " << plugin_name << ", valid names are 'ce', 'ic'"<setDisassEnabled(true); LOGGER(disass)::reporting_level() = logging::INFO; @@ -151,9 +177,14 @@ int main(int argc, char *argv[]) { } vm->reset(start_address); auto cycles = clim["instructions"].as(); - return vm->start(cycles, dump); + res = vm->start(cycles, dump); } catch (std::exception &e) { LOG(ERROR) << "Unhandled Exception reached the top of main: " << e.what() << ", application will now exit" << std::endl; - return 2; + res=2; } + // cleanup to let plugins report of needed + for(auto* p:plugin_list){ + delete p; + } + return res; } diff --git a/riscv/src/plugin/cycle_estimate.cpp b/riscv/src/plugin/cycle_estimate.cpp index e5270bd..2a68c61 100644 --- a/riscv/src/plugin/cycle_estimate.cpp +++ b/riscv/src/plugin/cycle_estimate.cpp @@ -63,7 +63,7 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& if(!arch_instr) return false; const std::string core_name = arch_instr->core_type_name(); Json::Value &val = root[core_name]; - if(val.isArray()){ + if(!val.isNull() && val.isArray()){ delays.reserve(val.size()); for(auto it:val){ auto name = it["name"]; @@ -76,6 +76,8 @@ bool iss::plugin::cycle_estimate::registration(const char* const version, vm_if& delays.push_back(instr_desc{size.asUInt(), delay[0].asUInt(), delay[1].asUInt()}); } } + } else { + LOG(ERROR)<<"plugin cycle_estimate: could not find an entry for "<get_next_pc()-arch_instr->get_pc()) != (entry.size/8); - if(taken && entry.taken > 1 ) // 1 is the default increment per instruction - arch_instr->set_curr_instr_cycles(entry.taken); - if(!taken && entry.not_taken > 1) // 1 is the default increment per instruction - arch_instr->set_curr_instr_cycles(entry.not_taken); + uint32_t delay = taken ? entry.taken : entry.not_taken; + if(delay>1) arch_instr->set_curr_instr_cycles(delay); } diff --git a/riscv/src/plugin/instruction_count.cpp b/riscv/src/plugin/instruction_count.cpp index 282b173..eedb59a 100644 --- a/riscv/src/plugin/instruction_count.cpp +++ b/riscv/src/plugin/instruction_count.cpp @@ -68,7 +68,7 @@ bool iss::plugin::instruction_count::registration(const char* const version, vm_ if(!instr_if) return false; const std::string core_name = instr_if->core_type_name(); Json::Value &val = root[core_name]; - if(val.isArray()){ + if(!val.isNull() && val.isArray()){ delays.reserve(val.size()); for(auto it:val){ auto name = it["name"]; @@ -84,6 +84,8 @@ bool iss::plugin::instruction_count::registration(const char* const version, vm_ } } rep_counts.resize(delays.size()); + } else { + LOG(ERROR)<<"plugin instruction_count: could not find an entry for "<