gem5-users@gem5.org

The gem5 Users mailing list

View all threads

Running gem5 with custom instructions

NF
Nick F
Sat, Jun 3, 2023 4:34 PM

Good afternoon folks,

As part of a research project I have been trying to setup a Gem5
simulation with a RISC-V ISA while adding in a custom operation. I found
a handful of old articles
https://nitish2112.github.io/post/adding-instruction-riscv/ [2
https://stackoverflow.com/questions/32953911/how-to-add-a-new-custom-instruction-in-the-riscv-instruction-set]
and videos https://youtu.be/Z5B02jkNpck on how to accomplish this but
appear to be out of date. I noticed there is a gem5 doc on ISA Parsing
https://www.gem5.org/documentation/general_docs/architecture_support/isa_parser/
that has a few unfinished sections.

I tried following the tutorial but have run into some issues getting the
RISC-V tools to compile.

After spending a lot of time trying to build things, I've found myself
stuck on this error when trying to build the riscv-pk project:

gcc: error: unrecognized argument in option '-mcmodel=medany'

gcc: note: valid arguments to '-mcmodel=' are: 32 kernel large medium small
make: *** [Makefile:319: file.o] Error 1

Does anyone know if I'm going down the wrong path here? Is there a good
tutorial that you recommend?

Thanks all,

Nick Felker

Good afternoon folks, As part of a research project I have been trying to setup a Gem5 simulation with a RISC-V ISA while adding in a custom operation. I found a handful of old articles <https://nitish2112.github.io/post/adding-instruction-riscv/> [2 <https://stackoverflow.com/questions/32953911/how-to-add-a-new-custom-instruction-in-the-riscv-instruction-set>] and videos <https://youtu.be/Z5B02jkNpck> on how to accomplish this but appear to be out of date. I noticed there is a gem5 doc on ISA Parsing <https://www.gem5.org/documentation/general_docs/architecture_support/isa_parser/> that has a few unfinished sections. I tried following the tutorial but have run into some issues getting the RISC-V tools to compile. After spending a lot of time trying to build things, I've found myself stuck on this error when trying to build the riscv-pk project: gcc: error: unrecognized argument in option '-mcmodel=medany' gcc: note: valid arguments to '-mcmodel=' are: 32 kernel large medium small make: *** [Makefile:319: file.o] Error 1 Does anyone know if I'm going down the wrong path here? Is there a good tutorial that you recommend? Thanks all, Nick Felker
AA
Ayaz Akram
Sun, Jun 4, 2023 2:16 AM

Hi Nick,

One of the common reasons you might see the error you are noticing is if
you somehow end up using the host compiler instead of the RISC-V compiler.
I will recommend that you verify that riscv toolchain directory is added to
your $PATH. See this for reference:
https://github.com/riscv-software-src/riscv-tools/issues/292

-Ayaz

On Sat, Jun 3, 2023 at 9:36 AM Nick F via gem5-users gem5-users@gem5.org
wrote:

Good afternoon folks,

As part of a research project I have been trying to setup a Gem5
simulation with a RISC-V ISA while adding in a custom operation. I found a
handful of old articles
https://nitish2112.github.io/post/adding-instruction-riscv/ [2
https://stackoverflow.com/questions/32953911/how-to-add-a-new-custom-instruction-in-the-riscv-instruction-set]
and videos https://youtu.be/Z5B02jkNpck on how to accomplish this but
appear to be out of date. I noticed there is a gem5 doc on ISA Parsing
https://www.gem5.org/documentation/general_docs/architecture_support/isa_parser/
that has a few unfinished sections.

I tried following the tutorial but have run into some issues getting the
RISC-V tools to compile.

After spending a lot of time trying to build things, I've found myself
stuck on this error when trying to build the riscv-pk project:

gcc: error: unrecognized argument in option '-mcmodel=medany'

gcc: note: valid arguments to '-mcmodel=' are: 32 kernel large medium small
make: *** [Makefile:319: file.o] Error 1

Does anyone know if I'm going down the wrong path here? Is there a good
tutorial that you recommend?

Thanks all,

Nick Felker


gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-leave@gem5.org

Hi Nick, One of the common reasons you might see the error you are noticing is if you somehow end up using the host compiler instead of the RISC-V compiler. I will recommend that you verify that riscv toolchain directory is added to your $PATH. See this for reference: https://github.com/riscv-software-src/riscv-tools/issues/292 -Ayaz On Sat, Jun 3, 2023 at 9:36 AM Nick F via gem5-users <gem5-users@gem5.org> wrote: > Good afternoon folks, > > As part of a research project I have been trying to setup a Gem5 > simulation with a RISC-V ISA while adding in a custom operation. I found a > handful of old articles > <https://nitish2112.github.io/post/adding-instruction-riscv/> [2 > <https://stackoverflow.com/questions/32953911/how-to-add-a-new-custom-instruction-in-the-riscv-instruction-set>] > and videos <https://youtu.be/Z5B02jkNpck> on how to accomplish this but > appear to be out of date. I noticed there is a gem5 doc on ISA Parsing > <https://www.gem5.org/documentation/general_docs/architecture_support/isa_parser/> > that has a few unfinished sections. > > I tried following the tutorial but have run into some issues getting the > RISC-V tools to compile. > > After spending a lot of time trying to build things, I've found myself > stuck on this error when trying to build the riscv-pk project: > > > gcc: error: unrecognized argument in option '-mcmodel=medany' > > gcc: note: valid arguments to '-mcmodel=' are: 32 kernel large medium small > make: *** [Makefile:319: file.o] Error 1 > > Does anyone know if I'm going down the wrong path here? Is there a good > tutorial that you recommend? > > Thanks all, > > Nick Felker > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-leave@gem5.org >