Skip to content
Lab Material for CAE
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
finasgmt finasgmt: Updated task3 binary input Nov 14, 2018
lab2 cleanup Sep 10, 2018
lab3 2018: Fixed lab names Aug 31, 2018
lab6 VMWare link Oct 4, 2018
lab7
snippets README for code snippets Aug 11, 2017
LICENSE DTU holds the Copyright Aug 15, 2017
README.md fix link Oct 9, 2018

README.md

Lab Material for Computer Architecture

This repository provides lab material for the 2017 Computer Architecture and Engineering course (02155) at DTU. Although this lab is customized for the DTU course, it can also serve as introduction lab for computer architecture in general and the RISC-V instruction set specifically.

The lab is based on COD: Computer Organization and Design RISC-V Edition: The Hardware Software Interface, 1st Edition, by David A. Patterson (Author), John L. Hennessy (Author).

To use this material you can: (1) just browse it online on GitHub, (2) clone the repo to have all material offline (using it also for your solutions), or (3) fork the repo (and clone locally), to be able to contribute back with changes.

Contributions: We are happily accepting contributions in the form of pull requests. Even the fix of a small typo is appreciated.

Lab Overview

The following list gives an overview of all lab sessions and assignments. For lab sessions where no link is given, we will provide the material in CampusNet.

  • week 1: Number representation and performance
  • week 2: Lab 2
  • week 3: Lab 3
  • week 4: Exercises from Chapter 3
  • week 5: work on first assignment
  • week 6: Lab 6
  • week 7: Lab 7

Resources

RISC-V Simple Simulator

For the first labs we will use the web based RISC-V simulator Venus. Venus executes in your browser and there is no need to install any tools on your laptop. You can also save that web page to have a local copy of the simulator to work when offline.

RISC-V C Compiler and Spike

However, for later lab exercises and your final project we need the full RISC-V toolchain, including a port of gcc and the spike simulator.

If you are using Ubuntu (or any other Linux version) or a Mac OS X laptop, you can install the tools natively on your machine. However, to simplify life we provide a virtual machine (VM) with Ubuntu and all needed tools installed. You need about 18 GB of free disk space for the VM and another temporary space of 7 GB for the .zip file

Test the VM by opening a terminal and starting the compiler with:

riscv32-unknown-elf-gcc

You should get an error, similar to following

riscv32-unknown-elf-gcc: fatal error: no input files
compilation terminated.

which is good as you know the the compiler is installed. You are now prepared for all RISC-V based lab work and projects.

For the more curious, you can sneak ahead and compile and run Hello World program on RISC-V spike as follows:

echo -e '#include <stdio.h>\n int main(void) { printf("Hello world!\\n"); return 0; }' > hello.c
riscv32-unknown-elf-gcc -o hello hello.c
spike pk hello

Links

Other University Courses using RISC-V

Some More (Unchecked) Links

VM and Tool Installation

This is a log how I prepared the Ubuntu VM for the CAE lab. It might be useful for your own installation of the RISC-V tools.

Please note that this is a log on how I prepared the Ubuntu VM for the CAE lab. This instructions might be out of date soon. Please refer to the original README documents of the RISC-V tools.

  • Use VMware Workstation 15 Player
  • Use Ubuntu 18.04 desktop
  • Do not use VMware easy install
  • Do not use LVM
  • Settings: turn off screen locking

Install VM tools for clipboard support and restart VM

sudo apt install open-vm-tools

Install git

sudo apt install git

Follow the instructions for installing the RISC-V tools here, except do not execute

./build.sh

Instead, change all references in build-rv32ima.sh from rv32ima to rv32i. Set the RISCV variable and path by adding this into .profile (including logout and login to update your environment variables):

# RISC-V tools
export RISCV=$HOME/riscv-tools
export PATH=$PATH:$RISCV/bin

Then run

./build-rv32ima.sh

Create a file linker.ld in the $HOME directory containing the following:

SECTIONS {
.text :{*(*)}
}

Download the RISCV pipeline simulator Ripes from here. No installation is required, however, enable the file's execute bit to make it executable.

RISC-V Tools on macOS

Ubuntu on macOS

There is no free VMWaare Player available for macOS. You can buy their VMware Fusion.

An alternative is to use the free VM VirtualBox.

We provide:

  • An Ubuntu VM for VirtualBox with RISC-V tools installed

Native Installation on macOS

For diverse GNU tools you need a packet manager for those tools under macOS.

Homebrew is one of the popular ones. For the packets listed in the Ubuntu installation you need to find the related ones for brew/macOS. As my (Martin's) Mac has brew already installed, I cannot list all that are needed. But if anyone is doing this installation from scratch I would love to add this information here.

According to the RISC-V tools README, following Homebrew packages need to be installed with following command:

brew install libusb dtc gawk gnu-sed gmp mpfr libmpc isl wget automake md5sha1sum

Then follow the instructions above like the setup on Ubuntu.

You can’t perform that action at this time.