2
votes

Now, I'm implemented an ASP (Application Specific Processor) and I want to develop it with an RISC-type architecture. Reading a bit on the web, I concluded that the best option is to use RISC-V.

The idea is to develop a design in Verilog so that it can run the RISC-V ISA. And the software application that the processor should run is very simple, only a few arithmetic operations. For this reason as it is only one application it is not necessary that the processor supports an operating system.

I'm thinking of generating a hex file from my C application and loading the file into a ROM memory. But I could not find how I can generate the hex file from my code in C?

I built correctly my program with riscv64-unknown-elf-gcc

$ riscv64-unknown-elf-gcc -o hello hello.c

But I don't know how to generate a hex file.

Could someone tell me how can I create this file?

1

1 Answers

3
votes

You can use the program elf2hex, which is installed when building the RISC-V toolchain. You can see an example of generating hex files in the riscv-tests/benchmark repository's Makefile (https://github.com/riscv/riscv-tests/blob/master/benchmarks/Makefile):

%.hex: %
    elf2hex 16 32768 $< > $@

And the usage:

elf2hex <width> <depth> <elf_file>