chipsalliance / chipsalliance/rocket-chip

Implementation of Zicntr

Open
#3,207 3 comments 0 reactions 0 assignees View on GitHub
proposal
Dominant language
Scala
Stars
3.9k
Forks
1.3k
Avg merge
5d 13m
Merged PRs (30d)
1

Description

**Type of issue**: feature request

**Impact**: API modification

**Development Phase**: proposal

**Other information**

**If the current behavior is a bug, please provide the steps to reproduce the problem:**

**What is the current behavior?**

For the zicntr extension, we have implemented the `cycle` and `instret` CSR (see https://github.com/chipsalliance/rocket-chip/commit/3ff921de046367dbd114150bfca471b5eb0c1550). However, to fully support zicntr, we still need to implement a `time` CSR.

This can not be simply done by connecting `mtime` to `time` as `mtime` is MMIO and currenly it is provided by clint.

**What is the expected behavior?**

There are two ways to provide the `time` CSR

* Hardwire `time` to `reg_cycle`. The spec said simple platform can do this; also, we have already used this fact by `csr.io.time`.
* Hardwire the RTC counter in [HasRTCModuleImp](https://github.com/chipsalliance/rocket-chip/blob/d706071fdc39233277a74d5332f566aa8358010e/src/main/scala/subsystem/RTC.scala#L24) to the CSR. However, not all possible config has the RTC module and CLINT.

The latter can be compliant with the spec on

> The real-time clocks of all harts must be synchronized to within one tick of the real-time clock.

Another final way is to provide `time` CSR from RTC if there is RTC; and fallback to `reg_cycle` if there is none. That will need to pass the `CLINTKey` to the `CSRFile`.

Contributor guide

Open the contributing guide

Research direction

Start with src/main/scala/subsystem/RTC.scala and HasRTCModuleImp, then inspect the CSRFile and existing cycle and instret CSR implementation referenced in the issue. Compare the proposed reg_cycle fallback with sourcing time from the RTC, including whether CLINTKey must reach CSRFile. Done means zicntr time is provided correctly with and without RTC or CLINT configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.