Complete hex file is not loading to verilator model

69 views
Skip to first unread message

Shiva

unread,
Sep 11, 2020, 2:05:44 AM9/11/20
to RISC-V ISA Dev
Hi,
Currently I am doing C to hex conversion and hex loading to verilator model for a simple addition program.
int main() {
    int a = 32;
    int b = 23;
     {
        int c = a + b;
    }
    return 0;
}
I converted this C code to hex using new version (10.1.0) of riscv gnu tool chain. But the result hex code is not loading properly in my verilator model.

Disassembly of section .text:

1c000000 <_start>:
1c000000:    00001197              auipc    gp,0x1
1c000004:    18018193              addi    gp,gp,384 # 1c001180 <__global_pointer$>
1c000008:    00001517              auipc    a0,0x1
1c00000c:    95850513              addi    a0,a0,-1704 # 1c000960 <__FRAME_END__>
1c000010:    00001617              auipc    a2,0x1
1c000014:    97060613              addi    a2,a2,-1680 # 1c000980 <completed.1>
1c000018:    40a60633              sub    a2,a2,a0
1c00001c:    00000593              li    a1,0
1c000020:    1a8000ef              jal    ra,1c0001c8 <memset>
1c000024:    00000517              auipc    a0,0x0

in the  dump file section after 1c000024 the pgm jump to 1c0001c8 
1c0001c8 <memset>:
1c0001c8:    00f00313              li    t1,15
1c0001cc:    00050713              mv    a4,a0
1c0001d0:    02c37e63              bgeu    t1,a2,1c00020c <memset+0x44>
1c0001d4:    00f77793              andi    a5,a4,15
1c0001d8:    0a079063              bnez    a5,1c000278 <memset+0xb0>
1c0001dc:    08059263              bnez    a1,1c000260 <memset+0x98>
1c0001e0:    ff067693              andi    a3,a2,-16
1c0001e4:    00f67613              andi    a2,a2,15
1c0001e8:    00e686b3              add    a3,a3,a4
1c0001ec:    00b72023              sw    a1,0(a4)
1c0001f0:    00b72223              sw    a1,4(a4)
1c0001f4:    00b72423              sw    a1,8(a4)
1c0001f8:    00b72623              sw    a1,12(a4)
1c0001fc:    01070713              addi    a4,a4,16
1c000200:    fed766e3              bltu    a4,a3,1c0001ec <memset+0x24>
1c000204:    00061463              bnez    a2,1c00020c <memset+0x44>
After executing 1c8 to 204 again going to 1ec to 1f8. Loading the instructions stop by 1c0001f8.
my linker file is like this:
ENTRY( _start )
SECTIONS
{
  . = 0x1C000000;
  .text : { *(.text) }
  .data : { *(.data) }
  .bss : { *(.bss) }
  PROVIDE( edata = . );
  _edata = .;
. = ALIGN(16);
  __global_pointer$ = . + 0x800;

    . = ALIGN (16);
    stack_init = . + 0x400;

  PROVIDE( end = . );
  _end = ALIGN(8);
}


what should I do to load complete hex code to my verilator model.please help me............

Shiva

unread,
Sep 11, 2020, 8:11:48 AM9/11/20
to RISC-V ISA Dev, Shiva
Is there any way to avoid this memset jump?The program is not return to satrt section after memset call...I tried with -fno-zero-initialized-in-bss , but not worked

Luís Marques

unread,
Sep 11, 2020, 11:46:07 AM9/11/20
to Shiva, RISC-V ISA Dev
On Fri, Sep 11, 2020 at 1:11 PM Shiva <shilpa...@gmail.com> wrote:
> After executing 1c8 to 204 again going to 1ec to 1f8. Loading the instructions stop by 1c0001f8.

The "again going" part seems reasonable, it's using a loop to zero out
that part of memory. I don't understand what you mean by "Loading the
instructions stop by 1c0001f8". Is the program not reaching
0x1c0000248 (return from memset)?

Shilpa Gireesh

unread,
Sep 11, 2020, 12:41:20 PM9/11/20
to Luís Marques, RISC-V ISA Dev
Yes... The program is not return from memset and stop the execution by reaching 1C0001F8.I want to load complete hex code to verilator model. What should I do for that? 
Reply all
Reply to author
Forward
0 new messages