0% found this document useful (0 votes)
103 views11 pages

32-Bit RISC-V Microprocessor Design

This document describes the design of a 32-bit RISC-V microprocessor. It was created by Reuel Reuben, Rishabh Jain, and Shravan Kumar under the guidance of Prof. Sudhir Bussa for their academic year 2021-22 project. The document provides an overview of the RISC-V instruction set architecture and describes the implementation of a pipelined 32-bit RISC-V processor, including the stages of instruction fetch, decode, execute, memory access, and write back. It also specifies details of the RISC-V processor such as the 32 general purpose registers and instruction encoding.

Uploaded by

Shravan Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views11 pages

32-Bit RISC-V Microprocessor Design

This document describes the design of a 32-bit RISC-V microprocessor. It was created by Reuel Reuben, Rishabh Jain, and Shravan Kumar under the guidance of Prof. Sudhir Bussa for their academic year 2021-22 project. The document provides an overview of the RISC-V instruction set architecture and describes the implementation of a pipelined 32-bit RISC-V processor, including the stages of instruction fetch, decode, execute, memory access, and write back. It also specifies details of the RISC-V processor such as the 32 general purpose registers and instruction encoding.

Uploaded by

Shravan Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Designing of 32 Bit RISC-V Microprocessor
  • Certificate
  • Acknowledgement
  • Introduction
  • Specification of RISC – 5 Processor
  • Instruction Types
  • Pipelining of RISC – 5 Processor

Designing of 32 Bit

RISC-V Microprocessor

Under the guidance of

Prof. Sudhir Bussa

By
Reuel Reuben
Rishabh Jain
Shravan Kumar
Department of Electronics & Telecommunication Engineering
Bharati Vidyapeeth (Deemed To Be) University
College of Engineering,Pune – 4110043

Academic Year 2021-22


BHARATI VIDYAPEETH (DEEMED TO BE) UNIVERSITY
COLLEGE OF ENGINEERING, PUNE – 4110043
DEPARTMENT OF ELECTRONICS& TELECOMMUNICATION
ENGINEERING

CERTIFICATE

Certified that the project report entitled, “32 Bit RISC-V Processor” is a bonafied work done
by Reuel Reuben,Shravan Kumar, Rishabh Jain in fulfillment of the requirements for the
award of degree of Bachelor of Technology in Electronics& Telecommunication
Engineering.

Date:

Prof. Sudhir Bussa Prof. Deepak Ray Prof. R.M. Khaire


Guide Project Coordinator HOD

Examiner 1:
Examiner 2:
ACKNOWLEDGEMENT

We would like to extend our sincere gratitude to the Principal Dr. A. R.


Bhalerao, Head of Department Electronics & Telecommunication, Prof. Shruti
Oza, for nurturing a congenial yet competitive environment, which motivates
all the students not only to pursue goals but also to elevate the Humanitarian
level.

Inspiration and guidance are invaluable in every aspect of life, which we have
received from our respected project guide Prof. Sudhir Bussa, who gave us his
careful and ardent guidance because of which we are able to complete this
project. More words won’t suffice to express our gratitude to his untiring
devotion. He undoubtedly belongs to the members of the artistic gallery who are
masters in all aspects.

We would also like to thank all the faculty members who directly or indirectly
helped us from time to time with their invaluable inputs.
Introduction
RISC-V pronounced as “RISC-five”, is an open-source
standard Instruction Set Architecture (ISA), designed
based on Reduced Instruction Set Computer (RISC)
principles.
With a flexible architecture to build systems ranging
from a simple microprocessor to complex multi-core
systems, RISC-V caters to any market.
The RISC-V ISA provides two specifications, one, the
User Level Instructions which guides in developing
simple embedded systems and connectivity applications
and two, the Privilege Level Instructions which guides
in building secure systems, kernel, and protected
software stacks. RISC-V currently supports three
privilege levels, viz..
Machine/Supervisor/User, with each level having
dedicated Control Status Registers (CSRs) for system
state observation and manipulation.
In addition, RISC-V provides 31 read/write registers.
While all can be used as general-purpose registers, they
have dedicated functions as well. RISC-V is divided
into different categories based on the maximum width
of registers the architecture can support, for example,
RV32 (RISC-V 32) provides registers whose maximum
width is 32-bits and RV64 (RISC-V 64) provides
registers whose maximum width is 64-bits.
Processors with larger register widths can support
instructions and data of smaller widths. So an RV64
platform supports both RV32 and RV64.
PART-I of the RISC-V programmer’s manual, details
RISC-V assembly instructions, registers in use and the
machine privilege level. Advanced concepts on
Privilege levels, Memory Management unit and Trap
delegation will be dealt with in PART-II of the manual.
The objective of the RISC-V ASM (assembly language)
programmer manual is to aid users in writing extensive
assembly programs and provide necessary information
to write simple embedded applications.
 We'll start with an exploration of the instruction set
design of a common Reduced Instruction Set
Architecture (RISC) processor.
 It is a 32-bit processor, which means it can only
process 32 bits of data at a time.
 There are Four main instruction types- R-Type , I-
Type, S-Type, U-Type.
 Overview of the different instruction selected under
each instruction type.
 Pipelined implementation of the processor and the
steps involved.
 We will be implementing pipelines for our
processor :-
-Stages of Pipeline implementation =>
 Instruction Fetch
 Instruction Decode
 Instruction Execute
 Memory Access
 Write Back.
Specification of RISC – 5
Processor
 We'll be utilising the RV32I Base Instruction Set
architecture, which covers Chapter 2 of the RISC –
5 instruction set manual.
 We have 32 General Purpose Registers which are
each 32 bits long in size which marked as x0 - x31.
 The x0 general purpose register holds the constant
value of 0.
 The x1 general purpose register holds the value of
the return address on call.
 A special purpose 32 bit Program counter (PC) and
New PC (NPC) register is also present. This points
to the next instruction in the memory to be Fetched
and Executed.
 The instructions are stored in a 32 Instruction
Registers (IR) which are 32 Bit long in size.
Instruction Types

 rs1 - Source Register 1.


 rs2 - Source Register 2.
 opcode - Operation Code (This specifies the operation performed
by the ALU).
 funct - Specifies the function for a particular operation code (i.e.
each opcode can have different functionality depending on the
function specified).
 imm - Immediate data (Usually specified by the user).
Pipelining of RISC – 5
Processor
We will be implementing pipelines for our RISC
processor.

Stages of Pipeline implementation:


 Instruction Fetch
 Instruction Decode
 Instruction Execute
 Memory Access
 Write Back
Basic requirements for pipelining the RISC32 data path:
- We should be able to start a new instruction every clock cycle.
- Each of the five steps mentioned before (IF, ID, EX, MEM and
WB)
becomes a pipeline stage.
- Each stage must finish its execution within one clock cycle.

1. Instruction Fetch

 The instruction pointed to by Program Counter is fetched from memory here and next

value of Program Counter is computed.

1. Each RISC-V instruction has a 32-bit length.


2. Each memory word is 32 bits long and has a distinct address.
3. The target address for a branch instruction could be the value of the program counter. As
a result, PC is not changed at this point instead, the new value is saved in a register

called NPC.
2. Instruction Decode

 The Instruction which are already fetched from the 32 bit IR Is Decoded.
 The 32 bit Register is divided into-
I) Opcode is 6-bits (bits 6:0).
II) First source register rs1 (bits 19:15), second source register rs2 (bits 24:20).
III) Destination register rd (11:7).
IV) 12-bit immediate data (bits 31:20) or (bits 31:25 & bits 11:7).
V) 20-bit immediate data (bits 31:12).
VI) Immediates are always sign-extended.
3. Instruction Execute

 In this step, the ALU is used to perform some


calculation.
 The exact operation depends on the instruction that
is already decoded.
 The ALU operates on operands that have been
already made ready in the previous cycle.
- A, B, Imm, etc.
 We also calculate/compute the effective addresses
in this stage.
[Link] Access / Branch Completion
 The only instructions that make use of this step are loads, stores, and branches.

– The load and store instructions access the memory.

– The branch instruction updates PC depending upon the outcome of the

branch condition.

Common questions

Powered by AI

The RV32I Base Instruction Set architecture of the RISC-V processor supports various instruction types, including R-Type, I-Type, S-Type, and U-Type instructions. R-Type instructions are used for operations between registers, utilizing rs1, rs2 for source registers, and rd for the destination register, with the operation specified by the opcode and funct fields . I-Type instructions involve immediate data for arithmetic and load operations, where the opcode specifies the operation and the funct determines specific activities . S-Type instructions are used for store operations, involving immediate values and two registers, typically addressing operand locations . U-Type instructions provide upper immediate values for further calculations or operations . Each type has a specific role in arithmetic, logical, memory, and control operations, forming the backbone of the RISC-V processor's functionality.

The pipelining process in a RISC-V processor consists of five stages: Instruction Fetch, Instruction Decode, Instruction Execute, Memory Access, and Write Back . In the Instruction Fetch stage, the instruction pointed by the Program Counter (PC) is fetched and the next PC value is computed . During Instruction Decode, the fetched instruction from the 32-bit Instruction Register is divided into opcode, source and destination registers, and immediate data . In the Instruction Execute stage, the ALU performs relevant calculations based on previously decoded instructions . Memory Access is where load and store operations are executed, and branch operations conditionally update the PC . Finally, Write Back updates the destination register with the result of execution . Each stage completes within one clock cycle, allowing new instructions to begin every cycle, significantly improving throughput and processor performance.

In RISC-V, branch instructions involve the use of immediate values and comparisons between registers to determine execution flow . The outcome of these branch instructions can lead to conditional updating of the Program Counter (PC). When a branch condition is met, the PC is updated with the target address calculated during the instruction decode and execute stages . This address is either a computed effective address or an immediate value offsetting the current PC, saved temporarily in a New PC (NPC) register without directly changing the PC during the process . This mechanism ensures precise control of instruction flow within pipelined processing, allowing for efficient execution and minimal stalling.

The 32 general-purpose registers in a RISC-V processor, each 32-bits long, significantly contribute to its computational abilities by providing flexible storage for temporary data and operands used in arithmetic, logic, and control operations . While all registers can be used generally, certain registers have distinctive roles: x0 is hardwired to zero for immediate availability of constant zero values; x1 holds the return address for procedure calls; others are conventionally used for frame and stack pointers, function arguments, and return values according to the application's ABI (Application Binary Interface). This organization allows efficient data handling and processing, minimizing the need for frequent memory accesses and enhancing computation efficiency.

RISC-V ensures instruction throughput and minimizes latency through its pipelining architecture, where each instruction is broken into five stages: Instruction Fetch, Instruction Decode, Instruction Execute, Memory Access, and Write Back. These stages operate in parallel, each completing in a single clock cycle, allowing a new instruction to be fetched every cycle. This overlapping increases throughput since multiple instructions are processed simultaneously at different stages . Additionally, mechanisms for handling data hazards and branch prediction optimize alignment and flow, reducing stalls and maintaining pipeline efficiency . Such a design ensures consistent throughput with minimal latency by maximizing hardware utilization and resource parallelism.

The open-source nature of the RISC-V Instruction Set Architecture (ISA) allows widespread adaptability across different computing systems due to its cost-effectiveness and freedom from proprietary restrictions . Developers can tailor RISC-V to specific needs by adding custom extensions without license fees, facilitating innovation and collaboration in academia, industry, and research . This adaptability supports a diverse range of applications, from simple embedded systems to complex multi-core environments. Additionally, the open-source model encourages a collaborative community, which helps improve and evolve the ISA continually, ensuring it meets varying technical demands while maintaining competitive performance standards.

In RISC-V instruction encoding, immediate fields provide constant values directly within instructions, allowing the processor to perform operations requiring fixed data efficiently without additional memory accesses . Immediate fields are used for addressing calculations, branch offsets, and arithmetic operations. The encoding structure varies by instruction type: for I-Type, a 12-bit immediate is split between bits 31:20 or bits 31:25 & 11:7; for S-Type, portions of the immediate value are distributed across bits 31:25 & 11:7; U-Type instructions use a 20-bit immediate across bits 31:12 . All immediates are sign-extended to fit operation requirements, supporting both positive and negative values.

Control Status Registers (CSRs) in a RISC-V processor are pivotal for system configuration and operational control, particularly at different privilege levels . Each privilege level—Machine, Supervisor, and User—has a set of CSRs that are used to observe and manipulate the system state, manage interrupts, control floating-point operations, and handle exceptions . They allow for flexible configuration and secure access control, facilitating seamless communication between software and hardware. The CSRs ensure that operations are appropriately privileged, maintaining system security and efficiency by executing commands relevant to the specific trust level of the executing process.

The RISC-V architecture includes three privilege levels: Machine, Supervisor, and User, each with dedicated Control Status Registers (CSRs) to manage system state . Machine level is the highest privilege, providing control over the entire processor and handling low-level hardware operations. The Supervisor level manages kernel tasks and system resources within an operating system context . The User level runs applications with the least privilege, limiting access to sensitive operations and hardware, which helps prevent unauthorized actions. This tiered structure helps maintain security by ensuring that only designated privilege levels have access to certain operations, thus promoting system stability and reducing potential vulnerabilities.

The RISC-V processor manages memory access through dedicated stages in its pipeline, specifically during the Memory Access phase . Load operations access data from memory, specified by effective addresses calculated during the Instruction Execute stage, and the data is then transferred to a register in the Write Back stage . Conversely, store operations involve writing data from a register into a memory location defined by the effective address . These operations use the same 32-bit bus architecture and are synchronized so that memory accesses do not interfere with each other, ensuring efficient throughput and minimal pipeline stalls.

Designing of 32 Bit
          RISC-V Microprocessor
     Under the guidance of 
          Prof. Sudhir Bussa
BHARATI VIDYAPEETH (DEEMED TO BE) UNIVERSITY
COLLEGE OF ENGINEERING, PUNE – 4110043 
DEPARTMENT OF ELECTRONICS& TELECOMMUNICA
ACKNOWLEDGEMENT
We would like to extend our sincere gratitude to the Principal  Dr. A. R.
Bhalerao, Head of Department Electr
Introduction
RISC-V pronounced as “RISC-five”, is an open-source 
standard Instruction Set Architecture (ISA), designed 
base
In addition, RISC-V provides 31 read/write registers. 
While all can be used as general-purpose registers, they 
have dedicat
We'll start with an exploration of the instruction set
design of a common Reduced Instruction Set 
Architecture (RISC) proce
Specification of RISC – 5 
Processor 
We'll be utilising the RV32I Base Instruction Set 
architecture, which covers Chapter
Instruction Types 
rs1 - Source Register 1.
rs2 - Source Register 2.
opcode - Operation Code (This specifies the operation
Pipelining of RISC – 5 
Processor 
We will be implementing pipelines for our RISC 
processor.
Stages of Pipeline implementati
2. Instruction Decode 
The Instruction which are already fetched from the 32 bit IR Is Decoded. 
The 32 bit Register is div

You might also like