Code Monkey home page Code Monkey logo

clic's Introduction

RISC-V CLIC

RISC-V Core Local Interrupt Controller (CLIC) is an interrupt controller for RISC-V cores subsuming the original RISC-V local interrupt scheme (CLINT). It promises pre-emptive, low-latency, vectored, priority/level based interrupts.

This IP is meant to be used together with a suitably modified version of a core. Currently, a modified version of the CV32E40P is supported.

Here is the detailed specification this IP is based on. For the upstream specification visit this link.

Note that this IP is based on an intermediate development version of the CLIC specification which will still change substantially. This IP will try to track the changes of the specification. The specification document in this repository is a snapshot of the upstream specification and the version this IP is based on.

Features

  • RISC-V Core Local Interrupt Controller (CLIC) compliant interrupt controller
  • Support up to 4096 interrupt lines
  • Support up to 8 bits of priority/level information per interrupt line
  • Supports (a modified) CV32E40P

Parametrization

Some parameters are configurable. See the marked variables in the table below.

Name             Value Range                   Description
CLICANDBASIC     0-1     (depends on core)     Implements original basic mode also?
CLICPRIVMODES    1-3     (depends on core)     Number privilege modes: 1=M, 2=M/U,
                                                                       3=M/S/U
CLICLEVELS       2-256                         Number of interrupt levels including 0
*NUM_INTERRUPT*  4-4096  (default=256)         Always has MSIP, MTIP, MEIP, CSIP
CLICMAXID        12-4095                       Largest interrupt ID
*CLICINTCTLBITS* 0-8     (default=8)           Number of bits implemented in
                                               clicintctl[i]
CLICCFGMBITS     0-ceil(lg2(CLICPRIVMODES))    Number of bits implemented for
                                               cliccfg.nmbits
CLICCFGLBITS     0-ceil(lg2(CLICLEVELS))       Number of bits implemented for
                                               cliccfg.nlbits
CLICSELHVEC      0-1     (0-1)                 Selective hardware vectoring supported?
CLICMTVECALIGN   6-13    (depends on core)     Number of hardwired-zero least
                                               significant bits in mtvec address.
CLICXNXTI        0-1     (depends on core)     Has xnxti CSR implemented?
CLICXCSW         0-1     (depends on core)     Has xscratchcsw/xscratchcswl
                                               implemented?

Integration and Dependencies

This IP requires

and a suitably modified core (see sections below).

The bender and legacy IPApproX flow are supported.

Besides the native register_interface there is an APB wrapper available.

CLIC and CV32E40P

The patch required to use the CV32E40P together with the CLIC lives in this branch. The CLIC mode is an elaboration time parameter at this moment, but will support a dynamic switch at some point.

Here is the summary

Name             Value
CLICANDBASIC     0   (dynamic mode under development)
CLICPRIVMODES    2
NUM_INTERRUPT    32-256
CLICINTCTLBITS   0-8
CLICSELHVEC      1
CLICMTVECALIGN   8
CLICXNXTI        0   (partial, under development)
CLICXCSW         1

CLIC and CVA6

Not supported yet.

FreeRTOS Support

There is very basic support for the CLIC in pulp-freertos with more a more complete level/priority implementation in the works.

Register interface

By default the CLIC's register file is manually written requiring no attention of the user.

Alternatively, regtool can be used to generate the register file. For that, go to src/gen/ and call make all with the environment variable REGTOOL pointing to regtool.py of the register_interface repository and NUM_INTERRUPT and CLICINTCTLBITS appropriately set. These three environment variables can be passed when using make, e.g.

    make NUM_INTERRUPT=128 CLICINTCTLBITS=4

Finally, make sure your src_files.yml or Bender.yml points to

  • src/gen/clic_reg_pkg.sv
  • src/gen/clic_reg_top.sv
  • src/gen/clic_reg_adapater.sv

regtool has various limitations on how the register map can look like, requiring the memory map description (src/gen/clic.hjson) to be derived from a template (src/gen/clic.hjson.tpl), resulting in rather unwieldy code and documentation.

Directory Structure

.
├── doc      CLIC spec, Blockdiagrams
├── src      RTL
├── src/gen  Templates and python scripts

License

This project uses sourcecode from lowRISC licensed under Apache 2.0. The changes and additions are being made available using Apache 2.0 see LICENSE for more details.

clic's People

Contributors

alex96295 avatar bluewww avatar christian-herber-nxp avatar micprog avatar niwis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

clic's Issues

Memory Layout

According to the RISC-V CLIC spec, the memory layout of the memory mapped registers should be as follows:

  0x1000+4*i 1B/input R or RW clicintip[i]
  0x1001+4*i 1B/input RW clicintie[i]
  0x1002+4*i 1B/input RW clicintattr[i]
  0x1003+4*i 1B/input RW clicintctl[i]
  ...
  0x4FFC 1B/input R or RW clicintip[4095]
  0x4FFD 1B/input RW clicintie[4095]
  0x4FFE 1B/input RW clicintattr[4095]
  0x4FFF 1B/input RW clicintctl[4095]

The clicint[ip/ie/attr/clt] registers have a width of 1 byte. See https://github.com/riscv/riscv-fast-interrupt/blob/master/clic.adoc#clic-memory-map

However, in the current implementation they are 4 bytes wide.

Not standardized yet

Great to see this appearing and thanks for the contribution to open-source hardware, but the blurb is misleading.
The CLIC is still under development and is not standardized yet. Please be clear in the writeup that this is an implementation of an intermediate development version and spec will change in substantial software-visible ways before ratification. Thanks.

Add mask to define implemented interrupt sources

Most interrupt lists have gaps. Usually because a chip is available in many configuration with different peripherals. Sometimes sources are reserved to ensure you can grow in the future without reshuffling the interrupt map. Even the RISC-V definition of interrupts has this. Therefore, a top level parameter is needed to mask out certain sources.

parameter [N_SOURCE-1:0] MASK = {N_SOURCE{1'b1}}

Parameterization of number of IRQ levels

I do not see a top level parameter to specify the number of interrupt levels. This would be important, as most designs will only need a few, not 256. I would expect between 3 and 5 level bits to be used, with the rest fixed to one.
The CLIC specification defines a standard parameter, but that definition is currently being reworked. Thus, I would suggest waiting on riscv/riscv-fast-interrupt#331 to complete

Add parameter to hardwire clicintattr.trig values

clicintattr.trig allows run-time configurability of edge vs level and active high vs low.

CLIC states:

Some implementations may want to save these bits so only certain trigger types are supported. In this case, these bits become hard-wired to fixed values (WARL).

This makes a lot of sense, as this is something that doesn't change at run-time. Will need a new eloboration time parameter.

Lint error when setting INTCTLBITS to non-default value

Hi,
I am linting the clic_apb module with Verilator using verilator --lint-only --top-module clic_apb $(bender script verilator).
There are a few warnings, but no errors.

However, when I change the parameter INTCTLBITS of clic_apb to a non-default value (e.g. 4), I get the following error:

%Error: [...]/clic/src/clic.sv:114:19: SEL unexpected in assignment to unpacked array
  114 |     .prio_i      (intctl),
      |                   ^~~~~~

This happens because signal intctl has a hardcoded width of 8 and not INTCTLBITS bits (same for signal irq_max).
The error can likely be fixed by changing the width of these signals, but I am not sure if any other logic needs to be changed also.

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.