Coder Social home page Coder Social logo

pphilippos / simodense Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 7.0 1.08 MB

Simodense: a RISC-V softcore for custom SIMD instructions

License: Other

C 26.33% Python 0.02% Makefile 2.55% Shell 0.25% Fortran 1.33% Assembly 0.28% C++ 1.56% HTML 38.76% JavaScript 2.54% CSS 1.69% Verilog 24.70%

simodense's Introduction

Simodense: a RISC-V softcore for custom SIMD instructions

(mirrors: philippos.info, GitHub)

Welcome to the source code repository for a RISC-V softcore optimised for exploring advanced reconfigurable SIMD instructions

This repository contains a softcore built from scratch for supporting custom SIMD instruction development by Philippos Papaphilippou @ Imperial College London. See below for additional material from the publication, including a video tutorial.

The source code is divided into 4 directories. A separate README file accompanies each directory, to explain how the source code can be used to reproduce the experiments in the paper.

  • RTL_and_simulation This folder contains the main code of the softcore for simulation, as well as the template and examples for custom SIMD instructions.
  • Benchmarks This directory contains the benchmarks and micro-benchmarks (sort & prefix sum) used in the evaluation section.
  • FPGA_Implementation_AXI_peripheral The FPGA directory provides additional Verilog code for interfacing with the an AXI interconnect (such as for Avnet's Ultra96 with the Xilinx device ZU3EG) and the relevant information for creating a Vivado project
  • ARM_Linux_Client_for_Ultra96 The optional Linux (for ARM) client mainly provides C code for interfacing with the softcore in our heterogeneous platform. Having Linux and the specific board is not necessary, as AXI is a versatile protocol, at least for Xilinx boards. Though bridges to other protocols exist as well.

Setting up the environment

  • In order to run the simulations, Icarus Verilog is the main requirement for running the provided examples (tested with version 11.0 (stable) (v11_0)). For the debugging functionality through waveforms, a waveform viewer is recommended, such as GTKWave Analyzer (tested on version 3.3.108).

  • For software development for the softcore, we need to install the RISC-V GNU Compiler Toolchain, and modify it for supporting the custom SIMD instructions for inline assembly.

First we fetch the code using the bash command (6.65GB of data, about 10GB after compilation):

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

and change directory:

$ cd riscv-gnu-toolchain

Then we provide the target directory where GCC and related tools are installed. This is for bare-metal applications, based on the 32-bit "RV32I" base specification and "M" multiplication/division extension. The size of the prefix directory will become about 1.1 GB after compilation.

$ ./configure --prefix=/opt/riscv32im_custom --with-arch=rv32im --with-abi=ilp32    

Before compiling, we need to add the support of custom instructions to binutils. In order to do that, we add the following lines to the C file riscv-gnu-toolchain/riscv-binutils/opcodes/riscv-opc.c inside the lengthy const struct riscv_opcode riscv_opcodes[] array:

{"c0_lv",      0, INSN_CLASS_I, "d,s,t,j",   MATCH_CUSTOM0, MASK_CUSTOM0, match_opcode, 0 },
{"c0_sv",      0, INSN_CLASS_I, "d,s,t,j",   MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1, match_opcode, 0 },
{"c1",      0, INSN_CLASS_I, "d,s,j",   MATCH_CUSTOM1, MASK_CUSTOM1, match_opcode, 0 },
{"c2",      0, INSN_CLASS_I, "d,s,j",   MATCH_CUSTOM2, MASK_CUSTOM2, match_opcode, 0 },
{"c3",      0, INSN_CLASS_I, "d,s,j",   MATCH_CUSTOM3, MASK_CUSTOM3, match_opcode, 0 },

where c0_lv, c0_sv are two custom instructions for vector load and store respectively, using the same opcode and the S' instruction type. c1, c2 and c3 are for the custom instructions, and are using the I' instruction type. Currently, c1, c2 and c3 are used for the merge, sort and prefix SIMD instruction examples, but can be replaced as well as increased and aliased. For more information on the pre-defined opcodes for custom instructions, and for adding more, see file riscv-gnu-toolchain/riscv-binutils/include/opcode/riscv-opc.h. The equivalent files are also included in the riscv-gnu-toolchain/riscv-gdb, should this be of use.

Note that with the latest versions of the riscv-gnu-toolchain, the custom opcodes need to be added manually inside the file riscv-gnu-toolchain/riscv-binutils/include/opcode/riscv-opc.h. For example, the following snippet can be copied from an earlier version of riscv-opc.h from here, as shown below.

#define MATCH_CUSTOM0 0xb
#define MASK_CUSTOM0  0x707f
#define MATCH_CUSTOM0_RS1 0x200b
#define MASK_CUSTOM0_RS1  0x707f	 // ...
#define MATCH_CUSTOM1 0x2b
#define MASK_CUSTOM1  0x707f		// ...
#define MATCH_CUSTOM2 0x5b
#define MASK_CUSTOM2  0x707f		// ...
#define MATCH_CUSTOM3 0x7b
#define MASK_CUSTOM3  0x707f

Finally, we compile the tools by running make, preferably with multiple-threads (15 in the example), as it can take a while.

$ make newlib -j15
  • For experimentation on Xilinx FPGAs, the freely-available Webpack version of Vivado is enough, given that your FPGA board is mentioned in the licence (see Release Notes).

License

The following license applies to this source code, except on code of other projects like some benchmarks in the Benchmarks folder.

Copyright 2021-2024 Philippos Papaphilippou
   
Simodense Software License v1.0

You are free to use, learn from, modify and distribute this creative work under 
  the following conditions:
1. No code, text, or other elements of this work can be used as an input to models
  for the purposes of training. Generative A.I. and language models are prohibited
  from using this work. These do not include search engines and related tools whose
  main purpose is to index and appropriately point to the original source and author.
2. It comes under no warranties.
3. Any modification to the code shall be made available in the style of GNU General
  Public License v2.0 (GPL-2.0), but published under the same license (not GPL-2.0,
  and clause 7 still refers to the original copyright holder).
4. A proper attribution of the author (copyright holder) is required when the work 
  is used. (If applicable, it would be appreciated to cite the related academic
  publication that introduced the work.)
5. It cannot be used for commercial purposes unless specific permission is given by
  the author. 
6. A redistribution shall include this license in its entirety.
7. The author has the right to change this license for future versions of this work,
  as well as to update and clarify the author's original intentions of the current
  version, such as with regard to what is considered "fair use" by the author for
  future entities and technologies.  

Related publications

Philippos Papaphilippou, Myrtle Shah "FPGA-extended General Purpose Computer Architecture" The 18th International Symposium on Applied Reconfigurable Computing (ARC) 2022 pdf link source (framework is based on Simodense) program slides video bib

(cite this) Philippos Papaphilippou, Paul H. J. Kelly and Wayne Luk "Simodense: a RISC-V softcore optimised for exploring custom SIMD instructions" The International Conference on Field-Programmable Logic and Applications (FPL) 2021 pdf link source video program bib

Philippos Papaphilippou, Paul H. J. Kelly and Wayne Luk "Demonstrating custom SIMD instruction development for a RISC-V softcore (demo abstract)" The International Conference on Field-Programmable Logic and Applications (FPL) 2021 pdf link source video bib

Philippos Papaphilippou, Paul H. J. Kelly and Wayne Luk "Extending the RISC-V ISA for exploring advanced reconfigurable SIMD instructions" The Fifth Workshop on Computer Architecture Research with RISC-V (CARRV 2021) (co-located with ISCA 2021) pdf slides source video program bib

Thanks

General comments or feedback on this repository has been provided by: Tim Todman, Hakam Atassi, Yutaka Nagashima

simodense's People

Contributors

pphilippos avatar

Stargazers

guoyibin avatar  avatar WangZiXu avatar Kamyar Mohajerani avatar  avatar Niu Wenxu avatar Xue Da avatar Jeff Carpenter avatar Thinh Pham avatar  avatar João Carlos avatar David Brochart avatar  avatar

Watchers

Kamyar Mohajerani avatar  avatar  avatar

simodense's Issues

cpu.v concat typo.

Line 167 of cpu.v is missing a curly brace. bash run.sh fails without this fix.

3'h2: begin num1 ={32{data1[31]}},data1}; num2 = {32'b0,data2}; end

is changed to

3'h2: begin num1 ={{32{data1[31]}},data1}; num2 = {32'b0,data2}; end
_______________^

Extending the number of Vector Registers

Hello @pphilippos ,

Hope you are well.

I've been working on an algorithm that very specificly requires 10 vector registers instead of the 4 that is currently supported. Based one the code, I was able to find a parameter that seems to control the number of VREGS provided, but when I increase it to 8, I'm able to perform a c0_lv instruction, but the c0_sv instruction does not even compile. I suspect that this is a result of the opcode encoding or something to that extent.

The first step is to figure out how to increase the number of vectors from 4-> 8 using the parameter provided.

The second step is to increase the number of registers for 8->10 by messing with the RTL and potentially the opcodes/opcode masks, if needed.

I'll provide some screenshots from my other laptop in just a second.

If you could help me figure this out, that would be great. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.