Skip to content

shivakarthik07/vsd-riscv2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started with RISC-V on GitHub Codespaces

Follow the steps below to set up and run programs in your own Codespace.


Step 1. Open the Repository

Go to:
https://github.com/vsdip/vsd-riscv2


Step 2. Create a Codespace

  1. Log in with your GitHub account.
  2. Click the green Code button.
  3. Select Open with CodespacesNew codespace.
  4. Wait while the environment builds. (First time may take 10–15 minutes.)

Step 3. Verify the Setup

In the terminal that opens, type:

riscv64-unknown-elf-gcc --version
spike --version
iverilog -V

You should see version information for each tool.


Step 4. Run Your First Program

  1. Go to the samples folder.

  2. Compile the program:

    riscv64-unknown-elf-gcc -o sum1ton.o sum1ton.c
  3. Run it with Spike:

    spike pk sum1ton.o

Expected output:

Sum from 1 to 9 is 45

Step 5. Next Steps

  • You can edit and run your own C programs.
  • You can also try Verilog programs using iverilog.

Working with GUI Desktop (noVNC) – Advanced

The following steps show how to use a full Linux desktop inside your Codespace and run the same RISC-V programs there.


Step 6. Launch the noVNC Desktop

  1. In your Codespace, click the PORTS tab.

  2. Look for the forwarded port named noVNC Desktop (6080).

  3. Click the Forwarded Address link.

    noVNC port

  4. A new browser tab opens with a directory listing. Click vnc_lite.html.

    noVNC directory listing

  5. The Linux desktop appears in your browser.

    Desktop view


Step 7. Open a Terminal Inside the Desktop

  1. Right-click anywhere on the desktop background.

  2. Select Open Terminal Here.

    Open terminal here

A terminal window will open on the desktop.


Step 8. Navigate to the Sample Programs

In the terminal, go to the workspace and then to the samples folder:

cd /workspaces/vsd-riscv2
cd samples
ls -ltr

You should see files like sum1ton.c, 1ton_custom.c, load.S, and Makefile.

Samples folder listing


Step 9. Compile and Run Using Native GCC (x86)

First, compile and run the C program with the standard gcc compiler:

gcc sum1ton.c
./a.out

Expected output:

Sum from 1 to 9 is 45

Native GCC run


Step 10. Compile and Run Using RISC-V GCC and Spike

Now compile the same program for RISC-V and run it on the Spike ISA simulator:

riscv64-unknown-elf-gcc -o sum1ton.o sum1ton.c
spike pk sum1ton.o

You will see the proxy kernel (pk) messages and then the program output.

Spike run


Step 11. Edit the C Program Using gedit (GUI Editor)

To edit the program using a graphical editor:

gedit sum1ton.c &

This opens sum1ton.c in gedit on the noVNC desktop.

gedit editing

Make changes (for example, change n = 9; to another value), save the file, and re-run:

riscv64-unknown-elf-gcc -o sum1ton.o sum1ton.c
spike pk sum1ton.o

You have now:

  • Launched a full Linux desktop inside GitHub Codespaces
  • Compiled and executed a C program with native GCC
  • Compiled and executed the same program on a RISC-V target using Spike
  • Edited and rebuilt the code using a GUI editor over noVNC

You’re ready to explore more RISC-V and Verilog labs in this Codespace.

About

setup for vsd squadron internship

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 100.0%