RISC-V Implementation in C++

988 views
Skip to first unread message

Awais Ahmed

unread,
Feb 14, 2018, 5:13:32 AM2/14/18
to RISC-V Teach
Hi,

       Is there anyone to who has implemented RISC-V (5 stage pipelined architecture) in C++  for simulation purpose? I have to implement RISC-V architecture in C++ so i have no idea how to start it. If it possible then please share your code.

Regards,
Awais Ahmed  

Stef O'Rear

unread,
Feb 14, 2018, 6:02:33 AM2/14/18
to Awais Ahmed, RISC-V Teach
Are you looking for something like http://gem5.org/ ?

-s

Christopher Batten

unread,
Feb 14, 2018, 7:46:52 AM2/14/18
to Stef O'Rear, Awais Ahmed, RISC-V Teach

Hi Awais,

As Stef says, you might want to take a look at gem5. gem5 includes both simple in-order microarchitectural timing models as well as more complex out-of-order microarchitectural timing models. It may or may not be suitable for teaching depending on the scope of what you are trying to achieve.

Alec Roelke and Mircea Stan at the University of Virginia took the lead on the initial RISC-V gem5 port with support for single-threaded syscall emulation. This should currently be available in the master branch for gem5:

https://gem5.googlesource.com/public/gem5/+/master/src/arch/riscv

My own research group at Cornell has been taking the lead on the RISC-V gem5 port with support for multi-threaded syscall emulation. We are in the process of upstreaming our patches and going through the corresponding code review.

Best,
Chris

----------------------

Christopher F. Batten

Associate Professor @ ECE, Cornell University
Visiting Scholar @ The Computer Laboratory, University of Cambridge
Visiting Fellow @ Clare Hall, University of Cambridge

email : cba...@cornell.edu
web : http://www.csl.cornell.edu/~cbatten
cell : +44 7577 002610
addr : Room SC12, Computer Laboratory
William Gates Building, 15 JJ Thomson Ave, Cambridge, UK
> --
> You received this message because you are subscribed to the Google Groups "RISC-V Teach" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to riscv-teach...@groups.riscv.org.
> To post to this group, send email to riscv...@groups.riscv.org.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/riscv-teach/CADJ6UvM9V6ufy3hzbSOgMcDnfB24HGvmQqpUXHzbZYKH72%2BFjg%40mail.gmail.com.

Jeremy Bennett

unread,
Feb 14, 2018, 2:54:05 PM2/14/18
to riscv...@groups.riscv.org, Graham Markall
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Awais,

Here is another approach which may be of interest. Depends what you
want to use your simulation for.

We generate a cycle accurate C++ model from the Verilog of the PULP
project's RI5CY core using Verilator (although I think they have a 4
stage pipeline). This model is used for nightly GNU tool chain
regression testing. It runs at around 400KHz on a modern laptop.

https://github.com/embecosm/ri5cy

You will need a very up-to-date version of verilator.

I'm not sure the instructions in the README are correct. You might
need to run "make" just from the verilator-model directory. I'm OoO,
so I've copied in my colleague, Graham Markall who may be able to
clarify this.

There is a simple testbench to exercise the model. There is a separate
repository with a GDB server to wrap around the model so you can
connect from GDB to load and run programs.

HTH,


Jeremy

>
> Regards, Awais Ahmed
>
> -- You received this message because you are subscribed to the
> Google Groups "RISC-V Teach" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> riscv-teach...@groups.riscv.org
> <mailto:riscv-teach...@groups.riscv.org>. To post to this
> group, send email to riscv...@groups.riscv.org
> <mailto:riscv...@groups.riscv.org>. To view this discussion on
> the web visit
> https://groups.google.com/a/groups.riscv.org/d/msgid/riscv-teach/09636014-3068-431e-8e88-941e1d8645fd%40groups.riscv.org
>
>
>
<https://groups.google.com/a/groups.riscv.org/d/msgid/riscv-teach/09636014-3068-431e-8e88-941e1d8645fd%40groups.riscv.org?utm_medium=email&utm_source=footer>.

- --
Tel: +44 (1590) 610184
Cell: +44 (7970) 676050
SkypeID: jeremybennett
Twitter: @jeremypbennett
Email: jeremy....@embecosm.com
Web: www.embecosm.com
PGP key: 1024D/BEF58172FB4754E1 2009-03-20
-----BEGIN PGP SIGNATURE-----

iGMEARECACMFAlqEk9gcHGplcmVteS5iZW5uZXR0QGVtYmVjb3NtLmNvbQAKCRC+
9YFy+0dU4VwhAKCN+OCYQA+Jkk3zW6hFJ1D6qKW1WwCeKTnuoHtqltOO7A4Mmxc1
RTOQV7w=
=/qQU
-----END PGP SIGNATURE-----

graham....@embecosm.com

unread,
Feb 15, 2018, 5:01:00 AM2/15/18
to RISC-V Teach, graham....@embecosm.com, jeremy....@embecosm.com
We submitted the Verilator model back to the upstream pulp-platform project, so it would be best to use that version instead, which will have all the latest fixes and changes to the core - to use it, see the README in the upstream repo:  https://github.com/pulp-platform/riscv/tree/master/verilator-model

The testbench demonstrates how to put a program in memory and step the CPU, and to read debug registers, so you needn't use a gdbserver etc. just for trying it out and running simple programs.


Best regards,
Graham.

Peiqi Chen

unread,
Nov 30, 2022, 12:16:47 PM11/30/22
to RISC-V Teach, Awais Ahmed
Hi,

If you have implementation about RISC-V (5 stage pipeline version), mind sharing with me? Just need to do it and have no idea how to implement 5 stage core:/ Just done with single core.

Thanks!
Peiqi
Reply all
Reply to author
Forward
0 new messages