RISC-V反汇编程序转储与周期精确仿真器输出不同?

时间:2016-08-31 19:23:46

标签: riscv

美好的一天!

我在运行RISC-V火箭芯片周期精确模拟器时遇到问题,我编译的dummy_rocc_test.c程序位于火箭芯片库中(riscv-tools / riscv-isa-sim / dummy_rocc)。

我将在下面解释我的步骤并在之后解决问题。我采取的步骤:

  1. git clone https://github.com/ucb-bar/rocket-chip.git
  2. {li} git submodule update --init --recursive位于rocket-chiprocket-chip/riscv-tools目录中
  3. export RISCV=[a folder called riscv-toolchain]
  4. export PATH=[...]/riscv-toolchain/bin:$PATH
  5. . rocket-chip/riscv-tools/build.sh(之后未运行build-rv32im.sh
  6. {li> make CONFIG=RoccExampleConfig位于rocket-chip/emulator目录
  7. cd rocket-chip/riscv-tools/riscv-isa-sim/dummy_rocc
  8. riscv64-unknown-elf-gcc dummy_rocc_test.c -o dummy_rocc_test.out
  9. (在dummy_rocc文件夹中) rocket-chip/emulator/emulator-TestHarness-RoccExampleConfig +dramsim +max-cycles=10000 +verbose pk dummy_rocc_test.out 3>&1 1>&2 2>&3 | spike-dasm > dummy_rocc_test.log
  10. riscv64-unknown-elf-objdump --disassemble-all dummy_rocc_test.out > dummy_rocc_test.dump
  11. dummy_rocc_test.log文件的输出(前25行,全文here):

    C0:          0 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          1 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          2 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          3 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          4 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          5 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          6 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          7 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          8 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:          9 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         10 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         11 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         12 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         13 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         14 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         15 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         16 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         17 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         18 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
    C0:         19 [0] pc=[0000001000] W[r 0=0000000000000000][0] R[r13=0000000000000000] R[r 0=918250ce690efa03] inst=[0e06b783] ld      a5, 224(a3)
    C0:         20 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui     s11, 0x6
    C0:         21 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui     s11, 0x6
    C0:         22 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui     s11, 0x6
    C0:         23 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui     s11, 0x6
    C0:         24 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui     s11, 0x6
    C0:         25 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui     s11, 0x6
    ...
    

    dummy_rocc_test.dump的输出(前35行,全文here

    dummy_rocc_test.out:     file format elf64-littleriscv
    
    
    Disassembly of section .text:
    
    0000000000010000 <_ftext>:
       10000:   00008197            auipc   gp,0x8
       10004:   d8018193            addi    gp,gp,-640 # 17d80 <_gp>
       10008:   00007297            auipc   t0,0x7
       1000c:   5d028293            addi    t0,t0,1488 # 175d8 <_PathLocale>
       10010:   00007317            auipc   t1,0x7
       10014:   67030313            addi    t1,t1,1648 # 17680 <_end>
       10018:   0002b023            sd  zero,0(t0)
       1001c:   00828293            addi    t0,t0,8
       10020:   fe62ece3            bltu    t0,t1,10018 <_ftext+0x18>
       10024:   00000517            auipc   a0,0x0
       10028:   2f050513            addi    a0,a0,752 # 10314 <__libc_fini_array>
       1002c:   2a4000ef            jal 102d0 <atexit>
       10030:   3c0000ef            jal 103f0 <__libc_init_array>
       10034:   00012503            lw  a0,0(sp)
       10038:   00810593            addi    a1,sp,8
       1003c:   00000613            li  a2,0
       10040:   124000ef            jal 10164 <main>
       10044:   2a00006f            j   102e4 <exit>
    
    0000000000010048 <_fini>:
       10048:   00008067            ret
    
    000000000001004c <deregister_tm_clones>:
       1004c:   00017537            lui a0,0x17
       10050:   000177b7            lui a5,0x17
       10054:   57850713            addi    a4,a0,1400 # 17578 <__TMC_END__>
       10058:   57f78793            addi    a5,a5,1407 # 1757f <__TMC_END__+0x7>
       1005c:   40e787b3            sub a5,a5,a4
    ...
    

    我的主要问题是我无法使模拟器输出SUCCESS!,并且编译后的程序dummy_rocc_test.c具有正确的周期数。相同的程序与spike pk运行良好。仿真器dummy_rocc_test.log的输出显示正在执行反汇编程序文件dummy_rocc_test.dump的指令;所以程序本身并没有被模拟器执行。

    我理解模拟器在其寄存器中以随机值开始,这解释了pc中的第一个值。之后,它设置为[0000001000],如果我错了,请更正我,但我认为如果使用代理内核运行,程序开始执行的0x10000地址相同(dummy_rocc_test.dump中的第一条指令应该是)。

    我确实认为pc应首先使用值0x200 / pc=[0000000200]开始,然后启动代理内核(0x200作为首选地址由RISC-V开始裸机程序。即使我在步骤9中为+maxcycles提供了更大的数字,pc只会循环遍历相同的地址,也不会再次通过[0000001000][0000000200]并输出相同的FAILED! {1}}最终因为程序显然没有及时执行。

    我想了解我在做什么或在我正在采取的步骤中的错误。谢谢你的时间!

0 个答案:

没有答案