ibex/vendor/lowrisc_ip/ip/prim
Greg Chadwick 71683aa595 Update lowrisc_ip to lowRISC/opentitan@e0c4026501
Update code from upstream repository
https://github.com/lowRISC/opentitan to revision
e0c40265019aa0c74e6903d3b3a144c48a3815ec

* [prim/lint] Fix long line lint error in prim_intr_hw (Alexander
  Williams)
* [csr_seq_lib] Avoid slicing a queue (Rupert Swarbrick)
* [dv] Make mem_model's compare_byte function less chatty (Rupert
  Swarbrick)
* [doc,prim] Improve comments in prim_intr_hw (Harry Callahan)
* [dvsim] Format FormalCfg code. (Miguel Osorio)
* [dvsim] Add results_server dependency to FormalCfg (Miguel Osorio)
* [prim_sha2] Add `hash_running_o` (Andreas Kurth)
* [prim_sha2] Add `hash_continue_i` (Andreas Kurth)
* [prim_sha2] Make digest writable from input while disabled (Andreas
  Kurth)
* [dv,random_reset] Enhance handling of random resets (Guillermo
  Maturana)
* [dv] Change implementation of special mubi access modes (Michael
  Schaffner)
* [dv,cov_merge] Do serial coverage merge for vcs (Guillermo Maturana)
* [dv/csr_utils] Change csr_peek to return the peeked value (Rupert
  Swarbrick)
* [dv/csr_utils] Expand a documentation comment in csr_peek (Rupert
  Swarbrick)
* [dv/csr_utils] Simplify HDL path checking in csr_peek (Rupert
  Swarbrick)
* [dv/csr_utils] Use DV_CHECK to simplify code structure in csr_peek
  (Rupert Swarbrick)
* [dv/csr_utils] Fix a seeming typo in csr_peek (Rupert Swarbrick)
* [dv/csr_utils] Change `csr_peek` to function (Andreas Kurth)
* [prim] Fix lint error in shadow register subreg primitive (Pirmin
  Vogel)
* [otp_ctrl] Add second HW_CFG partition (Michael Schaffner)
* [primgen] Fix parameters in a primgen template (Rupert Swarbrick)
* [prim] Avoid unnecessary Impl parameter in prim_onehot_check (Rupert
  Swarbrick)
* [hw,prim,sha2] Fix syntax error in waiver file (Robert Schilling)
* [prim_sha2,rtl] prim_sha2 minor RTL and styling fixes (Ghada
  Dessouky)
* [prim_sha2,rtl] Add RTL implementation + update core + lint waivers
  (Ghada Dessouky)
* [otp_ctrl] Remove entropy_src chicken switches (Michael Schaffner)
* [dv] Correct direct prediction of regwen (Michael Schaffner)
* [clkmgr] Restructure division clock feedback (Michael Schaffner)
* Revert "[edn] Move prim_edn_req out of prim" (Rupert Swarbrick)
* [rtl, prim] Add 'commit' functionality to prim_count (Greg Chadwick)
* [prim] Fix up 1r1w cores (Alexander Williams)
* [prim] Add two-port memory ECC wrappers (Michael Schaffner)
* [prim] Add two-port memory implementation (Michael Schaffner)
* [prim] Make copies of dual port memory files (Michael Schaffner)
* [otp_ctrl] Add support for multiple HW_CFG partitions (Michael
  Schaffner)
* [otp_ctrl] Add option to disable integrity on a partition (Michael
  Schaffner)
* [dv] Enhance RAL model with clearable mubi types (Michael Schaffner)

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2024-03-01 10:18:25 +00:00
..
doc Update lowrisc_ip to lowRISC/opentitan@e6a0e9a136 2023-11-24 17:27:25 +00:00
dv Update lowrisc_ip to lowRISC/opentitan@4cf2479b8e 2024-01-19 03:24:48 +00:00
fpv Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
lint Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
pre_dv Update lowrisc_ip to lowRISC/opentitan@4cf2479b8e 2024-01-19 03:24:48 +00:00
rtl Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
util Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
BUILD Update lowrisc_ip to lowRISC/opentitan@be1359d27 2021-12-08 08:54:54 +00:00
prim.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_alert.core Update lowrisc_ip to lowRISC/opentitan@3a672eb36 2021-11-29 17:25:30 +00:00
prim_and2.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_arbiter.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_assert.core Update lowrisc_ip to lowRISC/opentitan@0747afbdd 2022-03-31 15:20:56 +01:00
prim_blanker.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_buf.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_cdc_rand_delay.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_cipher.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_cipher_pkg.core Update lowrisc_ip to lowRISC/opentitan@f29a0f7a7 2021-04-06 12:49:51 +01:00
prim_clock_buf.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_clock_div.core Update lowrisc_ip to lowRISC/opentitan@e6a0e9a136 2023-11-24 17:27:25 +00:00
prim_clock_gating.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_clock_gp_mux2.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_clock_inv.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_clock_meas.core Update lowrisc_ip to lowRISC/opentitan@3a672eb36 2021-11-29 17:25:30 +00:00
prim_clock_mux2.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_count.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_crc32.core Update lowrisc_ip to lowRISC/opentitan@be1359d27 2021-12-08 08:54:54 +00:00
prim_diff_decode.core Update lowrisc_ip to lowRISC/opentitan@ad629e3e6 2021-11-16 10:49:23 +00:00
prim_dom_and_2share.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_double_lfsr.core Update lowrisc_ip to lowRISC/opentitan@0747afbdd 2022-03-31 15:20:56 +01:00
prim_edge_detector.core Update lowrisc_ip to lowRISC/opentitan@ad629e3e6 2021-11-16 10:49:23 +00:00
prim_edn_req.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_esc.core Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd 2022-03-10 14:15:03 +00:00
prim_fifo.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_flash.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_flop.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_flop_2sync.core Update lowrisc_ip to lowRISC/opentitan@1740ccd1a 2022-04-13 14:36:52 -07:00
prim_flop_en.core Update lowrisc_ip to lowRISC/opentitan@ca950b43a 2021-05-11 18:28:56 +01:00
prim_gf_mult.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
prim_lc_and_hardened.core Update lowrisc_ip to lowRISC/opentitan@34de51f3a 2022-11-17 17:33:09 +00:00
prim_lc_combine.core Update lowrisc_ip to lowRISC/opentitan@ad629e3e6 2021-11-16 10:49:23 +00:00
prim_lc_dec.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_lc_or_hardened.core Update lowrisc_ip to lowRISC/opentitan@34de51f3a 2022-11-17 17:33:09 +00:00
prim_lc_sender.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_lc_sync.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_lfsr.core Update lowrisc_ip to lowRISC/opentitan@3a672eb36 2021-11-29 17:25:30 +00:00
prim_macros.core Update lowrisc_ip to lowRISC/opentitan@affb06d8d 2022-11-04 15:21:14 +01:00
prim_max_tree.core Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd 2022-03-10 14:15:03 +00:00
prim_msb_extend.core Update lowrisc_ip to lowRISC/opentitan@f29a0f7a7 2021-04-06 12:49:51 +01:00
prim_mubi.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_multibit_sync.core Update lowrisc_ip to lowRISC/opentitan@e619fc60 2020-11-28 12:12:27 +00:00
prim_onehot.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_onehot_check.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_otp.core Update lowrisc_ip to lowRISC/opentitan@7117c349d 2021-05-25 15:14:52 +01:00
prim_otp_pkg.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_pad_attr.core Update lowrisc_ip to lowRISC/opentitan@ca950b43a 2021-05-11 18:28:56 +01:00
prim_pad_wrapper.core Update lowrisc_ip to lowRISC/opentitan@ca950b43a 2021-05-11 18:28:56 +01:00
prim_pad_wrapper_pkg.core Update lowrisc_ip to lowRISC/opentitan@ca950b43a 2021-05-11 18:28:56 +01:00
prim_pkg.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
prim_ram_1p.core Update lowrisc_ip to lowRISC/opentitan@1ae03937f 2021-03-12 16:15:22 +00:00
prim_ram_1p_adv.core Update lowrisc_ip to lowRISC/opentitan@6cc5c164b 2021-03-04 09:56:36 +00:00
prim_ram_1p_pkg.core Update lowrisc_ip to lowRISC/opentitan@1ae03937f 2021-03-12 16:15:22 +00:00
prim_ram_1p_scr.core Update lowrisc_ip to lowRISC/opentitan@3a672eb36 2021-11-29 17:25:30 +00:00
prim_ram_1r1w.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_ram_1r1w_adv.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_ram_1r1w_async_adv.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_ram_2p.core Update lowrisc_ip to lowRISC/opentitan@1ae03937f 2021-03-12 16:15:22 +00:00
prim_ram_2p_adv.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
prim_ram_2p_async_adv.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
prim_ram_2p_pkg.core Update lowrisc_ip to lowRISC/opentitan@1ae03937f 2021-03-12 16:15:22 +00:00
prim_reg_we_check.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_rom.core Update lowrisc_ip to lowRISC/opentitan@1ae03937f 2021-03-12 16:15:22 +00:00
prim_rom_adv.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
prim_rom_pkg.core Update lowrisc_ip to lowRISC/opentitan@1ae03937f 2021-03-12 16:15:22 +00:00
prim_rst_sync.core Update lowrisc_ip to lowRISC/opentitan@affb06d8d 2022-11-04 15:21:14 +01:00
prim_sec_anchor.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_secded.core Update lowrisc_ip to lowRISC/opentitan@f9e667550 2022-08-05 18:00:25 +01:00
prim_sha2.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_sha2_pkg.core Update lowrisc_ip to lowRISC/opentitan@e0c4026501 2024-03-01 10:18:25 +00:00
prim_sparse_fsm.core Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd 2022-03-10 14:15:03 +00:00
prim_subreg.core Update lowrisc_ip to lowRISC/opentitan@e6a0e9a136 2023-11-24 17:27:25 +00:00
prim_sum_tree.core Update lowrisc_ip to lowRISC/opentitan@7c4f8b3fd 2022-03-10 14:15:03 +00:00
prim_trivium.core Update lowrisc_ip to lowRISC/opentitan@4cf2479b8e 2024-01-19 03:24:48 +00:00
prim_usb_diff_rx.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_util.core Update lowrisc_ip to lowRISC/opentitan@affb06d8d 2022-11-04 15:21:14 +01:00
prim_util_get_scramble_params.core Update lowrisc_ip to lowRISC/opentitan@da3ac7c4e 2021-07-20 13:44:11 +01:00
prim_util_memload.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
prim_xnor2.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_xor2.core Update lowrisc_ip to lowRISC/opentitan@0deeaa99e 2023-07-06 07:55:47 +00:00
prim_xoshiro256pp.core Update lowrisc_ip to lowRISC/opentitan@3a672eb36 2021-11-29 17:25:30 +00:00
primgen.core Update paths for vendored DV code 2020-11-28 12:12:27 +00:00
README.md Update lowrisc_ip to lowRISC/opentitan@e6a0e9a136 2023-11-24 17:27:25 +00:00

lowRISC Hardware Primitives

prim_alert:

prim_esc:

prim_lfsr:

prim_present:

prim_prince:

Concepts

This directory contains basic building blocks to create a hardware design, called primitives. A primitive is described by its name, and has a well-defined list of ports and parameters.

Under the hood, primitives are slightly special, as they can have multiple implementations. In contrast to many other modules in a hardware design, primitives must often be implemented in technology-dependent ways. For example, a clock multiplexer for a Xilinx FPGA is implemented differently than one for a specific ASIC technology.

Not all primitives need to have multiple implementations.

  • Primitives with a single, generic, implementation are normal SystemVerilog modules inside the hw/ip/prim/rtl directory. We call these primitives "technology-independent primitives".
  • Primitives with multiple implementations have only a FuseSoC core file in the hw/ip/prim directory. The actual implementations are in "technology libraries". We call these primitives "technology-dependent primitives".

Abstract primitives

Abstract primitives are wrappers around technology-dependent implementations of primitives, with the ability to select a specific implementation if needed.

In more technical terms, abstract primitives are SystemVerilog modules. The example below shows one.

`ifndef PRIM_DEFAULT_IMPL
  `define PRIM_DEFAULT_IMPL prim_pkg::ImplGeneric
`endif

module prim_pad_wrapper
#(
  parameter int unsigned AttrDw = 6
) (
  inout wire         inout_io, // bidirectional pad
  output logic       in_o,     // input data
  input              out_i,    // output data
  input              oe_i,     // output enable
  // additional attributes {drive strength, keeper, pull-up, pull-down, open-drain, invert}
  input [AttrDw-1:0] attr_i
);
  parameter prim_pkg::impl_e Impl = `PRIM_DEFAULT_IMPL;

  if (Impl == prim_pkg::ImplGeneric) begin : gen_generic
    prim_generic_pad_wrapper u_impl_generic (
      .*
    );
  end else if (Impl == prim_pkg::ImplXilinx) begin : gen_xilinx
    prim_xilinx_pad_wrapper u_impl_xilinx (
      .*
    );
  end else begin : gen_failure
    // TODO: Find code that works across tools and causes a compile failure
  end

endmodule

As seen from the source code snippet, abstract primitives have the following properties:

  • They have an Impl parameter which can be set to choose a specific implementation of the primitive.
  • The Impl parameter is set to a system-wide default determined by the PRIM_DEFAULT_IMPL define.
  • All ports and parameters of the abstract primitive are forwarded to the implementations.

Technology libraries

Technology libraries collect implementations of primitives.

At least one technology library must exist: the generic technology library, which contains a pure-SystemVerilog implementation of the functionality. This library is commonly used for simulations and as functional reference. The generic technology library is contained in the hw/ip/prim_generic directory.

In addition to the implementation in the generic library, primitives may be implemented by as many other libraries as needed.

Technology libraries are referenced by their name.

Technology library discovery

In many cases, technology libraries contain vendor-specific code which cannot be shared widely or openly. Therefore, a FuseSoC looks for available technology libraries at build time, and makes all libraries it finds available.

The discovery is performed based on the agreed-on naming scheme for primitives.

  • FuseSoC scans all libraries (e.g. as specified by its --cores-root command line argument) for cores.
  • All cores with a name matching lowrisc:prim_TECHLIBNAME:PRIMNAME are considered. TECHLIBNAME is then added to the list of technology libraries.

After the discovery process has completed, a script (primgen) creates

  • an abstract primitive (see above), and
  • an entry in the prim_pkg package in the form of prim_pkg::ImplTechlibname to identify the technology library by its name.

User Guide

Use primitives

Primitives are normal SystemVerilog modules, and can be used as usual:

  • instantiate it like a normal SystemVerilog module, and
  • add a dependency in the FuseSoC core file.

Technology-dependent primitives have an additional parameter called Impl. Set this parameter to use a specific implementation of the primitive for this specific instance. For example:

prim_ram_2p #(
  .Width (TotalWidth),
  .Depth (Depth),
  // Force the use of the tsmc40lp technology library for this instance, instead
  // of using the build-time default.
  .Impl(prim_pkg::ImplTsmc40lp)
) u_mem (
  .clk_a_i    (clk_i),
  ...
)

Set the default technology library

If no specific technology library is chosen for an instantiated primitive the default library is used. The SystemVerilog define PRIM_DEFAULT_IMPL can be used to set the default for the whole design. Set this define to one of the enum values in prim_pkg.sv in the form prim_pkg::ImplTechlibname. Techlibname is the capitalized name of the technology library.

In the top-level FuseSoC core file the default technology library can be chosen like this:

# my_toplevel.core

# Declare filesets and other things (omitted)

parameters:
  # Make the parameter known to FuseSoC to enable overrides from the
  # command line. If not overwritten, use the generic technology library.
  PRIM_DEFAULT_IMPL:
    datatype: str
    paramtype: vlogdefine
    description: Primitives implementation to use, e.g. "prim_pkg::ImplGeneric".
    default: prim_pkg::ImplGeneric

targets:
  fpga_synthesis:
    filesets:
      - my_rtl_files
    parameters:
      # Use the xilinx technology library for this target by default.
      - PRIM_DEFAULT_IMPL=prim_pkg::ImplXilinx
    toplevel: my_toplevel

Create a technology library

To create a technology library follow these steps:

  • Choose a name for the new technology library. Names are all lower-case. To ease sharing of technology libraries it is encouraged to pick a very specific name, e.g. tsmc40lp, and not asic.
  • Copy the prim_generic folder into an arbitrary location (can be outside of this repository). Name the folder prim_YOURLIBRARYNAME.
  • Replace the word generic everywhere with the name of your technology library. This includes
    • file and directory names (e.g. prim_generic_ram1p.sv becomes prim_tsmc40lp_ram1p.sv),
    • module names (e.g. prim_generic_ram1p becomes prim_tsmc40lp_ram1p), and
    • all other references (grep for it!).
  • Implement all primitives. Replace the module body of the generic implementation with a technology-specific implementation as needed. Do not modify the list of ports or parameters in any way!

Implementation details

Technology-dependent primitives are implemented as a FuseSoC generator. The core of the primitive (e.g. lowrisc:prim:rom in prim/prim_rom.core) calls a FuseSoC generator. This generator is the script util/primgen.py. As input, the script receives a list of all cores found by FuseSoC anywhere in its search path. The script then looks through the cores FuseSoC discovered and extracts a list of technology libraries out of it. It then goes on to create the abstract primitive (copying over the list of parameters and ports from the generic implementation), and an associated core file, which depends on all technology-dependent libraries that were found.