How to generate risc-v machine code

2,764 views
Skip to first unread message

Zhang

unread,
Jun 27, 2018, 8:02:44 AM6/27/18
to RISC-V SW Dev
I'm building a RISC-V processor in systemC, and I need a tool to generate RISC-V machine code from a piece of C++ code.
Is there a tool who can generate RISC-V instruction binary file from C++ code?

John Leidel

unread,
Jun 27, 2018, 8:23:01 AM6/27/18
to Zhang, RISC-V SW Dev
Zhang, I'm assuming you're referring to a compiler? I would take a
look at the riscv-tools GCC port: https://github.com/riscv/riscv-tools

It has a functional C/C++ compiler.
> --
> You received this message because you are subscribed to the Google Groups
> "RISC-V SW Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sw-dev+un...@groups.riscv.org.
> To post to this group, send email to sw-...@groups.riscv.org.
> Visit this group at
> https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit
> https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/61305a4f-fad0-483d-a75b-c0513d869209%40groups.riscv.org.

Jim Wilson

unread,
Jun 27, 2018, 10:11:10 AM6/27/18
to John Leidel, Zhang, RISC-V SW Dev
On Wed, Jun 27, 2018 at 5:22 AM, John Leidel <john....@gmail.com> wrote:
> Zhang, I'm assuming you're referring to a compiler? I would take a
> look at the riscv-tools GCC port: https://github.com/riscv/riscv-tools

riscv-tools is poorly maintained and difficult to build. If you just
want a compiler, riscv-gnu-toolchain is a better choice.

If you have a recent debian or ubuntu system, you can just install the
gcc-8-riscv64-linux-gnu and/or gcc-7-riscv64-linux-gnu package to get
a cross compiler. This is even easier. Other systems may also have
similar packages by now.

Jim

Luke Kenneth Casson Leighton

unread,
Jun 27, 2018, 11:19:45 AM6/27/18
to Jim Wilson, John Leidel, Zhang, RISC-V SW Dev
so for debian/testing, to get a c++ compiler, that'll be:

$ sudo bash
# apt-get install g++-8-riscv64-linux-gnu OR
# apt-get install g++-7-riscv64-linux-gnu

and for the c compiler:

# apt-get install g++-8-riscv64-linux-gnu OR
# apt-get install g++-7-riscv64-linux-gnu

remember to exit the root command-mode by pressing Ctrl-D afterwards.

to add testing repos to debian follow the instructions here:

https://www.binarytides.com/enable-testing-repo-debian/

which basically boils down to adding these lines (as the user root) to
/etc/apt/sources.list *or* to a separate file e.g.
/etc/apt/sources.list.d/testing.list

# Testing repository - main, contrib and non-free branches
deb http://http.us.debian.org/debian testing main non-free contrib
deb-src http://http.us.debian.org/debian testing main non-free contrib

l.

cw2...@email.vccs.edu

unread,
Feb 8, 2019, 3:53:08 AM2/8/19
to RISC-V SW Dev
google venus stimulator rise v

Tommy Murphy

unread,
Feb 8, 2019, 4:10:57 AM2/8/19
to cw2...@email.vccs.edu, RISC-V SW Dev
Reply all
Reply to author
Forward
Message has been deleted
0 new messages