Commit graph

409 commits

Author SHA1 Message Date
Michael Rogenmoser
54533b0744 [rtl] Add 16 external performance counters at mhpmcounter[28:13] 2021-01-21 17:12:51 +01:00
Michael Rogenmoser
24e3d1d090 [rtl] Switch to tc_clk_gating from pulp tech_cells_generic 2021-01-21 17:12:51 +01:00
Michael Rogenmoser
28be76be62 [rtl] Correct direction of irq_x_i port and width of irq_x_ack_id_o 2021-01-21 17:12:51 +01:00
Maximilian Koschay
ebc92e8c82 Make miex register all ones on reset
The register is redundant to the PLIC in pulpissimo and is never written by the PULP_SDK.
Therefore enable all Interrupts from the beginning to ensure functionality.
2021-01-21 17:12:51 +01:00
Pirmin Vogel
0d6e220d79 [rtl] Add CLINTx: 32 fast interrupts and custom CSRs + ACK signaling
This commit adds 32 non-standard, custom, fast interrupts to Ibex. These
interrupts are managed via 3 custom CSRs: `miex`, `mipx` and `mtvecx`.
`mtvecx` is initialized just like `mtvec`. Upon handling such a custom
interrupt, the core uses two signals (ACK + ID) to inform a possible
platform-level interrupt controller accordingly.

The purpose of adding these non-standard interrupts is to have an
interrupt framework compatible with RI5CY/CV32E40P for platforms that can
use the two cores interchangeably (PULP/PULPissmio).

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-01-21 17:12:51 +01:00
Pirmin Vogel
57108c3184 [rtl] Switch to cluster_clock_gating
This commit replaces the generic `prim_clock_gating` cell with the
`cluster_clock_gating` cell used in PULPissimo.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2021-01-21 17:12:51 +01:00
Pirmin Vogel
c69fc8b6f2 [rtl] Fix overlapping encodings of immediate instructions in tracer package
This commit modifies the encoding of SROI, RORI, SBEXTI, GREVI and GORCI by
forcing Bit 26 to zero to prevent overlapping encodings with FSRI.

The bitmanip draft spec doesn't explicitly state that Bit 26 for those
instructions must be zero. However, those instructions only ever use
log2(XLEN) LSBs of the immediate. This means they don't use Bit 26 in RV32.
Instead, whenever Bit 26 is set, these instructions are instead decoded as
FSRI.
2021-01-21 17:11:47 +01:00
Pirmin Vogel
e64f94e798 [rtl] Fix encoding of ZIP/UNZIP pseudo-instrcutions in tracer package
Just like for the corresponding base instructions SHFLI/UNSHFLI the MSBs of
all these pseudo-instructions must be 6'b0000_10.
2021-01-21 17:11:47 +01:00
Pirmin Vogel
760baa1eb2 [rtl] Fix encoding for ORC16/REV16 instructions in tracer package
This bug was originally found by @micprog.
2021-01-19 15:05:07 +01:00
Greg Chadwick
6a61e0ec0c [rtl] Fix PMP NAPOT matching for 0 PMPGranularity 2021-01-19 10:24:32 +00:00
Tobias Wölfel
ca31ca43f3 [rtl] Add B extension to misa
Reflect the availability of the B extension in the misa register.
2021-01-19 09:01:36 +01:00
Tobias Wölfel
90c78203cc [rtl] Use tracer parameters for decoding
Instead of repeating the values from the tracer package use the
definitions to decode the instructions.
2021-01-11 16:20:33 +01:00
Tobias Wölfel
3371732f94 [rtl] Disable definition of unused instructions
The parameters are not used as the instructions are not yet widely
supported.
Keep definitions so they can be easily activated later.

Tracked in issue lowrisc/ibex#1228
2021-01-11 16:20:33 +01:00
Tobias Wölfel
90258b6d07 [rtl] Remove unused tracer branch instruction
`INSTR_BALL` was introduced in 47b713fd as a vector instruction.
This is not used and is probably a leftover so can be removed.
2021-01-11 16:20:33 +01:00
Fresher14
0199bbae66 Use overlapping implications for Xcelium 19.03
Xcelium 19.03 doesn't support the `->` (binary logical) operator, but
using `|->` (overlapping implication) is equivalent here and supported;
use this operator instead.

Fixes #1213
2020-12-17 11:25:03 +00:00
Tom Roberts
8db89a9dfc [rtl] Add branch prediction signals to icache
These changes correspond to similar changes in the prefetch buffer to
support branch prediction. A registered version of fill_ext_done was
required to prevent a combinational loop from branch_i in to valid_o
out.

Multiplexing priorities for fifo_addr have been swapped to match
fetch_addr_d in the same module and all similar multiplexing in the
icache (prioritize incoming branch_i over branch_mispredict_i). Note
however that it is not expected that these conditions will actually
occur together, and an assertion has been added to check that.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-12-02 15:10:48 +00:00
Tom Roberts
64ee9a930d [rtl] icache performance updates
Remove the SpeculativeRequest parameter, and replace it with a
policy. If the cache is disabled, make the request on the basis that we
definitely won't hit in the cache and so should make the bus request
asap.

Stop fill buffers from fetching complete cache lines when the cache is
disabled. When the core branches into the middle of a line, the lower
words would normally be fetched to complete the line. This is
unnecessary when the cache is disabled since those words will just be
thrown away and the core will stall while they are being fetched.

These two changes make the performance using the disabled icache the
same as using non-icache prefetch buffer.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-12-02 15:10:48 +00:00
Philipp Wagner
86084b9d3d Fix Xcelium warnings
(Likely) fix the following warnings from Xcelium (we cannot actually
confirm that without the tool):

```
                      |fill_ext_req;
                      |
xmvlog: *W,DUPBWO (../src/lowrisc_ibex_ibex_icache_0.1/rtl/ibex_icache.sv,830|22): error prone bit-wise OR ('|') sequence detected [4.1.11(IEEE)].
  `ASSERT_IF(BranchInsTypeOneHot, $onehot0({instr_j, instr_b, instr_cj, instr_cb}), fetch_valid_i);
                                                                                                  |
xmvlog: *W,UEXPSC (../src/lowrisc_ibex_ibex_core_0.1/rtl/ibex_branch_predict.sv,91|98): Ignored unexpected semicolon following SystemVerilog description keyword (end).
    `ASSERT(NoPredictSkid, instr_skid_valid_q |-> ~predict_branch_taken);
                                                                        |
xmvlog: *W,UEXPSC (../src/lowrisc_ibex_ibex_core_0.1/rtl/ibex_if_stage.sv,488|72): Ignored unexpected semicolon following SystemVerilog description keyword (end).
    `ASSERT(NoPredictIllegal, predict_branch_taken |-> ~illegal_c_insn);
                                                                       |
xmvlog: *W,UEXPSC (../src/lowrisc_ibex_ibex_core_0.1/rtl/ibex_if_stage.sv,489|71): Ignored unexpected semicolon following SystemVerilog description keyword (end).
```
2020-11-18 10:16:48 +00:00
Tom Roberts
62405f931f [rtl] Fix performance counter bug
- Make sure performance counters only count retired, non-trapping
  instructions excluding ebrk/ecall
- Rewire some signalling through the writeback stage to allow
  instruction retire to be signalled from one place
- Relates to #1132

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-11-10 11:43:17 +00:00
Michael Platzer
6fb378c40c [rtl] Reduce size of PMP addr CSRs to minimum
- Reduce the size of the PMP address configuration registers to the
  permissible minimum depending on granularity.
- Ensure consistency between PMP address CSR reads and the addresses
  forwarded to the PMP module.
- Follow the specification more strictly, by returning bits
  pmpaddr[G-2:0] as all ones when pmpcfg.A[1] is set (i.e. mode is
  NAPOT or NA4, though the latter is invalid for G > 0) and bits
  pmpaddr[G-1:0] as all zeros when pmpcfg.A[0] is clear (i.e. mode is
  OFF or TOR).
- Fixes #1181
2020-11-09 14:49:06 +00:00
Michael Platzer
9b0d78cf97 [rtl] Fix NAPOT address matching
- Generate correct masks for NAPOT range addresses covering the entire
  granule. When PMPGranularity > 0, then a NAPOT range can span the
  whole granule, which requires the next-lowest bit (i.e. highest bit
  that is not part of the granule) to be 0.
- Fixes #1178
2020-11-06 17:47:26 +00:00
Tom Roberts
5826af8ad9 [rtl] Instantiate shadow CSRs
Instantiate shadow CSRs and wire up to the alert output.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-11-05 10:02:24 +00:00
Greg Chadwick
c1cfb2106e [rtl] Lint fix for unused signal in multdiv
Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-11-02 17:04:49 +00:00
Paul OKeeffe
09f6d4f5bc [ibex/dv/rtl] Updates to run Cadence Xcelium
This PR makes changes to support Cadence Xcelium 20.09.001

Compile error 1: Fixed the following rtl compile error in ibex_cs_registers.sv

assign tselect_rdata = {'b0, tselect_q};
                          |
xmvlog: *E,NONOWD (/proj/riscv_ibex/users/paulok/lowRISC/ibex_1/rtl/ibex_cs_registers.sv,1288|30): Illegal use of a constant without an explicit width specification [4.1.14(IEEE)].

Compile error 2: Fixed the following DV compile error in ibex_mem_intf.sv
.data_req_o (data_mem_vif.request ),
|
xmelab: *E,ICDCBA (./tb/core_ibex_tb_top.sv,89|14): Illegal combination of driver and output clockvar to variable 'request' detected (output clockvar found in clocking block at line 25 in file ./common/ibex_mem_intf_agent/ibex_mem_intf.sv).

Simulation probes: Fixed issue with probing in yaml for xrun and added licqueue.

Signed-off-by: Paul OKeeffe <paul_okeeffe@crevinn.com>
2020-10-30 17:22:04 +00:00
Philipp Wagner
58e3cb5bf3 Tie off branch predictor signals when icache is used
Fix two Verilator lint warnings if icache is used. The branch predictor
is currently only used together with the prefetch buffer, and those
signals are unused in the icache configuration.
2020-10-27 11:30:09 +00:00
Tom Roberts
d977e146ba [rtl] Various small lint fixes
- Move various unused signal fixes from the waiver file to the rtl, so
  that all tools can pick them up.
- Fix some oversize line issues.
- Fix some signed / unsigned casting issues.
- Remove some extraneous semicolons.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-10-27 11:29:35 +00:00
Tobias Wölfel
4431023516 Add support for additional HW breakpoints
Add parameter `DbgHwBreakNum` to configure the number of HW breakpoints.
The parameters controls the number of trigger registers available if
debug support is enabled with `DbgTriggerEn`.

Closes #1070
2020-10-19 13:20:08 +02:00
Tom Roberts
dbd92c5d4b [rtl] Fix illegal write to DCSR cause field
- This field is read-only to software, and so should retain its previous
  value on a write. This fixes #1134.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-10-14 17:35:00 +01:00
Tom Roberts
1a9545baaf [rtl] Add CSR module and instantiate
- This change should have no functional impact on the design
- Adding the separate module will allow easy parameterization
  of security hardening for individual CSRs in the future
- As a side benefit, clock gating is added for CSRs that didn't
  previously have it
- Note that this change makes the cpuctrl register always present,
  rather than individual bits being added depending on parameterized
  features. This is not ideal, but the parameterization becomes rather
  messy otherwise.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-10-14 15:53:33 +01:00
Tom Roberts
8953d82ca4 [rtl] Various security feature bugfixes
- Document that SecureIbex cannot be used without a multiplier and add
  an assertion in the rtl. This fixes #1080.
- Move the PC checking hardware onto its own parameter to match all the
  other individual security features.
- Make the PC increment behavior more sensible on fetch errors (and make
  it match the icache behavior). Factor this into the PC increment check
  to prevent false triggering, fixes #1094.
- Stop the PC mismatch checker firing on dummy instructions, fixes
  #1095.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-10-14 15:46:10 +01:00
Tom Roberts
adc574b8b0 [rtl] Fix missing else branch in decoder
- Without the B extension, a gorci instruction should decode as an
  illegal instruction.
- Relates to #1129

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-10-14 09:49:30 +01:00
Tobias Wölfel
bcbf1a7adf [rtl] Add plusarg to disable trace log
Option to control the state of the Ibex tracer.
Defaults to enable, but allows a setting to disable the trace log.

In long running simulations this file can get quite big and the contents
might not be needed. Use the argument `+ibex_tracer_enable=0` to prevent
the creation of the file.
2020-10-13 15:23:22 +02:00
Sam Elliott
f9f0cb1133 [simple_system] Update CSR Access for LLVM and GCC
At some point in the future, the version of binutils we're using, and
the released version of LLVM, will coincide to use the correct name. In
the meantime, this change just uses the number which is supported by
both compilers.

This is, as I understand it, the only stumbling block to compiling the
in-repo C benchmark code with both GCC and LLVM. Being able to do so
would make it much easier for us to do comparisons on the benchmarks for
both compilers.

Signed-off-by: Sam Elliott <selliott@lowrisc.org>
2020-09-22 16:57:14 +01:00
Tobias Wölfel
1553636a7d [formal] Add check for multdiv cycle consumption
Check that the number of cycles are always as specified for the current
configuration for data independent operations.

The required input signals for each arithmetic operation are split into
different files which are included into the testbench.
For each combination of operation and configured configuration
(slow/fast/single) a define stores the number of cycles in a separate
file. A target exists for each combination.
For a convenient execution the targets are grouped together in a
makefile.

The implementation is based on the formal/icache checks.

For the selection of the single cycle multiplication with the fast
multiplication the parameter is set directly to the enum integer value.
2020-09-16 16:30:20 +01:00
Tom Roberts
2c22c1ee01 [rtl] Fix debug step over EBREAK issue
- If there is a request to enter debug mode (either due to a halt
  request or single stepping mode) on the same cycle as an EBREAK
  instruction, continue with the EBREAK and capture the ID PC rather
  than the IF PC.
- relates to #1106

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-09-14 14:19:35 +01:00
Tom Roberts
f30e84ba00 [rtl] Remove outdated assertion
- The core does not rely on instr_err_i being always valid, and most bus
  protocols don't support that

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-08-27 11:40:28 +01:00
Greg Chadwick
2f1b95d214 [doc] Document branch prediction configuration 2020-08-27 11:25:17 +01:00
Greg Chadwick
6123ac7719 [rtl] Introduce static branch prediction 2020-08-27 11:25:17 +01:00
Udi
b1531f2e38 [ibex/rtl] Remove duplicate check for irq_fast[5]
Currently in ibex_controller.sv when generating the ID of any fast
interrupts, irq_fast[5] is checked for twice.
This is a redundant line, and so this PR simply removes it.

Signed-off-by: Udi <udij@google.com>
2020-08-21 13:03:24 -07:00
Pirmin Vogel
9559bbb6ff Add RegFile parameter for selecting register file implementation
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-08-21 14:20:34 +02:00
Tom Roberts
23e21c9494 [rtl] Fix FENCE comment in decoder
- Clarify FENCE treatment rationale
- Update comment around ICache flushing
- Fixes #1048

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-08-21 11:09:12 +01:00
Pirmin Vogel
2ef5e5e3f2 Add a single RV32M enum parameter to select multiplier implementation
This commit replaces the previous combination of `RV32M` bit parameter
used to en/disable the M extension and the `MultiplierImplementation`
used to select the multiplier implementation by a single enum parameter.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-08-20 11:50:08 +02:00
Pirmin Vogel
4127a5464b B extension: Correct doc and parameter usage
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-08-20 11:50:08 +02:00
Greg Chadwick
21ad662418 [rtl] remove lsu_req_in_id signal
This signal aimed to ensure loads/stores completed succesfully when an
interrupt or debug request appeared at the same time they were being
executed when the writeback stage is present. However other stall logic
suffices for this purpose (debug/interrupt will wait for instruction to
unstall in ID/EX which only happens once request has been sent out, then
first instruction of debug/interrupt handler will stall until load/store
response has been seen based on the generic stall logic for lsu requests
in the writeback stage).

With this signal in place debug single stepping was broken around loads
and stores.

Fixes #1029
2020-08-11 14:12:07 +01:00
Udi
7eaf0e4a6e [ibex/rtl] Fix pmpaddr write enable signal
Updates the write enable for `pmpaddr[i]` CSRs to deny writes if
`pmpcfg[i+1].lock == 1` and `pmpcfg[i+1].mode == TOR`, as per the
spec.
2020-08-05 01:17:33 -07:00
Pirmin Vogel
7f9e704f36 [rtl] Make sure decoder also checks bits 26 and 25 for slli, srli, srai
Previously, these bits were not checked when decoding slli, srli and
srai, causing some illegal instruction encodings not to trigger an
illegal instructions exception.

This resolves lowRISC/Ibex#1018.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-07-17 17:05:36 +02:00
Tom Roberts
03a8ae70d6 [rtl] Add security hardened PC
- Checks that PC increments as expected
- Raises an alert if not

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-07-16 15:00:05 +01:00
Tom Roberts
c542edbb1a [rtl] Add register-file ECC checking
- Add SECDED ECC checking to the register file when SecureIbex is
  enabled
- No correction is attempted, but an alert is raised for the system to
  intervene

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-07-15 09:50:23 +01:00
Tom Roberts
aae437d75b [rtl] Add alert outputs
- Add a major and minor alert output which can be used by the system to
  react to fault injection attacks

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-07-15 09:50:23 +01:00
Philipp Wagner
4223803d22 Lint: Fix some line length warnings
AscentLint complains about lines longer than 100 characters, as seen in
the nightly lint reports. Fix some (all?) of them.
2020-07-09 13:42:33 +01:00