OpenCores
URL https://opencores.org/ocsvn/fwrisc/fwrisc/trunk

Subversion Repositories fwrisc

[/] [fwrisc/] [trunk/] [doc/] [fwrisc_design.md] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mballance
# FWRISC Design Notes
2
 
3
## Execution State Machine
4
fwrisc uses a state machine to implement instruction execution. Most logical and arithmetic instructions execute in three cycles (Fetch, Decode, Execute). Memory instructions have an additional MEMR or MEMW state. CSR instructions use several states to implement the atomic read/modify/write
5
behavior of these instructions.
6
 
7
## Memory Interface
8
The memory interface for both the instruction-fetch and data interfaces follows a simple valid/ready handshake scheme.
9
 
10
Reads begin with the core asserting VALID along with the address. Read data is sampled when the READY signal is also high.
11
 
12
Writes begin with the core asserting VALID along with address, data, strobes, and write. The cycle terminates when the READY signal
13
is also high.
14
 
15
 
16
## Register File
17
fwrisc uses FPGA blockram to implement the core RISC-V registers, as well as the CSRs. Currently, dual-port
18
full-width RAM is used to increase performance.
19
 
20
## Performance Counters
21
Compliance with the RISC-V spec requires that MCYCLE and MINSTR counters be implemented that track, respectively, the number of cycles since some point in the past, and the number of instructions executed since some point in the past. Limiting the size of an FPGA implementation requires minimizing the number of required flip-flops. As a consequence, these counters are maintained within the register memory block. Updating these
22
registers every cycle would impose an extraordinary overhead on performance, so two small 8-bit counters are used to maintain an intermediate
23
cycle and instruction count. When the cycle count exceeds half its capacity, the copy of the MCYCLE and MINSTR registers are updated with the
24
number of cycles and instructions executed since the last update. This minimizes the resource overhead of maintaining these counters, while
25
maintaining adequate performance.
26
 
27
 
28
 
29
# CSR Instructions
30
The CSR instructions require several steps to execute:
31
- reading the target CSR and (optionally) storing the unmodified version to the destination register
32
- (optionally) Modifying the target CSR based on rs1 and the instruction type
33
- (optionally) Writing the modified CSR value back to the CSR.
34
 
35
In all cases, a temporary register (CSR_tmp) is used to store intermediate values during the read/modify/write operation.
36
 
37
The following diagram shows how a basic CSRRW instruction is implemented
38
![alt text](imgs/csrrw.png "CSRRW Timing Diagram")
39
![alt text](imgs/csrrs.png "CSRRS Timing Diagram")
40
 
41
The CSRRC instruction is implemented by AND-ing the CSRRC argument with the CSR value to form a clear mask, then
42
XOR-ing that mask with the CSR value to derive the new CSR value.
43
![alt text](imgs/csrrc.png "CSRRC Timing Diagram")
44
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.