Commit graph

585 commits

Author SHA1 Message Date
Philipp Wagner
cef7b4d154
Remove unused ibex_pkg from tracer (#737)
Signed-off-by: Philipp Wagner <phw@lowrisc.org>
2020-03-26 14:14:24 -07:00
Tom Roberts
b897300cbd [rtl] Branch signal timing fix
- Before this fix, the branch signal was qualified by the illegal
  instruction signal and the illegal csr signal.
- This patch removes both of these since the decoder already masks
  branches with illegal isntruction, and a branch cannot be a CSR op.
- This improves the worst path in the design significantly without the
  branch target ALU.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-25 15:26:02 +00:00
Tom Roberts
624ef41462 [rtl] Extend BT ALU to be used for all jumps
- Create separate operand muxes for the branch/jump target ALU
- Complete jump instructions in one cycle when BT ALU configured

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-25 15:25:22 +00:00
Tom Roberts
3c561e4106 [rtl/icache] Fix an inconsistency in data output
- valid_o could be asserted for one cycle then dropped when receiving
  rvalid data for a request which has branched into  the middle of a
  line.
- This fix keeps valid_o asserted by using the offset version of
  fill_rvd_cnt_q (fill_rvd_beat) to compare against fill_out_cnt_q
  (which is also offset by the branch).

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-24 13:47:57 +00:00
Tom Roberts
f8f8560563 [rtl] Remove stall cycle with BT ALU
- Branches don't need to stall with the branch target ALU

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-24 13:47:25 +00:00
Tom Roberts
0a540cffb3 [rtl/icache] Fix a couple of icache bugs
- Speculative requests observing a PMP error shouldn't increment the
  external request counter
- Remove redundant logic on fill_rvd_exp

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-23 12:57:54 +00:00
Tom Roberts
c054a63c3d [rtl] Instantiate instruction cache
- Add parameters and actual instantiation of icache
- Add a custom CSR in the M-mode custom RW range to enable the cache
- Wire up the cache invalidation signal to trigger on fence.i

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-23 12:57:31 +00:00
Tom Roberts
42aa761c5d [rtl] Fix mtval for unaligned instr errors
mtval should record which half of the instruction caused the error
rather than just recording the PC.
An extra signal is added in the IF stage to indicate when an error is
caused by the second half of an unaligned instruction. This signal is
then used to increment the PC by 2 for mtval capture on an error.

Fixes #709
2020-03-18 12:53:35 +00:00
Tom Roberts
8bb649e4ab [rtl/icache] Fix PMP error logic
Instruction requests triggering PMP errors have their external request
suppressed. The beat counting logic therefore needs to know that these
requests will never receive any rvalid data responses.

This fix stops the external request counter from incrementing, and marks
all external requests complete as soon as any error is received.

The data in the cache line beyond the error is not required since the
core cannot access it without consuming the error first.
2020-03-18 12:53:09 +00:00
Tom Roberts
ef17d4fcc2 [rtl] Add Icache ECC
- Add modules for ecc generation and checking
- Add supporting logic to icache module

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-18 11:28:06 +00:00
Tom Roberts
fe00eb46e9 [rtl] Icache RAM primitive changes
- Bring in a version of ram primitive with configurable width similar to
  the OT RAM primitive.
- Change the RAM banking structure to be a single bank of LineSize (64
  bits) to match the upcoming ECC granularity.

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2020-03-18 11:28:06 +00:00
Tom Roberts
854faeda39 [rtl/icache] Make age matrix more consistent
The design currently relies on fill_done remaining set in the cycle
after the fill buffer completes to ensure the fill_older_q entry gets
cleared (when a fill buffer completes in the same cycle that one is
allocated). This fix makes the behaviour a bit more consistent and easy
to reason about.
2020-03-16 13:12:19 +00:00
Greg Chadwick
3927fd8d2a [rtl/sw] Add multiply and divide wait counters 2020-03-13 14:48:29 +00:00
Rupert Swarbrick
0a0a18c2cb Notes on the ICache specification
This also adds a couple of comments splitting up the ports in
ibex_icache.sv that I found helpful when working out what everything
did.
2020-03-13 13:13:19 +00:00
Philipp Wagner
73c0b810a9 Use a syntax compatible with Verible
Verible doesn't do real pre-processing currently, and fails to parse
code if define sections span across headers of blocks, as we did.

Use another syntax instead for the one case where we did that to work
around this limitation. The code isn't less readable as result, making
this an acceptable trade-off.

Works around https://github.com/google/verible/issues/228
2020-03-13 10:34:12 +00:00
Greg Chadwick
4f31a0e6e8 [rtl] Fixes for single-cycle mutiply
* single cycle multiplier configuration needlessly stalled for a cycle
* mult_hold wasn't being set in mult state machine in single cycle
  multiplier
2020-03-11 11:53:54 +00:00
Tom Roberts
6be55207f3 [rtl] Refactor some IF/ID stage registers
- Rewrite the ID instr flops to be clock gate friendly
2020-03-11 11:43:40 +00:00
Tom Roberts
2a90ef94ed [rtl] IF stage timing fix
- ready_i input to the prefetch buffer factored both it's own valid_o
  output and the pc_set branch signal, neither of which are required.
- Refactoring the ready_i signal to just id_in_ready_i improves timing
  significantly for the icache.
- Also removed offset_in_init signal which appeared to serve no purpose.
2020-03-11 11:43:40 +00:00
Tom Roberts
82ebf6fd20 [I-Cache] Initial commit of prototype RTL
- Working prototype of RTL
- Initial documentation
- Still some TODOs to be dealt with
2020-03-06 16:34:48 +00:00
Greg Chadwick
89e5fc11ed [RTL] Add configurable third pipeline stage
The third pipeline stage is a new writeback stage. Ibex can now be
configured as the original two stage design or the new three stage
design using the `WritebackStage` parameter in ibex_core. This defaults
to 0 (giving the original two stage design).

The three stage design is *EXPERIMENTAL*

In the three stage design all register write back occurs in the third,
final stage. This allows a cycle for responses to loads and stores so
when the memory system can respond in a single cycle there will be no
stall. This offers significant performance benefits.

Documentation of the three stage design is still to be written so
existing documentation applies to the two stage design only as various
aspects of Ibex behaviour will change in the three stage design.

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-03-06 15:29:14 +00:00
Noam Gallmann
11a5fc24d4
Merge pull request #624 from ganoam/fpga-opt-perf-mon-pr
Modifiy Performance Counter for DSP Inference
2020-03-06 12:49:51 +01:00
Rupert Swarbrick
f870accab6 Remove stray semicolon
This seems to cause lint errors with ncsim (see bug #650).
2020-03-05 16:09:17 +00:00
Greg Chadwick
b932a8bbf3 [rtl] Break path from data_err_o -> instr_req_o
Fixes #649
2020-03-05 10:51:25 +00:00
Rupert Swarbrick
e9872889bf Split have_instr definition out of always block in if_stage
This should cause no functional change, but avoids a seeming
combinatorial loop reported by Verilator.

The seeming loop is because the always_comb process that contained
have_instr is sensitive to if_id_pipe_reg_we but that process wrote
the have_instr signal, which is used in the continuous assignment to
if_id_pipe_reg_we later on.
2020-03-02 12:42:17 +00:00
dawidzim
fde40564a2
Tracer: Mark all functions "automatic"
By default, variables in functions are static in SystemVerilog. This caused `string desc = "";` in `get_fence_description` to be executed only once, i.e. the text was continuously extended from the last call.

Mark all functions `automatic` to get behavior as one would expect from normal functions.
2020-02-21 10:31:05 +00:00
Tobias Wölfel
7c9c7599d2 [rtl] Change misa for RV32E
Following RISC-V privileged architecture version 1.11,
the "E" bit of misa should return the complement of the "I" bit.

Set the "I" bit only if RV32E is not used.

Closes lowRISC/ibex#612.
2020-02-20 14:29:32 +00:00
Greg Chadwick
f90faa6ca3 [rtl] Alter multdiv to better match style guide
Use of case inside in always_ff block does not meet style guide
recomendations. Refactored to remove this.

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
2020-02-17 13:41:55 +00:00
ganoam
48c4b6a5ea [rtl] Add Single Cycle Multiplier targeting FPGA
* Integrate option to implement a multiplier using 3 parallel 17 bit
        multipliers in order to compute MUL instructions in 1 cycle
        MULH in 2 cycles.

* Add parameter SingleCycleMultiply to select single cycle
        multiplication.

The single cycle multiplication capability is intended for FPGA
targets. Using three parallel multiplication units improves performance
of multiplication operations at the cost of DSP primitives. For ASIC
targets, the area consumed by the multiplication structure will grow
approximately 3-4x.

The functionality is selected within the module using the parameter
`SingleCycleMultiply`. From the top level it can be chosen by setting
the parameter `MultiplierImplementation` to 'single_cc'.

Signed-off-by: ganoam <gnoam@live.com>
2020-02-11 16:09:41 +01:00
Stefan Mach
ba2240f138 Reduce latency of slow multiplier
- The slow multiplier is modified to terminate iterations early instead
  of always going the full 32 iterations for `MUL` instructions.
- Multiplications now terminate early after clog2(`op_b`) iterations.
- The slow multiplier can be further optimized by swapping the smaller
  operand into `op_b` when in the `MD_IDLE` state.
2020-02-10 18:28:14 +01:00
Greg Chadwick
24cbc32249 [rtl] Fix assertion issues
Fixes #548
2020-02-10 17:01:38 +00:00
Greg Chadwick
5d16a5b104 [rtl] Introduce default clk/reset to prim_assert
This mirrors the change made in OpenTitan
(https://github.com/lowRISC/opentitan/pull/1485)
2020-02-10 09:42:52 +00:00
Pirmin Vogel
2a42c23eaf [rtl] Decouple mip and mie CSRs
This commit modifies the `mip` CSR to not depend on the `mie` CSR. While
the values of both these CSRs are combined to decide whether an
interrupt shall be handled, the RISC-V spec does not state that the
content of of `mip` should depend on `mie`. This commit better aligns
Ibex with other open-source RISC-V cores.

This resolves lowRISC/ibex#567 reported by @pfmooney.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-02-04 16:15:38 +01:00
Pirmin Vogel
b22fca7bbe Ignore all interrupts in NMI mode, clarify interrupt documentation
This is related to lowRISC/ibex#557, lowRISC/ibex#469 and
lowRISC/ibex#434.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-01-31 13:09:09 +01:00
Greg Chadwick
3fcede8a13 [rtl] Comment and naming tweaks 2020-01-31 09:32:20 +00:00
Greg Chadwick
86c1775a64 [rtl] Timing fix for pc_mux_o in ibex_controller 2020-01-31 09:32:20 +00:00
Greg Chadwick
b52aacf91b [rtl] Add multdiv_sel signal to decode
multdiv_sel signals the mult/div operand should be selected for the ALU
inputs. Previously the mult_en/div_en signals were used but these factor
in whether the instruction is actually happening which is not relevant
for the mux select. The dedicated select signal gives better timing.
2020-01-31 09:32:20 +00:00
Greg Chadwick
486bf45711 [rtl] Replicate instruction flops to reduce fanout
Adds a second set of instruction flops that are used to determine ALU
operation and operand selection. This reduces fanout from the
instruction flops and so helps timing.
2020-01-31 09:32:20 +00:00
Greg Chadwick
639964514c [RTL] Added seperate ALU for branch target
On branches now compute target same cycle as the condition.  This
removes a stall cycle from all taken conditional branches.
2020-01-31 09:32:20 +00:00
Daniel Mlynek
9d232d1cde Include assert macros when they are used
prim_assert.sv is a file containing assertion macros (defines).
Previously, prim_assert.sv was compiled as normal SystemVerilog file.
This made the defines available for the whole compilation unit as soon
as they were defined. Since all cores using prim_assert depended (in
fusesoc) on the lowrisc:prim:assert core, prim_assert was always
compiled first, and the defines were visible in subsequent files.

All of that is only true if all files end up in one comilation unit. The
SV standard states that what makes up a compilation unit is
tool-defined, but also states that typically, passing multiple files (or
a file list/.f file) to a single tool invocation means that all files
end up in one compilation unit; if the tool is called multiple times,
then the files end up in separate compilation units.

Edalize (the fusesoc backend) doesn't guarantee either behavior, and so
it happens that for Vivado, Verilator, Cadence and Synopsys simulators,
all files are compiled into a single compilation unit. But for Riviera,
each file is a separate compilation unit.

To avoid relying on the definition of compilation units, and to do the
generally right thing (TM), this commit changes the code to always
include the prim_assert.sv file when it is used in a source file.
Include guards are introduced in the prim_assert.sv file to avoid
defining things twice.
2020-01-28 14:46:48 +00:00
ganoam
0f9e2e33e0 [rtl] Fix Typo in FPGA Register File
* Line 46: baddr_b_i > raddr_b_i.
2020-01-20 17:01:30 +00:00
ganoam
7969cb722b [rtl] Add FPGA Register File
This commit adds a register file designed to be synthesized into FPGA
synchronous-write / asynchronous-read design elements.

For the artya7-100 example, the register file is implemented by 12
RAM32M primitives, conserving approximately 600 Logic LUTs and 1000
flip-flops at the expense of 48 LUTRAMs.

Signed-off-by: ganoam <gnoam@live.com>
2020-01-14 16:21:58 +01:00
Greg Chadwick
9c6ddae626 [rtl] Don't elaborate unused mhpmcounter flops
Refactors performance counters so only flops that are required from the
given parameters are explicitly elaborated without relying on
optimization to remove unused flops.

Fixes #473
2020-01-07 10:23:12 +00:00
Pirmin Vogel
7e2283056b [rtl] Trigger C decoder assertions only if instr valid
This commit ensures that the assertions in the compressed decoder do
not fire if the compressed decoder sees invalid data from the prefetch
buffer.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2020-01-03 09:36:16 +01:00
Pirmin Vogel
e9a6295e57 [rtl] By default, forward incoming instruction in C decoder
This commit modifies the compressed decoder to forward the incoming
instruction to the output. It is marked as legal, unless:
1) the decoder cannot determine if the instruction is compressed (e.g.
   because of unknown selector bits), or
2) the instruction is compressed but
    a) it cannot be successfully decompressed (e.g. because of unknown
       selector bits), or
    b) it is indeed illegal.

In the case of 2b) the compressed decoder may output an illegal
decompressed instruction instead of the incoming instruction.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2019-12-20 10:09:09 +01:00
Pirmin Vogel
29923e6679 [rtl] Use macros for all SystemVerilog assertions
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2019-12-20 10:09:09 +01:00
Pirmin Vogel
0778008f33 [rtl] Remove X assignments, add SVAs for selector signals
This commit replaces all X assignments in the RTL with defined
values. In addition, SystemVerilog Assertions are added to catch
invalid signal values in simulation. A new file containing the
corresponding assertion macros is added as well.

Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2019-12-20 10:09:09 +01:00
Pirmin Vogel
b10039c4ef [rtl] Consistently use data_offset signal in LSU
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
2019-12-20 10:09:09 +01:00
Greg Chadwick
328aabb548 [RTL] Only restore from mstack in nmi mode
Fixes #492
2019-12-16 19:51:22 +00:00
Tom Roberts
088cd11593 [dbg] Add minimal hardware breakpoint support
- Add the minimum amount of trigger system to support GDB hbreak
- Only a single trigger is implemented
- Only instruction address matching
- Only break into debug mode (no native debug)
- Fixes #382

Signed-off-by: Tom Roberts <tomroberts@lowrisc.org>
2019-12-11 15:02:06 +00:00
Tom Roberts
0f4e802b20 [csr] Add U Mode support to misa 2019-12-04 13:28:54 +00:00