Giter Club home page Giter Club logo

piperv32n's Introduction

pipeRV32N

A simple pipelined 32-bit RISCV core with only 8 base integer registers

Features

  • 4-stage RISC-V32 cpu core:
    • IF stage -- instruction fetching
    • ID stage -- instruction decoder
    • EX stage -- execution
    • MEM/WB -- memory and write back
  • Contain only 8 basic core registers
  • Support for nearly entire base integer instructions for RISC-V32, except synch, environment and CSR instructions
  • No pipeline stalling in JAL instruction
  • Maximum 2 pipeline stalling when dealing with JALR,Branch instructions
  • Utilize a dual port SRAM as main memory to avoid structural hazard
  • IF and MEM/WB stages could make pipeline stalling to wait for data reading/writing to memory, compatible for any kind of memory interface.

Further Improvement

  • Support for interruptions
  • Add control statue registers and support for synch, environment and CSR instructions
  • Change the dual port SRAM as CPU cache for both instruction and data
  • Support for AXI Bus

Getting Start with pipeRV32N

Platform

  • win7 or later version

Software Requirements

  • Quartus II
  • ModelSim
  • Python3
  • RISC-V Embedded GCC

Compile your own RISC-V assembly program

  • Write a RISC-V assembly program, example like ‘main.s’
    • place this assembly program file under 'test' folder
    • Since the maximum size of main memory for pipeRV32N core is 256 Byte, only small assembly program is allowed
    • Please make sure the entry point is labled as 'main'
.text
.globl main
main:
	la ra, array
	li sp, 10
loop:
	lw t0, 0(ra)
	lw t1, 4(ra)
	lw t2, 8(ra)
	add gp, t0, t1
	add gp, gp, t2
	sw gp, 12(ra)
	addi ra, ra, 4
	addi sp, sp, -1
	bgtz sp, loop
L2:
	j	L2
.data
array: .word 1,1,1
tmp:   .word 0,0,0,0,0,0,0,0,0,0 
  • Open a terminal under 'test' folder and compile the RISC-V assembly program:
riscv-none-embed-gcc.exe -c main.s --specs=nosys.specs -march=rv32i -o main.o
  • Link:
riscv-none-embed-ld.exe main.o -T .\linker_script.ld  -o main.elf
  • Convert it into hex file 'ram.hex':
python .\elf2hex.py main.elf 
  • Copy this 'ram.hex' file to replace the one under 'src' folder

Use Quartus to compile and simulate pipeRV32N core

  • Create a new Quartus project, choose device family 'Cyclone II' and set ModelSim as simulation tool
  • Import these files under ‘src’ folder to project:
core.v
if_stage.v
id_stage.v
ex_stage.v
wb_mem_stage.v
register_file.v
main_memory.v
ram_element.qip
  • Set ‘core.v’ as top level entity
  • Set ‘test/core_vlg_tst.vt’ as test bench file
  • Compile and start simulation

Simulation result example

waveform

piperv32n's People

Contributors

husterzc avatar

Stargazers

 avatar

Watchers

 avatar

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.