HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

2022/06/20

【2022年版】最近流行の RISC-Vプロセッサの環境を WSL Ubuntu上に構築する方法 【2022年版】最近流行の RISC-Vプロセッサの環境を WSL Ubuntu上に構築する方法

(RISC-Vプロセッサの Rocket Chipの開発環境を Windows上に構築して Verilogする方法)

Tags: [FPGA], [電子工作], [Xilinx XC6SLX9], [FPGA 2022]




●最近流行の RISC-Vプロセッサの環境を WSL Ubuntu上に構築する方法

 RISC-Vプロセッサの Rocket Chipの開発環境を Windows上に構築して Verilogする方法。

RISC-V

 RISC-V(リスク ファイブ)は、確立された縮小命令セットコンピュータ (RISC) の原則に基づいたオープン標準の命令セットアーキテクチャ (ISA) である。


 RISC-Vの実装として何種類か有りますが Rocket Chipが有名っぽいのでこれを選びました。

Rocket Chip Generator 🚀

rocket-tools

The RISC-V QEMU Port is Upstream

rth7680 / qemu-palcode

RISC-V Cores and SoC Overview - THIS PAGE IS NOW ARCHIVED


RISC-VとChiselで学ぶ はじめてのCPU自作 ――オープンソース命令セットによるカスタムCPU実装への第一歩 単行本(ソフトカバー) - 2021/8/25
ASIN: 4297123053

RISC-V原典 オープンアーキテクチャのススメ 単行本 - 2018/10/18
ASIN: 4822292819

FPGAマガジンNo.18 Googleも推す新オープンソースCPU RISC-Vづくり 単行本 - 2018/2/2
ASIN: 4789846288

作って学ぶコンピュータアーキテクチャ - LLVMとRISC-Vによる低レイヤプログラミングの基礎 単行本(ソフトカバー) - 2022/7/1
ASIN: 4297129140


● Windowsにコマンドラインで WSLと Ubuntuをインストールする
rem 管理者権限の PowerShell
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

rem コマンドライン
wsl --list --online

NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS

wsl --install --distribution Ubuntu

wsl --list --verbose

NAME      STATE           VERSION
Ubuntu    Installing      1



● RISC-V on WSL Ubuntu
# https://github.com/chipsalliance/rocket-chip/blob/master/README.md

# Update and Install Git
sudo apt-get update
sudo apt-get install -y git

# Install Python 2.x
sudo apt install -y python

python -V
# Python 2.7.18

# Install Device Tree Compiler dtc
# Ubuntu Manpage: dtc - Device Tree Compiler

sudo apt install -y device-tree-compiler

dtc -v
# Version: DTC 1.5.0


# RISC-V Root directory
cd
mkdir riscv
cd riscv
export RISCV_ROOT=$PWD

# Quick Instructions
# Checkout The Code
cd $RISCV_ROOT
# https://github.com/freechipsproject/rocket-chip
git clone https://github.com/chipsalliance/rocket-chip
cd rocket-chip
export ROCKETCHIP=`pwd`

git tag
git checkout -b v1.5
git submodule update --init --recursive

# Setting up the RISCV environment variable
cd $RISCV_ROOT
mkdir toolchain
cd toolchain
export RISCV=$PWD

cd $RISCV_ROOT
# git clone https://github.com/freechipsproject/rocket-tools
git clone https://github.com/chipsalliance/rocket-tools
cd rocket-tools

# Install Necessary Dependencies
# rocket-tools "Ubuntu Packages Needed"
# Ubuntu packages needed
sudo apt-get install -y autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev libfl-dev

# Install Java
sudo apt-get install -y default-jre

gcc -v
# gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

# https://github.com/chipsalliance/rocket-chip/blob/master/riscv-tools.hash
# rocket-chip/riscv-tools.hash
# e2c6d1577a75f506fe992c3eb20a75174504476e

# Hash given in the rocket-chip repository
git checkout e2c6d1577a75f506fe992c3eb20a75174504476e
git submodule update --init riscv-gnu-toolchain
cd riscv-gnu-toolchain
# https://github.com/riscv/riscv-qemu.git
git submodule set-url riscv-qemu https://github.com/riscvarchive/riscv-qemu.git
git submodule sync
cd riscv-qemu
git submodule set-url roms/qemu-palcode https://github.com/rth7680/qemu-palcode.git
git submodule sync
cd ../..
git submodule update --init --recursive --progress

# export MAKEFLAGS="$MAKEFLAGS -jN" # Assuming you have N cores on your host system
unset MAKEFLAGS
export MAKEFLAGS="$MAKEFLAGS -j4" # 4 core
time ./build.sh

# Installing project riscv-tests
# RISC-V Toolchain installation completed!

# 4 core
# real    34m22.310s
# user    42m4.625s
# sys     27m22.344s

riscv-tools
cd $RISCV_ROOT
git clone https://github.com/riscv-software-src/riscv-tools
cd riscv-tools
export RISCV_TOOLS=$PWD
ls -l $RISCV_TOOLS

# Ubuntu packages needed
sudo apt-get install -y autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev

# Quickstart
git submodule update --init --recursive

# export RISCV=/path/to/install/riscv/toolchain
echo $RISCV

./build.sh

# No installed jimsh or tclsh, building local bootstrap jimsh0

・ Install jimsh
sudo apt-get install -y jimsh
# Setting up jimsh (0.79+dfsg0-2) ...

・ Install tclsh
sudo apt-get install -y tclsh
sudo apt-get install -y tcl
# Setting up tcl (8.6.9+1) ...

・ Build & Install jimsh
The Jim Interpreter
# Get It
cd $RISCV_ROOT
git clone https://github.com/msteveb/jimtcl.git

# Build It
cd jimtcl
./configure
make

# Test It
make test

# Try It
# ./jimsh
# Welcome to Jim version 0.81

# Install
sudo make install

● riscv-tests
cd $RISCV_ROOT
git clone https://github.com/riscv-software-src/riscv-tests
cd riscv-tests

git submodule update --init --recursive

autoconf
# ./configure --prefix=$RISCV/target
./configure --prefix=$RISCV/target

time make -j4

sudo make install
# install -d /usr/local/share/riscv-tests/isa
# install -d /usr/local/share/riscv-tests/benchmarks

● rocket-rocc-examples
cd $RISCV_ROOT
git clone https://github.com/seldridge/rocket-rocc-examples
cd rocket-rocc-examples

autoconf
ls -l

mkdir build
cd build

echo $RISCV_TOOLS
# /home/user/riscv/toolchain
../configure --with-riscvtools=$RISCV_TOOLS
ls -l

make -j4

make[1]: riscv64-unknown-elf-gcc: Command not found
make[1]: *** [/home/user/riscv/rocket-rocc-examples/build/../bareMetal/Makefile:24: examples-bareMetal-p-accumulator] Error 127
make[1]: riscv64-unknown-elf-gcc: Command not found
make[1]: Leaving directory '/home/user/riscv/rocket-rocc-examples/build/bareMetal'
make[1]: *** [/home/user/riscv/rocket-rocc-examples/build/../pk/Makefile:19: examples-pk-accumulator] Error 127
make[1]: Leaving directory '/home/user/riscv/rocket-rocc-examples/build/pk'
make: *** [Makefile:19: bareMetal] Error 2
make: *** Waiting for unfinished jobs....
make: *** [Makefile:23: pk] Error 2

export PATH=$PATH:$RISCV/bin

make -j4

/home/user/riscv/rocket-rocc-examples/build/../bareMetal/accumulator.S:1:10: fatal error: riscv_test.h: No such file or directory
 #include "riscv_test.h"
          ^~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [/home/user/riscv/rocket-rocc-examples/build/../bareMetal/Makefile:24: examples-bareMetal-p-accumulator] Error 1
make[1]: Leaving directory '/home/user/riscv/rocket-rocc-examples/build/bareMetal'
make: *** [Makefile:19: bareMetal] Error 2
make: *** Waiting for unfinished jobs....
In file included from /home/user/riscv/rocket-rocc-examples/build/../pk/accumulator.c:6:0:
/home/user/riscv/rocket-rocc-examples/build/../include/accumulator.h:6:10: fatal error: rocc-software/src/xcustom.h: No such file or directory
 #include "rocc-software/src/xcustom.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cd
cd riscv
export RISCV_ROOT=$PWD

cd $RISCV_ROOT
cd rocket-chip
export ROCKETCHIP=`pwd`
ls -l $ROCKETCHIP

cd $RISCV_ROOT
cd toolchain
export RISCV=$PWD
ls -l $RISCV

cd $RISCV_ROOT
cd riscv-tools
export RISCV_TOOLS=$PWD
ls -l $RISCV_TOOLS

cd $RISCV_ROOT
ls -l $RISCV_ROOT
cd $ROCKETCHIP
cd emulator
make

# make[1]: Leaving directory '/home/user/riscv/rocket-chip/emulator/generated-src/freechips.rocketchip.system.DefaultConfig'

ls -l
# -rw-r--r-- 1 user user    2183 Jun 21 21:31 Makefile
# -rw-r--r-- 1 user user    4204 Jun 21 21:31 Makefrag-verilator
# -rwxr-xr-x 1 user user 6036040 Jun 22 19:32 emulator-freechips.rocketchip.system-freechips.rocketchip.system.DefaultConfig
# drwxr-xr-x 1 user user    4096 Jun 22 19:30 generated-src
# drwxr-xr-x 1 user user    4096 Jun 22 15:40 verilator

# emulator-freechips.rocketchip.system-freechips.rocketchip.system.DefaultConfig
# Building The Project
cd $ROCKETCHIP/vsim
make verilog

ls -l
# -rw-r--r-- 1 user user  870 Jun 23 15:15 Makefile
# -rw-r--r-- 1 user user 2525 Jun 23 15:15 Makefrag
# -rw-r--r-- 1 user user 2800 Jun 23 15:15 Makefrag-verilog
# drwxr-xr-x 1 user user 4096 Jun 23 22:49 generated-src

ls -l generated-src
# -rw-r--r-- 1 user user   786376 Jun 23 22:49 TestHarness.anno.json
# drwxr-xr-x 1 user user     4096 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig
# -rw-r--r-- 1 user user    36053 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.0x0.0.regmap.json
# -rw-r--r-- 1 user user   296939 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.0x0.1.regmap.json
# -rw-r--r-- 1 user user     4524 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.0x2000000.0.regmap.json
# -rw-r--r-- 1 user user     4942 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.0x40.0.regmap.json
# -rw-r--r-- 1 user user     5033 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.0xc000000.0.regmap.json
# -rw-r--r-- 1 user user   786376 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.anno.json
# -rw-r--r-- 1 user user     8703 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.behav_srams.v
# -rw-r--r-- 1 user user      392 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.conf
# -rw-r--r-- 1 user user    32796 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.d
# -rw-r--r-- 1 user user     2468 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.dts
# -rw-r--r-- 1 user user 21469456 Jun 23 22:48 freechips.rocketchip.system.DefaultConfig.fir
# -rw-r--r-- 1 user user   305842 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.graphml
# -rw-r--r-- 1 user user     2822 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.json
# -rw-r--r-- 1 user user      870 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.memmap.json
# -rw-r--r-- 1 user user      613 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.plusArgs
# -rw-r--r-- 1 user user        0 Jun 23 22:48 freechips.rocketchip.system.DefaultConfig.rom.conf
# -rw-r--r-- 1 user user  9552850 Jun 23 22:49 freechips.rocketchip.system.DefaultConfig.v

tail generated-src/freechips.rocketchip.system.DefaultConfig.v


# First, to build the C simulator:
cd $ROCKETCHIP/emulator
make

# Or to build the VCS simulator:
# Synopsys VCS
cd $ROCKETCHIP/vsim
make
cd $ROCKETCHIP/emulator
make

# In either case, you can run a set of assembly tests or simple benchmarks (Assuming you have N cores on your host system):
time make -j4 run-asm-tests
# WSL ネットワークのアクセスはキャンセルした
#   [ PASSED ] output/rv64um-v-mulw.out    Completed after 194036 cycles
#   [ PASSED ] output/rv64um-v-remuw.out   Completed after 178304 cycles
#   [ PASSED ] output/rv64um-v-remw.out    Completed after 178700 cycles

# real    6m54.587s
# user    49m51.609s
# sys     2m32.703s

time make -j4 run-bmark-tests
#   [ PASSED ] output/vvadd.riscv.out      Completed after 169564 cycles
#   [ PASSED ] output/dhrystone.riscv.out          Completed after 475092 cycles
#   [ PASSED ] output/mt-matmul.riscv.out          Completed after 273660 cycles

# real    1m13.281s
# user    7m30.016s
# sys     0m24.359s


● Rocket chip RISC-Vのツールチェインのテスト

第505回 オープン規格の新しい命令セットアーキテクチャRISC-V入門 ツールチェインを用意する

mkdir ~/test && cd $_
export PATH=$PATH:$RISCV/bin
echo -e '#include \n int main(void) { printf("Hello world!\\n"); return 0; }' > hello.c
riscv64-unknown-elf-gcc -o hello hello.c
file hello
# hello: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), statically linked, not stripped
which spike
# /home/user/riscv/toolchain/bin/spike

find $RISCV -name pk
# /home/user/riscv/toolchain/riscv64-unknown-elf/bin/pk

spike pk hello
# Hello world!

cd $ROCKETCHIP/emulator
ls -l
# -rwxr-xr-x 1 user user 6036040 Jun 22 19:32 emulator-freechips.rocketchip.system-freechips.rocketchip.system.DefaultConfig

seldridge / rocket-rocc-examples
 Collection of example libraries and test programs for the existing Rocket Custom Coprocessor (RoCC) accelerators for Rocket Chip.


● Rocket chip RISC-Vのビルド時のエラーの解決方法

・ ./build.sh
# ./build.sh: line 11: automake: command not found
# ./build.sh: line 11: autoconf: command not found
cd rocket-tools
export MAKEFLAGS="$MAKEFLAGS -j1" # 1 core
./build.sh

# Starting RISC-V Toolchain build process
# ./build.sh: line 11: automake: command not found
# ./build.sh: line 11: autoconf: command not found
# build.common: line 32: autoreconf: command not found

# E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.68.0-1ubuntu2.7_amd64.deb  404  Not Found [IP: 2620:2d:4000:1::16 80]
# E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/libcurl4_7.68.0-1ubuntu2.7_amd64.deb  404  Not Found [IP: 2620:2d:4000:1::16 80]
# E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
sudo apt-get update

# Solution:
# Install Necessary Dependencies
# rocket-tools "Ubuntu Packages Needed"
# Ubuntu packages needed
sudo apt-get install -y autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev libfl-dev

・ make: the '-j' option requires a positive integer argument
# Configuring project riscv-gnu-toolchain
# Building project riscv-gnu-toolchain
# make: the '-j' option requires a positive integer argument

# Solution:
# export MAKEFLAGS="$MAKEFLAGS -jN" to export MAKEFLAGS="$MAKEFLAGS -j1"
unset MAKEFLAGS
export MAKEFLAGS="$MAKEFLAGS -j1" # 1 core
./build.sh

・ riscv-binutils-gdb/configure: not found
# /bin/sh: 1: /home/user/riscv/rocket-tools/riscv-gnu-toolchain/build/../riscv-binutils-gdb/configure: not found
# make: *** [Makefile:334: stamps/build-binutils-newlib] Error 127

# Solution:
# /bin/sh: 1: /home/ */riscv/riscv-gnu-toolchain/riscv-binutils/configure: not found #350


# Solution:
# can't do make for no configure files at /riscv-gnu-toolchain/riscv-binutils/ #371


git submodule update --init --recursive
./build.sh

・ riscv-binutils-gdb/configure: not found
・ fatal: clone of 'git://github.com/riscv/riscv-qemu.git'
# Removing existing riscv-gnu-toolchain/build directory
# Configuring project riscv-gnu-toolchain
# Building project riscv-gnu-toolchain
# /bin/sh: 1: /home/user/riscv/rocket-tools/riscv-gnu-toolchain/build/../riscv-binutils-gdb/configure: not found
# make: *** [Makefile:334: stamps/build-binutils-newlib] Error 127

git submodule update --init --recursive
# fatal: clone of 'git://github.com/riscv/riscv-qemu.git' into submodule path '/home/user/riscv/rocket-tools/riscv-gnu-toolchain/riscv-qemu' failed
# Failed to clone 'riscv-qemu' a second time, aborting
# Failed to recurse into submodule path 'riscv-gnu-toolchain'

# Solution:
# The unauthenticated git protocol on port 9418 is no longer supported #20


# https://github.com/chipsalliance/rocket-chip/blob/master/riscv-tools.hash
# rocket-chip/riscv-tools.hash
# e2c6d1577a75f506fe992c3eb20a75174504476e

git clone https://github.com/chipsalliance/rocket-tools
cd rocket-tools
# Hash given in the rocket-chip repository
git checkout e2c6d1577a75f506fe992c3eb20a75174504476e
git submodule update --init riscv-gnu-toolchain
cd riscv-gnu-toolchain
# https://github.com/riscv/riscv-qemu.git
git submodule set-url riscv-qemu https://github.com/riscvarchive/riscv-qemu.git
git submodule sync
cd riscv-qemu
git submodule set-url roms/qemu-palcode https://github.com/rth7680/qemu-palcode.git
git submodule sync
cd ../..
git submodule update --init --recursive --progress

・ java: command not found
cd $ROCKETCHIP
cd emulator
make

# cd /home/user/riscv/rocket-chip && java -Xmx2G -Xss8M -jar /home/user/riscv/rocket-chip/sbt-launch.jar assembly
# /bin/bash: java: command not found
# make: *** [/home/user/riscv/rocket-chip/Makefrag:49: /home/user/riscv/rocket-chip/rocketchip.jar] Error 127

# Solution:
sudo apt-get install -y default-jre
# or
sudo apt-get install -y default-jdk

java -version
# openjdk version "11.0.15" 2022-04-19
# OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
# OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)

・ ‘python’: No such file or directory
cd $ROCKETCHIP
cd emulator
make

# /usr/bin/env: ‘python’: No such file or directory
# make: *** [Makefrag-verilator:28: /home/user/riscv/rocket-chip/emulator/generated-src/freechips.rocketchip.system.DefaultConfig.behav_srams.v] Error 127

# $ python
# Command 'python' not found, did you mean:
#   command 'python3' from deb python3
#   command 'python' from deb python-is-python3

# Solution:
# Emulator make error #2629


# Install Python 2.x
sudo apt install -y python

python -V
# Python 2.7.18


● Linux Windows WSLでの CPUコアの数と Thread数の確認方法

● Intel NUC8i5BEH Core i5-8259U
$ cpucore
cpucore: command not found

$ grep physical.id /proc/cpuinfo | sort -u | wc -l
1

$ grep cpu.cores /proc/cpuinfo | sort -u
cpu cores       : 4

$ grep processor /proc/cpuinfo | wc -l
8

$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       36 bits physical, 48 bits virtual
CPU(s):              8
On-line CPU(s) list: 0-7
Thread(s) per core:  2
Core(s) per socket:  4
Socket(s):           1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               142
Model name:          Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Stepping:            10
CPU MHz:             2304.000
CPU max MHz:         2304.0000
BogoMIPS:            4608.00
Hypervisor vendor:   Windows Subsystem for Linux
Virtualization type: container
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr s                     se sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm pni pclmulqdq dtes64 est tm2 ssse3 fma cx16 xtpr
                     pdcm pcid sse4_1 sse4_2 movbe popcnt aes xsave osxsave avx f16c rdrand hypervisor lahf_lm abm 3dnow                     prefetch fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt ibrs i                     bpb stibp ssbd

● Lenovo M75s Small Gen2 AMD Ryzen 7 PRO 4750G
$ grep cpu.cores /proc/cpuinfo | sort -u
cpu cores       : 8

$ grep processor /proc/cpuinfo | wc -l
16

$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       36 bits physical, 48 bits virtual
CPU(s):              16
On-line CPU(s) list: 0-15
Thread(s) per core:  2
Core(s) per socket:  8
Socket(s):           1
Vendor ID:           AuthenticAMD
CPU family:          23
Model:               96
Model name:          AMD Ryzen 7 PRO 4750G with Radeon Graphics
Stepping:            1
CPU MHz:             3600.000
CPU max MHz:         3600.0000
BogoMIPS:            7200.00
Hypervisor vendor:   Windows Subsystem for Linux
Virtualization type: container
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 h
                     t syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe pop
                     cnt aes xsave osxsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignss
                     e 3dnowprefetch osvw wdt topoext fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt
                     clwb sha_ni umip rdpid


● RISC-Vの試行錯誤のメモ

# How should I use the Rocket chip generator?
cd $RISCV_ROOT
cd rocket-chip
export ROCKETCHIP=`pwd`
git submodule update --init

echo $RISCV
# /home/user/riscv/toolchain

# Using the high-performance cycle-accurate Verilator
cd $ROCKETCHIP/emulator
time make -j4 run

# 2) Mapping a Rocket core to an FPGA
# The Verilog used for the FPGA tools will be generated in vsim/generated-src
cd $ROCKETCHIP/vsim
make verilog CONFIG=freechips.rocketchip.system.DefaultFPGAConfig

ls -l generated-src

# https://github.com/sifive/freedom/blob/master/README.md

# Synopsys VCS
cd $ROCKETCHIP/vsim
make -j4 run CONFIG=freechips.rocketchip.system.DefaultFPGAConfig

# Synopsys VCS
# /bin/bash: line 2: vcs: command not found
# make: *** [Makefrag:69: simv-freechips.rocketchip.system-DefaultFPGAConfig] Error 127
# make: *** Waiting for unfinished jobs....
# ln -fs /home/user/riscv/toolchain/riscv64-unknown-elf/share/riscv-tests/isa/rv64ua-p-amoor_w output/rv64ua-p-amoor_w

# https://github.com/riscvarchive/riscv-qemu

# git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
git submodule update --init --recursive

# https://github.com/riscvarchive/riscv-qemu
# Remove everything for archive

cd
cd riscv

git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain

# Prerequisites
sudo apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev

# Installation (Linux)
# The build defaults to targeting RV64GC (64-bit) with glibc
./configure --prefix=/opt/riscv
make linux

# 32-bit build environment. To build the 32-bit RV32GC toolchain
./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d
make linux

# Download QEMU
# https://www.qemu.org/download/

cd
cd riscv

wget https://download.qemu.org/qemu-7.0.0.tar.xz
tar xvJf qemu-7.0.0.tar.xz
cd qemu-7.0.0
./configure
make
sudo make install

# chisel3 "Installation"
# Constructing Hardware in a Scala Embedded Language (Chisel)
# Chisel Local Setup


# Install Java
sudo apt-get install default-jdk

# Install sbt according to the instructions from sbt download

# Linux (deb)
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install -y sbt

# Install prerequisites (if not installed already)
sudo apt-get install -y git make autoconf g++ flex bison

# Clone the Verilator repository
# Veripool


cd
cd riscv
git clone http://git.veripool.org/git/verilator

# In the Verilator repository directory, check out a known good version
cd verilator
git pull
git checkout v4.016

# Install Verilator

# On Ubuntu
sudo apt-get install -y verilator

# The following is optional but is recommended for nicely rendered command line help when running Verilator
sudo apt-get install -y perl-doc


● crosstool-NG
Installing crosstool-NG
cd
git clone https://github.com/crosstool-ng/crosstool-ng
./bootstrap

# configure: error: missing required tool: help2man
sudo apt install -y help2man

# configure: error: Required tool not found: libtool
sudo apt install -y libtool-bin

# configure: error: curses library not found
sudo apt-get install -y libncurses5-dev

make distclean
mkdir build
cd build

../configure
make

./ct-ng -v
# GNU Make 4.2.1
# Built for x86_64-pc-linux-gnu
# Copyright (C) 1988-2016 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.

sudo make install
# make[1]: Leaving directory '/home/user/crosstool-ng'

ls -l /home/user/crosstool-ng

# no need export PATH="${PATH}:/some/place/bin"

ct-ng -v
# GNU Make 4.2.1



Tags: [FPGA], [電子工作], [Xilinx XC6SLX9], [FPGA 2022]

●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)

AMD Xilinxの FPGA Spartan-6 XC6SLX16のボードを買ってアーケード ゲームを動かす
AMD Xilinxの FPGA Spartan-6 XC6SLX16のボードを買ってアーケード ゲームを動かす

  ALINX AX309 XC6SLX9の中華クローンの XC6SLX16版を購入しました

AMD Xilinxの FPGAの開発アプリ ISE WebPackをダウンロードして Windows 10で動かす方法
AMD Xilinxの FPGAの開発アプリ ISE WebPackをダウンロードして Windows 10で動かす方法

  Spartan-6の FPGAの開発用に Xilinx ISE WebPack開発ソフトウェアを Windows 10で動かす方法

Xilinxの FPGA Spartan-6の Block RAM RAMB8BWERに初期値を入れて ROMとして使う方法
Xilinxの FPGA Spartan-6の Block RAM RAMB8BWERに初期値を入れて ROMとして使う方法

  Xilinxの FPGA Spartan-6の Block RAM RAMB8BWERに初期値を入れて ROMとして使う方法

FPGA Spartan-6 XC6SLX16でファミコンを動かす!
FPGA Spartan-6 XC6SLX16でファミコンを動かす!

  Xilinx FPGA Spartan-6 XC6SLX16 NES clone in ALINX AX309

Xilinxの FPGA Spartan-6で PicoBlaze KCPSM 8 ビット マイクロコントローラーを動かす!
Xilinxの FPGA Spartan-6で PicoBlaze KCPSM 8 ビット マイクロコントローラーを動かす!

  PicoBlaze KCPSM6 in Spartan-6 with ISE WebPack

Xilinxの FPGA Spartan-6で MicroBlazeを ISE WebPack 14.7で無料ライセンスで動かす方法
Xilinxの FPGA Spartan-6で MicroBlazeを ISE WebPack 14.7で無料ライセンスで動かす方法

  How to MicroBlaze in Spartan-6 with ISE WebPack 14.7 only Free License to Blink LED !

USB HOST機能を FPGAに実装する方法、FPGAの GPIOに USB HIDデバイスを接続したい!!
USB HOST機能を FPGAに実装する方法、FPGAの GPIOに USB HIDデバイスを接続したい!!

  FPGAに USB HOST機能を実装して Low Speedの USB HIDデバイスを接続するのら

USBの通信プロトコルを勉強する
USBの通信プロトコルを勉強する

  今まで漠然としていた USBデバイスの通信方法を理解します

USB HOST機能が欲しいのでワンチップマイコンの GPIOで USB HOST機能を実現する
USB HOST機能が欲しいのでワンチップマイコンの GPIOで USB HOST機能を実現する

  FPGAに USBデバイスを接続したいのですが、USB HOSTの通信を実装できないので困っています

OLIMEX LPC-H40(Philips LPC2106)
OLIMEX LPC-H40(Philips LPC2106)

  MOTHER BOARD for LPC-H40(LPC-H2106) and ASM Sample Program.

線形帰還シフトレジスタ LFSRのまとめ、FPGAの Verilog HDLでの実装例
線形帰還シフトレジスタ LFSRのまとめ、FPGAの Verilog HDLでの実装例

  LFSR Linear Feedback Shift Registerについて調べた

XILINX FPGAのBlock RAMをROMとして使う方法
XILINX FPGAのBlock RAMをROMとして使う方法

  FPGAに内蔵のBLOCK-RAMにROMとして初期値を与える方法

スパルタン2で
スパルタン2で"ギャラクシアン基板"を作る!

  Verilog言語で記述してあります

スパルタン2で
スパルタン2で"MIDWAY 8080(TAITO インベーダ基板)"を動かす!

  ハードウェアで本物を作ります

スパルタン2で
スパルタン2で"パックマン"を動かす!

  FPGAでパックマンが動きます

スパルタン2で
スパルタン2で"ド*キーコ*グ"を動かす!

  これもFPGAで動いちゃいます

スパルタン3でアーケードゲームを動かす!
スパルタン3でアーケードゲームを動かす!

  XAPP694の使用例、INVADER/GALAXIAN/PACMAN/D*NKEY-K*NG/TIME PILOT




[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2022 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/fpga/risc_v_rocket_chip/