Add files using upload-large-folder tool
Browse files- snapshots/pulp-platform_common_cells_pr280/.gitlab-ci.yml +63 -0
- snapshots/pulp-platform_common_cells_pr280/Bender.yml +183 -0
- snapshots/pulp-platform_common_cells_pr280/CHANGELOG.md +533 -0
- snapshots/pulp-platform_common_cells_pr280/Makefile +9 -0
- snapshots/pulp-platform_common_cells_pr280/README.md +209 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/.gitignore +3 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/Makefile +28 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/debug_rom.S +100 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/debug_rom.h +44 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/debug_rom.sv +65 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/gen_rom.py +134 -0
- snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/link.ld +16 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dm_csrs.sv +647 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dm_mem.sv +497 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dm_pkg.sv +414 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dm_sba.sv +172 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dm_top.sv +222 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dmi_cdc.sv +73 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dmi_jtag.sv +264 -0
- snapshots/pulp-platform_riscv-dbg_pr53/src/dmi_jtag_tap.sv +349 -0
snapshots/pulp-platform_common_cells_pr280/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2023 ETH Zurich and University of Bologna.
|
| 2 |
+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
| 3 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 4 |
+
|
| 5 |
+
# Author: Nils Wistoff <nwistoff@iis.ee.ethz.ch>
|
| 6 |
+
|
| 7 |
+
variables:
|
| 8 |
+
VSIM: questa-2022.3 vsim -64
|
| 9 |
+
VLIB: questa-2022.3 vlib
|
| 10 |
+
VMAP: questa-2022.3 vmap
|
| 11 |
+
VCOM: questa-2022.3 vcom -64
|
| 12 |
+
VLOG: questa-2022.3 vlog -64
|
| 13 |
+
VOPT: questa-2022.3 vopt -64
|
| 14 |
+
|
| 15 |
+
stages:
|
| 16 |
+
- test
|
| 17 |
+
|
| 18 |
+
.test-tpl:
|
| 19 |
+
stage: test
|
| 20 |
+
needs:
|
| 21 |
+
variables:
|
| 22 |
+
TOPLEVEL: ""
|
| 23 |
+
PARAM1: ""
|
| 24 |
+
PARAM2: ""
|
| 25 |
+
timeout: 10min
|
| 26 |
+
script:
|
| 27 |
+
- bender checkout
|
| 28 |
+
- bender script vsim -t test > compile.tcl
|
| 29 |
+
- $VSIM -c -quiet -do 'source compile.tcl; quit'
|
| 30 |
+
- $VSIM -c $TOPLEVEL -voptargs="-timescale 1ns/100ps" -do "run -all" $PARAM1 $PARAM2
|
| 31 |
+
- (! grep -n "Error:" transcript)
|
| 32 |
+
|
| 33 |
+
tests:
|
| 34 |
+
extends: .test-tpl
|
| 35 |
+
parallel:
|
| 36 |
+
matrix:
|
| 37 |
+
- TOPLEVEL:
|
| 38 |
+
- addr_decode_tb
|
| 39 |
+
- cb_filter_tb
|
| 40 |
+
# - cdc_fifo_clearable_tb
|
| 41 |
+
- clk_int_div_tb
|
| 42 |
+
- clk_int_div_static_tb
|
| 43 |
+
- clk_mux_glitch_free_tb
|
| 44 |
+
- id_queue_tb
|
| 45 |
+
- isochronous_crossing_tb
|
| 46 |
+
- passthrough_stream_fifo_tb
|
| 47 |
+
- popcount_tb
|
| 48 |
+
- rr_arb_tree_tb
|
| 49 |
+
- stream_omega_net_tb
|
| 50 |
+
- stream_register_tb
|
| 51 |
+
- stream_to_mem_tb
|
| 52 |
+
- stream_xbar_tb
|
| 53 |
+
- sub_per_hash_tb
|
| 54 |
+
- lossy_valid_to_stream_tb
|
| 55 |
+
- TOPLEVEL: graycode_tb
|
| 56 |
+
PARAM1: [-GN=1, -GN=2, -GN=3, -GN=4, -GN=8, -GN=16]
|
| 57 |
+
- TOPLEVEL: fifo_tb
|
| 58 |
+
PARAM1: [-GDEPTH=1, -GDEPTH=13, -GDEPTH=32 -GFALL_THROUGH=1]
|
| 59 |
+
# - TOPLEVEL: [cdc_2phase_tb, cdc_2phase_clearable_tb]
|
| 60 |
+
# PARAM1: -GUNTIL=1000000
|
| 61 |
+
# - TOPLEVEL: cdc_fifo_tb
|
| 62 |
+
# PARAM1: [-GDEPTH=1, -GDEPTH=2, -GDEPTH=3, -GDEPTH=4, -GDEPTH=5]
|
| 63 |
+
# PARAM2: [-GGRAY=0, -GGRAY=1]
|
snapshots/pulp-platform_common_cells_pr280/Bender.yml
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ch>"
|
| 5 |
+
- "Fabian Schuiki <fschuiki@iis.ee.ethz.ch>"
|
| 6 |
+
- "Michael Schaffner <schaffner@iis.ee.ethz.ch>"
|
| 7 |
+
- "Andreas Kurth <akurth@iis.ee.ethz.ch>"
|
| 8 |
+
- "Manuel Eggimann <meggimann@iis.ee.ethz.ch>"
|
| 9 |
+
- "Stefan Mach <smach@iis.ee.ethz.ch>"
|
| 10 |
+
- "Wolfgang Roenninger <wroennin@student.ethz.ch>"
|
| 11 |
+
- "Thomas Benz <tbenz@iis.ee.ethz.ch>"
|
| 12 |
+
|
| 13 |
+
dependencies:
|
| 14 |
+
common_verification: { git: "https://github.com/pulp-platform/common_verification.git", version: 0.2.0 }
|
| 15 |
+
tech_cells_generic: { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.2.11 }
|
| 16 |
+
|
| 17 |
+
export_include_dirs:
|
| 18 |
+
- include
|
| 19 |
+
|
| 20 |
+
sources:
|
| 21 |
+
# Source files grouped in levels. Files in level 0 have no dependencies on files in this package.
|
| 22 |
+
# Files in level 1 only depend on files in level 0, files in level 2 on files in levels 1 and 0,
|
| 23 |
+
# etc. Files within a level are ordered alphabetically.
|
| 24 |
+
|
| 25 |
+
# Level 0
|
| 26 |
+
- src/binary_to_gray.sv
|
| 27 |
+
|
| 28 |
+
- target: not(all(xilinx,vivado_ipx))
|
| 29 |
+
files:
|
| 30 |
+
- src/cb_filter_pkg.sv
|
| 31 |
+
- src/cc_onehot.sv
|
| 32 |
+
- src/cdc_reset_ctrlr_pkg.sv
|
| 33 |
+
- src/cf_math_pkg.sv
|
| 34 |
+
- src/clk_int_div.sv
|
| 35 |
+
- src/credit_counter.sv
|
| 36 |
+
- src/delta_counter.sv
|
| 37 |
+
- src/ecc_pkg.sv
|
| 38 |
+
- src/edge_propagator_tx.sv
|
| 39 |
+
- src/exp_backoff.sv
|
| 40 |
+
- src/fifo_v3.sv
|
| 41 |
+
- src/gray_to_binary.sv
|
| 42 |
+
- src/heaviside.sv
|
| 43 |
+
- src/isochronous_4phase_handshake.sv
|
| 44 |
+
- src/isochronous_spill_register.sv
|
| 45 |
+
- src/lfsr.sv
|
| 46 |
+
- src/lfsr_16bit.sv
|
| 47 |
+
- src/lfsr_8bit.sv
|
| 48 |
+
- src/lossy_valid_to_stream.sv
|
| 49 |
+
- src/mv_filter.sv
|
| 50 |
+
- src/onehot_to_bin.sv
|
| 51 |
+
- src/plru_tree.sv
|
| 52 |
+
- src/passthrough_stream_fifo.sv
|
| 53 |
+
- src/popcount.sv
|
| 54 |
+
- src/ring_buffer.sv
|
| 55 |
+
- src/rr_arb_tree.sv
|
| 56 |
+
- src/rstgen_bypass.sv
|
| 57 |
+
- src/serial_deglitch.sv
|
| 58 |
+
- src/shift_reg.sv
|
| 59 |
+
- src/shift_reg_gated.sv
|
| 60 |
+
- src/spill_register_flushable.sv
|
| 61 |
+
- src/stream_demux.sv
|
| 62 |
+
- src/stream_filter.sv
|
| 63 |
+
- src/stream_fork.sv
|
| 64 |
+
- src/stream_intf.sv
|
| 65 |
+
- src/stream_join_dynamic.sv
|
| 66 |
+
- src/stream_mux.sv
|
| 67 |
+
- src/stream_throttle.sv
|
| 68 |
+
- src/sub_per_hash.sv
|
| 69 |
+
- src/sync.sv
|
| 70 |
+
- src/sync_wedge.sv
|
| 71 |
+
- src/unread.sv
|
| 72 |
+
- src/read.sv
|
| 73 |
+
# Level 1
|
| 74 |
+
- src/addr_decode_dync.sv
|
| 75 |
+
- src/boxcar.sv
|
| 76 |
+
- src/cdc_2phase.sv
|
| 77 |
+
- src/cdc_4phase.sv
|
| 78 |
+
- src/clk_int_div_static.sv
|
| 79 |
+
- src/trip_counter.sv
|
| 80 |
+
# Level 2
|
| 81 |
+
- src/addr_decode.sv
|
| 82 |
+
- src/addr_decode_napot.sv
|
| 83 |
+
- src/multiaddr_decode.sv
|
| 84 |
+
- target: not(all(xilinx,vivado_ipx))
|
| 85 |
+
files:
|
| 86 |
+
- src/cb_filter.sv
|
| 87 |
+
- src/cdc_fifo_2phase.sv
|
| 88 |
+
- src/clk_mux_glitch_free.sv
|
| 89 |
+
- src/counter.sv
|
| 90 |
+
- src/ecc_decode.sv
|
| 91 |
+
- src/ecc_encode.sv
|
| 92 |
+
- src/edge_detect.sv
|
| 93 |
+
- src/lzc.sv
|
| 94 |
+
- src/max_counter.sv
|
| 95 |
+
- src/rstgen.sv
|
| 96 |
+
- src/spill_register.sv
|
| 97 |
+
- src/stream_delay.sv
|
| 98 |
+
- src/stream_fifo.sv
|
| 99 |
+
- src/stream_fork_dynamic.sv
|
| 100 |
+
- src/stream_join.sv
|
| 101 |
+
# Level 2
|
| 102 |
+
- src/cdc_reset_ctrlr.sv
|
| 103 |
+
- src/cdc_fifo_gray.sv
|
| 104 |
+
- src/fall_through_register.sv
|
| 105 |
+
- src/id_queue.sv
|
| 106 |
+
- src/stream_to_mem.sv
|
| 107 |
+
- src/stream_arbiter_flushable.sv
|
| 108 |
+
- src/stream_fifo_optimal_wrap.sv
|
| 109 |
+
- src/stream_register.sv
|
| 110 |
+
- src/stream_xbar.sv
|
| 111 |
+
# Level 3
|
| 112 |
+
- src/cdc_fifo_gray_clearable.sv
|
| 113 |
+
- src/cdc_2phase_clearable.sv
|
| 114 |
+
- src/mem_to_banks_detailed.sv
|
| 115 |
+
- src/stream_arbiter.sv
|
| 116 |
+
- src/stream_omega_net.sv
|
| 117 |
+
# Level 4
|
| 118 |
+
- src/mem_to_banks.sv
|
| 119 |
+
|
| 120 |
+
- target: all(simulation, not(verilator))
|
| 121 |
+
files:
|
| 122 |
+
- src/deprecated/sram.sv
|
| 123 |
+
|
| 124 |
+
- target: test
|
| 125 |
+
files:
|
| 126 |
+
# Level 0
|
| 127 |
+
- test/addr_decode_tb.sv
|
| 128 |
+
- test/cb_filter_tb.sv
|
| 129 |
+
- test/cdc_2phase_tb.sv
|
| 130 |
+
- test/cdc_2phase_clearable_tb.sv
|
| 131 |
+
- test/cdc_fifo_tb.sv
|
| 132 |
+
- test/cdc_fifo_clearable_tb.sv
|
| 133 |
+
- test/fifo_tb.sv
|
| 134 |
+
- test/graycode_tb.sv
|
| 135 |
+
- test/id_queue_tb.sv
|
| 136 |
+
- test/passthrough_stream_fifo_tb.sv
|
| 137 |
+
- test/popcount_tb.sv
|
| 138 |
+
- test/rr_arb_tree_tb.sv
|
| 139 |
+
- test/stream_test.sv
|
| 140 |
+
- test/stream_register_tb.sv
|
| 141 |
+
- test/stream_to_mem_tb.sv
|
| 142 |
+
- test/sub_per_hash_tb.sv
|
| 143 |
+
# Level 1
|
| 144 |
+
- test/isochronous_crossing_tb.sv
|
| 145 |
+
- test/stream_omega_net_tb.sv
|
| 146 |
+
- test/stream_xbar_tb.sv
|
| 147 |
+
- test/clk_int_div_tb.sv
|
| 148 |
+
- test/clk_int_div_static_tb.sv
|
| 149 |
+
- test/clk_mux_glitch_free_tb.sv
|
| 150 |
+
- test/lossy_valid_to_stream_tb.sv
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
- target: synth_test
|
| 154 |
+
files:
|
| 155 |
+
# Level 0
|
| 156 |
+
- test/cdc_2phase_synth.sv
|
| 157 |
+
- test/id_queue_synth.sv
|
| 158 |
+
- test/stream_arbiter_synth.sv
|
| 159 |
+
- test/ecc_synth.sv
|
| 160 |
+
# Level 1
|
| 161 |
+
- test/synth_bench.sv
|
| 162 |
+
|
| 163 |
+
# Deprecated modules
|
| 164 |
+
# Level 0
|
| 165 |
+
- src/deprecated/clock_divider_counter.sv
|
| 166 |
+
- src/deprecated/clk_div.sv
|
| 167 |
+
- src/deprecated/find_first_one.sv
|
| 168 |
+
- src/deprecated/generic_LFSR_8bit.sv
|
| 169 |
+
- src/deprecated/generic_fifo.sv
|
| 170 |
+
- src/deprecated/prioarbiter.sv
|
| 171 |
+
- src/deprecated/pulp_sync.sv
|
| 172 |
+
- src/deprecated/pulp_sync_wedge.sv
|
| 173 |
+
- src/deprecated/rrarbiter.sv
|
| 174 |
+
# Level 1
|
| 175 |
+
- src/deprecated/clock_divider.sv
|
| 176 |
+
- src/deprecated/fifo_v2.sv
|
| 177 |
+
# Level 2
|
| 178 |
+
- src/deprecated/fifo_v1.sv
|
| 179 |
+
|
| 180 |
+
# Depend on deprecated modules
|
| 181 |
+
- src/edge_propagator_ack.sv
|
| 182 |
+
- src/edge_propagator.sv
|
| 183 |
+
- src/edge_propagator_rx.sv
|
snapshots/pulp-platform_common_cells_pr280/CHANGELOG.md
ADDED
|
@@ -0,0 +1,533 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
All notable changes to this project will be documented in this file.
|
| 3 |
+
|
| 4 |
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
| 5 |
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
| 6 |
+
|
| 7 |
+
## 1.39.0 - 2025-11-20
|
| 8 |
+
### Added
|
| 9 |
+
- `boxcar`: Add boxcar function to compose bit masks
|
| 10 |
+
- `heaviside`: Add Heaviside function to compose bit masks
|
| 11 |
+
- `ring_buffer`: Add ring buffer with sequential write and random reads
|
| 12 |
+
- `trip_counter`: Add counter with 'trip' output when reaching threshold value
|
| 13 |
+
|
| 14 |
+
### Changed
|
| 15 |
+
- `cb_filter`, `id_queue`, `lzc`, `rr_arb_tree`: Speed up Verilator simulation
|
| 16 |
+
- `cdc_fifo_gray*`, `isochronous_spill_register`: Change flip-flops without to flip-flops with reset
|
| 17 |
+
- `isochronous_spill_register`: Remove unnecessary data stability assertions
|
| 18 |
+
- `addr_decode*`: Change assumed integer index to arbitrary type (default remains integer)
|
| 19 |
+
|
| 20 |
+
### Fixed
|
| 21 |
+
- `id_queue`: Fix struct access
|
| 22 |
+
- `cdc_fifo_gray*`: Fix Spyglass linting edge case
|
| 23 |
+
- `lzc`: Fix assertion for degenerate case `WIDTH == 0`
|
| 24 |
+
- Fix Verilator compilation by adding guard statements
|
| 25 |
+
|
| 26 |
+
## 1.38.0 - 2025-02-28
|
| 27 |
+
### Changed
|
| 28 |
+
- Assertions no longer disabled for Verilator. Define `ASSERTS_OFF` to disable.
|
| 29 |
+
- Define `ASSERTS_OVERRIDE_ON` to override any defines that turn assertions off otherwise.
|
| 30 |
+
- `id_queue`: Parametrize number of compare ports.
|
| 31 |
+
- `assertions.svh`: Add optional argument to assertion macros to display custom error message.
|
| 32 |
+
- `stream_to_mem`: Disable assertions during reset.
|
| 33 |
+
- `addr_decode_dync`, `cdc_fifo_gray_clearable`, `multiaddr_decode`, `spill_register_flushable`: Promote `$warning` to `$error`.
|
| 34 |
+
- `rr_arb_tree`, `stream_omega_net`, `stream_xbar`: Remove default assertion disable.
|
| 35 |
+
|
| 36 |
+
### Fixed
|
| 37 |
+
- `delta_counter`: Fix inverted reset.
|
| 38 |
+
- `stream_join_dynamic`: Handshake only selected streams.
|
| 39 |
+
- Various tool compatibility improvements.
|
| 40 |
+
|
| 41 |
+
## 1.37.0 - 2024-07-18
|
| 42 |
+
### Added
|
| 43 |
+
- `credit_counter`: Add up/down counter for credit.
|
| 44 |
+
|
| 45 |
+
### Fixed
|
| 46 |
+
- `mem_to_banks_detailed`: Ensure no spurious response after full dead write.
|
| 47 |
+
|
| 48 |
+
## 1.36.0 - 2024-07-08
|
| 49 |
+
### Fixed
|
| 50 |
+
- `registers`: Fix else statement in FFARNC macro.
|
| 51 |
+
- `stream_arbiter_flushable`: Do not lock priority arbiter.
|
| 52 |
+
|
| 53 |
+
## 1.35.0 - 2024-04-22
|
| 54 |
+
### Changed
|
| 55 |
+
- `id_queue`: Add parameter to cut a critical path.
|
| 56 |
+
|
| 57 |
+
## 1.34.0 - 2024-04-09
|
| 58 |
+
### Changed
|
| 59 |
+
- `stream_xbar`: Add payload assertion stability mask.
|
| 60 |
+
|
| 61 |
+
## 1.33.1 - 2024-03-16
|
| 62 |
+
### Fixed
|
| 63 |
+
- `stream_omega_net`: Fix assertion.
|
| 64 |
+
- Revert gitlab-ci trigger condition to `pull_request`.
|
| 65 |
+
|
| 66 |
+
## 1.33.0 - 2024-03-07
|
| 67 |
+
### Added
|
| 68 |
+
- Add `passthrough_stream_fifo`: Stream FIFO which does not cut the timing path, this allows it to do a simultaneous push and pop when full.
|
| 69 |
+
- Registers: Add FFARNC macro: Flip-Flop with asynchronous active-low reset and synchronous clear.
|
| 70 |
+
|
| 71 |
+
### Changed
|
| 72 |
+
- Enable assertions in verilator.
|
| 73 |
+
- Change `pragma translate_off` statements to ```ifndef SYNTHESIS`` according to IEEE 1364.1-2005 spec 6.3.2.
|
| 74 |
+
- `plru_tree`: Add assertion that output is onehot.
|
| 75 |
+
- Update CI trigger condition.
|
| 76 |
+
|
| 77 |
+
### Fixed
|
| 78 |
+
- `onehot_to_bin`: Fix width mismatch in assignment.
|
| 79 |
+
- `plru_tree`: Improve tool compatibility.
|
| 80 |
+
- `stream_xbar`: Fix masked assertion.
|
| 81 |
+
|
| 82 |
+
## 1.32.0 - 2023-09-26
|
| 83 |
+
### Added
|
| 84 |
+
- Add `stream_join_dynamic`: `stream_join` with a dynamically configurable subset selection.
|
| 85 |
+
- Add `multiaddr_decode`: Address map decoder using NAPOT regions and allowing for multiple address inputs.
|
| 86 |
+
- Add `addr_decode_dync`: `addr_decode` with support for dynamic online configuration.
|
| 87 |
+
|
| 88 |
+
### Changed
|
| 89 |
+
- `mem_to_banks`: Change default value for `NumBanks` from `0` to `1` to avoid division by zero.
|
| 90 |
+
|
| 91 |
+
## 1.31.1 - 2023-08-09
|
| 92 |
+
### Fixed
|
| 93 |
+
- `mem_to_banks`: Keep defaut values for localparams
|
| 94 |
+
|
| 95 |
+
## 1.31.0 - 2023-08-08
|
| 96 |
+
### Added
|
| 97 |
+
- Add `mem_to_banks_detailed`: `mem_to_banks` with detailed response signals
|
| 98 |
+
|
| 99 |
+
### Fixed
|
| 100 |
+
- `unread`: Add dummy signal assignment when targeting Vivado to avoid blackbox inference
|
| 101 |
+
|
| 102 |
+
## 1.30.0 - 2023-06-09
|
| 103 |
+
### Added
|
| 104 |
+
- Add `lossy_valid_to_stream`: A converter between valid-only protocols and ready-valid where the latest transaction overwrites the most recently queue one.
|
| 105 |
+
- Add `clk_int_div_static`: A wrapper for `clk_int_div` for static clock division.
|
| 106 |
+
|
| 107 |
+
### Changed
|
| 108 |
+
- `popcount`: Refactor and support all input widths.
|
| 109 |
+
- `clk_int_div`: Support clock output during reset.
|
| 110 |
+
- `stream_delay`: Support larger counts.
|
| 111 |
+
|
| 112 |
+
### Fixed
|
| 113 |
+
- `clk_int_div`: Fix possible deadlock and avoid hold issues.
|
| 114 |
+
|
| 115 |
+
## 1.29.0 - 2023-04-14
|
| 116 |
+
### Added
|
| 117 |
+
- Add `shift_reg_gated`: Shift register with ICG for arbitrary types.
|
| 118 |
+
|
| 119 |
+
### Changed
|
| 120 |
+
- CI: Run testbenches in `test/` on internal gitlab mirror.
|
| 121 |
+
- `fifo_tb`: Add test for DEPTH not power of two.
|
| 122 |
+
|
| 123 |
+
### Fixed
|
| 124 |
+
- `clk_int_div`: Allow configuration while clock is disabled.
|
| 125 |
+
- `mem_to_banks`: Cut possible timing loop for HideStrb feature.
|
| 126 |
+
- Improved tool compatibility (Verilator, Questasim, Synopsys).
|
| 127 |
+
|
| 128 |
+
## 1.28.0 - 2022-12-15
|
| 129 |
+
### Added
|
| 130 |
+
- Add `clk_mux_glitch_free`: A glitch-free clock multiplexer.
|
| 131 |
+
|
| 132 |
+
## 1.27.1 - 2022-12-06
|
| 133 |
+
### Fixed
|
| 134 |
+
- `fall_through_register`: Remove superfluous `$size()` call for tool compatibility
|
| 135 |
+
|
| 136 |
+
## 1.27.0 - 2022-12-01
|
| 137 |
+
### Added
|
| 138 |
+
- Add `mem_to_banks`: split memory access over multiple parallel banks. Moved from the `AXI4+ATOP`
|
| 139 |
+
[`axi_to_mem`](https://github.com/pulp-platform/axi/blob/2f395b176bee1c769c80f060a4345fda965bb04b/src/axi_to_mem.sv#L563) module.
|
| 140 |
+
- Add `read`: dummy module that prevents a signal from being removed during synthesis
|
| 141 |
+
|
| 142 |
+
### Changed
|
| 143 |
+
- `stream_fifo_optimal_wrap`: Remove asserts
|
| 144 |
+
- `fall_through_register`: Update fifo to `fifo_v3`
|
| 145 |
+
|
| 146 |
+
### Fixed
|
| 147 |
+
- FuseSoC: Add `assertions.svh`
|
| 148 |
+
|
| 149 |
+
## 1.26.0 - 2022-08-26
|
| 150 |
+
### Added
|
| 151 |
+
- Add `stream_throttle`: restricts the number of outstanding transfers in a stream.
|
| 152 |
+
|
| 153 |
+
### Changed
|
| 154 |
+
- Allow out-of-bounds (i.e. `'0`) top end address in addr_map of `addr_decode` module for end of address space.
|
| 155 |
+
- Update CI.
|
| 156 |
+
|
| 157 |
+
## 1.25.0 - 2022-08-10
|
| 158 |
+
### Added
|
| 159 |
+
- Add `addr_decode_napot`: variant of `addr_decode` which uses a base address and mask instead of a start and end address.
|
| 160 |
+
- Add `stream_fifo_optimal_wrap`: instantiates a more optimal `spill_register` instead of a `stream_fifo` for `depth == 2`.
|
| 161 |
+
|
| 162 |
+
### Changed
|
| 163 |
+
- Make `stream_register` truly stream by replacing internal FIFO with FFs.
|
| 164 |
+
- Avoid using `$bits()` call in `id_queue`'s parameters.
|
| 165 |
+
- Remove `cb_filter` and `cb_filter_pkg` from from Vivado IP packager project sources due to compatibility issues.
|
| 166 |
+
- Use `tc_clk_mux` as glitch-free muxes in `rstgen_bypass` to avoid combinational glitches.
|
| 167 |
+
- Avoid program blocks in testbenches for simulator compatibility.
|
| 168 |
+
|
| 169 |
+
### Fixed
|
| 170 |
+
- Update `src_files.yml` and `common_cells.core`
|
| 171 |
+
|
| 172 |
+
## 1.24.1 - 2022-04-13
|
| 173 |
+
### Fixed
|
| 174 |
+
- Fix typos in `Bender.yml` and `src_files.yml`
|
| 175 |
+
|
| 176 |
+
## 1.24.0 - 2022-03-31
|
| 177 |
+
### Added
|
| 178 |
+
- Add `edge_propagator_ack`: Edge/pulse propagator with sender-synchronous receive-acknowledge
|
| 179 |
+
output. `edge_propagator` is now implemented by instantiating `edge_propagator_ack`.
|
| 180 |
+
- Add `4phase_cdc`: A 4 phase handshaking CDC that allows glitch-free resetting (used internally in the new clearable CDC IPs).
|
| 181 |
+
- Add one-sided clearable and/or async resettable flavors of 2phase CDC (`cdc_2phase_clearable`) and gray-counting FIFO CDCs (`cdc_fifo_gray_clearable`).
|
| 182 |
+
- Add reset CDC controller `cdc_reset_ctrl` that supports reset/synchronous clear sequencing across clock domain crossings (used internally in clearable CDC IPs).
|
| 183 |
+
- Add `clk_int_div` arbitrary integer clock divider with *at-runtime*
|
| 184 |
+
configurable divider selection and glitch-free, 50%duty cycle output clock.
|
| 185 |
+
- Add an assertion to the `lzc` to verify parameters.
|
| 186 |
+
|
| 187 |
+
### Fixed
|
| 188 |
+
- Correct reset polarity in assertions in `isochronous_4phase_handshake` and `isochronous_spill_register`
|
| 189 |
+
- Fix compatibility of `sub_per_hash` constructs with Verilator
|
| 190 |
+
|
| 191 |
+
### Changed
|
| 192 |
+
- Add `dont_touch` and `async_reg` attribute to FFs in `sync` cell.
|
| 193 |
+
- Improved reset behavior documentation (in module header) of existing CDC IPs.
|
| 194 |
+
- Deprecated flawed `clk_div` module and add elaboration warning message that
|
| 195 |
+
will be shown for existing designs (can be disabled with optional
|
| 196 |
+
instantiation parameter).
|
| 197 |
+
- Add optional `Seed` parameter to `stream_delay` module
|
| 198 |
+
- Update `tech_cells_generic` to `0.2.9`
|
| 199 |
+
|
| 200 |
+
## 1.23.0 - 2021-09-05
|
| 201 |
+
### Added
|
| 202 |
+
- Add `cc_onehot`
|
| 203 |
+
- `isochronous_4phase_handshake`: Isochronous clock domain crossing cutting all paths using a 4-phase handshake.
|
| 204 |
+
- Changed `isochronous_spill_register_tb` to `isochronous_crossing_tb` also covering the `isochronous_4phase_handshake`
|
| 205 |
+
module.
|
| 206 |
+
- Make reset value of `sync` module parameterizable.
|
| 207 |
+
|
| 208 |
+
### Changed
|
| 209 |
+
- `id_queue`: Allow simultaneous input and output requests in `FULL_BW` mode
|
| 210 |
+
|
| 211 |
+
## 1.22.1 - 2021-06-14
|
| 212 |
+
### Fixed
|
| 213 |
+
- Remove breaking change of `spill_register`
|
| 214 |
+
|
| 215 |
+
## 1.22.0 - 2021-06-09
|
| 216 |
+
### Added
|
| 217 |
+
- Add `spill_register_flushable`
|
| 218 |
+
|
| 219 |
+
### Changed
|
| 220 |
+
- `registers.svh`: Merge explicit and implicit register variants into `` `FF `` and `` `FFL `` macros
|
| 221 |
+
- `rr_arb_tree`: Allow flushing locked decision
|
| 222 |
+
- Improved `verific` compatibility
|
| 223 |
+
|
| 224 |
+
## 1.21.0 - 2021-01-28
|
| 225 |
+
### Changed
|
| 226 |
+
- Remove `timeprecision/timeunit` arguments
|
| 227 |
+
- Update `common_verification` to `0.2.0`
|
| 228 |
+
- Update `tech_cells_generic` to `0.2.3`
|
| 229 |
+
|
| 230 |
+
## 1.20.1 - 2021-01-21
|
| 231 |
+
### Changed
|
| 232 |
+
- `id_queue`: Replace default or reset value of signals that were assigned `'x` with `'0`.
|
| 233 |
+
- `id_queue`: Use `cf_math_pkg::idx_width()` for computation of localparams.
|
| 234 |
+
|
| 235 |
+
### Fixed
|
| 236 |
+
- Add `XSIM` define guard for statements incompatible with `xsim`.
|
| 237 |
+
|
| 238 |
+
## 1.20.0 - 2020-11-04
|
| 239 |
+
### Added
|
| 240 |
+
- assertions: Assertion include header with macros (from lowrisc)
|
| 241 |
+
|
| 242 |
+
### Changed
|
| 243 |
+
- `sram.sv`: Deprecated as it has been moved to `tech_cells_generic`
|
| 244 |
+
|
| 245 |
+
### Fixed
|
| 246 |
+
- `stream_register`: Fix `DATA_WIDTH` of instantiated FIFO.
|
| 247 |
+
- `stream_xbar`: Add missing argument in assertion error string.
|
| 248 |
+
- Lint style fixes
|
| 249 |
+
- `stream_omega`: Fix parse issue with verible.
|
| 250 |
+
- `src_files.yml`: Fix compile order and missing modules.
|
| 251 |
+
|
| 252 |
+
## 1.19.0 - 2020-05-25
|
| 253 |
+
### Added
|
| 254 |
+
- stream_to_mem: Allows to use memories with flow control (req/gnt) for requests but
|
| 255 |
+
without flow control for output data to be used in streams.
|
| 256 |
+
- isochronous_spill_register: Isochronous clock domain crossing cutting all paths.
|
| 257 |
+
- `rr_arb_tree_tb`: Systemverilog testbench for `rr_arb_tree`, which checks for fair throughput.
|
| 258 |
+
- `cf_math_pkg::idx_width`: Constant function for defining the binary representation width
|
| 259 |
+
of an index signal.
|
| 260 |
+
|
| 261 |
+
### Changed
|
| 262 |
+
- `addr_decode`: Use `cf_math_pkg::idx_width` for computing the index width, inline documentation.
|
| 263 |
+
- `lzc`: Use `cf_math_pkg::idx_width` for computing the index width, inline documentation.
|
| 264 |
+
- `Bender`: Change levels of modules affected by depending on `cf_math_pkg::idx_width()`.
|
| 265 |
+
- `stream_xbar`: Fully connected stream bassed interconnect with variable number of inputs and outputs.
|
| 266 |
+
- `stream_xbar`: Fully connected stream-bassed interconnect with a variable number of inputs and outputs.
|
| 267 |
+
- `stream_omega_net`: Stream-based network implementing an omega topology. Variable number of inputs,
|
| 268 |
+
outputs and radix. Topology is isomorphic to a butterfly network.
|
| 269 |
+
|
| 270 |
+
### Fixed
|
| 271 |
+
- Improve tool compatibility.
|
| 272 |
+
- `rr_arb_tree`: Properly degenerate `rr_i` and `idx_o` signals.
|
| 273 |
+
- `rr_arb_tree`: Add parameter `FairArb` to distribute throughput of input requests evenly when
|
| 274 |
+
not all inputs have requests active.
|
| 275 |
+
- `stream_demux`: Properly degenerate `inp_sel_i` signal.
|
| 276 |
+
|
| 277 |
+
## 1.18.0 - 2020-04-15
|
| 278 |
+
### Added
|
| 279 |
+
- stream_fork_dynamic: Wrapper around `stream_fork` for partial forking.
|
| 280 |
+
- stream_join: Join multiple Ready/Valid handshakes to one common handshake.
|
| 281 |
+
- SECDED (Single Error Correction, Double Error Detection) encoder and decoder
|
| 282 |
+
- SECDED Verilator-based testbench
|
| 283 |
+
- Travis build for SECDED module
|
| 284 |
+
|
| 285 |
+
## 1.17.0 - 2020-04-09
|
| 286 |
+
### Added
|
| 287 |
+
- stream_fifo: Ready/Valid handshake wrapper around `fifo_v3`
|
| 288 |
+
|
| 289 |
+
## 1.16.4 - 2020-03-02
|
| 290 |
+
### Fixed
|
| 291 |
+
- id_queue: Fix generation of `head_tail_q` registers
|
| 292 |
+
|
| 293 |
+
## 1.16.3 - 2020-02-11
|
| 294 |
+
### Fixed
|
| 295 |
+
- Handle degenerated `addr_decode` with `NoIndices == 1`, change default parameters to `32'd0`
|
| 296 |
+
|
| 297 |
+
## 1.16.2 - 2020-02-04
|
| 298 |
+
### Fixed
|
| 299 |
+
- Fix author section in Bender.yml
|
| 300 |
+
|
| 301 |
+
## 1.16.1 - 2020-02-03
|
| 302 |
+
### Fixed
|
| 303 |
+
- `rr_arb_tree`: Add guard SVA statement for Verilator
|
| 304 |
+
- Added missing sources in `Bender.yml` and `src_files.yml`
|
| 305 |
+
|
| 306 |
+
## 1.16.0 - 2020-01-13
|
| 307 |
+
### Fixed
|
| 308 |
+
- Handle degenerated `onehot_to_bin` with `ONEHOT_WIDTH == 1`
|
| 309 |
+
- Handle degenerated `id_queue` with `CAPACITY == 1` or `HT_CAPACITY == 1`
|
| 310 |
+
- Fix `cdc_fifo_gray` to be a safe clock domain crossing (CDC)
|
| 311 |
+
|
| 312 |
+
## 1.15.0 - 2019-12-09
|
| 313 |
+
### Added
|
| 314 |
+
- Added address map decoder module
|
| 315 |
+
|
| 316 |
+
### Fixed
|
| 317 |
+
- Handle degenerated `lzc` with `WIDTH == 1`
|
| 318 |
+
|
| 319 |
+
## 1.14.0 - 2019-10-08
|
| 320 |
+
|
| 321 |
+
### Added
|
| 322 |
+
- Added spubstitution-permutation hash function module
|
| 323 |
+
- Added couning-bloom-filter module
|
| 324 |
+
- `spill_register`: Added Bypass parameter
|
| 325 |
+
- `counter`: Added sticky overflow
|
| 326 |
+
- Added counter with variable delta
|
| 327 |
+
- Added counter that tracks its maximum value
|
| 328 |
+
|
| 329 |
+
### Changed
|
| 330 |
+
- Added formal testbench for `fifo` and `fall_through_regsiter`
|
| 331 |
+
|
| 332 |
+
## 1.13.1 - 2019-06-01
|
| 333 |
+
|
| 334 |
+
### Changed
|
| 335 |
+
|
| 336 |
+
- Fix path in `src_files.yml` for `stream_arbiter` and `stream_arbiter_flushable`
|
| 337 |
+
|
| 338 |
+
## 1.13.0 - 2019-05-29
|
| 339 |
+
|
| 340 |
+
### Added
|
| 341 |
+
|
| 342 |
+
- Added exponential backoff window module
|
| 343 |
+
- Added parametric Galois LFSR module with optional whitening feature
|
| 344 |
+
- Added `cf_math_pkg`: Constant Function implementations of mathematical functions for HDL elaboration
|
| 345 |
+
|
| 346 |
+
### Changed
|
| 347 |
+
- Parametric payload data type for `rr_arb_tree`
|
| 348 |
+
|
| 349 |
+
### Deprecated
|
| 350 |
+
- The following arbiter implementations are deprecated and superseded by `rr_arb_tree`:
|
| 351 |
+
- Priority arbiter `prioarbiter`
|
| 352 |
+
- Round-robin arbiter `rrarbiter`
|
| 353 |
+
|
| 354 |
+
### Fixed
|
| 355 |
+
|
| 356 |
+
## 1.12.0 - 2019-04-09
|
| 357 |
+
|
| 358 |
+
### Added
|
| 359 |
+
- Add priority arbiter
|
| 360 |
+
- Add Pseudo Least Recently Used tree
|
| 361 |
+
- Add round robin arbiter mux tree
|
| 362 |
+
|
| 363 |
+
### Changed
|
| 364 |
+
- Add selectable arbiter implementation for `stream_arbiter` and `stream_arbiter_flushable`. One can choose between priority (`prio`) and round-robin arbitration (`rr`).
|
| 365 |
+
- Add `$onehot0` assertion in one-hot to bin
|
| 366 |
+
- Rework `rrarbiter` unit (uses `rr_arb_tree` implementation underneath)
|
| 367 |
+
|
| 368 |
+
## 1.11.0 - 2019-03-20
|
| 369 |
+
|
| 370 |
+
### Added
|
| 371 |
+
- Add stream fork
|
| 372 |
+
- Add fall-through register
|
| 373 |
+
- Add stream filter
|
| 374 |
+
- Add ID queue
|
| 375 |
+
|
| 376 |
+
### Changed
|
| 377 |
+
- `sync_wedge` use existing synchronizer. This defines a single place where a tech-specific synchronizer can be defined.
|
| 378 |
+
|
| 379 |
+
### Fixed
|
| 380 |
+
- Fix FIFO push and pop signals in `stream_register` to observe interface prerequisites.
|
| 381 |
+
- In `fifo_v3`, fix data output when pushing into empty fall-through FIFO. Previously, the data
|
| 382 |
+
output of an empty fall-through FIFO with data at its input (and `push_i=1`) depended on
|
| 383 |
+
`pop_i`: When `pop_i=0`, old, invalid data were visible at the output (even though `empty_o=0`,
|
| 384 |
+
indicating that the data output is valid). Only when `pop_i=1`, the data from the input fell
|
| 385 |
+
through. One consequence of this bug was that `data_o` of the `fall_through_register` could change
|
| 386 |
+
while `valid_o=1`, violating the basic stream specification.
|
| 387 |
+
|
| 388 |
+
## 1.10.0 - 2018-12-18
|
| 389 |
+
|
| 390 |
+
### Added
|
| 391 |
+
- Add `fifo_v3` with generic fill count
|
| 392 |
+
- Add 16 bit LFSR
|
| 393 |
+
- Add stream delayer
|
| 394 |
+
- Add stream arbiter
|
| 395 |
+
- Add register macros for RTL
|
| 396 |
+
- Add shift register
|
| 397 |
+
|
| 398 |
+
### Changed
|
| 399 |
+
- Make number of registers of `rstgen_bypass` a parameter.
|
| 400 |
+
|
| 401 |
+
### Fixed
|
| 402 |
+
- Fix `valid_i` and `grant_i` guarantees in `generic_fifo` for backward compatibility.
|
| 403 |
+
- LZC: Synthesis of streaming operators in ternary operators
|
| 404 |
+
- Add missing entry for `popcount` to `Bender.yml`.
|
| 405 |
+
- Add default values for parameters to improve compatibility with Synopsys DC and Vivado.
|
| 406 |
+
|
| 407 |
+
## 1.9.0 - 2018-11-02
|
| 408 |
+
|
| 409 |
+
### Added
|
| 410 |
+
- Add popcount circuit `popcount`
|
| 411 |
+
|
| 412 |
+
## 1.8.0 - 2018-10-15
|
| 413 |
+
|
| 414 |
+
### Added
|
| 415 |
+
- Add lock feature to the rrarbiter. This prevents the arbiter to change the decision when we have pending requests that remain unaknowledged for several cycles.
|
| 416 |
+
- Add deglitching circuit
|
| 417 |
+
- Add generic clock divider
|
| 418 |
+
- Add edge detecter as alias to sync_wedge (name is more expressive)
|
| 419 |
+
- Add generic counter
|
| 420 |
+
- Add moving deglitcher
|
| 421 |
+
|
| 422 |
+
## 1.7.6 - 2018-09-27
|
| 423 |
+
|
| 424 |
+
### Added
|
| 425 |
+
- Add reset synchronizer with explicit reset bypass in testmode
|
| 426 |
+
|
| 427 |
+
## 1.7.5 - 2018-09-06
|
| 428 |
+
### Fixed
|
| 429 |
+
- Fix incompatibility with verilator
|
| 430 |
+
- Fix dependency to open-source repo
|
| 431 |
+
|
| 432 |
+
## 1.7.4 - 2018-09-06
|
| 433 |
+
- Fix assertions in `fifo_v2` (write on full / read on empty did not trigger properly)
|
| 434 |
+
|
| 435 |
+
## 1.7.3 - 2018-08-27
|
| 436 |
+
### Fixed
|
| 437 |
+
- Use proper `fifo_v2` in `generic_fifo` module.
|
| 438 |
+
|
| 439 |
+
## 1.7.2 - 2018-08-27
|
| 440 |
+
### Added
|
| 441 |
+
- Almost full/empty flags to FIFO, as `fifo_v2`.
|
| 442 |
+
|
| 443 |
+
### Changed
|
| 444 |
+
- FIFO moved to `fifo_v1` and instantiates `fifo_v2`.
|
| 445 |
+
|
| 446 |
+
## 1.7.1 - 2018-08-27
|
| 447 |
+
### Fixed
|
| 448 |
+
- Revert breaking changes to `fifo`.
|
| 449 |
+
|
| 450 |
+
## 1.7.0 - 2018-08-24
|
| 451 |
+
### Added
|
| 452 |
+
- Add stream register (`stream_register`).
|
| 453 |
+
- Add stream multiplexer and demultiplexer (`stream_mux`, `stream_demux`).
|
| 454 |
+
- Add round robin arbiter (`rrarbiter`).
|
| 455 |
+
- Add leading zero counter (`lzc`).
|
| 456 |
+
|
| 457 |
+
### Changed
|
| 458 |
+
- Deprecate `find_first_one` in favor of `lzc`.
|
| 459 |
+
|
| 460 |
+
## 1.6.0 - 2018-04-03
|
| 461 |
+
### Added
|
| 462 |
+
- Add binary to Gray code converter.
|
| 463 |
+
- Add Gray code to binary converter.
|
| 464 |
+
- Add Gray code testbench.
|
| 465 |
+
- Add CDC FIFO based on Gray counters. This is a faster alternative to the 2-phase FIFO which also works if a domain's clock has stopped.
|
| 466 |
+
|
| 467 |
+
### Changed
|
| 468 |
+
- Rename `cdc_fifo` to `cdc_fifo_2phase`.
|
| 469 |
+
- Adjust CDC FIFO testbench to cover both implementations.
|
| 470 |
+
|
| 471 |
+
## 1.5.4 - 2018-03-31
|
| 472 |
+
### Changed
|
| 473 |
+
- Replace explicit clock gate in `fifo` with implicit one.
|
| 474 |
+
|
| 475 |
+
## 1.5.3 - 2018-03-16
|
| 476 |
+
### Changed
|
| 477 |
+
- Remove duplicate deprecated modules.
|
| 478 |
+
|
| 479 |
+
## 1.5.2 - 2018-03-16
|
| 480 |
+
### Changed
|
| 481 |
+
- Remove deprecated `rstgen` and fix interface.
|
| 482 |
+
|
| 483 |
+
## 1.5.1 - 2018-03-16
|
| 484 |
+
### Changed
|
| 485 |
+
- Remove deprecated `onehot_to_bin`.
|
| 486 |
+
|
| 487 |
+
## 1.5.0 - 2018-03-14
|
| 488 |
+
### Added
|
| 489 |
+
- Add behavioural SRAM model
|
| 490 |
+
|
| 491 |
+
## 1.4.0 - 2018-03-14
|
| 492 |
+
### Added
|
| 493 |
+
- Clock domain crossing FIFO
|
| 494 |
+
|
| 495 |
+
### Changed
|
| 496 |
+
- Re-name new sync modules to resolve namespace collisions
|
| 497 |
+
|
| 498 |
+
## 1.3.0 - 2018-03-12
|
| 499 |
+
### Added
|
| 500 |
+
- 2-phase clock domain crossing
|
| 501 |
+
- Add old common cells as deprecated legacy modules
|
| 502 |
+
|
| 503 |
+
## 1.2.3 - 2018-03-09
|
| 504 |
+
### Added
|
| 505 |
+
- Backwards compatibility wrapper for `generic_LFSR_8bit`
|
| 506 |
+
|
| 507 |
+
## 1.2.2 - 2018-03-09
|
| 508 |
+
### Added
|
| 509 |
+
- Backwards compatibility wrapper for `generic_fifo`
|
| 510 |
+
|
| 511 |
+
## 1.2.1 - 2018-03-09
|
| 512 |
+
### Fixed
|
| 513 |
+
- Fix an issue in the spill register which causes transactions to be lost
|
| 514 |
+
|
| 515 |
+
## 1.2.0 - 2018-03-09
|
| 516 |
+
### Added
|
| 517 |
+
- Add spill register
|
| 518 |
+
|
| 519 |
+
## 1.1.0 - 2018-03-06
|
| 520 |
+
### Added
|
| 521 |
+
- Find first zero
|
| 522 |
+
|
| 523 |
+
## 1.0.0 - 2018-03-02
|
| 524 |
+
### Added
|
| 525 |
+
- Re-implementation of the generic FIFO supporting all kinds of use-cases
|
| 526 |
+
- Testbench for FIFO
|
| 527 |
+
|
| 528 |
+
### Changed
|
| 529 |
+
- Re-formatting and artistic code clean-up
|
| 530 |
+
|
| 531 |
+
## 0.1.0 - 2018-02-23
|
| 532 |
+
### Added
|
| 533 |
+
- Fork of PULP common cells repository
|
snapshots/pulp-platform_common_cells_pr280/Makefile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: Apache-2.0
|
| 2 |
+
|
| 3 |
+
VERILATOR ?= verilator
|
| 4 |
+
|
| 5 |
+
all: ecc_encode ecc_decode
|
| 6 |
+
|
| 7 |
+
ecc_%: test/ecc/ecc_%.cpp test/ecc/ecc.cpp src/ecc_pkg.sv src/ecc_%.sv
|
| 8 |
+
$(VERILATOR) --cc $^ --top-module $@ --trace --exe
|
| 9 |
+
cd obj_dir && make -f V$@.mk > /dev/zero
|
snapshots/pulp-platform_common_cells_pr280/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[](https://github.com/pulp-platform/common_cells/actions/workflows/ci.yml?query=branch%3Amaster)
|
| 2 |
+
[](CHANGELOG.md)
|
| 3 |
+
[](LICENSE)
|
| 4 |
+
|
| 5 |
+
# Common Cells Repository
|
| 6 |
+
|
| 7 |
+
Maintainer: Philippe Sauter <phsauter@iis.ee.ethz.ch>
|
| 8 |
+
|
| 9 |
+
This repository contains commonly used cells and headers for use in various projects.
|
| 10 |
+
|
| 11 |
+
## Cell Contents
|
| 12 |
+
|
| 13 |
+
This repository currently contains the following cells, ordered by categories.
|
| 14 |
+
Please note that cells with status *deprecated* are not to be used for new designs and only serve to provide compatibility with old code.
|
| 15 |
+
|
| 16 |
+
### Clocks and Resets
|
| 17 |
+
|
| 18 |
+
| Name | Description | Status | Superseded By |
|
| 19 |
+
|--------------------------------------------------------------------|---------------------------------------------------------------------------------------|--------------|-------------------------------------|
|
| 20 |
+
| [`clk_int_div`](src/clk_int_div.sv) | Arbitrary integer clock divider with config interface and 50% output clock duty cycle | active | |
|
| 21 |
+
| [`clk_int_div_static`](src/clk_int_div_static.sv) | A convenience wrapper around `clk_int_div` with static division factor. | active | |
|
| 22 |
+
| [`clk_div`](src/deprecated/clk_div.sv) | Clock divider with integer divisor | *deprecated* | [`clk_int_div`](src/clk_int_div.sv) |
|
| 23 |
+
| [`clock_divider`](src/deprecated/clock_divider.sv) | Clock divider with configuration registers | *deprecated* | [`clk_int_div`](src/clk_int_div.sv) |
|
| 24 |
+
| [`clock_divider_counter`](src/deprecated/clock_divider_counter.sv) | Clock divider using a counter | *deprecated* | [`clk_int_div`](src/clk_int_div.sv) |
|
| 25 |
+
| [`rstgen`](src/rstgen.sv) | Reset synchronizer | active | |
|
| 26 |
+
| [`rstgen_bypass`](src/rstgen_bypass.sv) | Reset synchronizer with dedicated test reset bypass | active | |
|
| 27 |
+
|
| 28 |
+
### Clock Domains and Asynchronous Crossings
|
| 29 |
+
|
| 30 |
+
| Name | Description | Status | Superseded By |
|
| 31 |
+
|-----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|--------------|-----------------------------------|
|
| 32 |
+
| [`cdc_4phase`](src/cdc_4phase.sv) | Clock domain crossing using 4-phase handshake, with ready/valid interface | active | |
|
| 33 |
+
| [`cdc_2phase`](src/cdc_2phase.sv) | Clock domain crossing using two-phase handshake, with ready/valid interface | active | |
|
| 34 |
+
| [`cdc_2phase_clearable`](src/cdc_2phase_clearable.sv) | Identical to `cdc_2phase` but supports one-sided async/sync resetting of either src or dst | active | |
|
| 35 |
+
| [`cdc_fifo_2phase`](src/cdc_fifo_2phase.sv) | Clock domain crossing FIFO using two-phase handshake, with ready/valid interface | active | |
|
| 36 |
+
| [`cdc_fifo_gray`](src/cdc_fifo_gray.sv) | Clock domain crossing FIFO using a gray-counter, with ready/valid interface | active | |
|
| 37 |
+
| [`cdc_fifo_gray_clearable`](src/cdc_fifo_gray_clearable.sv) | Identical to `cdc_fifo_gray` but supports one-sided async/sync resetting of either src or dst | active | |
|
| 38 |
+
| [`cdc_reset_ctrlr`](src/cdc_reset_ctrlr.sv) | Lock-step reset sequencer accross clock domains (internally used by clearable CDCs) | active | |
|
| 39 |
+
| [`clk_mux_glitch_free`](src/clk_mux_glitch_free.sv) | A glitch-free clock multiplexer with parametrizeable number of inputs. | active | |
|
| 40 |
+
| [`edge_detect`](src/edge_detect.sv) | Rising/falling edge detector | active | |
|
| 41 |
+
| [`edge_propagator`](src/edge_propagator.sv) | Propagates a single-cycle pulse across an asynchronous clock domain crossing | active | |
|
| 42 |
+
| [`edge_propagator_ack`](src/edge_propagator_ack.sv) | `edge_propagator` with sender-synchronous acknowledge pin (flags received pulse) | active | |
|
| 43 |
+
| [`edge_propagator_rx`](src/edge_propagator_rx.sv) | Receive slice of `edge_propagator`, requires only the receiver clock | active | |
|
| 44 |
+
| [`edge_propagator_tx`](src/edge_propagator_tx.sv) | Transmit slice of `edge_propagator`, requires only the sender clock | active | |
|
| 45 |
+
| [`isochronous_spill_register`](src/isochronous_spill_register.sv) | Isochronous clock domain crossing and full handshake (like `spill_register`) | active | |
|
| 46 |
+
| [`isochronous_4phase_handshake`](src/isochronous_4phase_handshake.sv) | Isochronous four-phase handshake. | active | |
|
| 47 |
+
| [`pulp_sync`](src/deprecated/pulp_sync.sv) | Serial line synchronizer | *deprecated* | [`sync`](src/sync.sv) |
|
| 48 |
+
| [`pulp_sync_wedge`](src/deprecated/pulp_sync_wedge.sv) | Serial line synchronizer with edge detector | *deprecated* | [`sync_wedge`](src/sync_wedge.sv) |
|
| 49 |
+
| [`serial_deglitch`](src/serial_deglitch.sv) | Serial line deglitcher | active | |
|
| 50 |
+
| [`sync`](src/sync.sv) | Serial line synchronizer | active | |
|
| 51 |
+
| [`sync_wedge`](src/sync_wedge.sv) | Serial line synchronizer with edge detector | active | |
|
| 52 |
+
|
| 53 |
+
### Counters and Shift Registers
|
| 54 |
+
|
| 55 |
+
| Name | Description | Status | Superseded By |
|
| 56 |
+
| ---------------------------------------------------------- | ------------------------------------------------------------------- | ------------ | ------------------------------- |
|
| 57 |
+
| [`counter`](src/counter.sv) | Generic up/down counter with overflow detection | active | |
|
| 58 |
+
| [`credit_counter`](src/credit_counter.sv) | Up/down counter for credit | active | |
|
| 59 |
+
| [`delta_counter`](src/delta_counter.sv) | Up/down counter with variable delta and overflow detection | active | |
|
| 60 |
+
| [`generic_LFSR_8bit`](src/deprecated/generic_LFSR_8bit.sv) | 8-bit linear feedback shift register (LFSR) | *deprecated* | [`lfsr_8bit`](src/lfsr_8bit.sv) |
|
| 61 |
+
| [`lfsr_8bit`](src/lfsr_8bit.sv) | 8-bit linear feedback shift register (LFSR) | active | |
|
| 62 |
+
| [`lfsr_16bit`](src/lfsr_16bit.sv) | 16-bit linear feedback shift register (LFSR) | active | |
|
| 63 |
+
| [`lfsr`](src/lfsr.sv) | 4...64-bit parametric Galois LFSR with optional whitening feature | active | |
|
| 64 |
+
| [`max_counter`](src/max_counter.sv) | Up/down counter with variable delta that tracks its maximum value | active | |
|
| 65 |
+
| [`mv_filter`](src/mv_filter.sv) | **ZARUBAF ADD DESCRIPTION** | active | |
|
| 66 |
+
| [`trip_counter`](src/trip_counter.sv) | Counter that resets automatically when it reaches a specified bound | active | |
|
| 67 |
+
|
| 68 |
+
### Data Path Elements
|
| 69 |
+
|
| 70 |
+
| Name | Description | Status | Superseded By |
|
| 71 |
+
|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|--------------|-------------------------------------|
|
| 72 |
+
| [`addr_decode`](src/addr_decode.sv) | Address map decoder | active | |
|
| 73 |
+
| [`addr_decode_dync`](src/addr_decode_dync.sv) | Address map decoder extended to support dynamic online configuration | active | |
|
| 74 |
+
| [`addr_decode_napot`](src/addr_decode_napot.sv) | Address map decoder using naturally-aligned power of two (NAPOT) regions | active | |
|
| 75 |
+
| [`multiaddr_decode`](src/multiaddr_decode.sv) | Address map decoder using NAPOT regions and allowing for multiple address inputs | active | |
|
| 76 |
+
| [`ecc_decode`](src/ecc_decode.sv) | SECDED Decoder (Single Error Correction, Double Error Detection) | active | |
|
| 77 |
+
| [`ecc_encode`](src/ecc_encode.sv) | SECDED Encoder (Single Error Correction, Double Error Detection) | active | |
|
| 78 |
+
| [`binary_to_gray`](src/binary_to_gray.sv) | Binary to gray code converter | active | |
|
| 79 |
+
| [`find_first_one`](src/deprecated/find_first_one.sv) | Leading-one finder / leading-zero counter | *deprecated* | [`lzc`](src/lzc.sv) |
|
| 80 |
+
| [`gray_to_binary`](src/gray_to_binary.sv) | Gray code to binary converter | active | |
|
| 81 |
+
| [`lzc`](src/lzc.sv) | Leading/trailing-zero counter | active | |
|
| 82 |
+
| [`onehot_to_bin`](src/onehot_to_bin.sv) | One-hot to binary converter | active | |
|
| 83 |
+
| [`shift_reg`](src/shift_reg.sv) | Shift register for arbitrary types | active | |
|
| 84 |
+
| [`shift_reg_gated`](src/shift_reg_gated.sv) | Shift register with ICG for arbitrary types | active | |
|
| 85 |
+
| [`rr_arb_tree`](src/rr_arb_tree.sv) | Round-robin arbiter for req/gnt and vld/rdy interfaces with optional priority | active | |
|
| 86 |
+
| [`rrarbiter`](src/deprecated/rrarbiter.sv) | Round-robin arbiter for req/ack interface with look-ahead | *deprecated* | [`rr_arb_tree`](src/rr_arb_tree.sv) |
|
| 87 |
+
| [`prioarbiter`](src/deprecated/prioarbiter.sv) | Priority arbiter arbiter for req/ack interface with look-ahead | *deprecated* | [`rr_arb_tree`](src/rr_arb_tree.sv) |
|
| 88 |
+
| [`fall_through_register`](src/fall_through_register.sv) | Fall-through register with ready/valid interface | active | |
|
| 89 |
+
| [`spill_register_flushable`](src/spill_register_flushable.sv) | Register with ready/valid interface to cut all combinational interface paths and additional flush signal. | active | |
|
| 90 |
+
| [`spill_register`](src/spill_register.sv) | Register with ready/valid interface to cut all combinational interface paths | active | |
|
| 91 |
+
| [`stream_arbiter`](src/stream_arbiter.sv) | Round-robin arbiter for ready/valid stream interface | active | |
|
| 92 |
+
| [`stream_arbiter_flushable`](src/stream_arbiter_flushable.sv) | Round-robin arbiter for ready/valid stream interface and flush functionality | active | |
|
| 93 |
+
| [`stream_demux`](src/stream_demux.sv) | Ready/valid interface demultiplexer | active | |
|
| 94 |
+
| [`lossy_valid_to_stream`](src/lossy_valid_to_stream.sv) | Convert Valid-only to ready/valid by updating in-flight transaction | active | |
|
| 95 |
+
| [`stream_join`](src/stream_join.sv) | Ready/valid handshake join multiple to one common | active | |
|
| 96 |
+
| [`stream_join_dynamic`](src/stream_join_dynamic.sv) | Ready/valid handshake join multiple to one common, dynamically configurable subset selection | active | |
|
| 97 |
+
| [`stream_mux`](src/stream_mux.sv) | Ready/valid interface multiplexer | active | |
|
| 98 |
+
| [`stream_register`](src/stream_register.sv) | Register with ready/valid interface | active | |
|
| 99 |
+
| [`stream_fork`](src/stream_fork.sv) | Ready/valid fork | active | |
|
| 100 |
+
| [`stream_fork_dynamic`](src/stream_fork_dynamic.sv) | Ready/valid fork, with selection mask for partial forking | active | |
|
| 101 |
+
| [`stream_filter`](src/stream_filter.sv) | Ready/valid filter | active | |
|
| 102 |
+
| [`stream_delay`](src/stream_delay.sv) | Randomize or delay ready/valid interface | active | |
|
| 103 |
+
| [`stream_to_mem`](src/stream_to_mem.sv) | Use memories without flow control for output data in streams. | active | |
|
| 104 |
+
| [`stream_xbar`](src/stream_xbar.sv) | Fully connected crossbar with ready/valid interface. | active | |
|
| 105 |
+
| [`stream_omega_net`](src/stream_omega_net.sv) | One-way stream omega-net with ready/valid interface. Isomorphic to a butterfly. | active | |
|
| 106 |
+
| [`stream_throttle`](src/stream_throttle.sv) | Restrict the number of outstanding transfers in a stream. | active | |
|
| 107 |
+
| [`sub_per_hash`](src/sub_per_hash.sv) | Substitution-permutation hash function | active | |
|
| 108 |
+
| [`popcount`](src/popcount.sv) | Combinatorial popcount (hamming weight) | active | |
|
| 109 |
+
| [`mem_to_banks_detailed`](src/mem_to_banks_detailed.sv) | Split memory access over multiple parallel banks with detailed response signals | active | |
|
| 110 |
+
| [`mem_to_banks`](src/mem_to_banks.sv) | Split memory access over multiple parallel banks | active | |
|
| 111 |
+
| [`heaviside`](src/heaviside.sv) | Generates a mask obtained by applying the Heaviside step function | active | |
|
| 112 |
+
| [`boxcar`](src/boxcar.sv) | Generates a mask obtained by applying a boxcar function | active | |
|
| 113 |
+
|
| 114 |
+
### Data Structures
|
| 115 |
+
|
| 116 |
+
| Name | Description | Status | Superseded By |
|
| 117 |
+
| ---------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------ | ----------------------------------------------------------------------------------------------- |
|
| 118 |
+
| [`cb_filter`](src/cb_filter.sv) | Counting-Bloom-Filter with combinational lookup | active | |
|
| 119 |
+
| [`fifo`](src/deprecated/fifo_v1.sv) | FIFO register with upper threshold | *deprecated* | [`fifo_v3`](src/fifo_v3.sv) |
|
| 120 |
+
| [`fifo_v2`](src/deprecated/fifo_v2.sv) | FIFO register with upper and lower threshold | *deprecated* | [`fifo_v3`](src/fifo_v3.sv) |
|
| 121 |
+
| [`fifo_v3`](src/fifo_v3.sv) | FIFO register with generic fill counts | active | |
|
| 122 |
+
| [`passthrough_stream_fifo`](src/passthrough_stream_fifo.sv) | FIFO register with ready/valid interface and same-cycle push/pop when full | active | |
|
| 123 |
+
| [`ring_buffer`](src/ring_buffer.sv) | Ring buffer with sequential write and random-access read interfaces | active | |
|
| 124 |
+
| [`stream_fifo`](src/stream_fifo.sv) | FIFO register with ready/valid interface | active | |
|
| 125 |
+
| [`stream_fifo_optimal_wrap`](src/stream_fifo_optimal_wrap.sv) | Wrapper that optimally selects either a spill register or a FIFO | active | |
|
| 126 |
+
| [`generic_fifo`](src/deprecated/generic_fifo.sv) | FIFO register without thresholds | *deprecated* | [`fifo_v3`](src/fifo_v3.sv) |
|
| 127 |
+
| [`generic_fifo_adv`](src/deprecated/generic_fifo_adv.sv) | FIFO register without thresholds | *deprecated* | [`fifo_v3`](src/fifo_v3.sv) |
|
| 128 |
+
| [`sram`](src/deprecated/sram.sv) | SRAM behavioral model | *deprecated* | [`tc_sram`](https://github.com/pulp-platform/tech_cells_generic/blob/master/src/rtl/tc_sram.sv) |
|
| 129 |
+
| [`plru_tree`](src/plru_tree.sv) | Pseudo least recently used tree | active | |
|
| 130 |
+
| [`unread`](src/unread.sv) | Empty module to sink unconnected outputs into | active | |
|
| 131 |
+
| [`read`](src/read.sv) | Dummy module that prevents a signal from being removed during synthesis | active | |
|
| 132 |
+
|
| 133 |
+
## Header Contents
|
| 134 |
+
|
| 135 |
+
This repository currently contains the following header files.
|
| 136 |
+
|
| 137 |
+
### RTL Register Macros
|
| 138 |
+
|
| 139 |
+
The header file [`registers.svh`](include/common_cells/registers.svh) contains macros that expand to descriptions of registers.
|
| 140 |
+
To avoid misuse of `always_ff` blocks, only the following macros shall be used to describe sequential behavior.
|
| 141 |
+
The use of linter rules that flag explicit uses of `always_ff` in source code is encouraged.
|
| 142 |
+
|
| 143 |
+
| Macro | Arguments | Description |
|
| 144 |
+
| ------------ | ----------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
| 145 |
+
| <code>`FF</code> | `q_sig`, `d_sig`, `rst_val`, (`clk_sig`, `arstn_sig`) | Flip-flop with asynchronous active-low reset |
|
| 146 |
+
| <code>`FFAR</code> | `q_sig`, `d_sig`, `rst_val`, `clk_sig`, `arst_sig` | Flip-flop with asynchronous active-high reset |
|
| 147 |
+
| <code>`FFARN</code> | `q_sig`, `d_sig`, `rst_val`, `clk_sig`, `arstn_sig` | *deprecated* Flip-flop with asynchronous active-low reset |
|
| 148 |
+
| <code>`FFSR</code> | `q_sig`, `d_sig`, `rst_val`, `clk_sig`, `rst_sig` | Flip-flop with synchronous active-high reset |
|
| 149 |
+
| <code>`FFSRN</code> | `q_sig`, `d_sig`, `rst_val`, `clk_sig`, `rstn_sig` | Flip-flop with synchronous active-low reset |
|
| 150 |
+
| <code>`FFNR</code> | `q_sig`, `d_sig`, `clk_sig` | Flip-flop without reset |
|
| 151 |
+
| | | |
|
| 152 |
+
| <code>`FFL</code> | `q_sig`, `d_sig`, `load_ena`, `rst_val`, (`clk_sig`, `arstn_sig`) | Flip-flop with load-enable and asynchronous active-low reset |
|
| 153 |
+
| <code>`FFLAR</code> | `q_sig`, `d_sig`, `load_ena`, `rst_val`, `clk_sig`, `arst_sig` | Flip-flop with load-enable and asynchronous active-high reset |
|
| 154 |
+
| <code>`FFLARN</code> | `q_sig`, `d_sig`, `load_ena`, `rst_val`, `clk_sig`, `arstn_sig` | *deprecated* Flip-flop with load-enable and asynchronous active-low reset |
|
| 155 |
+
| <code>`FFLSR</code> | `q_sig`, `d_sig`, `load_ena`, `rst_val`, `clk_sig`, `rst_sig` | Flip-flop with load-enable and synchronous active-high reset |
|
| 156 |
+
| <code>`FFLSRN</code> | `q_sig`, `d_sig`, `load_ena`, `rst_val`, `clk_sig`, `rstn_sig` | Flip-flop with load-enable and synchronous active-low reset |
|
| 157 |
+
| <code>`FFLNR</code> | `q_sig`, `d_sig`, `load_ena`, `clk_sig` | Flip-flop with load-enable without reset |
|
| 158 |
+
- *The name of the clock and reset signals for implicit variants is `clk_i` and `rst_ni`, respectively.*
|
| 159 |
+
- *Argument suffix `_sig` indicates signal names for present and next state as well as clocks and resets.*
|
| 160 |
+
- *Argument `rst_val` specifies the value literal to be assigned upon reset.*
|
| 161 |
+
- *Argument `load_ena` specifies the boolean expression that forms the load enable of the register.*
|
| 162 |
+
|
| 163 |
+
### SystemVerilog Assertion Macros
|
| 164 |
+
|
| 165 |
+
The header file [`assertions.svh`](include/common_cells/assertions.svh) contains macros that expand to assertion blocks.
|
| 166 |
+
These macros should recduce the effort in writing many assertions and make it
|
| 167 |
+
easier to use them. They are similar to but incompatible with the macros used by [lowrisc](https://github.com/lowRISC/opentitan/blob/master/hw/ip/prim/rtl/prim_assert.sv).
|
| 168 |
+
|
| 169 |
+
#### Simple Assertion and Cover Macros
|
| 170 |
+
| Macro | Arguments | Description |
|
| 171 |
+
| ------------------ | ------------------------------------------------ | -------------------------------------------------------------------------- |
|
| 172 |
+
| <code>`ASSERT_I</code> | `__name`, `__prop`, (`__desc`) | Immediate assertion |
|
| 173 |
+
| <code>`ASSERT_INIT</code> | `__name`, `__prop`, (`__desc`) | Assertion in initial block. Can be used for things like parameter checking |
|
| 174 |
+
| <code>`ASSERT_FINAL</code> | `__name`, `__prop`, (`__desc`) | Assertion in final block |
|
| 175 |
+
| <code>`ASSERT</code> | `__name`, `__prop`, (`__clk`, `__rst`, `__desc`) | Assert a concurrent property directly |
|
| 176 |
+
| <code>`ASSERT_NEVER</code> | `__name`, `__prop`, (`__clk`, `__rst`, `__desc`) | Assert a concurrent property NEVER happens |
|
| 177 |
+
| <code>`ASSERT_KNOWN</code> | `__name`, `__sig`, (`__clk`, `__rst`, `__desc`) | Concurrent clocked assertion with custom error message |
|
| 178 |
+
| <code>`COVER</code> | `__name`, `__prop`, (`__clk`, `__rst`) | Cover a concurrent property |
|
| 179 |
+
- *The name of the clock and reset signals for implicit variants is `clk_i` and `rst_ni`, respectively.*
|
| 180 |
+
- *`__desc` is an optional string argument describing the failure causing the assertion to be violated that is embedded into the error report and defaults to `""`.*
|
| 181 |
+
|
| 182 |
+
#### Complex Assertion Macros
|
| 183 |
+
| Macro | Arguments | Description |
|
| 184 |
+
| --------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
| 185 |
+
| <code>`ASSERT_PULSE</code> | `__name`, `__sig`, (`__clk`, `__rst`, `__desc`) | Assert that signal is an active-high pulse with pulse length of 1 clock cycle |
|
| 186 |
+
| <code>`ASSERT_IF</code> | `__name`, `__prop`, `__enable`, (`__clk`, `__rst`, `__desc`) | Assert that a property is true only when an enable signal is set |
|
| 187 |
+
| <code>`ASSERT_KNOWN_IF</code> | `__name`, `__sig`, `__enable`, (`__clk`, `__rst`, `__desc`) | Assert that signal has a known value (each bit is either '0' or '1') after reset if enable is set |
|
| 188 |
+
| <code>`ASSERT_STABLE</code> | `__name`, `__valid`, `__ready`, `__data`, `__enable`, (`__clk`, `__rst`, `__desc`) | Assert that the data on a ready-valid interface is kept stable after valid is asserted, until ready is too |
|
| 189 |
+
- *The name of the clock and reset signals for implicit variants is `clk_i` and `rst_ni`, respectively.*
|
| 190 |
+
- *`__desc` is an optional string argument describing the failure causing the assertion to be violated that is embedded into the error report and defaults to `""`.*
|
| 191 |
+
|
| 192 |
+
#### Assumption Macros
|
| 193 |
+
|
| 194 |
+
| Macro | Arguments | Description |
|
| 195 |
+
| -------------- | ------------------------------------------------ | ---------------------------- |
|
| 196 |
+
| <code>`ASSUME</code> | `__name`, `__prop`, (`__clk`, `__rst`, `__desc`) | Assume a concurrent property |
|
| 197 |
+
| <code>`ASSUME_I</code> | `__name`, `__prop`, (`__desc`) | Assume an immediate property |
|
| 198 |
+
- *The name of the clock and reset signals for implicit variants is `clk_i` and `rst_ni`, respectively.*
|
| 199 |
+
- *`__desc` is an optional string argument describing the failure causing the assertion to be violated that is embedded into the error report and defaults to `""`.*
|
| 200 |
+
|
| 201 |
+
#### Formal Verification Macros
|
| 202 |
+
|
| 203 |
+
| Macro | Arguments | Description |
|
| 204 |
+
| ------------------ | ------------------------------------------------ | ------------------------------------------------------------ |
|
| 205 |
+
| <code>`ASSUME_FPV</code> | `__name`, `__prop`, (`__clk`, `__rst`, `__desc`) | Assume a concurrent property during formal verification only |
|
| 206 |
+
| <code>`ASSUME_I_FPV</code> | `__name`, `__prop`, (`__desc`) | Assume a concurrent property during formal verification only |
|
| 207 |
+
| <code>`COVER_FPV</code> | `__name`, `__prop`, (`__clk`, `__rst`) | Cover a concurrent property during formal verification |
|
| 208 |
+
- *The name of the clock and reset signals for implicit variants is `clk_i` and `rst_ni`, respectively.*
|
| 209 |
+
- *`__desc` is an optional string argument describing the failure causing the assertion to be violated that is embedded into the error report and defaults to `""`.*
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.bin
|
| 2 |
+
*.elf
|
| 3 |
+
debug_rom.img
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/Makefile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# See LICENSE.SiFive for license details
|
| 2 |
+
|
| 3 |
+
debug_rom = debug_rom.sv
|
| 4 |
+
|
| 5 |
+
GCC?=riscv64-unknown-elf-gcc
|
| 6 |
+
OBJCOPY?=riscv64-unknown-elf-objcopy
|
| 7 |
+
OBJDUMP?=riscv64-unknown-elf-objdump
|
| 8 |
+
PYTHON?=python
|
| 9 |
+
|
| 10 |
+
all: $(debug_rom)
|
| 11 |
+
|
| 12 |
+
%.sv: %.img
|
| 13 |
+
$(PYTHON) gen_rom.py $<
|
| 14 |
+
|
| 15 |
+
%.img: %.bin
|
| 16 |
+
dd if=$< of=$@ bs=256 count=1
|
| 17 |
+
|
| 18 |
+
%.bin: %.elf
|
| 19 |
+
$(OBJCOPY) -O binary $< $@
|
| 20 |
+
|
| 21 |
+
%.elf: %.S link.ld
|
| 22 |
+
$(GCC) -I$(RISCV)/include -Tlink.ld $< -nostdlib -fPIC -static -Wl,--no-gc-sections -o $@
|
| 23 |
+
|
| 24 |
+
%.dump: %.elf
|
| 25 |
+
$(OBJDUMP) -d $< --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data > $@
|
| 26 |
+
|
| 27 |
+
clean:
|
| 28 |
+
rm -f *.img *.dump *.bin *.sv
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/debug_rom.S
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// See LICENSE.SiFive for license details.
|
| 2 |
+
|
| 3 |
+
#include "encoding.h"
|
| 4 |
+
|
| 5 |
+
// These are implementation-specific addresses in the Debug Module
|
| 6 |
+
#define HALTED 0x100
|
| 7 |
+
#define GOING 0x104
|
| 8 |
+
#define RESUMING 0x108
|
| 9 |
+
#define EXCEPTION 0x10C
|
| 10 |
+
|
| 11 |
+
// Region of memory where each hart has 1
|
| 12 |
+
// byte to read.
|
| 13 |
+
#define FLAGS 0x400
|
| 14 |
+
#define FLAG_GO 0
|
| 15 |
+
#define FLAG_RESUME 1
|
| 16 |
+
|
| 17 |
+
.option norvc
|
| 18 |
+
.global entry
|
| 19 |
+
.global exception
|
| 20 |
+
|
| 21 |
+
// Entry location on ebreak, Halt, or Breakpoint
|
| 22 |
+
// It is the same for all harts. They branch when
|
| 23 |
+
// their GO or RESUME bit is set.
|
| 24 |
+
|
| 25 |
+
entry:
|
| 26 |
+
jal zero, _entry
|
| 27 |
+
resume:
|
| 28 |
+
jal zero, _resume
|
| 29 |
+
exception:
|
| 30 |
+
jal zero, _exception
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
_entry:
|
| 35 |
+
// This fence is required because the execution may have written something
|
| 36 |
+
// into the Abstract Data or Program Buffer registers.
|
| 37 |
+
fence
|
| 38 |
+
csrw CSR_DSCRATCH0, s0 // Save s0 to allow signaling MHARTID
|
| 39 |
+
csrw CSR_DSCRATCH1, a0 // Save a0 to allow loading arbitrary DM base
|
| 40 |
+
auipc a0, 0 // Get PC
|
| 41 |
+
srli a0, a0, 12 // And throw away lower 12 bits to get the DM base
|
| 42 |
+
slli a0, a0, 12
|
| 43 |
+
|
| 44 |
+
// We continue to let the hart know that we are halted in order that
|
| 45 |
+
// a DM which was reset is still made aware that a hart is halted.
|
| 46 |
+
// We keep checking both whether there is something the debugger wants
|
| 47 |
+
// us to do, or whether we should resume.
|
| 48 |
+
entry_loop:
|
| 49 |
+
csrr s0, CSR_MHARTID
|
| 50 |
+
sw s0, HALTED(a0)
|
| 51 |
+
add s0, s0, a0
|
| 52 |
+
lbu s0, FLAGS(s0) // 1 byte flag per hart. Only one hart advances here.
|
| 53 |
+
andi s0, s0, (1 << FLAG_GO)
|
| 54 |
+
bnez s0, going
|
| 55 |
+
csrr s0, CSR_MHARTID
|
| 56 |
+
add s0, s0, a0
|
| 57 |
+
lbu s0, FLAGS(s0) // multiple harts can resume here
|
| 58 |
+
andi s0, s0, (1 << FLAG_RESUME)
|
| 59 |
+
bnez s0, resume
|
| 60 |
+
jal zero, entry_loop
|
| 61 |
+
|
| 62 |
+
_exception:
|
| 63 |
+
// We can only get here due to an exception while in debug mode. Hence,
|
| 64 |
+
// we do not need to save a0 to a scratch register as it has already
|
| 65 |
+
// been saved on debug entry.
|
| 66 |
+
auipc a0, 0 // Get POC
|
| 67 |
+
srli a0, a0, 12 // And throw away lower 12 bits to get the DM base
|
| 68 |
+
slli a0, a0, 12
|
| 69 |
+
sw zero, EXCEPTION(a0) // Let debug module know you got an exception.
|
| 70 |
+
// It is safe to always restore the scratch registers here as they must
|
| 71 |
+
// have been saved on debug entry. Restoring them here avoids issues
|
| 72 |
+
// with registers being overwritten by exceptions occuring during
|
| 73 |
+
// program buffer execution.
|
| 74 |
+
csrr s0, CSR_DSCRATCH0 // Restore s0 here
|
| 75 |
+
csrr a0, CSR_DSCRATCH1 // Restore a0 here
|
| 76 |
+
ebreak
|
| 77 |
+
|
| 78 |
+
going:
|
| 79 |
+
sw zero, GOING(a0) // When debug module sees this write, the GO flag is reset.
|
| 80 |
+
csrr s0, CSR_DSCRATCH0 // Restore s0 here
|
| 81 |
+
csrr a0, CSR_DSCRATCH1 // Restore a0 here
|
| 82 |
+
jal zero, whereto
|
| 83 |
+
_resume:
|
| 84 |
+
csrr s0, CSR_MHARTID
|
| 85 |
+
sw s0, RESUMING(a0) // When Debug Module sees this write, the RESUME flag is reset.
|
| 86 |
+
csrr s0, CSR_DSCRATCH0 // Restore s0 here
|
| 87 |
+
csrr a0, CSR_DSCRATCH1 // Restore a0 here
|
| 88 |
+
dret
|
| 89 |
+
|
| 90 |
+
// END OF ACTUAL "ROM" CONTENTS. BELOW IS JUST FOR LINKER SCRIPT.
|
| 91 |
+
|
| 92 |
+
.section .whereto
|
| 93 |
+
whereto:
|
| 94 |
+
nop
|
| 95 |
+
// Variable "ROM" This is : jal x0 abstract, jal x0 program_buffer,
|
| 96 |
+
// or jal x0 resume, as desired.
|
| 97 |
+
// Debug Module state machine tracks what is 'desired'.
|
| 98 |
+
// We don't need/want to use jalr here because all of the
|
| 99 |
+
// Variable ROM contents are set by
|
| 100 |
+
// Debug Module before setting the OK_GO byte.
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/debug_rom.h
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Auto-generated code
|
| 2 |
+
|
| 3 |
+
const int reset_vec_size = 38;
|
| 4 |
+
|
| 5 |
+
uint32_t reset_vec[reset_vec_size] = {
|
| 6 |
+
0x00c0006f,
|
| 7 |
+
0x07c0006f,
|
| 8 |
+
0x04c0006f,
|
| 9 |
+
0x0ff0000f,
|
| 10 |
+
0x7b241073,
|
| 11 |
+
0x7b351073,
|
| 12 |
+
0x00000517,
|
| 13 |
+
0x00c55513,
|
| 14 |
+
0x00c51513,
|
| 15 |
+
0xf1402473,
|
| 16 |
+
0x10852023,
|
| 17 |
+
0x00a40433,
|
| 18 |
+
0x40044403,
|
| 19 |
+
0x00147413,
|
| 20 |
+
0x02041c63,
|
| 21 |
+
0xf1402473,
|
| 22 |
+
0x00a40433,
|
| 23 |
+
0x40044403,
|
| 24 |
+
0x00247413,
|
| 25 |
+
0xfa041ce3,
|
| 26 |
+
0xfd5ff06f,
|
| 27 |
+
0x00000517,
|
| 28 |
+
0x00c55513,
|
| 29 |
+
0x00c51513,
|
| 30 |
+
0x10052623,
|
| 31 |
+
0x7b202473,
|
| 32 |
+
0x7b302573,
|
| 33 |
+
0x00100073,
|
| 34 |
+
0x10052223,
|
| 35 |
+
0x7b202473,
|
| 36 |
+
0x7b302573,
|
| 37 |
+
0xa85ff06f,
|
| 38 |
+
0xf1402473,
|
| 39 |
+
0x10852423,
|
| 40 |
+
0x7b202473,
|
| 41 |
+
0x7b302573,
|
| 42 |
+
0x7b200073,
|
| 43 |
+
0x00000000
|
| 44 |
+
};
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/debug_rom.sv
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the "License"); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: $filename.v
|
| 12 |
+
*
|
| 13 |
+
* Description: Auto-generated bootrom
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
// Auto-generated code
|
| 17 |
+
module debug_rom (
|
| 18 |
+
input logic clk_i,
|
| 19 |
+
input logic req_i,
|
| 20 |
+
input logic [63:0] addr_i,
|
| 21 |
+
output logic [63:0] rdata_o
|
| 22 |
+
);
|
| 23 |
+
|
| 24 |
+
localparam int unsigned RomSize = 19;
|
| 25 |
+
|
| 26 |
+
const logic [RomSize-1:0][63:0] mem = {
|
| 27 |
+
64'h00000000_7b200073,
|
| 28 |
+
64'h7b302573_7b202473,
|
| 29 |
+
64'h10852423_f1402473,
|
| 30 |
+
64'ha85ff06f_7b302573,
|
| 31 |
+
64'h7b202473_10052223,
|
| 32 |
+
64'h00100073_7b302573,
|
| 33 |
+
64'h7b202473_10052623,
|
| 34 |
+
64'h00c51513_00c55513,
|
| 35 |
+
64'h00000517_fd5ff06f,
|
| 36 |
+
64'hfa041ce3_00247413,
|
| 37 |
+
64'h40044403_00a40433,
|
| 38 |
+
64'hf1402473_02041c63,
|
| 39 |
+
64'h00147413_40044403,
|
| 40 |
+
64'h00a40433_10852023,
|
| 41 |
+
64'hf1402473_00c51513,
|
| 42 |
+
64'h00c55513_00000517,
|
| 43 |
+
64'h7b351073_7b241073,
|
| 44 |
+
64'h0ff0000f_04c0006f,
|
| 45 |
+
64'h07c0006f_00c0006f
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
logic [$clog2(RomSize)-1:0] addr_q;
|
| 49 |
+
|
| 50 |
+
always_ff @(posedge clk_i) begin
|
| 51 |
+
if (req_i) begin
|
| 52 |
+
addr_q <= addr_i[$clog2(RomSize)-1+3:3];
|
| 53 |
+
end
|
| 54 |
+
end
|
| 55 |
+
|
| 56 |
+
// this prevents spurious Xes from propagating into
|
| 57 |
+
// the speculative fetch stage of the core
|
| 58 |
+
always_comb begin : p_outmux
|
| 59 |
+
rdata_o = '0;
|
| 60 |
+
if (addr_q < $clog2(RomSize)'(RomSize)) begin
|
| 61 |
+
rdata_o = mem[addr_q];
|
| 62 |
+
end
|
| 63 |
+
end
|
| 64 |
+
|
| 65 |
+
endmodule
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/gen_rom.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
|
| 3 |
+
from string import Template
|
| 4 |
+
import argparse
|
| 5 |
+
import os.path
|
| 6 |
+
import sys
|
| 7 |
+
import binascii
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
parser = argparse.ArgumentParser(description='Convert binary file to verilog rom')
|
| 11 |
+
parser.add_argument('filename', metavar='filename', nargs=1,
|
| 12 |
+
help='filename of input binary')
|
| 13 |
+
|
| 14 |
+
args = parser.parse_args()
|
| 15 |
+
file = args.filename[0];
|
| 16 |
+
|
| 17 |
+
# check that file exists
|
| 18 |
+
if not os.path.isfile(file):
|
| 19 |
+
print("File {} does not exist.".format(filename))
|
| 20 |
+
sys.exit(1)
|
| 21 |
+
|
| 22 |
+
filename = os.path.splitext(file)[0]
|
| 23 |
+
|
| 24 |
+
license = """\
|
| 25 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 26 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 27 |
+
* License, Version 0.51 (the "License"); you may not use this file except in
|
| 28 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 29 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 30 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 31 |
+
* this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
| 32 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 33 |
+
* specific language governing permissions and limitations under the License.
|
| 34 |
+
*
|
| 35 |
+
* File: $filename.v
|
| 36 |
+
*
|
| 37 |
+
* Description: Auto-generated bootrom
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
// Auto-generated code
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
module = """\
|
| 44 |
+
module $filename (
|
| 45 |
+
input logic clk_i,
|
| 46 |
+
input logic req_i,
|
| 47 |
+
input logic [63:0] addr_i,
|
| 48 |
+
output logic [63:0] rdata_o
|
| 49 |
+
);
|
| 50 |
+
|
| 51 |
+
localparam int unsigned RomSize = $size;
|
| 52 |
+
|
| 53 |
+
const logic [RomSize-1:0][63:0] mem = {
|
| 54 |
+
$content
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
logic [$$clog2(RomSize)-1:0] addr_q;
|
| 58 |
+
|
| 59 |
+
always_ff @(posedge clk_i) begin
|
| 60 |
+
if (req_i) begin
|
| 61 |
+
addr_q <= addr_i[$$clog2(RomSize)-1+3:3];
|
| 62 |
+
end
|
| 63 |
+
end
|
| 64 |
+
|
| 65 |
+
// this prevents spurious Xes from propagating into
|
| 66 |
+
// the speculative fetch stage of the core
|
| 67 |
+
always_comb begin : p_outmux
|
| 68 |
+
rdata_o = '0;
|
| 69 |
+
if (addr_q < $$clog2(RomSize)'(RomSize)) begin
|
| 70 |
+
rdata_o = mem[addr_q];
|
| 71 |
+
end
|
| 72 |
+
end
|
| 73 |
+
|
| 74 |
+
endmodule
|
| 75 |
+
"""
|
| 76 |
+
|
| 77 |
+
c_var = """\
|
| 78 |
+
// Auto-generated code
|
| 79 |
+
|
| 80 |
+
const int reset_vec_size = $size;
|
| 81 |
+
|
| 82 |
+
uint32_t reset_vec[reset_vec_size] = {
|
| 83 |
+
$content
|
| 84 |
+
};
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
def read_bin():
|
| 88 |
+
|
| 89 |
+
with open(filename + ".img", 'rb') as f:
|
| 90 |
+
rom = binascii.hexlify(f.read())
|
| 91 |
+
rom = map(''.join, zip(rom[::2], rom[1::2]))
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
# align to 64 bit
|
| 95 |
+
align = (int((len(rom) + 7) / 8 )) * 8;
|
| 96 |
+
|
| 97 |
+
for i in range(len(rom), align):
|
| 98 |
+
rom.append("00")
|
| 99 |
+
|
| 100 |
+
return rom
|
| 101 |
+
|
| 102 |
+
rom = read_bin()
|
| 103 |
+
|
| 104 |
+
""" Generate C header file for simulator
|
| 105 |
+
"""
|
| 106 |
+
with open(filename + ".h", "w") as f:
|
| 107 |
+
rom_str = ""
|
| 108 |
+
# process in junks of 32 bit (4 byte)
|
| 109 |
+
for i in range(0, int(len(rom)/4)):
|
| 110 |
+
rom_str += " 0x" + "".join(rom[i*4:i*4+4][::-1]) + ",\n"
|
| 111 |
+
|
| 112 |
+
# remove the trailing comma
|
| 113 |
+
rom_str = rom_str[:-2]
|
| 114 |
+
|
| 115 |
+
s = Template(c_var)
|
| 116 |
+
f.write(s.substitute(filename=filename, size=int(len(rom)/4), content=rom_str))
|
| 117 |
+
|
| 118 |
+
f.close()
|
| 119 |
+
|
| 120 |
+
""" Generate SystemVerilog bootcode for FPGA and ASIC
|
| 121 |
+
"""
|
| 122 |
+
with open(filename + ".sv", "w") as f:
|
| 123 |
+
rom_str = ""
|
| 124 |
+
# process in junks of 64 bit (8 byte)
|
| 125 |
+
for i in reversed(range(int(len(rom)/8))):
|
| 126 |
+
rom_str += " 64'h" + "".join(rom[i*8+4:i*8+8][::-1]) + "_" + "".join(rom[i*8:i*8+4][::-1]) + ",\n"
|
| 127 |
+
|
| 128 |
+
# remove the trailing comma
|
| 129 |
+
rom_str = rom_str[:-2]
|
| 130 |
+
|
| 131 |
+
f.write(license)
|
| 132 |
+
s = Template(module)
|
| 133 |
+
f.write(s.substitute(filename=filename, size=int(len(rom)/8), content=rom_str))
|
| 134 |
+
|
snapshots/pulp-platform_riscv-dbg_pr53/debug_rom/link.ld
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* See LICENSE.SiFive for license details. */
|
| 2 |
+
OUTPUT_ARCH( "riscv" )
|
| 3 |
+
ENTRY( entry )
|
| 4 |
+
SECTIONS
|
| 5 |
+
{
|
| 6 |
+
.whereto 0x300 :
|
| 7 |
+
{
|
| 8 |
+
*(.whereto)
|
| 9 |
+
}
|
| 10 |
+
. = 0x800;
|
| 11 |
+
.text :
|
| 12 |
+
{
|
| 13 |
+
*(.text)
|
| 14 |
+
}
|
| 15 |
+
_end = .;
|
| 16 |
+
}
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dm_csrs.sv
ADDED
|
@@ -0,0 +1,647 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: dm_csrs.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 30.6.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: Debug CSRs. Communication over Debug Transport Module (DTM)
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
module dm_csrs #(
|
| 19 |
+
parameter int unsigned NrHarts = 1,
|
| 20 |
+
parameter int unsigned BusWidth = 32,
|
| 21 |
+
parameter logic [NrHarts-1:0] SelectableHarts = {NrHarts{1'b1}}
|
| 22 |
+
) (
|
| 23 |
+
input logic clk_i, // Clock
|
| 24 |
+
input logic rst_ni, // Asynchronous reset active low
|
| 25 |
+
input logic testmode_i,
|
| 26 |
+
input logic dmi_rst_ni, // Debug Module Intf reset active-low
|
| 27 |
+
input logic dmi_req_valid_i,
|
| 28 |
+
output logic dmi_req_ready_o,
|
| 29 |
+
input dm::dmi_req_t dmi_req_i,
|
| 30 |
+
// every request needs a response one cycle later
|
| 31 |
+
output logic dmi_resp_valid_o,
|
| 32 |
+
input logic dmi_resp_ready_i,
|
| 33 |
+
output dm::dmi_resp_t dmi_resp_o,
|
| 34 |
+
// global ctrl
|
| 35 |
+
output logic ndmreset_o, // non-debug module reset active-high
|
| 36 |
+
output logic dmactive_o, // 1 -> debug-module is active,
|
| 37 |
+
// 0 -> synchronous re-set
|
| 38 |
+
// hart status
|
| 39 |
+
input dm::hartinfo_t [NrHarts-1:0] hartinfo_i, // static hartinfo
|
| 40 |
+
input logic [NrHarts-1:0] halted_i, // hart is halted
|
| 41 |
+
input logic [NrHarts-1:0] unavailable_i, // e.g.: powered down
|
| 42 |
+
input logic [NrHarts-1:0] resumeack_i, // hart acknowledged resume request
|
| 43 |
+
// hart control
|
| 44 |
+
output logic [19:0] hartsel_o, // hartselect to ctrl module
|
| 45 |
+
output logic [NrHarts-1:0] haltreq_o, // request to halt a hart
|
| 46 |
+
output logic [NrHarts-1:0] resumereq_o, // request hart to resume
|
| 47 |
+
output logic clear_resumeack_o,
|
| 48 |
+
|
| 49 |
+
output logic cmd_valid_o, // debugger writing to cmd field
|
| 50 |
+
output dm::command_t cmd_o, // abstract command
|
| 51 |
+
input logic cmderror_valid_i, // an error occurred
|
| 52 |
+
input dm::cmderr_e cmderror_i, // this error occurred
|
| 53 |
+
input logic cmdbusy_i, // cmd is currently busy executing
|
| 54 |
+
|
| 55 |
+
output logic [dm::ProgBufSize-1:0][31:0] progbuf_o, // to system bus
|
| 56 |
+
output logic [dm::DataCount-1:0][31:0] data_o,
|
| 57 |
+
|
| 58 |
+
input logic [dm::DataCount-1:0][31:0] data_i,
|
| 59 |
+
input logic data_valid_i,
|
| 60 |
+
// system bus access module (SBA)
|
| 61 |
+
output logic [BusWidth-1:0] sbaddress_o,
|
| 62 |
+
input logic [BusWidth-1:0] sbaddress_i,
|
| 63 |
+
output logic sbaddress_write_valid_o,
|
| 64 |
+
// control signals in
|
| 65 |
+
output logic sbreadonaddr_o,
|
| 66 |
+
output logic sbautoincrement_o,
|
| 67 |
+
output logic [2:0] sbaccess_o,
|
| 68 |
+
// data out
|
| 69 |
+
output logic sbreadondata_o,
|
| 70 |
+
output logic [BusWidth-1:0] sbdata_o,
|
| 71 |
+
output logic sbdata_read_valid_o,
|
| 72 |
+
output logic sbdata_write_valid_o,
|
| 73 |
+
// read data in
|
| 74 |
+
input logic [BusWidth-1:0] sbdata_i,
|
| 75 |
+
input logic sbdata_valid_i,
|
| 76 |
+
// control signals
|
| 77 |
+
input logic sbbusy_i,
|
| 78 |
+
input logic sberror_valid_i, // bus error occurred
|
| 79 |
+
input logic [2:0] sberror_i // bus error occurred
|
| 80 |
+
);
|
| 81 |
+
// the amount of bits we need to represent all harts
|
| 82 |
+
localparam int unsigned HartSelLen = (NrHarts == 1) ? 1 : $clog2(NrHarts);
|
| 83 |
+
localparam int unsigned NrHartsAligned = 2**HartSelLen;
|
| 84 |
+
|
| 85 |
+
dm::dtm_op_e dtm_op;
|
| 86 |
+
assign dtm_op = dm::dtm_op_e'(dmi_req_i.op);
|
| 87 |
+
|
| 88 |
+
logic resp_queue_full;
|
| 89 |
+
logic resp_queue_empty;
|
| 90 |
+
logic resp_queue_push;
|
| 91 |
+
logic resp_queue_pop;
|
| 92 |
+
logic [31:0] resp_queue_data;
|
| 93 |
+
|
| 94 |
+
localparam dm::dm_csr_e DataEnd = dm::dm_csr_e'(dm::Data0 + {4'b0, dm::DataCount} - 8'h01);
|
| 95 |
+
localparam dm::dm_csr_e ProgBufEnd = dm::dm_csr_e'(dm::ProgBuf0 + {4'b0, dm::ProgBufSize} - 8'h01);
|
| 96 |
+
|
| 97 |
+
logic [31:0] haltsum0, haltsum1, haltsum2, haltsum3;
|
| 98 |
+
logic [((NrHarts-1)/2**5 + 1) * 32 - 1 : 0] halted;
|
| 99 |
+
logic [(NrHarts-1)/2**5:0][31:0] halted_reshaped0;
|
| 100 |
+
logic [NrHarts/2**10:0][31:0] halted_reshaped1;
|
| 101 |
+
logic [NrHarts/2**15:0][31:0] halted_reshaped2;
|
| 102 |
+
logic [(NrHarts/2**10+1)*32-1:0] halted_flat1;
|
| 103 |
+
logic [(NrHarts/2**15+1)*32-1:0] halted_flat2;
|
| 104 |
+
logic [32-1:0] halted_flat3;
|
| 105 |
+
|
| 106 |
+
// haltsum0
|
| 107 |
+
logic [14:0] hartsel_idx0;
|
| 108 |
+
always_comb begin : p_haltsum0
|
| 109 |
+
halted = '0;
|
| 110 |
+
haltsum0 = '0;
|
| 111 |
+
hartsel_idx0 = hartsel_o[19:5];
|
| 112 |
+
halted[NrHarts-1:0] = halted_i;
|
| 113 |
+
halted_reshaped0 = halted;
|
| 114 |
+
if (hartsel_idx0 < 15'((NrHarts-1)/2**5+1)) begin
|
| 115 |
+
haltsum0 = halted_reshaped0[hartsel_idx0];
|
| 116 |
+
end
|
| 117 |
+
end
|
| 118 |
+
|
| 119 |
+
// haltsum1
|
| 120 |
+
logic [9:0] hartsel_idx1;
|
| 121 |
+
always_comb begin : p_reduction1
|
| 122 |
+
halted_flat1 = '0;
|
| 123 |
+
haltsum1 = '0;
|
| 124 |
+
hartsel_idx1 = hartsel_o[19:10];
|
| 125 |
+
|
| 126 |
+
for (int unsigned k = 0; k < NrHarts/2**5+1; k++) begin
|
| 127 |
+
halted_flat1[k] = |halted_reshaped0[k];
|
| 128 |
+
end
|
| 129 |
+
halted_reshaped1 = halted_flat1;
|
| 130 |
+
|
| 131 |
+
if (hartsel_idx1 < 10'((NrHarts/2**10+1))) begin
|
| 132 |
+
haltsum1 = halted_reshaped1[hartsel_idx1];
|
| 133 |
+
end
|
| 134 |
+
end
|
| 135 |
+
|
| 136 |
+
// haltsum2
|
| 137 |
+
logic [4:0] hartsel_idx2;
|
| 138 |
+
always_comb begin : p_reduction2
|
| 139 |
+
halted_flat2 = '0;
|
| 140 |
+
haltsum2 = '0;
|
| 141 |
+
hartsel_idx2 = hartsel_o[19:15];
|
| 142 |
+
|
| 143 |
+
for (int unsigned k = 0; k < NrHarts/2**10+1; k++) begin
|
| 144 |
+
halted_flat2[k] = |halted_reshaped1[k];
|
| 145 |
+
end
|
| 146 |
+
halted_reshaped2 = halted_flat2;
|
| 147 |
+
|
| 148 |
+
if (hartsel_idx2 < 5'((NrHarts/2**15+1))) begin
|
| 149 |
+
haltsum2 = halted_reshaped2[hartsel_idx2];
|
| 150 |
+
end
|
| 151 |
+
end
|
| 152 |
+
|
| 153 |
+
// haltsum3
|
| 154 |
+
always_comb begin : p_reduction3
|
| 155 |
+
halted_flat3 = '0;
|
| 156 |
+
for (int unsigned k = 0; k < NrHarts/2**15+1; k++) begin
|
| 157 |
+
halted_flat3[k] = |halted_reshaped2[k];
|
| 158 |
+
end
|
| 159 |
+
haltsum3 = halted_flat3;
|
| 160 |
+
end
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
dm::dmstatus_t dmstatus;
|
| 164 |
+
dm::dmcontrol_t dmcontrol_d, dmcontrol_q;
|
| 165 |
+
dm::abstractcs_t abstractcs;
|
| 166 |
+
dm::cmderr_e cmderr_d, cmderr_q;
|
| 167 |
+
dm::command_t command_d, command_q;
|
| 168 |
+
logic cmd_valid_d, cmd_valid_q;
|
| 169 |
+
dm::abstractauto_t abstractauto_d, abstractauto_q;
|
| 170 |
+
dm::sbcs_t sbcs_d, sbcs_q;
|
| 171 |
+
logic [63:0] sbaddr_d, sbaddr_q;
|
| 172 |
+
logic [63:0] sbdata_d, sbdata_q;
|
| 173 |
+
|
| 174 |
+
logic [NrHarts-1:0] havereset_d, havereset_q;
|
| 175 |
+
// program buffer
|
| 176 |
+
logic [dm::ProgBufSize-1:0][31:0] progbuf_d, progbuf_q;
|
| 177 |
+
logic [dm::DataCount-1:0][31:0] data_d, data_q;
|
| 178 |
+
|
| 179 |
+
logic [HartSelLen-1:0] selected_hart;
|
| 180 |
+
|
| 181 |
+
// a successful response returns zero
|
| 182 |
+
assign dmi_resp_o.resp = dm::DTM_SUCCESS;
|
| 183 |
+
assign dmi_resp_valid_o = ~resp_queue_empty;
|
| 184 |
+
assign dmi_req_ready_o = ~resp_queue_full;
|
| 185 |
+
assign resp_queue_push = dmi_req_valid_i & dmi_req_ready_o;
|
| 186 |
+
// SBA
|
| 187 |
+
assign sbautoincrement_o = sbcs_q.sbautoincrement;
|
| 188 |
+
assign sbreadonaddr_o = sbcs_q.sbreadonaddr;
|
| 189 |
+
assign sbreadondata_o = sbcs_q.sbreadondata;
|
| 190 |
+
assign sbaccess_o = sbcs_q.sbaccess;
|
| 191 |
+
assign sbdata_o = sbdata_q[BusWidth-1:0];
|
| 192 |
+
assign sbaddress_o = sbaddr_q[BusWidth-1:0];
|
| 193 |
+
|
| 194 |
+
assign hartsel_o = {dmcontrol_q.hartselhi, dmcontrol_q.hartsello};
|
| 195 |
+
|
| 196 |
+
// needed to avoid lint warnings
|
| 197 |
+
logic [NrHartsAligned-1:0] havereset_d_aligned, havereset_q_aligned,
|
| 198 |
+
resumeack_aligned, unavailable_aligned,
|
| 199 |
+
halted_aligned;
|
| 200 |
+
assign resumeack_aligned = NrHartsAligned'(resumeack_i);
|
| 201 |
+
assign unavailable_aligned = NrHartsAligned'(unavailable_i);
|
| 202 |
+
assign halted_aligned = NrHartsAligned'(halted_i);
|
| 203 |
+
|
| 204 |
+
assign havereset_d = NrHarts'(havereset_d_aligned);
|
| 205 |
+
assign havereset_q_aligned = NrHartsAligned'(havereset_q);
|
| 206 |
+
|
| 207 |
+
dm::hartinfo_t [NrHartsAligned-1:0] hartinfo_aligned;
|
| 208 |
+
always_comb begin : p_hartinfo_align
|
| 209 |
+
hartinfo_aligned = '0;
|
| 210 |
+
hartinfo_aligned[NrHarts-1:0] = hartinfo_i;
|
| 211 |
+
end
|
| 212 |
+
|
| 213 |
+
// helper variables
|
| 214 |
+
dm::sbcs_t sbcs;
|
| 215 |
+
dm::dmcontrol_t dmcontrol;
|
| 216 |
+
dm::abstractcs_t a_abstractcs;
|
| 217 |
+
logic [4:0] autoexecdata_idx;
|
| 218 |
+
always_comb begin : csr_read_write
|
| 219 |
+
// --------------------
|
| 220 |
+
// Static Values (R/O)
|
| 221 |
+
// --------------------
|
| 222 |
+
// dmstatus
|
| 223 |
+
dmstatus = '0;
|
| 224 |
+
dmstatus.version = dm::DbgVersion013;
|
| 225 |
+
// no authentication implemented
|
| 226 |
+
dmstatus.authenticated = 1'b1;
|
| 227 |
+
// we do not support halt-on-reset sequence
|
| 228 |
+
dmstatus.hasresethaltreq = 1'b0;
|
| 229 |
+
// TODO(zarubaf) things need to change here if we implement the array mask
|
| 230 |
+
dmstatus.allhavereset = havereset_q_aligned[selected_hart];
|
| 231 |
+
dmstatus.anyhavereset = havereset_q_aligned[selected_hart];
|
| 232 |
+
|
| 233 |
+
dmstatus.allresumeack = resumeack_aligned[selected_hart];
|
| 234 |
+
dmstatus.anyresumeack = resumeack_aligned[selected_hart];
|
| 235 |
+
|
| 236 |
+
dmstatus.allunavail = unavailable_aligned[selected_hart];
|
| 237 |
+
dmstatus.anyunavail = unavailable_aligned[selected_hart];
|
| 238 |
+
|
| 239 |
+
// as soon as we are out of the legal Hart region tell the debugger
|
| 240 |
+
// that there are only non-existent harts
|
| 241 |
+
dmstatus.allnonexistent = logic'(32'(hartsel_o) > (NrHarts - 1));
|
| 242 |
+
dmstatus.anynonexistent = logic'(32'(hartsel_o) > (NrHarts - 1));
|
| 243 |
+
|
| 244 |
+
// We are not allowed to be in multiple states at once. This is a to
|
| 245 |
+
// make the running/halted and unavailable states exclusive.
|
| 246 |
+
dmstatus.allhalted = halted_aligned[selected_hart] & ~unavailable_aligned[selected_hart];
|
| 247 |
+
dmstatus.anyhalted = halted_aligned[selected_hart] & ~unavailable_aligned[selected_hart];
|
| 248 |
+
|
| 249 |
+
dmstatus.allrunning = ~halted_aligned[selected_hart] & ~unavailable_aligned[selected_hart];
|
| 250 |
+
dmstatus.anyrunning = ~halted_aligned[selected_hart] & ~unavailable_aligned[selected_hart];
|
| 251 |
+
|
| 252 |
+
// abstractcs
|
| 253 |
+
abstractcs = '0;
|
| 254 |
+
abstractcs.datacount = dm::DataCount;
|
| 255 |
+
abstractcs.progbufsize = dm::ProgBufSize;
|
| 256 |
+
abstractcs.busy = cmdbusy_i;
|
| 257 |
+
abstractcs.cmderr = cmderr_q;
|
| 258 |
+
|
| 259 |
+
// abstractautoexec
|
| 260 |
+
abstractauto_d = abstractauto_q;
|
| 261 |
+
abstractauto_d.zero0 = '0;
|
| 262 |
+
|
| 263 |
+
// default assignments
|
| 264 |
+
havereset_d_aligned = NrHartsAligned'(havereset_q);
|
| 265 |
+
dmcontrol_d = dmcontrol_q;
|
| 266 |
+
cmderr_d = cmderr_q;
|
| 267 |
+
command_d = command_q;
|
| 268 |
+
progbuf_d = progbuf_q;
|
| 269 |
+
data_d = data_q;
|
| 270 |
+
sbcs_d = sbcs_q;
|
| 271 |
+
sbaddr_d = 64'(sbaddress_i);
|
| 272 |
+
sbdata_d = sbdata_q;
|
| 273 |
+
|
| 274 |
+
resp_queue_data = 32'b0;
|
| 275 |
+
cmd_valid_d = 1'b0;
|
| 276 |
+
sbaddress_write_valid_o = 1'b0;
|
| 277 |
+
sbdata_read_valid_o = 1'b0;
|
| 278 |
+
sbdata_write_valid_o = 1'b0;
|
| 279 |
+
clear_resumeack_o = 1'b0;
|
| 280 |
+
|
| 281 |
+
// helper variables
|
| 282 |
+
sbcs = '0;
|
| 283 |
+
dmcontrol = '0;
|
| 284 |
+
a_abstractcs = '0;
|
| 285 |
+
|
| 286 |
+
autoexecdata_idx = dmi_req_i.addr[4:0] - 5'(dm::Data0);
|
| 287 |
+
|
| 288 |
+
// localparam int unsigned DataCountAlign = $clog2(dm::DataCount);
|
| 289 |
+
// reads
|
| 290 |
+
if (dmi_req_ready_o && dmi_req_valid_i && dtm_op == dm::DTM_READ) begin
|
| 291 |
+
unique case ({1'b0, dmi_req_i.addr}) inside
|
| 292 |
+
[(dm::Data0):DataEnd]: begin
|
| 293 |
+
// logic [$clog2(dm::DataCount)-1:0] resp_queue_idx;
|
| 294 |
+
// resp_queue_idx = dmi_req_i.addr[4:0] - int'(dm::Data0);
|
| 295 |
+
resp_queue_data = data_q[$clog2(dm::DataCount)'(autoexecdata_idx)];
|
| 296 |
+
if (!cmdbusy_i) begin
|
| 297 |
+
// check whether we need to re-execute the command (just give a cmd_valid)
|
| 298 |
+
if (autoexecdata_idx < $bits(abstractauto_q.autoexecdata)) begin
|
| 299 |
+
cmd_valid_d = abstractauto_q.autoexecdata[autoexecdata_idx];
|
| 300 |
+
end
|
| 301 |
+
end
|
| 302 |
+
end
|
| 303 |
+
dm::DMControl: resp_queue_data = dmcontrol_q;
|
| 304 |
+
dm::DMStatus: resp_queue_data = dmstatus;
|
| 305 |
+
dm::Hartinfo: resp_queue_data = hartinfo_aligned[selected_hart];
|
| 306 |
+
dm::AbstractCS: resp_queue_data = abstractcs;
|
| 307 |
+
dm::AbstractAuto: resp_queue_data = abstractauto_q;
|
| 308 |
+
// command is read-only
|
| 309 |
+
dm::Command: resp_queue_data = '0;
|
| 310 |
+
[(dm::ProgBuf0):ProgBufEnd]: begin
|
| 311 |
+
resp_queue_data = progbuf_q[dmi_req_i.addr[$clog2(dm::ProgBufSize)-1:0]];
|
| 312 |
+
if (!cmdbusy_i) begin
|
| 313 |
+
// check whether we need to re-execute the command (just give a cmd_valid)
|
| 314 |
+
// range of autoexecprogbuf is 31:16
|
| 315 |
+
cmd_valid_d = abstractauto_q.autoexecprogbuf[{1'b1, dmi_req_i.addr[3:0]}];
|
| 316 |
+
end
|
| 317 |
+
end
|
| 318 |
+
dm::HaltSum0: resp_queue_data = haltsum0;
|
| 319 |
+
dm::HaltSum1: resp_queue_data = haltsum1;
|
| 320 |
+
dm::HaltSum2: resp_queue_data = haltsum2;
|
| 321 |
+
dm::HaltSum3: resp_queue_data = haltsum3;
|
| 322 |
+
dm::SBCS: begin
|
| 323 |
+
resp_queue_data = sbcs_q;
|
| 324 |
+
end
|
| 325 |
+
dm::SBAddress0: begin
|
| 326 |
+
// access while the SBA was busy
|
| 327 |
+
if (sbbusy_i) begin
|
| 328 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 329 |
+
end else begin
|
| 330 |
+
resp_queue_data = sbaddr_q[31:0];
|
| 331 |
+
end
|
| 332 |
+
end
|
| 333 |
+
dm::SBAddress1: begin
|
| 334 |
+
// access while the SBA was busy
|
| 335 |
+
if (sbbusy_i) begin
|
| 336 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 337 |
+
end else begin
|
| 338 |
+
resp_queue_data = sbaddr_q[63:32];
|
| 339 |
+
end
|
| 340 |
+
end
|
| 341 |
+
dm::SBData0: begin
|
| 342 |
+
// access while the SBA was busy
|
| 343 |
+
if (sbbusy_i) begin
|
| 344 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 345 |
+
end else begin
|
| 346 |
+
sbdata_read_valid_o = (sbcs_q.sberror == '0);
|
| 347 |
+
resp_queue_data = sbdata_q[31:0];
|
| 348 |
+
end
|
| 349 |
+
end
|
| 350 |
+
dm::SBData1: begin
|
| 351 |
+
// access while the SBA was busy
|
| 352 |
+
if (sbbusy_i) begin
|
| 353 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 354 |
+
end else begin
|
| 355 |
+
resp_queue_data = sbdata_q[63:32];
|
| 356 |
+
end
|
| 357 |
+
end
|
| 358 |
+
default:;
|
| 359 |
+
endcase
|
| 360 |
+
end
|
| 361 |
+
|
| 362 |
+
// write
|
| 363 |
+
if (dmi_req_ready_o && dmi_req_valid_i && dtm_op == dm::DTM_WRITE) begin
|
| 364 |
+
unique case (dm::dm_csr_e'({1'b0, dmi_req_i.addr})) inside
|
| 365 |
+
[(dm::Data0):DataEnd]: begin
|
| 366 |
+
// attempts to write them while busy is set does not change their value
|
| 367 |
+
if (!cmdbusy_i && dm::DataCount > 0) begin
|
| 368 |
+
data_d[dmi_req_i.addr[$clog2(dm::DataCount)-1:0]] = dmi_req_i.data;
|
| 369 |
+
// check whether we need to re-execute the command (just give a cmd_valid)
|
| 370 |
+
if (autoexecdata_idx < $bits(abstractauto_q.autoexecdata)) begin
|
| 371 |
+
cmd_valid_d = abstractauto_q.autoexecdata[autoexecdata_idx];
|
| 372 |
+
end
|
| 373 |
+
end
|
| 374 |
+
end
|
| 375 |
+
dm::DMControl: begin
|
| 376 |
+
dmcontrol = dm::dmcontrol_t'(dmi_req_i.data);
|
| 377 |
+
// clear the havreset of the selected hart
|
| 378 |
+
if (dmcontrol.ackhavereset) begin
|
| 379 |
+
havereset_d_aligned[selected_hart] = 1'b0;
|
| 380 |
+
end
|
| 381 |
+
dmcontrol_d = dmi_req_i.data;
|
| 382 |
+
end
|
| 383 |
+
dm::DMStatus:; // write are ignored to R/O register
|
| 384 |
+
dm::Hartinfo:; // hartinfo is R/O
|
| 385 |
+
// only command error is write-able
|
| 386 |
+
dm::AbstractCS: begin // W1C
|
| 387 |
+
// Gets set if an abstract command fails. The bits in this
|
| 388 |
+
// field remain set until they are cleared by writing 1 to
|
| 389 |
+
// them. No abstract command is started until the value is
|
| 390 |
+
// reset to 0.
|
| 391 |
+
a_abstractcs = dm::abstractcs_t'(dmi_req_i.data);
|
| 392 |
+
// reads during abstract command execution are not allowed
|
| 393 |
+
if (!cmdbusy_i) begin
|
| 394 |
+
cmderr_d = dm::cmderr_e'(~a_abstractcs.cmderr & cmderr_q);
|
| 395 |
+
end else if (cmderr_q == dm::CmdErrNone) begin
|
| 396 |
+
cmderr_d = dm::CmdErrBusy;
|
| 397 |
+
end
|
| 398 |
+
end
|
| 399 |
+
dm::Command: begin
|
| 400 |
+
// writes are ignored if a command is already busy
|
| 401 |
+
if (!cmdbusy_i) begin
|
| 402 |
+
cmd_valid_d = 1'b1;
|
| 403 |
+
command_d = dm::command_t'(dmi_req_i.data);
|
| 404 |
+
// if there was an attempted to write during a busy execution
|
| 405 |
+
// and the cmderror field is zero set the busy error
|
| 406 |
+
end else if (cmderr_q == dm::CmdErrNone) begin
|
| 407 |
+
cmderr_d = dm::CmdErrBusy;
|
| 408 |
+
end
|
| 409 |
+
end
|
| 410 |
+
dm::AbstractAuto: begin
|
| 411 |
+
// this field can only be written legally when there is no command executing
|
| 412 |
+
if (!cmdbusy_i) begin
|
| 413 |
+
abstractauto_d = 32'b0;
|
| 414 |
+
abstractauto_d.autoexecdata = 12'(dmi_req_i.data[dm::DataCount-1:0]);
|
| 415 |
+
abstractauto_d.autoexecprogbuf = 16'(dmi_req_i.data[dm::ProgBufSize-1+16:16]);
|
| 416 |
+
end else if (cmderr_q == dm::CmdErrNone) begin
|
| 417 |
+
cmderr_d = dm::CmdErrBusy;
|
| 418 |
+
end
|
| 419 |
+
end
|
| 420 |
+
[(dm::ProgBuf0):ProgBufEnd]: begin
|
| 421 |
+
// attempts to write them while busy is set does not change their value
|
| 422 |
+
if (!cmdbusy_i) begin
|
| 423 |
+
progbuf_d[dmi_req_i.addr[$clog2(dm::ProgBufSize)-1:0]] = dmi_req_i.data;
|
| 424 |
+
// check whether we need to re-execute the command (just give a cmd_valid)
|
| 425 |
+
// this should probably throw an error if executed during another command
|
| 426 |
+
// was busy
|
| 427 |
+
// range of autoexecprogbuf is 31:16
|
| 428 |
+
cmd_valid_d = abstractauto_q.autoexecprogbuf[{1'b1, dmi_req_i.addr[3:0]}];
|
| 429 |
+
end
|
| 430 |
+
end
|
| 431 |
+
dm::SBCS: begin
|
| 432 |
+
// access while the SBA was busy
|
| 433 |
+
if (sbbusy_i) begin
|
| 434 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 435 |
+
end else begin
|
| 436 |
+
sbcs = dm::sbcs_t'(dmi_req_i.data);
|
| 437 |
+
sbcs_d = sbcs;
|
| 438 |
+
// R/W1C
|
| 439 |
+
sbcs_d.sbbusyerror = sbcs_q.sbbusyerror & (~sbcs.sbbusyerror);
|
| 440 |
+
sbcs_d.sberror = sbcs_q.sberror & (~sbcs.sberror);
|
| 441 |
+
end
|
| 442 |
+
end
|
| 443 |
+
dm::SBAddress0: begin
|
| 444 |
+
// access while the SBA was busy
|
| 445 |
+
if (sbbusy_i) begin
|
| 446 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 447 |
+
end else begin
|
| 448 |
+
sbaddr_d[31:0] = dmi_req_i.data;
|
| 449 |
+
sbaddress_write_valid_o = (sbcs_q.sberror == '0);
|
| 450 |
+
end
|
| 451 |
+
end
|
| 452 |
+
dm::SBAddress1: begin
|
| 453 |
+
// access while the SBA was busy
|
| 454 |
+
if (sbbusy_i) begin
|
| 455 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 456 |
+
end else begin
|
| 457 |
+
sbaddr_d[63:32] = dmi_req_i.data;
|
| 458 |
+
end
|
| 459 |
+
end
|
| 460 |
+
dm::SBData0: begin
|
| 461 |
+
// access while the SBA was busy
|
| 462 |
+
if (sbbusy_i) begin
|
| 463 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 464 |
+
end else begin
|
| 465 |
+
sbdata_d[31:0] = dmi_req_i.data;
|
| 466 |
+
sbdata_write_valid_o = (sbcs_q.sberror == '0);
|
| 467 |
+
end
|
| 468 |
+
end
|
| 469 |
+
dm::SBData1: begin
|
| 470 |
+
// access while the SBA was busy
|
| 471 |
+
if (sbbusy_i) begin
|
| 472 |
+
sbcs_d.sbbusyerror = 1'b1;
|
| 473 |
+
end else begin
|
| 474 |
+
sbdata_d[63:32] = dmi_req_i.data;
|
| 475 |
+
end
|
| 476 |
+
end
|
| 477 |
+
default:;
|
| 478 |
+
endcase
|
| 479 |
+
end
|
| 480 |
+
// hart threw a command error and has precedence over bus writes
|
| 481 |
+
if (cmderror_valid_i) begin
|
| 482 |
+
cmderr_d = cmderror_i;
|
| 483 |
+
end
|
| 484 |
+
|
| 485 |
+
// update data registers
|
| 486 |
+
if (data_valid_i) begin
|
| 487 |
+
data_d = data_i;
|
| 488 |
+
end
|
| 489 |
+
|
| 490 |
+
// set the havereset flag when we did a ndmreset
|
| 491 |
+
if (ndmreset_o) begin
|
| 492 |
+
havereset_d_aligned[NrHarts-1:0] = '1;
|
| 493 |
+
end
|
| 494 |
+
// -------------
|
| 495 |
+
// System Bus
|
| 496 |
+
// -------------
|
| 497 |
+
// set bus error
|
| 498 |
+
if (sberror_valid_i) begin
|
| 499 |
+
sbcs_d.sberror = sberror_i;
|
| 500 |
+
end
|
| 501 |
+
// update read data
|
| 502 |
+
if (sbdata_valid_i) begin
|
| 503 |
+
sbdata_d = 64'(sbdata_i);
|
| 504 |
+
end
|
| 505 |
+
|
| 506 |
+
// dmcontrol
|
| 507 |
+
// TODO(zarubaf) we currently do not implement the hartarry mask
|
| 508 |
+
dmcontrol_d.hasel = 1'b0;
|
| 509 |
+
// we do not support resetting an individual hart
|
| 510 |
+
dmcontrol_d.hartreset = 1'b0;
|
| 511 |
+
dmcontrol_d.setresethaltreq = 1'b0;
|
| 512 |
+
dmcontrol_d.clrresethaltreq = 1'b0;
|
| 513 |
+
dmcontrol_d.zero1 = '0;
|
| 514 |
+
dmcontrol_d.zero0 = '0;
|
| 515 |
+
// Non-writeable, clear only
|
| 516 |
+
dmcontrol_d.ackhavereset = 1'b0;
|
| 517 |
+
if (!dmcontrol_q.resumereq && dmcontrol_d.resumereq) begin
|
| 518 |
+
clear_resumeack_o = 1'b1;
|
| 519 |
+
end
|
| 520 |
+
if (dmcontrol_q.resumereq && resumeack_i) begin
|
| 521 |
+
dmcontrol_d.resumereq = 1'b0;
|
| 522 |
+
end
|
| 523 |
+
// static values for dcsr
|
| 524 |
+
sbcs_d.sbversion = 3'b1;
|
| 525 |
+
sbcs_d.sbbusy = sbbusy_i;
|
| 526 |
+
sbcs_d.sbasize = $bits(sbcs_d.sbasize)'(BusWidth);
|
| 527 |
+
sbcs_d.sbaccess128 = 1'b0;
|
| 528 |
+
sbcs_d.sbaccess64 = logic'(BusWidth == 32'd64);
|
| 529 |
+
sbcs_d.sbaccess32 = logic'(BusWidth == 32'd32);
|
| 530 |
+
sbcs_d.sbaccess16 = 1'b0;
|
| 531 |
+
sbcs_d.sbaccess8 = 1'b0;
|
| 532 |
+
sbcs_d.sbaccess = (BusWidth == 32'd64) ? 3'd3 : 3'd2;
|
| 533 |
+
end
|
| 534 |
+
|
| 535 |
+
// output multiplexer
|
| 536 |
+
always_comb begin : p_outmux
|
| 537 |
+
selected_hart = hartsel_o[HartSelLen-1:0];
|
| 538 |
+
// default assignment
|
| 539 |
+
haltreq_o = '0;
|
| 540 |
+
resumereq_o = '0;
|
| 541 |
+
if (selected_hart < (HartSelLen+1)'(NrHarts)) begin
|
| 542 |
+
haltreq_o[selected_hart] = dmcontrol_q.haltreq;
|
| 543 |
+
resumereq_o[selected_hart] = dmcontrol_q.resumereq;
|
| 544 |
+
end
|
| 545 |
+
end
|
| 546 |
+
|
| 547 |
+
assign dmactive_o = dmcontrol_q.dmactive;
|
| 548 |
+
assign cmd_o = command_q;
|
| 549 |
+
assign cmd_valid_o = cmd_valid_q;
|
| 550 |
+
assign progbuf_o = progbuf_q;
|
| 551 |
+
assign data_o = data_q;
|
| 552 |
+
|
| 553 |
+
assign resp_queue_pop = dmi_resp_ready_i & ~resp_queue_empty;
|
| 554 |
+
|
| 555 |
+
assign ndmreset_o = dmcontrol_q.ndmreset;
|
| 556 |
+
|
| 557 |
+
// response FIFO
|
| 558 |
+
fifo_v2 #(
|
| 559 |
+
.dtype ( logic [31:0] ),
|
| 560 |
+
.DEPTH ( 2 )
|
| 561 |
+
) i_fifo (
|
| 562 |
+
.clk_i ( clk_i ),
|
| 563 |
+
.rst_ni ( dmi_rst_ni ), // reset only when system is re-set
|
| 564 |
+
.flush_i ( 1'b0 ), // we do not need to flush this queue
|
| 565 |
+
.testmode_i ( testmode_i ),
|
| 566 |
+
.full_o ( resp_queue_full ),
|
| 567 |
+
.empty_o ( resp_queue_empty ),
|
| 568 |
+
.alm_full_o ( ),
|
| 569 |
+
.alm_empty_o ( ),
|
| 570 |
+
.data_i ( resp_queue_data ),
|
| 571 |
+
.push_i ( resp_queue_push ),
|
| 572 |
+
.data_o ( dmi_resp_o.data ),
|
| 573 |
+
.pop_i ( resp_queue_pop )
|
| 574 |
+
);
|
| 575 |
+
|
| 576 |
+
always_ff @(posedge clk_i or negedge rst_ni) begin : p_regs
|
| 577 |
+
// PoR
|
| 578 |
+
if (!rst_ni) begin
|
| 579 |
+
dmcontrol_q <= '0;
|
| 580 |
+
// this is the only write-able bit during reset
|
| 581 |
+
cmderr_q <= dm::CmdErrNone;
|
| 582 |
+
command_q <= '0;
|
| 583 |
+
abstractauto_q <= '0;
|
| 584 |
+
progbuf_q <= '0;
|
| 585 |
+
data_q <= '0;
|
| 586 |
+
sbcs_q <= '0;
|
| 587 |
+
sbaddr_q <= '0;
|
| 588 |
+
sbdata_q <= '0;
|
| 589 |
+
havereset_q <= '1;
|
| 590 |
+
end else begin
|
| 591 |
+
havereset_q <= SelectableHarts & havereset_d;
|
| 592 |
+
// synchronous re-set of debug module, active-low, except for dmactive
|
| 593 |
+
if (!dmcontrol_q.dmactive) begin
|
| 594 |
+
dmcontrol_q.haltreq <= '0;
|
| 595 |
+
dmcontrol_q.resumereq <= '0;
|
| 596 |
+
dmcontrol_q.hartreset <= '0;
|
| 597 |
+
dmcontrol_q.ackhavereset <= '0;
|
| 598 |
+
dmcontrol_q.zero1 <= '0;
|
| 599 |
+
dmcontrol_q.hasel <= '0;
|
| 600 |
+
dmcontrol_q.hartsello <= '0;
|
| 601 |
+
dmcontrol_q.hartselhi <= '0;
|
| 602 |
+
dmcontrol_q.zero0 <= '0;
|
| 603 |
+
dmcontrol_q.setresethaltreq <= '0;
|
| 604 |
+
dmcontrol_q.clrresethaltreq <= '0;
|
| 605 |
+
dmcontrol_q.ndmreset <= '0;
|
| 606 |
+
// this is the only write-able bit during reset
|
| 607 |
+
dmcontrol_q.dmactive <= dmcontrol_d.dmactive;
|
| 608 |
+
cmderr_q <= dm::CmdErrNone;
|
| 609 |
+
command_q <= '0;
|
| 610 |
+
cmd_valid_q <= '0;
|
| 611 |
+
abstractauto_q <= '0;
|
| 612 |
+
progbuf_q <= '0;
|
| 613 |
+
data_q <= '0;
|
| 614 |
+
sbcs_q <= '0;
|
| 615 |
+
sbaddr_q <= '0;
|
| 616 |
+
sbdata_q <= '0;
|
| 617 |
+
end else begin
|
| 618 |
+
dmcontrol_q <= dmcontrol_d;
|
| 619 |
+
cmderr_q <= cmderr_d;
|
| 620 |
+
command_q <= command_d;
|
| 621 |
+
cmd_valid_q <= cmd_valid_d;
|
| 622 |
+
abstractauto_q <= abstractauto_d;
|
| 623 |
+
progbuf_q <= progbuf_d;
|
| 624 |
+
data_q <= data_d;
|
| 625 |
+
sbcs_q <= sbcs_d;
|
| 626 |
+
sbaddr_q <= sbaddr_d;
|
| 627 |
+
sbdata_q <= sbdata_d;
|
| 628 |
+
end
|
| 629 |
+
end
|
| 630 |
+
end
|
| 631 |
+
|
| 632 |
+
///////////////////////////////////////////////////////
|
| 633 |
+
// assertions
|
| 634 |
+
///////////////////////////////////////////////////////
|
| 635 |
+
|
| 636 |
+
//pragma translate_off
|
| 637 |
+
`ifndef VERILATOR
|
| 638 |
+
haltsum: assert property (
|
| 639 |
+
@(posedge clk_i) disable iff (!rst_ni)
|
| 640 |
+
(dmi_req_ready_o && dmi_req_valid_i && dtm_op == dm::DTM_READ) |->
|
| 641 |
+
!({1'b0, dmi_req_i.addr} inside
|
| 642 |
+
{dm::HaltSum0, dm::HaltSum1, dm::HaltSum2, dm::HaltSum3}))
|
| 643 |
+
else $warning("Haltsums have not been properly tested yet.");
|
| 644 |
+
`endif
|
| 645 |
+
//pragma translate_on
|
| 646 |
+
|
| 647 |
+
endmodule : dm_csrs
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dm_mem.sv
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: dm_mem.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 11.7.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: Memory module for execution-based debug clients
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
module dm_mem #(
|
| 20 |
+
parameter int unsigned NrHarts = 1,
|
| 21 |
+
parameter int unsigned BusWidth = 32,
|
| 22 |
+
parameter logic [NrHarts-1:0] SelectableHarts = {NrHarts{1'b1}}
|
| 23 |
+
) (
|
| 24 |
+
input logic clk_i, // Clock
|
| 25 |
+
input logic rst_ni, // debug module reset
|
| 26 |
+
|
| 27 |
+
output logic [NrHarts-1:0] debug_req_o,
|
| 28 |
+
input logic [19:0] hartsel_i,
|
| 29 |
+
// from Ctrl and Status register
|
| 30 |
+
input logic [NrHarts-1:0] haltreq_i,
|
| 31 |
+
input logic [NrHarts-1:0] resumereq_i,
|
| 32 |
+
input logic clear_resumeack_i,
|
| 33 |
+
|
| 34 |
+
// state bits
|
| 35 |
+
output logic [NrHarts-1:0] halted_o, // hart acknowledge halt
|
| 36 |
+
output logic [NrHarts-1:0] resuming_o, // hart is resuming
|
| 37 |
+
|
| 38 |
+
input logic [dm::ProgBufSize-1:0][31:0] progbuf_i, // program buffer to expose
|
| 39 |
+
|
| 40 |
+
input logic [dm::DataCount-1:0][31:0] data_i, // data in
|
| 41 |
+
output logic [dm::DataCount-1:0][31:0] data_o, // data out
|
| 42 |
+
output logic data_valid_o, // data out is valid
|
| 43 |
+
// abstract command interface
|
| 44 |
+
input logic cmd_valid_i,
|
| 45 |
+
input dm::command_t cmd_i,
|
| 46 |
+
output logic cmderror_valid_o,
|
| 47 |
+
output dm::cmderr_e cmderror_o,
|
| 48 |
+
output logic cmdbusy_o,
|
| 49 |
+
// data interface
|
| 50 |
+
|
| 51 |
+
// SRAM interface
|
| 52 |
+
input logic req_i,
|
| 53 |
+
input logic we_i,
|
| 54 |
+
input logic [BusWidth-1:0] addr_i,
|
| 55 |
+
input logic [BusWidth-1:0] wdata_i,
|
| 56 |
+
input logic [BusWidth/8-1:0] be_i,
|
| 57 |
+
output logic [BusWidth-1:0] rdata_o
|
| 58 |
+
);
|
| 59 |
+
localparam int unsigned DbgAddressBits = 12;
|
| 60 |
+
localparam int unsigned HartSelLen = (NrHarts == 1) ? 1 : $clog2(NrHarts);
|
| 61 |
+
localparam int unsigned NrHartsAligned = 2**HartSelLen;
|
| 62 |
+
localparam int unsigned MaxAar = (BusWidth == 64) ? 4 : 3;
|
| 63 |
+
|
| 64 |
+
localparam logic [DbgAddressBits-1:0] DataBaseAddr = (dm::DataAddr);
|
| 65 |
+
localparam logic [DbgAddressBits-1:0] DataEndAddr = (dm::DataAddr + 4*dm::DataCount - 1);
|
| 66 |
+
localparam logic [DbgAddressBits-1:0] ProgBufBaseAddr = (dm::DataAddr - 4*dm::ProgBufSize);
|
| 67 |
+
localparam logic [DbgAddressBits-1:0] ProgBufEndAddr = (dm::DataAddr - 1);
|
| 68 |
+
localparam logic [DbgAddressBits-1:0] AbstractCmdBaseAddr = (ProgBufBaseAddr - 4*10);
|
| 69 |
+
localparam logic [DbgAddressBits-1:0] AbstractCmdEndAddr = (ProgBufBaseAddr - 1);
|
| 70 |
+
|
| 71 |
+
localparam logic [DbgAddressBits-1:0] WhereToAddr = 'h300;
|
| 72 |
+
localparam logic [DbgAddressBits-1:0] FlagsBaseAddr = 'h400;
|
| 73 |
+
localparam logic [DbgAddressBits-1:0] FlagsEndAddr = 'h7FF;
|
| 74 |
+
|
| 75 |
+
localparam logic [DbgAddressBits-1:0] HaltedAddr = 'h100;
|
| 76 |
+
localparam logic [DbgAddressBits-1:0] GoingAddr = 'h104;
|
| 77 |
+
localparam logic [DbgAddressBits-1:0] ResumingAddr = 'h108;
|
| 78 |
+
localparam logic [DbgAddressBits-1:0] ExceptionAddr = 'h10C;
|
| 79 |
+
|
| 80 |
+
logic [dm::ProgBufSize/2-1:0][63:0] progbuf;
|
| 81 |
+
logic [7:0][63:0] abstract_cmd;
|
| 82 |
+
logic [NrHarts-1:0] halted_d, halted_q;
|
| 83 |
+
logic [NrHarts-1:0] resuming_d, resuming_q;
|
| 84 |
+
logic resume, go, going;
|
| 85 |
+
|
| 86 |
+
logic exception;
|
| 87 |
+
logic unsupported_command;
|
| 88 |
+
|
| 89 |
+
logic [63:0] rom_rdata;
|
| 90 |
+
logic [63:0] rdata_d, rdata_q;
|
| 91 |
+
logic word_enable32_q;
|
| 92 |
+
|
| 93 |
+
// this is needed to avoid lint warnings related to array indexing
|
| 94 |
+
// resize hartsel to valid range
|
| 95 |
+
logic [HartSelLen-1:0] hartsel, wdata_hartsel;
|
| 96 |
+
|
| 97 |
+
assign hartsel = hartsel_i[HartSelLen-1:0];
|
| 98 |
+
assign wdata_hartsel = wdata_i[HartSelLen-1:0];
|
| 99 |
+
|
| 100 |
+
logic [NrHartsAligned-1:0] resumereq_aligned, haltreq_aligned,
|
| 101 |
+
halted_d_aligned, halted_q_aligned,
|
| 102 |
+
halted_aligned, resumereq_wdata_aligned,
|
| 103 |
+
resuming_d_aligned, resuming_q_aligned;
|
| 104 |
+
|
| 105 |
+
assign resumereq_aligned = NrHartsAligned'(resumereq_i);
|
| 106 |
+
assign haltreq_aligned = NrHartsAligned'(haltreq_i);
|
| 107 |
+
assign resumereq_wdata_aligned = NrHartsAligned'(resumereq_i);
|
| 108 |
+
|
| 109 |
+
assign halted_q_aligned = NrHartsAligned'(halted_q);
|
| 110 |
+
assign halted_d = NrHarts'(halted_d_aligned);
|
| 111 |
+
assign resuming_q_aligned = NrHartsAligned'(resuming_q);
|
| 112 |
+
assign resuming_d = NrHarts'(resuming_d_aligned);
|
| 113 |
+
|
| 114 |
+
// distinguish whether we need to forward data from the ROM or the FSM
|
| 115 |
+
// latch the address for this
|
| 116 |
+
logic fwd_rom_d, fwd_rom_q;
|
| 117 |
+
dm::ac_ar_cmd_t ac_ar;
|
| 118 |
+
|
| 119 |
+
// Abstract Command Access Register
|
| 120 |
+
assign ac_ar = dm::ac_ar_cmd_t'(cmd_i.control);
|
| 121 |
+
assign debug_req_o = haltreq_i;
|
| 122 |
+
assign halted_o = halted_q;
|
| 123 |
+
assign resuming_o = resuming_q;
|
| 124 |
+
|
| 125 |
+
// reshape progbuf
|
| 126 |
+
assign progbuf = progbuf_i;
|
| 127 |
+
|
| 128 |
+
typedef enum logic [1:0] { Idle, Go, Resume, CmdExecuting } state_e;
|
| 129 |
+
state_e state_d, state_q;
|
| 130 |
+
|
| 131 |
+
// hart ctrl queue
|
| 132 |
+
always_comb begin : p_hart_ctrl_queue
|
| 133 |
+
cmderror_valid_o = 1'b0;
|
| 134 |
+
cmderror_o = dm::CmdErrNone;
|
| 135 |
+
state_d = state_q;
|
| 136 |
+
go = 1'b0;
|
| 137 |
+
resume = 1'b0;
|
| 138 |
+
cmdbusy_o = 1'b1;
|
| 139 |
+
|
| 140 |
+
unique case (state_q)
|
| 141 |
+
Idle: begin
|
| 142 |
+
cmdbusy_o = 1'b0;
|
| 143 |
+
if (cmd_valid_i && halted_q_aligned[hartsel] && !unsupported_command) begin
|
| 144 |
+
// give the go signal
|
| 145 |
+
state_d = Go;
|
| 146 |
+
end else if (cmd_valid_i) begin
|
| 147 |
+
// hart must be halted for all requests
|
| 148 |
+
cmderror_valid_o = 1'b1;
|
| 149 |
+
cmderror_o = dm::CmdErrorHaltResume;
|
| 150 |
+
end
|
| 151 |
+
// CSRs want to resume, the request is ignored when the hart is
|
| 152 |
+
// requested to halt or it didn't clear the resuming_q bit before
|
| 153 |
+
if (resumereq_aligned[hartsel] && !resuming_q_aligned[hartsel] &&
|
| 154 |
+
!haltreq_aligned[hartsel] && halted_q_aligned[hartsel]) begin
|
| 155 |
+
state_d = Resume;
|
| 156 |
+
end
|
| 157 |
+
end
|
| 158 |
+
|
| 159 |
+
Go: begin
|
| 160 |
+
// we are already busy here since we scheduled the execution of a program
|
| 161 |
+
cmdbusy_o = 1'b1;
|
| 162 |
+
go = 1'b1;
|
| 163 |
+
// the thread is now executing the command, track its state
|
| 164 |
+
if (going) begin
|
| 165 |
+
state_d = CmdExecuting;
|
| 166 |
+
end
|
| 167 |
+
end
|
| 168 |
+
|
| 169 |
+
Resume: begin
|
| 170 |
+
cmdbusy_o = 1'b1;
|
| 171 |
+
resume = 1'b1;
|
| 172 |
+
if (resuming_q_aligned[hartsel]) begin
|
| 173 |
+
state_d = Idle;
|
| 174 |
+
end
|
| 175 |
+
end
|
| 176 |
+
|
| 177 |
+
CmdExecuting: begin
|
| 178 |
+
cmdbusy_o = 1'b1;
|
| 179 |
+
go = 1'b0;
|
| 180 |
+
// wait until the hart has halted again
|
| 181 |
+
if (halted_aligned[hartsel]) begin
|
| 182 |
+
state_d = Idle;
|
| 183 |
+
end
|
| 184 |
+
end
|
| 185 |
+
|
| 186 |
+
default: ;
|
| 187 |
+
endcase
|
| 188 |
+
|
| 189 |
+
// only signal once that cmd is unsupported so that we can clear cmderr
|
| 190 |
+
// in subsequent writes to abstractcs
|
| 191 |
+
if (unsupported_command && cmd_valid_i) begin
|
| 192 |
+
cmderror_valid_o = 1'b1;
|
| 193 |
+
cmderror_o = dm::CmdErrNotSupported;
|
| 194 |
+
end
|
| 195 |
+
|
| 196 |
+
if (exception) begin
|
| 197 |
+
cmderror_valid_o = 1'b1;
|
| 198 |
+
cmderror_o = dm::CmdErrorException;
|
| 199 |
+
end
|
| 200 |
+
end
|
| 201 |
+
|
| 202 |
+
// word mux for 32bit and 64bit buses
|
| 203 |
+
logic [63:0] word_mux;
|
| 204 |
+
assign word_mux = (fwd_rom_q) ? rom_rdata : rdata_q;
|
| 205 |
+
|
| 206 |
+
if (BusWidth == 64) begin : gen_word_mux64
|
| 207 |
+
assign rdata_o = word_mux;
|
| 208 |
+
end else begin : gen_word_mux32
|
| 209 |
+
assign rdata_o = (word_enable32_q) ? word_mux[32 +: 32] : word_mux[0 +: 32];
|
| 210 |
+
end
|
| 211 |
+
|
| 212 |
+
// read/write logic
|
| 213 |
+
logic [63:0] data_bits;
|
| 214 |
+
logic [7:0][7:0] rdata;
|
| 215 |
+
always_comb begin : p_rw_logic
|
| 216 |
+
|
| 217 |
+
halted_d_aligned = NrHartsAligned'(halted_q);
|
| 218 |
+
resuming_d_aligned = NrHartsAligned'(resuming_q);
|
| 219 |
+
rdata_d = rdata_q;
|
| 220 |
+
// convert the data in bits representation
|
| 221 |
+
data_bits = data_i;
|
| 222 |
+
rdata = '0;
|
| 223 |
+
|
| 224 |
+
// write data in csr register
|
| 225 |
+
data_valid_o = 1'b0;
|
| 226 |
+
exception = 1'b0;
|
| 227 |
+
halted_aligned = '0;
|
| 228 |
+
going = 1'b0;
|
| 229 |
+
|
| 230 |
+
// The resume ack signal is lowered when the resume request is deasserted
|
| 231 |
+
if (clear_resumeack_i) begin
|
| 232 |
+
resuming_d_aligned[hartsel] = 1'b0;
|
| 233 |
+
end
|
| 234 |
+
// we've got a new request
|
| 235 |
+
if (req_i) begin
|
| 236 |
+
// this is a write
|
| 237 |
+
if (we_i) begin
|
| 238 |
+
unique case (addr_i[DbgAddressBits-1:0]) inside
|
| 239 |
+
HaltedAddr: begin
|
| 240 |
+
halted_aligned[wdata_hartsel] = 1'b1;
|
| 241 |
+
halted_d_aligned[wdata_hartsel] = 1'b1;
|
| 242 |
+
end
|
| 243 |
+
GoingAddr: begin
|
| 244 |
+
going = 1'b1;
|
| 245 |
+
end
|
| 246 |
+
ResumingAddr: begin
|
| 247 |
+
// clear the halted flag as the hart resumed execution
|
| 248 |
+
halted_d_aligned[wdata_hartsel] = 1'b0;
|
| 249 |
+
// set the resuming flag which needs to be cleared by the debugger
|
| 250 |
+
resuming_d_aligned[wdata_hartsel] = 1'b1;
|
| 251 |
+
end
|
| 252 |
+
// an exception occurred during execution
|
| 253 |
+
ExceptionAddr: exception = 1'b1;
|
| 254 |
+
// core can write data registers
|
| 255 |
+
[DataBaseAddr:DataEndAddr]: begin
|
| 256 |
+
data_valid_o = 1'b1;
|
| 257 |
+
for (int i = 0; i < $bits(be_i); i++) begin
|
| 258 |
+
if (be_i[i]) begin
|
| 259 |
+
data_bits[i*8+:8] = wdata_i[i*8+:8];
|
| 260 |
+
end
|
| 261 |
+
end
|
| 262 |
+
end
|
| 263 |
+
default ;
|
| 264 |
+
endcase
|
| 265 |
+
|
| 266 |
+
// this is a read
|
| 267 |
+
end else begin
|
| 268 |
+
unique case (addr_i[DbgAddressBits-1:0]) inside
|
| 269 |
+
// variable ROM content
|
| 270 |
+
WhereToAddr: begin
|
| 271 |
+
// variable jump to abstract cmd, program_buffer or resume
|
| 272 |
+
if (resumereq_wdata_aligned[wdata_hartsel]) begin
|
| 273 |
+
rdata_d = {32'b0, dm::jal('0, 21'(dm::ResumeAddress[11:0])-21'(WhereToAddr))};
|
| 274 |
+
end
|
| 275 |
+
|
| 276 |
+
// there is a command active so jump there
|
| 277 |
+
if (cmdbusy_o) begin
|
| 278 |
+
// transfer not set is shortcut to the program buffer if postexec is set
|
| 279 |
+
// keep this statement narrow to not catch invalid commands
|
| 280 |
+
if (cmd_i.cmdtype == dm::AccessRegister &&
|
| 281 |
+
!ac_ar.transfer && ac_ar.postexec) begin
|
| 282 |
+
rdata_d = {32'b0, dm::jal('0, 21'(ProgBufBaseAddr)-21'(WhereToAddr))};
|
| 283 |
+
// this is a legit abstract cmd -> execute it
|
| 284 |
+
end else begin
|
| 285 |
+
rdata_d = {32'b0, dm::jal('0, 21'(AbstractCmdBaseAddr)-21'(WhereToAddr))};
|
| 286 |
+
end
|
| 287 |
+
end
|
| 288 |
+
end
|
| 289 |
+
|
| 290 |
+
[DataBaseAddr:DataEndAddr]: begin
|
| 291 |
+
rdata_d = {
|
| 292 |
+
data_i[$clog2(dm::ProgBufSize)'(addr_i[DbgAddressBits-1:3] -
|
| 293 |
+
DataBaseAddr[DbgAddressBits-1:3] + 1'b1)],
|
| 294 |
+
data_i[$clog2(dm::ProgBufSize)'(addr_i[DbgAddressBits-1:3] -
|
| 295 |
+
DataBaseAddr[DbgAddressBits-1:3])]
|
| 296 |
+
};
|
| 297 |
+
end
|
| 298 |
+
|
| 299 |
+
[ProgBufBaseAddr:ProgBufEndAddr]: begin
|
| 300 |
+
rdata_d = progbuf[$clog2(dm::ProgBufSize)'(addr_i[DbgAddressBits-1:3] -
|
| 301 |
+
ProgBufBaseAddr[DbgAddressBits-1:3])];
|
| 302 |
+
end
|
| 303 |
+
|
| 304 |
+
// two slots for abstract command
|
| 305 |
+
[AbstractCmdBaseAddr:AbstractCmdEndAddr]: begin
|
| 306 |
+
// return the correct address index
|
| 307 |
+
rdata_d = abstract_cmd[3'(addr_i[DbgAddressBits-1:3] -
|
| 308 |
+
AbstractCmdBaseAddr[DbgAddressBits-1:3])];
|
| 309 |
+
end
|
| 310 |
+
// harts are polling for flags here
|
| 311 |
+
[FlagsBaseAddr:FlagsEndAddr]: begin
|
| 312 |
+
// release the corresponding hart
|
| 313 |
+
if (({addr_i[DbgAddressBits-1:3], 3'b0} - FlagsBaseAddr[DbgAddressBits-1:0]) ==
|
| 314 |
+
(DbgAddressBits'(hartsel) & {{(DbgAddressBits-3){1'b1}}, 3'b0})) begin
|
| 315 |
+
rdata[DbgAddressBits'(hartsel) & DbgAddressBits'(3'b111)] = {6'b0, resume, go};
|
| 316 |
+
end
|
| 317 |
+
rdata_d = rdata;
|
| 318 |
+
end
|
| 319 |
+
default: ;
|
| 320 |
+
endcase
|
| 321 |
+
end
|
| 322 |
+
end
|
| 323 |
+
|
| 324 |
+
data_o = data_bits;
|
| 325 |
+
end
|
| 326 |
+
|
| 327 |
+
always_comb begin : p_abstract_cmd_rom
|
| 328 |
+
// this abstract command is currently unsupported
|
| 329 |
+
unsupported_command = 1'b0;
|
| 330 |
+
// default memory
|
| 331 |
+
// if ac_ar.transfer is not set then we can take a shortcut to the program buffer
|
| 332 |
+
abstract_cmd[0][31:0] = dm::illegal();
|
| 333 |
+
// load debug module base address into a0, this is shared among all commands
|
| 334 |
+
abstract_cmd[0][63:32] = dm::auipc(5'd10, '0);
|
| 335 |
+
abstract_cmd[1][31:0] = dm::srli(5'd10, 5'd10, 6'd12); // clr lowest 12b -> DM base offset
|
| 336 |
+
abstract_cmd[1][63:32] = dm::slli(5'd10, 5'd10, 6'd12);
|
| 337 |
+
abstract_cmd[2][31:0] = dm::nop();
|
| 338 |
+
abstract_cmd[2][63:32] = dm::nop();
|
| 339 |
+
abstract_cmd[3][31:0] = dm::nop();
|
| 340 |
+
abstract_cmd[3][63:32] = dm::nop();
|
| 341 |
+
abstract_cmd[4][31:0] = dm::csrr(dm::CSR_DSCRATCH1, 5'd10);
|
| 342 |
+
abstract_cmd[4][63:32] = dm::ebreak();
|
| 343 |
+
abstract_cmd[7:5] = '0;
|
| 344 |
+
|
| 345 |
+
// this depends on the command being executed
|
| 346 |
+
unique case (cmd_i.cmdtype)
|
| 347 |
+
// --------------------
|
| 348 |
+
// Access Register
|
| 349 |
+
// --------------------
|
| 350 |
+
dm::AccessRegister: begin
|
| 351 |
+
if (32'(ac_ar.aarsize) < MaxAar && ac_ar.transfer && ac_ar.write) begin
|
| 352 |
+
// store a0 in dscratch1
|
| 353 |
+
abstract_cmd[0][31:0] = dm::csrw(dm::CSR_DSCRATCH1, 5'd10);
|
| 354 |
+
// this range is reserved
|
| 355 |
+
if (ac_ar.regno[15:14] != '0) begin
|
| 356 |
+
abstract_cmd[0][31:0] = dm::ebreak(); // we leave asap
|
| 357 |
+
unsupported_command = 1'b1;
|
| 358 |
+
// A0 access needs to be handled separately, as we use A0 to load
|
| 359 |
+
// the DM address offset need to access DSCRATCH1 in this case
|
| 360 |
+
end else if (ac_ar.regno[12] && (!ac_ar.regno[5]) &&
|
| 361 |
+
(ac_ar.regno[4:0] == 5'd10)) begin
|
| 362 |
+
// store s0 in dscratch
|
| 363 |
+
abstract_cmd[2][31:0] = dm::csrw(dm::CSR_DSCRATCH0, 5'd8);
|
| 364 |
+
// load from data register
|
| 365 |
+
abstract_cmd[2][63:32] = dm::load(ac_ar.aarsize, 5'd8, 5'd10, dm::DataAddr);
|
| 366 |
+
// and store it in the corresponding CSR
|
| 367 |
+
abstract_cmd[3][31:0] = dm::csrw(dm::CSR_DSCRATCH1, 5'd8);
|
| 368 |
+
// restore s0 again from dscratch
|
| 369 |
+
abstract_cmd[3][63:32] = dm::csrr(dm::CSR_DSCRATCH0, 5'd8);
|
| 370 |
+
// GPR/FPR access
|
| 371 |
+
end else if (ac_ar.regno[12]) begin
|
| 372 |
+
// determine whether we want to access the floating point register or not
|
| 373 |
+
if (ac_ar.regno[5]) begin
|
| 374 |
+
abstract_cmd[2][31:0] =
|
| 375 |
+
dm::float_load(ac_ar.aarsize, ac_ar.regno[4:0], 5'd10, dm::DataAddr);
|
| 376 |
+
end else begin
|
| 377 |
+
abstract_cmd[2][31:0] =
|
| 378 |
+
dm::load(ac_ar.aarsize, ac_ar.regno[4:0], 5'd10, dm::DataAddr);
|
| 379 |
+
end
|
| 380 |
+
// CSR access
|
| 381 |
+
end else begin
|
| 382 |
+
// data register to CSR
|
| 383 |
+
// store s0 in dscratch
|
| 384 |
+
abstract_cmd[2][31:0] = dm::csrw(dm::CSR_DSCRATCH0, 5'd8);
|
| 385 |
+
// load from data register
|
| 386 |
+
abstract_cmd[2][63:32] = dm::load(ac_ar.aarsize, 5'd8, 5'd10, dm::DataAddr);
|
| 387 |
+
// and store it in the corresponding CSR
|
| 388 |
+
abstract_cmd[3][31:0] = dm::csrw(dm::csr_reg_t'(ac_ar.regno[11:0]), 5'd8);
|
| 389 |
+
// restore s0 again from dscratch
|
| 390 |
+
abstract_cmd[3][63:32] = dm::csrr(dm::CSR_DSCRATCH0, 5'd8);
|
| 391 |
+
end
|
| 392 |
+
end else if (32'(ac_ar.aarsize) < MaxAar && ac_ar.transfer && !ac_ar.write) begin
|
| 393 |
+
// store a0 in dscratch1
|
| 394 |
+
abstract_cmd[0][31:0] = dm::csrw(dm::CSR_DSCRATCH1, 5'd10);
|
| 395 |
+
// this range is reserved
|
| 396 |
+
if (ac_ar.regno[15:14] != '0) begin
|
| 397 |
+
abstract_cmd[0][31:0] = dm::ebreak(); // we leave asap
|
| 398 |
+
unsupported_command = 1'b1;
|
| 399 |
+
// A0 access needs to be handled separately, as we use A0 to load
|
| 400 |
+
// the DM address offset need to access DSCRATCH1 in this case
|
| 401 |
+
end else if (ac_ar.regno[12] && (!ac_ar.regno[5]) &&
|
| 402 |
+
(ac_ar.regno[4:0] == 5'd10)) begin
|
| 403 |
+
// store s0 in dscratch
|
| 404 |
+
abstract_cmd[2][31:0] = dm::csrw(dm::CSR_DSCRATCH0, 5'd8);
|
| 405 |
+
// read value from CSR into s0
|
| 406 |
+
abstract_cmd[2][63:32] = dm::csrr(dm::CSR_DSCRATCH1, 5'd8);
|
| 407 |
+
// and store s0 into data section
|
| 408 |
+
abstract_cmd[3][31:0] = dm::store(ac_ar.aarsize, 5'd8, 5'd10, dm::DataAddr);
|
| 409 |
+
// restore s0 again from dscratch
|
| 410 |
+
abstract_cmd[3][63:32] = dm::csrr(dm::CSR_DSCRATCH0, 5'd8);
|
| 411 |
+
// GPR/FPR access
|
| 412 |
+
end else if (ac_ar.regno[12]) begin
|
| 413 |
+
// determine whether we want to access the floating point register or not
|
| 414 |
+
if (ac_ar.regno[5]) begin
|
| 415 |
+
abstract_cmd[2][31:0] =
|
| 416 |
+
dm::float_store(ac_ar.aarsize, ac_ar.regno[4:0], 5'd10, dm::DataAddr);
|
| 417 |
+
end else begin
|
| 418 |
+
abstract_cmd[2][31:0] =
|
| 419 |
+
dm::store(ac_ar.aarsize, ac_ar.regno[4:0], 5'd10, dm::DataAddr);
|
| 420 |
+
end
|
| 421 |
+
// CSR access
|
| 422 |
+
end else begin
|
| 423 |
+
// CSR register to data
|
| 424 |
+
// store s0 in dscratch
|
| 425 |
+
abstract_cmd[2][31:0] = dm::csrw(dm::CSR_DSCRATCH0, 5'd8);
|
| 426 |
+
// read value from CSR into s0
|
| 427 |
+
abstract_cmd[2][63:32] = dm::csrr(dm::csr_reg_t'(ac_ar.regno[11:0]), 5'd8);
|
| 428 |
+
// and store s0 into data section
|
| 429 |
+
abstract_cmd[3][31:0] = dm::store(ac_ar.aarsize, 5'd8, 5'd10, dm::DataAddr);
|
| 430 |
+
// restore s0 again from dscratch
|
| 431 |
+
abstract_cmd[3][63:32] = dm::csrr(dm::CSR_DSCRATCH0, 5'd8);
|
| 432 |
+
end
|
| 433 |
+
end else if (32'(ac_ar.aarsize) >= MaxAar || ac_ar.aarpostincrement == 1'b1) begin
|
| 434 |
+
// this should happend when e.g. ac_ar.aarsize >= MaxAar
|
| 435 |
+
// Openocd will try to do an access with aarsize=64 bits
|
| 436 |
+
// first before falling back to 32 bits.
|
| 437 |
+
abstract_cmd[0][31:0] = dm::ebreak(); // we leave asap
|
| 438 |
+
unsupported_command = 1'b1;
|
| 439 |
+
end
|
| 440 |
+
|
| 441 |
+
// Check whether we need to execute the program buffer. When we
|
| 442 |
+
// get an unsupported command we really should abort instead of
|
| 443 |
+
// still trying to execute the program buffer, makes it easier
|
| 444 |
+
// for the debugger to recover
|
| 445 |
+
if (ac_ar.postexec && !unsupported_command) begin
|
| 446 |
+
// issue a nop, we will automatically run into the program buffer
|
| 447 |
+
abstract_cmd[4][63:32] = dm::nop();
|
| 448 |
+
end
|
| 449 |
+
end
|
| 450 |
+
// not supported at the moment
|
| 451 |
+
// dm::QuickAccess:;
|
| 452 |
+
// dm::AccessMemory:;
|
| 453 |
+
default: begin
|
| 454 |
+
abstract_cmd[0][31:0] = dm::ebreak();
|
| 455 |
+
unsupported_command = 1'b1;
|
| 456 |
+
end
|
| 457 |
+
endcase
|
| 458 |
+
end
|
| 459 |
+
|
| 460 |
+
logic [63:0] rom_addr;
|
| 461 |
+
assign rom_addr = 64'(addr_i);
|
| 462 |
+
debug_rom i_debug_rom (
|
| 463 |
+
.clk_i,
|
| 464 |
+
.req_i,
|
| 465 |
+
.addr_i ( rom_addr ),
|
| 466 |
+
.rdata_o ( rom_rdata )
|
| 467 |
+
);
|
| 468 |
+
|
| 469 |
+
// ROM starts at the HaltAddress of the core e.g.: it immediately jumps to
|
| 470 |
+
// the ROM base address
|
| 471 |
+
assign fwd_rom_d = logic'(addr_i[DbgAddressBits-1:0] >= dm::HaltAddress[DbgAddressBits-1:0]);
|
| 472 |
+
|
| 473 |
+
always_ff @(posedge clk_i or negedge rst_ni) begin : p_regs
|
| 474 |
+
if (!rst_ni) begin
|
| 475 |
+
fwd_rom_q <= 1'b0;
|
| 476 |
+
rdata_q <= '0;
|
| 477 |
+
state_q <= Idle;
|
| 478 |
+
word_enable32_q <= 1'b0;
|
| 479 |
+
end else begin
|
| 480 |
+
fwd_rom_q <= fwd_rom_d;
|
| 481 |
+
rdata_q <= rdata_d;
|
| 482 |
+
state_q <= state_d;
|
| 483 |
+
word_enable32_q <= addr_i[2];
|
| 484 |
+
end
|
| 485 |
+
end
|
| 486 |
+
|
| 487 |
+
always_ff @(posedge clk_i or negedge rst_ni) begin
|
| 488 |
+
if (!rst_ni) begin
|
| 489 |
+
halted_q <= 1'b0;
|
| 490 |
+
resuming_q <= 1'b0;
|
| 491 |
+
end else begin
|
| 492 |
+
halted_q <= SelectableHarts & halted_d;
|
| 493 |
+
resuming_q <= SelectableHarts & resuming_d;
|
| 494 |
+
end
|
| 495 |
+
end
|
| 496 |
+
|
| 497 |
+
endmodule : dm_mem
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dm_pkg.sv
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: dm_pkg.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 30.6.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: Debug-module package, contains common system definitions.
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
package dm;
|
| 20 |
+
localparam logic [3:0] DbgVersion013 = 4'h2;
|
| 21 |
+
// size of program buffer in junks of 32-bit words
|
| 22 |
+
localparam logic [4:0] ProgBufSize = 5'h8;
|
| 23 |
+
|
| 24 |
+
// amount of data count registers implemented
|
| 25 |
+
localparam logic [3:0] DataCount = 4'h2;
|
| 26 |
+
|
| 27 |
+
// address to which a hart should jump when it was requested to halt
|
| 28 |
+
localparam logic [63:0] HaltAddress = 64'h800;
|
| 29 |
+
localparam logic [63:0] ResumeAddress = HaltAddress + 4;
|
| 30 |
+
localparam logic [63:0] ExceptionAddress = HaltAddress + 8;
|
| 31 |
+
|
| 32 |
+
// address where data0-15 is shadowed or if shadowed in a CSR
|
| 33 |
+
// address of the first CSR used for shadowing the data
|
| 34 |
+
localparam logic [11:0] DataAddr = 12'h380; // we are aligned with Rocket here
|
| 35 |
+
|
| 36 |
+
// debug registers
|
| 37 |
+
typedef enum logic [7:0] {
|
| 38 |
+
Data0 = 8'h04,
|
| 39 |
+
Data1 = 8'h05,
|
| 40 |
+
Data2 = 8'h06,
|
| 41 |
+
Data3 = 8'h07,
|
| 42 |
+
Data4 = 8'h08,
|
| 43 |
+
Data5 = 8'h09,
|
| 44 |
+
Data6 = 8'h0A,
|
| 45 |
+
Data7 = 8'h0B,
|
| 46 |
+
Data8 = 8'h0C,
|
| 47 |
+
Data9 = 8'h0D,
|
| 48 |
+
Data10 = 8'h0E,
|
| 49 |
+
Data11 = 8'h0F,
|
| 50 |
+
DMControl = 8'h10,
|
| 51 |
+
DMStatus = 8'h11, // r/o
|
| 52 |
+
Hartinfo = 8'h12,
|
| 53 |
+
HaltSum1 = 8'h13,
|
| 54 |
+
HAWindowSel = 8'h14,
|
| 55 |
+
HAWindow = 8'h15,
|
| 56 |
+
AbstractCS = 8'h16,
|
| 57 |
+
Command = 8'h17,
|
| 58 |
+
AbstractAuto = 8'h18,
|
| 59 |
+
DevTreeAddr0 = 8'h19,
|
| 60 |
+
DevTreeAddr1 = 8'h1A,
|
| 61 |
+
DevTreeAddr2 = 8'h1B,
|
| 62 |
+
DevTreeAddr3 = 8'h1C,
|
| 63 |
+
NextDM = 8'h1D,
|
| 64 |
+
ProgBuf0 = 8'h20,
|
| 65 |
+
ProgBuf15 = 8'h2F,
|
| 66 |
+
AuthData = 8'h30,
|
| 67 |
+
HaltSum2 = 8'h34,
|
| 68 |
+
HaltSum3 = 8'h35,
|
| 69 |
+
SBAddress3 = 8'h37,
|
| 70 |
+
SBCS = 8'h38,
|
| 71 |
+
SBAddress0 = 8'h39,
|
| 72 |
+
SBAddress1 = 8'h3A,
|
| 73 |
+
SBAddress2 = 8'h3B,
|
| 74 |
+
SBData0 = 8'h3C,
|
| 75 |
+
SBData1 = 8'h3D,
|
| 76 |
+
SBData2 = 8'h3E,
|
| 77 |
+
SBData3 = 8'h3F,
|
| 78 |
+
HaltSum0 = 8'h40
|
| 79 |
+
} dm_csr_e;
|
| 80 |
+
|
| 81 |
+
// debug causes
|
| 82 |
+
localparam logic [2:0] CauseBreakpoint = 3'h1;
|
| 83 |
+
localparam logic [2:0] CauseTrigger = 3'h2;
|
| 84 |
+
localparam logic [2:0] CauseRequest = 3'h3;
|
| 85 |
+
localparam logic [2:0] CauseSingleStep = 3'h4;
|
| 86 |
+
|
| 87 |
+
typedef struct packed {
|
| 88 |
+
logic [31:23] zero1;
|
| 89 |
+
logic impebreak;
|
| 90 |
+
logic [21:20] zero0;
|
| 91 |
+
logic allhavereset;
|
| 92 |
+
logic anyhavereset;
|
| 93 |
+
logic allresumeack;
|
| 94 |
+
logic anyresumeack;
|
| 95 |
+
logic allnonexistent;
|
| 96 |
+
logic anynonexistent;
|
| 97 |
+
logic allunavail;
|
| 98 |
+
logic anyunavail;
|
| 99 |
+
logic allrunning;
|
| 100 |
+
logic anyrunning;
|
| 101 |
+
logic allhalted;
|
| 102 |
+
logic anyhalted;
|
| 103 |
+
logic authenticated;
|
| 104 |
+
logic authbusy;
|
| 105 |
+
logic hasresethaltreq;
|
| 106 |
+
logic devtreevalid;
|
| 107 |
+
logic [3:0] version;
|
| 108 |
+
} dmstatus_t;
|
| 109 |
+
|
| 110 |
+
typedef struct packed {
|
| 111 |
+
logic haltreq;
|
| 112 |
+
logic resumereq;
|
| 113 |
+
logic hartreset;
|
| 114 |
+
logic ackhavereset;
|
| 115 |
+
logic zero1;
|
| 116 |
+
logic hasel;
|
| 117 |
+
logic [25:16] hartsello;
|
| 118 |
+
logic [15:6] hartselhi;
|
| 119 |
+
logic [5:4] zero0;
|
| 120 |
+
logic setresethaltreq;
|
| 121 |
+
logic clrresethaltreq;
|
| 122 |
+
logic ndmreset;
|
| 123 |
+
logic dmactive;
|
| 124 |
+
} dmcontrol_t;
|
| 125 |
+
|
| 126 |
+
typedef struct packed {
|
| 127 |
+
logic [31:24] zero1;
|
| 128 |
+
logic [23:20] nscratch;
|
| 129 |
+
logic [19:17] zero0;
|
| 130 |
+
logic dataaccess;
|
| 131 |
+
logic [15:12] datasize;
|
| 132 |
+
logic [11:0] dataaddr;
|
| 133 |
+
} hartinfo_t;
|
| 134 |
+
|
| 135 |
+
typedef enum logic [2:0] {
|
| 136 |
+
CmdErrNone, CmdErrBusy, CmdErrNotSupported,
|
| 137 |
+
CmdErrorException, CmdErrorHaltResume,
|
| 138 |
+
CmdErrorBus, CmdErrorOther = 7
|
| 139 |
+
} cmderr_e;
|
| 140 |
+
|
| 141 |
+
typedef struct packed {
|
| 142 |
+
logic [31:29] zero3;
|
| 143 |
+
logic [28:24] progbufsize;
|
| 144 |
+
logic [23:13] zero2;
|
| 145 |
+
logic busy;
|
| 146 |
+
logic zero1;
|
| 147 |
+
cmderr_e cmderr;
|
| 148 |
+
logic [7:4] zero0;
|
| 149 |
+
logic [3:0] datacount;
|
| 150 |
+
} abstractcs_t;
|
| 151 |
+
|
| 152 |
+
typedef enum logic [7:0] {
|
| 153 |
+
AccessRegister = 8'h0,
|
| 154 |
+
QuickAccess = 8'h1,
|
| 155 |
+
AccessMemory = 8'h2
|
| 156 |
+
} cmd_e;
|
| 157 |
+
|
| 158 |
+
typedef struct packed {
|
| 159 |
+
cmd_e cmdtype;
|
| 160 |
+
logic [23:0] control;
|
| 161 |
+
} command_t;
|
| 162 |
+
|
| 163 |
+
typedef struct packed {
|
| 164 |
+
logic [31:16] autoexecprogbuf;
|
| 165 |
+
logic [15:12] zero0;
|
| 166 |
+
logic [11:0] autoexecdata;
|
| 167 |
+
} abstractauto_t;
|
| 168 |
+
|
| 169 |
+
typedef struct packed {
|
| 170 |
+
logic zero1;
|
| 171 |
+
logic [22:20] aarsize;
|
| 172 |
+
logic aarpostincrement;
|
| 173 |
+
logic postexec;
|
| 174 |
+
logic transfer;
|
| 175 |
+
logic write;
|
| 176 |
+
logic [15:0] regno;
|
| 177 |
+
} ac_ar_cmd_t;
|
| 178 |
+
|
| 179 |
+
// DTM
|
| 180 |
+
typedef enum logic [1:0] {
|
| 181 |
+
DTM_NOP = 2'h0,
|
| 182 |
+
DTM_READ = 2'h1,
|
| 183 |
+
DTM_WRITE = 2'h2
|
| 184 |
+
} dtm_op_e;
|
| 185 |
+
|
| 186 |
+
typedef struct packed {
|
| 187 |
+
logic [31:29] sbversion;
|
| 188 |
+
logic [28:23] zero0;
|
| 189 |
+
logic sbbusyerror;
|
| 190 |
+
logic sbbusy;
|
| 191 |
+
logic sbreadonaddr;
|
| 192 |
+
logic [19:17] sbaccess;
|
| 193 |
+
logic sbautoincrement;
|
| 194 |
+
logic sbreadondata;
|
| 195 |
+
logic [14:12] sberror;
|
| 196 |
+
logic [11:5] sbasize;
|
| 197 |
+
logic sbaccess128;
|
| 198 |
+
logic sbaccess64;
|
| 199 |
+
logic sbaccess32;
|
| 200 |
+
logic sbaccess16;
|
| 201 |
+
logic sbaccess8;
|
| 202 |
+
} sbcs_t;
|
| 203 |
+
|
| 204 |
+
localparam logic[1:0] DTM_SUCCESS = 2'h0;
|
| 205 |
+
|
| 206 |
+
typedef struct packed {
|
| 207 |
+
logic [6:0] addr;
|
| 208 |
+
dtm_op_e op;
|
| 209 |
+
logic [31:0] data;
|
| 210 |
+
} dmi_req_t;
|
| 211 |
+
|
| 212 |
+
typedef struct packed {
|
| 213 |
+
logic [31:0] data;
|
| 214 |
+
logic [1:0] resp;
|
| 215 |
+
} dmi_resp_t;
|
| 216 |
+
|
| 217 |
+
// privilege levels
|
| 218 |
+
typedef enum logic[1:0] {
|
| 219 |
+
PRIV_LVL_M = 2'b11,
|
| 220 |
+
PRIV_LVL_S = 2'b01,
|
| 221 |
+
PRIV_LVL_U = 2'b00
|
| 222 |
+
} priv_lvl_t;
|
| 223 |
+
|
| 224 |
+
// debugregs in core
|
| 225 |
+
typedef struct packed {
|
| 226 |
+
logic [31:28] xdebugver;
|
| 227 |
+
logic [27:16] zero2;
|
| 228 |
+
logic ebreakm;
|
| 229 |
+
logic zero1;
|
| 230 |
+
logic ebreaks;
|
| 231 |
+
logic ebreaku;
|
| 232 |
+
logic stepie;
|
| 233 |
+
logic stopcount;
|
| 234 |
+
logic stoptime;
|
| 235 |
+
logic [8:6] cause;
|
| 236 |
+
logic zero0;
|
| 237 |
+
logic mprven;
|
| 238 |
+
logic nmip;
|
| 239 |
+
logic step;
|
| 240 |
+
priv_lvl_t prv;
|
| 241 |
+
} dcsr_t;
|
| 242 |
+
|
| 243 |
+
// CSRs
|
| 244 |
+
typedef enum logic [11:0] {
|
| 245 |
+
// Floating-Point CSRs
|
| 246 |
+
CSR_FFLAGS = 12'h001,
|
| 247 |
+
CSR_FRM = 12'h002,
|
| 248 |
+
CSR_FCSR = 12'h003,
|
| 249 |
+
CSR_FTRAN = 12'h800,
|
| 250 |
+
// Supervisor Mode CSRs
|
| 251 |
+
CSR_SSTATUS = 12'h100,
|
| 252 |
+
CSR_SIE = 12'h104,
|
| 253 |
+
CSR_STVEC = 12'h105,
|
| 254 |
+
CSR_SCOUNTEREN = 12'h106,
|
| 255 |
+
CSR_SSCRATCH = 12'h140,
|
| 256 |
+
CSR_SEPC = 12'h141,
|
| 257 |
+
CSR_SCAUSE = 12'h142,
|
| 258 |
+
CSR_STVAL = 12'h143,
|
| 259 |
+
CSR_SIP = 12'h144,
|
| 260 |
+
CSR_SATP = 12'h180,
|
| 261 |
+
// Machine Mode CSRs
|
| 262 |
+
CSR_MSTATUS = 12'h300,
|
| 263 |
+
CSR_MISA = 12'h301,
|
| 264 |
+
CSR_MEDELEG = 12'h302,
|
| 265 |
+
CSR_MIDELEG = 12'h303,
|
| 266 |
+
CSR_MIE = 12'h304,
|
| 267 |
+
CSR_MTVEC = 12'h305,
|
| 268 |
+
CSR_MCOUNTEREN = 12'h306,
|
| 269 |
+
CSR_MSCRATCH = 12'h340,
|
| 270 |
+
CSR_MEPC = 12'h341,
|
| 271 |
+
CSR_MCAUSE = 12'h342,
|
| 272 |
+
CSR_MTVAL = 12'h343,
|
| 273 |
+
CSR_MIP = 12'h344,
|
| 274 |
+
CSR_PMPCFG0 = 12'h3A0,
|
| 275 |
+
CSR_PMPADDR0 = 12'h3B0,
|
| 276 |
+
CSR_MVENDORID = 12'hF11,
|
| 277 |
+
CSR_MARCHID = 12'hF12,
|
| 278 |
+
CSR_MIMPID = 12'hF13,
|
| 279 |
+
CSR_MHARTID = 12'hF14,
|
| 280 |
+
CSR_MCYCLE = 12'hB00,
|
| 281 |
+
CSR_MINSTRET = 12'hB02,
|
| 282 |
+
CSR_DCACHE = 12'h701,
|
| 283 |
+
CSR_ICACHE = 12'h700,
|
| 284 |
+
|
| 285 |
+
CSR_TSELECT = 12'h7A0,
|
| 286 |
+
CSR_TDATA1 = 12'h7A1,
|
| 287 |
+
CSR_TDATA2 = 12'h7A2,
|
| 288 |
+
CSR_TDATA3 = 12'h7A3,
|
| 289 |
+
CSR_TINFO = 12'h7A4,
|
| 290 |
+
|
| 291 |
+
// Debug CSR
|
| 292 |
+
CSR_DCSR = 12'h7b0,
|
| 293 |
+
CSR_DPC = 12'h7b1,
|
| 294 |
+
CSR_DSCRATCH0 = 12'h7b2, // optional
|
| 295 |
+
CSR_DSCRATCH1 = 12'h7b3, // optional
|
| 296 |
+
|
| 297 |
+
// Counters and Timers
|
| 298 |
+
CSR_CYCLE = 12'hC00,
|
| 299 |
+
CSR_TIME = 12'hC01,
|
| 300 |
+
CSR_INSTRET = 12'hC02
|
| 301 |
+
} csr_reg_t;
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
// Instruction Generation Helpers
|
| 305 |
+
function automatic logic [31:0] jal (logic [4:0] rd,
|
| 306 |
+
logic [20:0] imm);
|
| 307 |
+
// OpCode Jal
|
| 308 |
+
return {imm[20], imm[10:1], imm[11], imm[19:12], rd, 7'h6f};
|
| 309 |
+
endfunction
|
| 310 |
+
|
| 311 |
+
function automatic logic [31:0] jalr (logic [4:0] rd,
|
| 312 |
+
logic [4:0] rs1,
|
| 313 |
+
logic [11:0] offset);
|
| 314 |
+
// OpCode Jal
|
| 315 |
+
return {offset[11:0], rs1, 3'b0, rd, 7'h67};
|
| 316 |
+
endfunction
|
| 317 |
+
|
| 318 |
+
function automatic logic [31:0] andi (logic [4:0] rd,
|
| 319 |
+
logic [4:0] rs1,
|
| 320 |
+
logic [11:0] imm);
|
| 321 |
+
// OpCode andi
|
| 322 |
+
return {imm[11:0], rs1, 3'h7, rd, 7'h13};
|
| 323 |
+
endfunction
|
| 324 |
+
|
| 325 |
+
function automatic logic [31:0] slli (logic [4:0] rd,
|
| 326 |
+
logic [4:0] rs1,
|
| 327 |
+
logic [5:0] shamt);
|
| 328 |
+
// OpCode slli
|
| 329 |
+
return {6'b0, shamt[5:0], rs1, 3'h1, rd, 7'h13};
|
| 330 |
+
endfunction
|
| 331 |
+
|
| 332 |
+
function automatic logic [31:0] srli (logic [4:0] rd,
|
| 333 |
+
logic [4:0] rs1,
|
| 334 |
+
logic [5:0] shamt);
|
| 335 |
+
// OpCode srli
|
| 336 |
+
return {6'b0, shamt[5:0], rs1, 3'h5, rd, 7'h13};
|
| 337 |
+
endfunction
|
| 338 |
+
|
| 339 |
+
function automatic logic [31:0] load (logic [2:0] size,
|
| 340 |
+
logic [4:0] dest,
|
| 341 |
+
logic [4:0] base,
|
| 342 |
+
logic [11:0] offset);
|
| 343 |
+
// OpCode Load
|
| 344 |
+
return {offset[11:0], base, size, dest, 7'h03};
|
| 345 |
+
endfunction
|
| 346 |
+
|
| 347 |
+
function automatic logic [31:0] auipc (logic [4:0] rd,
|
| 348 |
+
logic [20:0] imm);
|
| 349 |
+
// OpCode Auipc
|
| 350 |
+
return {imm[20], imm[10:1], imm[11], imm[19:12], rd, 7'h17};
|
| 351 |
+
endfunction
|
| 352 |
+
|
| 353 |
+
function automatic logic [31:0] store (logic [2:0] size,
|
| 354 |
+
logic [4:0] src,
|
| 355 |
+
logic [4:0] base,
|
| 356 |
+
logic [11:0] offset);
|
| 357 |
+
// OpCode Store
|
| 358 |
+
return {offset[11:5], src, base, size, offset[4:0], 7'h23};
|
| 359 |
+
endfunction
|
| 360 |
+
|
| 361 |
+
function automatic logic [31:0] float_load (logic [2:0] size,
|
| 362 |
+
logic [4:0] dest,
|
| 363 |
+
logic [4:0] base,
|
| 364 |
+
logic [11:0] offset);
|
| 365 |
+
// OpCode Load
|
| 366 |
+
return {offset[11:0], base, size, dest, 7'b00_001_11};
|
| 367 |
+
endfunction
|
| 368 |
+
|
| 369 |
+
function automatic logic [31:0] float_store (logic [2:0] size,
|
| 370 |
+
logic [4:0] src,
|
| 371 |
+
logic [4:0] base,
|
| 372 |
+
logic [11:0] offset);
|
| 373 |
+
// OpCode Store
|
| 374 |
+
return {offset[11:5], src, base, size, offset[4:0], 7'b01_001_11};
|
| 375 |
+
endfunction
|
| 376 |
+
|
| 377 |
+
function automatic logic [31:0] csrw (csr_reg_t csr,
|
| 378 |
+
logic [4:0] rs1);
|
| 379 |
+
// CSRRW, rd, OpCode System
|
| 380 |
+
return {csr, rs1, 3'h1, 5'h0, 7'h73};
|
| 381 |
+
endfunction
|
| 382 |
+
|
| 383 |
+
function automatic logic [31:0] csrr (csr_reg_t csr,
|
| 384 |
+
logic [4:0] dest);
|
| 385 |
+
// rs1, CSRRS, rd, OpCode System
|
| 386 |
+
return {csr, 5'h0, 3'h2, dest, 7'h73};
|
| 387 |
+
endfunction
|
| 388 |
+
|
| 389 |
+
function automatic logic [31:0] branch(logic [4:0] src2,
|
| 390 |
+
logic [4:0] src1,
|
| 391 |
+
logic [2:0] funct3,
|
| 392 |
+
logic [11:0] offset);
|
| 393 |
+
// OpCode Branch
|
| 394 |
+
return {offset[11], offset[9:4], src2, src1, funct3,
|
| 395 |
+
offset[3:0], offset[10], 7'b11_000_11};
|
| 396 |
+
endfunction
|
| 397 |
+
|
| 398 |
+
function automatic logic [31:0] ebreak ();
|
| 399 |
+
return 32'h00100073;
|
| 400 |
+
endfunction
|
| 401 |
+
|
| 402 |
+
function automatic logic [31:0] wfi ();
|
| 403 |
+
return 32'h10500073;
|
| 404 |
+
endfunction
|
| 405 |
+
|
| 406 |
+
function automatic logic [31:0] nop ();
|
| 407 |
+
return 32'h00000013;
|
| 408 |
+
endfunction
|
| 409 |
+
|
| 410 |
+
function automatic logic [31:0] illegal ();
|
| 411 |
+
return 32'h00000000;
|
| 412 |
+
endfunction
|
| 413 |
+
|
| 414 |
+
endpackage : dm
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dm_sba.sv
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: dm_sba.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 1.8.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: System Bus Access Module
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
module dm_sba #(
|
| 19 |
+
parameter int unsigned BusWidth = 32
|
| 20 |
+
) (
|
| 21 |
+
input logic clk_i, // Clock
|
| 22 |
+
input logic rst_ni,
|
| 23 |
+
input logic dmactive_i, // synchronous reset active low
|
| 24 |
+
|
| 25 |
+
output logic master_req_o,
|
| 26 |
+
output logic [BusWidth-1:0] master_add_o,
|
| 27 |
+
output logic master_we_o,
|
| 28 |
+
output logic [BusWidth-1:0] master_wdata_o,
|
| 29 |
+
output logic [BusWidth/8-1:0] master_be_o,
|
| 30 |
+
input logic master_gnt_i,
|
| 31 |
+
input logic master_r_valid_i,
|
| 32 |
+
input logic [BusWidth-1:0] master_r_rdata_i,
|
| 33 |
+
|
| 34 |
+
input logic [BusWidth-1:0] sbaddress_i,
|
| 35 |
+
input logic sbaddress_write_valid_i,
|
| 36 |
+
// control signals in
|
| 37 |
+
input logic sbreadonaddr_i,
|
| 38 |
+
output logic [BusWidth-1:0] sbaddress_o,
|
| 39 |
+
input logic sbautoincrement_i,
|
| 40 |
+
input logic [2:0] sbaccess_i,
|
| 41 |
+
// data in
|
| 42 |
+
input logic sbreadondata_i,
|
| 43 |
+
input logic [BusWidth-1:0] sbdata_i,
|
| 44 |
+
input logic sbdata_read_valid_i,
|
| 45 |
+
input logic sbdata_write_valid_i,
|
| 46 |
+
// read data out
|
| 47 |
+
output logic [BusWidth-1:0] sbdata_o,
|
| 48 |
+
output logic sbdata_valid_o,
|
| 49 |
+
// control signals
|
| 50 |
+
output logic sbbusy_o,
|
| 51 |
+
output logic sberror_valid_o, // bus error occurred
|
| 52 |
+
output logic [2:0] sberror_o // bus error occurred
|
| 53 |
+
);
|
| 54 |
+
|
| 55 |
+
typedef enum logic [2:0] { Idle, Read, Write, WaitRead, WaitWrite } state_e;
|
| 56 |
+
state_e state_d, state_q;
|
| 57 |
+
|
| 58 |
+
logic [BusWidth-1:0] address;
|
| 59 |
+
logic req;
|
| 60 |
+
logic gnt;
|
| 61 |
+
logic we;
|
| 62 |
+
logic [BusWidth/8-1:0] be;
|
| 63 |
+
logic [$clog2(BusWidth/8)-1:0] be_idx;
|
| 64 |
+
|
| 65 |
+
assign sbbusy_o = logic'(state_q != Idle);
|
| 66 |
+
|
| 67 |
+
always_comb begin : p_fsm
|
| 68 |
+
req = 1'b0;
|
| 69 |
+
address = sbaddress_i;
|
| 70 |
+
we = 1'b0;
|
| 71 |
+
be = '0;
|
| 72 |
+
be_idx = sbaddress_i[$clog2(BusWidth/8)-1:0];
|
| 73 |
+
|
| 74 |
+
sberror_o = '0;
|
| 75 |
+
sberror_valid_o = 1'b0;
|
| 76 |
+
sbaddress_o = sbaddress_i;
|
| 77 |
+
|
| 78 |
+
state_d = state_q;
|
| 79 |
+
|
| 80 |
+
unique case (state_q)
|
| 81 |
+
Idle: begin
|
| 82 |
+
// debugger requested a read
|
| 83 |
+
if (sbaddress_write_valid_i && sbreadonaddr_i) state_d = Read;
|
| 84 |
+
// debugger requested a write
|
| 85 |
+
if (sbdata_write_valid_i) state_d = Write;
|
| 86 |
+
// perform another read
|
| 87 |
+
if (sbdata_read_valid_i && sbreadondata_i) state_d = Read;
|
| 88 |
+
end
|
| 89 |
+
|
| 90 |
+
Read: begin
|
| 91 |
+
req = 1'b1;
|
| 92 |
+
if (gnt) state_d = WaitRead;
|
| 93 |
+
end
|
| 94 |
+
|
| 95 |
+
Write: begin
|
| 96 |
+
req = 1'b1;
|
| 97 |
+
we = 1'b1;
|
| 98 |
+
// generate byte enable mask
|
| 99 |
+
unique case (sbaccess_i)
|
| 100 |
+
3'b000: begin
|
| 101 |
+
be[be_idx] = '1;
|
| 102 |
+
end
|
| 103 |
+
3'b001: begin
|
| 104 |
+
be[int'({be_idx[$high(be_idx):1], 1'b0}) +: 2] = '1;
|
| 105 |
+
end
|
| 106 |
+
3'b010: begin
|
| 107 |
+
if (BusWidth == 32'd64) be[int'({be_idx[$high(be_idx)], 2'b0}) +: 4] = '1;
|
| 108 |
+
else be = '1;
|
| 109 |
+
end
|
| 110 |
+
3'b011: be = '1;
|
| 111 |
+
default: ;
|
| 112 |
+
endcase
|
| 113 |
+
if (gnt) state_d = WaitWrite;
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
WaitRead: begin
|
| 117 |
+
if (sbdata_valid_o) begin
|
| 118 |
+
state_d = Idle;
|
| 119 |
+
// auto-increment address
|
| 120 |
+
if (sbautoincrement_i) sbaddress_o = sbaddress_i + (32'b1 << sbaccess_i);
|
| 121 |
+
end
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
WaitWrite: begin
|
| 125 |
+
if (sbdata_valid_o) begin
|
| 126 |
+
state_d = Idle;
|
| 127 |
+
// auto-increment address
|
| 128 |
+
if (sbautoincrement_i) sbaddress_o = sbaddress_i + (32'b1 << sbaccess_i);
|
| 129 |
+
end
|
| 130 |
+
end
|
| 131 |
+
|
| 132 |
+
default: state_d = Idle; // catch parasitic state
|
| 133 |
+
endcase
|
| 134 |
+
|
| 135 |
+
// handle error case
|
| 136 |
+
if (sbaccess_i > 3 && state_q != Idle) begin
|
| 137 |
+
req = 1'b0;
|
| 138 |
+
state_d = Idle;
|
| 139 |
+
sberror_valid_o = 1'b1;
|
| 140 |
+
sberror_o = 3'd3;
|
| 141 |
+
end
|
| 142 |
+
// further error handling should go here ...
|
| 143 |
+
end
|
| 144 |
+
|
| 145 |
+
always_ff @(posedge clk_i or negedge rst_ni) begin : p_regs
|
| 146 |
+
if (!rst_ni) begin
|
| 147 |
+
state_q <= Idle;
|
| 148 |
+
end else begin
|
| 149 |
+
state_q <= state_d;
|
| 150 |
+
end
|
| 151 |
+
end
|
| 152 |
+
|
| 153 |
+
assign master_req_o = req;
|
| 154 |
+
assign master_add_o = address[BusWidth-1:0];
|
| 155 |
+
assign master_we_o = we;
|
| 156 |
+
assign master_wdata_o = sbdata_i[BusWidth-1:0];
|
| 157 |
+
assign master_be_o = be[BusWidth/8-1:0];
|
| 158 |
+
assign gnt = master_gnt_i;
|
| 159 |
+
assign sbdata_valid_o = master_r_valid_i;
|
| 160 |
+
assign sbdata_o = master_r_rdata_i[BusWidth-1:0];
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
//pragma translate_off
|
| 164 |
+
`ifndef VERILATOR
|
| 165 |
+
// maybe bump severity to $error if not handled at runtime
|
| 166 |
+
dm_sba_access_size: assert property(@(posedge clk_i) disable iff (dmactive_i !== 1'b0)
|
| 167 |
+
(state_d != Idle) |-> (sbaccess_i < 4))
|
| 168 |
+
else $warning ("accesses > 8 byte not supported at the moment");
|
| 169 |
+
`endif
|
| 170 |
+
//pragma translate_on
|
| 171 |
+
|
| 172 |
+
endmodule : dm_sba
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dm_top.sv
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: dm_top.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 30.6.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: Top-level of debug module (DM). This is an AXI-Slave.
|
| 16 |
+
* DTM protocol is equal to SiFives debug protocol to leverage
|
| 17 |
+
* SW infrastructure re-use. As of version 0.13
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
module dm_top #(
|
| 21 |
+
parameter int unsigned NrHarts = 1,
|
| 22 |
+
parameter int unsigned BusWidth = 32,
|
| 23 |
+
// Bitmask to select physically available harts for systems
|
| 24 |
+
// that don't use hart numbers in a contiguous fashion.
|
| 25 |
+
parameter logic [NrHarts-1:0] SelectableHarts = {NrHarts{1'b1}}
|
| 26 |
+
) (
|
| 27 |
+
input logic clk_i, // clock
|
| 28 |
+
input logic rst_ni, // asynchronous reset active low, connect PoR here, not the system reset
|
| 29 |
+
input logic testmode_i,
|
| 30 |
+
output logic ndmreset_o, // non-debug module reset
|
| 31 |
+
output logic dmactive_o, // debug module is active
|
| 32 |
+
output logic [NrHarts-1:0] debug_req_o, // async debug request
|
| 33 |
+
input logic [NrHarts-1:0] unavailable_i, // communicate whether the hart is unavailable (e.g.: power down)
|
| 34 |
+
dm::hartinfo_t [NrHarts-1:0] hartinfo_i,
|
| 35 |
+
|
| 36 |
+
input logic slave_req_i,
|
| 37 |
+
input logic slave_we_i,
|
| 38 |
+
input logic [BusWidth-1:0] slave_addr_i,
|
| 39 |
+
input logic [BusWidth/8-1:0] slave_be_i,
|
| 40 |
+
input logic [BusWidth-1:0] slave_wdata_i,
|
| 41 |
+
output logic [BusWidth-1:0] slave_rdata_o,
|
| 42 |
+
|
| 43 |
+
output logic master_req_o,
|
| 44 |
+
output logic [BusWidth-1:0] master_add_o,
|
| 45 |
+
output logic master_we_o,
|
| 46 |
+
output logic [BusWidth-1:0] master_wdata_o,
|
| 47 |
+
output logic [BusWidth/8-1:0] master_be_o,
|
| 48 |
+
input logic master_gnt_i,
|
| 49 |
+
input logic master_r_valid_i,
|
| 50 |
+
input logic [BusWidth-1:0] master_r_rdata_i,
|
| 51 |
+
|
| 52 |
+
// Connection to DTM - compatible to RocketChip Debug Module
|
| 53 |
+
input logic dmi_rst_ni,
|
| 54 |
+
input logic dmi_req_valid_i,
|
| 55 |
+
output logic dmi_req_ready_o,
|
| 56 |
+
input dm::dmi_req_t dmi_req_i,
|
| 57 |
+
|
| 58 |
+
output logic dmi_resp_valid_o,
|
| 59 |
+
input logic dmi_resp_ready_i,
|
| 60 |
+
output dm::dmi_resp_t dmi_resp_o
|
| 61 |
+
);
|
| 62 |
+
|
| 63 |
+
// Debug CSRs
|
| 64 |
+
logic [NrHarts-1:0] halted;
|
| 65 |
+
// logic [NrHarts-1:0] running;
|
| 66 |
+
logic [NrHarts-1:0] resumeack;
|
| 67 |
+
logic [NrHarts-1:0] haltreq;
|
| 68 |
+
logic [NrHarts-1:0] resumereq;
|
| 69 |
+
logic clear_resumeack;
|
| 70 |
+
logic cmd_valid;
|
| 71 |
+
dm::command_t cmd;
|
| 72 |
+
|
| 73 |
+
logic cmderror_valid;
|
| 74 |
+
dm::cmderr_e cmderror;
|
| 75 |
+
logic cmdbusy;
|
| 76 |
+
logic [dm::ProgBufSize-1:0][31:0] progbuf;
|
| 77 |
+
logic [dm::DataCount-1:0][31:0] data_csrs_mem;
|
| 78 |
+
logic [dm::DataCount-1:0][31:0] data_mem_csrs;
|
| 79 |
+
logic data_valid;
|
| 80 |
+
logic [19:0] hartsel;
|
| 81 |
+
// System Bus Access Module
|
| 82 |
+
logic [BusWidth-1:0] sbaddress_csrs_sba;
|
| 83 |
+
logic [BusWidth-1:0] sbaddress_sba_csrs;
|
| 84 |
+
logic sbaddress_write_valid;
|
| 85 |
+
logic sbreadonaddr;
|
| 86 |
+
logic sbautoincrement;
|
| 87 |
+
logic [2:0] sbaccess;
|
| 88 |
+
logic sbreadondata;
|
| 89 |
+
logic [BusWidth-1:0] sbdata_write;
|
| 90 |
+
logic sbdata_read_valid;
|
| 91 |
+
logic sbdata_write_valid;
|
| 92 |
+
logic [BusWidth-1:0] sbdata_read;
|
| 93 |
+
logic sbdata_valid;
|
| 94 |
+
logic sbbusy;
|
| 95 |
+
logic sberror_valid;
|
| 96 |
+
logic [2:0] sberror;
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
dm_csrs #(
|
| 100 |
+
.NrHarts(NrHarts),
|
| 101 |
+
.BusWidth(BusWidth),
|
| 102 |
+
.SelectableHarts(SelectableHarts)
|
| 103 |
+
) i_dm_csrs (
|
| 104 |
+
.clk_i,
|
| 105 |
+
.rst_ni,
|
| 106 |
+
.testmode_i,
|
| 107 |
+
.dmi_rst_ni,
|
| 108 |
+
.dmi_req_valid_i,
|
| 109 |
+
.dmi_req_ready_o,
|
| 110 |
+
.dmi_req_i,
|
| 111 |
+
.dmi_resp_valid_o,
|
| 112 |
+
.dmi_resp_ready_i,
|
| 113 |
+
.dmi_resp_o,
|
| 114 |
+
.ndmreset_o,
|
| 115 |
+
.dmactive_o,
|
| 116 |
+
.hartsel_o ( hartsel ),
|
| 117 |
+
.hartinfo_i,
|
| 118 |
+
.halted_i ( halted ),
|
| 119 |
+
.unavailable_i,
|
| 120 |
+
.resumeack_i ( resumeack ),
|
| 121 |
+
.haltreq_o ( haltreq ),
|
| 122 |
+
.resumereq_o ( resumereq ),
|
| 123 |
+
.clear_resumeack_o ( clear_resumeack ),
|
| 124 |
+
.cmd_valid_o ( cmd_valid ),
|
| 125 |
+
.cmd_o ( cmd ),
|
| 126 |
+
.cmderror_valid_i ( cmderror_valid ),
|
| 127 |
+
.cmderror_i ( cmderror ),
|
| 128 |
+
.cmdbusy_i ( cmdbusy ),
|
| 129 |
+
.progbuf_o ( progbuf ),
|
| 130 |
+
.data_i ( data_mem_csrs ),
|
| 131 |
+
.data_valid_i ( data_valid ),
|
| 132 |
+
.data_o ( data_csrs_mem ),
|
| 133 |
+
.sbaddress_o ( sbaddress_csrs_sba ),
|
| 134 |
+
.sbaddress_i ( sbaddress_sba_csrs ),
|
| 135 |
+
.sbaddress_write_valid_o ( sbaddress_write_valid ),
|
| 136 |
+
.sbreadonaddr_o ( sbreadonaddr ),
|
| 137 |
+
.sbautoincrement_o ( sbautoincrement ),
|
| 138 |
+
.sbaccess_o ( sbaccess ),
|
| 139 |
+
.sbreadondata_o ( sbreadondata ),
|
| 140 |
+
.sbdata_o ( sbdata_write ),
|
| 141 |
+
.sbdata_read_valid_o ( sbdata_read_valid ),
|
| 142 |
+
.sbdata_write_valid_o ( sbdata_write_valid ),
|
| 143 |
+
.sbdata_i ( sbdata_read ),
|
| 144 |
+
.sbdata_valid_i ( sbdata_valid ),
|
| 145 |
+
.sbbusy_i ( sbbusy ),
|
| 146 |
+
.sberror_valid_i ( sberror_valid ),
|
| 147 |
+
.sberror_i ( sberror )
|
| 148 |
+
);
|
| 149 |
+
|
| 150 |
+
dm_sba #(
|
| 151 |
+
.BusWidth(BusWidth)
|
| 152 |
+
) i_dm_sba (
|
| 153 |
+
.clk_i,
|
| 154 |
+
.rst_ni,
|
| 155 |
+
.dmactive_i ( dmactive_o ),
|
| 156 |
+
|
| 157 |
+
.master_req_o,
|
| 158 |
+
.master_add_o,
|
| 159 |
+
.master_we_o,
|
| 160 |
+
.master_wdata_o,
|
| 161 |
+
.master_be_o,
|
| 162 |
+
.master_gnt_i,
|
| 163 |
+
.master_r_valid_i,
|
| 164 |
+
.master_r_rdata_i,
|
| 165 |
+
|
| 166 |
+
.sbaddress_i ( sbaddress_csrs_sba ),
|
| 167 |
+
.sbaddress_o ( sbaddress_sba_csrs ),
|
| 168 |
+
.sbaddress_write_valid_i ( sbaddress_write_valid ),
|
| 169 |
+
.sbreadonaddr_i ( sbreadonaddr ),
|
| 170 |
+
.sbautoincrement_i ( sbautoincrement ),
|
| 171 |
+
.sbaccess_i ( sbaccess ),
|
| 172 |
+
.sbreadondata_i ( sbreadondata ),
|
| 173 |
+
.sbdata_i ( sbdata_write ),
|
| 174 |
+
.sbdata_read_valid_i ( sbdata_read_valid ),
|
| 175 |
+
.sbdata_write_valid_i ( sbdata_write_valid ),
|
| 176 |
+
.sbdata_o ( sbdata_read ),
|
| 177 |
+
.sbdata_valid_o ( sbdata_valid ),
|
| 178 |
+
.sbbusy_o ( sbbusy ),
|
| 179 |
+
.sberror_valid_o ( sberror_valid ),
|
| 180 |
+
.sberror_o ( sberror )
|
| 181 |
+
);
|
| 182 |
+
|
| 183 |
+
dm_mem #(
|
| 184 |
+
.NrHarts(NrHarts),
|
| 185 |
+
.BusWidth(BusWidth),
|
| 186 |
+
.SelectableHarts(SelectableHarts)
|
| 187 |
+
) i_dm_mem (
|
| 188 |
+
.clk_i,
|
| 189 |
+
.rst_ni,
|
| 190 |
+
.debug_req_o,
|
| 191 |
+
.hartsel_i ( hartsel ),
|
| 192 |
+
.haltreq_i ( haltreq ),
|
| 193 |
+
.resumereq_i ( resumereq ),
|
| 194 |
+
.clear_resumeack_i ( clear_resumeack ),
|
| 195 |
+
.halted_o ( halted ),
|
| 196 |
+
.resuming_o ( resumeack ),
|
| 197 |
+
.cmd_valid_i ( cmd_valid ),
|
| 198 |
+
.cmd_i ( cmd ),
|
| 199 |
+
.cmderror_valid_o ( cmderror_valid ),
|
| 200 |
+
.cmderror_o ( cmderror ),
|
| 201 |
+
.cmdbusy_o ( cmdbusy ),
|
| 202 |
+
.progbuf_i ( progbuf ),
|
| 203 |
+
.data_i ( data_csrs_mem ),
|
| 204 |
+
.data_o ( data_mem_csrs ),
|
| 205 |
+
.data_valid_o ( data_valid ),
|
| 206 |
+
.req_i ( slave_req_i ),
|
| 207 |
+
.we_i ( slave_we_i ),
|
| 208 |
+
.addr_i ( slave_addr_i ),
|
| 209 |
+
.wdata_i ( slave_wdata_i ),
|
| 210 |
+
.be_i ( slave_be_i ),
|
| 211 |
+
.rdata_o ( slave_rdata_o )
|
| 212 |
+
);
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
`ifndef VERILATOR
|
| 216 |
+
initial begin
|
| 217 |
+
assert (BusWidth == 32 || BusWidth == 64)
|
| 218 |
+
else $fatal(1, "DM needs a bus width of either 32 or 64 bits");
|
| 219 |
+
end
|
| 220 |
+
`endif
|
| 221 |
+
|
| 222 |
+
endmodule : dm_top
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dmi_cdc.sv
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: axi_riscv_debug_module.sv
|
| 12 |
+
* Author: Andreas Traber <atraber@iis.ee.ethz.ch>
|
| 13 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 14 |
+
*
|
| 15 |
+
* Description: Clock domain crossings for JTAG to DMI very heavily based
|
| 16 |
+
* on previous work by Andreas Traber for the PULP project.
|
| 17 |
+
* This is mainly a wrapper around the existing CDCs.
|
| 18 |
+
*/
|
| 19 |
+
module dmi_cdc (
|
| 20 |
+
// JTAG side (master side)
|
| 21 |
+
input logic tck_i,
|
| 22 |
+
input logic trst_ni,
|
| 23 |
+
|
| 24 |
+
input dm::dmi_req_t jtag_dmi_req_i,
|
| 25 |
+
output logic jtag_dmi_ready_o,
|
| 26 |
+
input logic jtag_dmi_valid_i,
|
| 27 |
+
|
| 28 |
+
output dm::dmi_resp_t jtag_dmi_resp_o,
|
| 29 |
+
output logic jtag_dmi_valid_o,
|
| 30 |
+
input logic jtag_dmi_ready_i,
|
| 31 |
+
|
| 32 |
+
// core side (slave side)
|
| 33 |
+
input logic clk_i,
|
| 34 |
+
input logic rst_ni,
|
| 35 |
+
|
| 36 |
+
output dm::dmi_req_t core_dmi_req_o,
|
| 37 |
+
output logic core_dmi_valid_o,
|
| 38 |
+
input logic core_dmi_ready_i,
|
| 39 |
+
|
| 40 |
+
input dm::dmi_resp_t core_dmi_resp_i,
|
| 41 |
+
output logic core_dmi_ready_o,
|
| 42 |
+
input logic core_dmi_valid_i
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
cdc_2phase #(.T(dm::dmi_req_t)) i_cdc_req (
|
| 46 |
+
.src_rst_ni ( trst_ni ),
|
| 47 |
+
.src_clk_i ( tck_i ),
|
| 48 |
+
.src_data_i ( jtag_dmi_req_i ),
|
| 49 |
+
.src_valid_i ( jtag_dmi_valid_i ),
|
| 50 |
+
.src_ready_o ( jtag_dmi_ready_o ),
|
| 51 |
+
|
| 52 |
+
.dst_rst_ni ( rst_ni ),
|
| 53 |
+
.dst_clk_i ( clk_i ),
|
| 54 |
+
.dst_data_o ( core_dmi_req_o ),
|
| 55 |
+
.dst_valid_o ( core_dmi_valid_o ),
|
| 56 |
+
.dst_ready_i ( core_dmi_ready_i )
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
cdc_2phase #(.T(dm::dmi_resp_t)) i_cdc_resp (
|
| 60 |
+
.src_rst_ni ( rst_ni ),
|
| 61 |
+
.src_clk_i ( clk_i ),
|
| 62 |
+
.src_data_i ( core_dmi_resp_i ),
|
| 63 |
+
.src_valid_i ( core_dmi_valid_i ),
|
| 64 |
+
.src_ready_o ( core_dmi_ready_o ),
|
| 65 |
+
|
| 66 |
+
.dst_rst_ni ( trst_ni ),
|
| 67 |
+
.dst_clk_i ( tck_i ),
|
| 68 |
+
.dst_data_o ( jtag_dmi_resp_o ),
|
| 69 |
+
.dst_valid_o ( jtag_dmi_valid_o ),
|
| 70 |
+
.dst_ready_i ( jtag_dmi_ready_i )
|
| 71 |
+
);
|
| 72 |
+
|
| 73 |
+
endmodule : dmi_cdc
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dmi_jtag.sv
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: axi_riscv_debug_module.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 19.7.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: JTAG DMI (debug module interface)
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
module dmi_jtag #(
|
| 20 |
+
parameter logic [31:0] IdcodeValue = 32'h00000001
|
| 21 |
+
) (
|
| 22 |
+
input logic clk_i, // DMI Clock
|
| 23 |
+
input logic rst_ni, // Asynchronous reset active low
|
| 24 |
+
input logic testmode_i,
|
| 25 |
+
|
| 26 |
+
output logic dmi_rst_no, // hard reset
|
| 27 |
+
output dm::dmi_req_t dmi_req_o,
|
| 28 |
+
output logic dmi_req_valid_o,
|
| 29 |
+
input logic dmi_req_ready_i,
|
| 30 |
+
|
| 31 |
+
input dm::dmi_resp_t dmi_resp_i,
|
| 32 |
+
output logic dmi_resp_ready_o,
|
| 33 |
+
input logic dmi_resp_valid_i,
|
| 34 |
+
|
| 35 |
+
input logic tck_i, // JTAG test clock pad
|
| 36 |
+
input logic tms_i, // JTAG test mode select pad
|
| 37 |
+
input logic trst_ni, // JTAG test reset pad
|
| 38 |
+
input logic td_i, // JTAG test data input pad
|
| 39 |
+
output logic td_o, // JTAG test data output pad
|
| 40 |
+
output logic tdo_oe_o // Data out output enable
|
| 41 |
+
);
|
| 42 |
+
assign dmi_rst_no = rst_ni;
|
| 43 |
+
|
| 44 |
+
logic test_logic_reset;
|
| 45 |
+
logic shift_dr;
|
| 46 |
+
logic update_dr;
|
| 47 |
+
logic capture_dr;
|
| 48 |
+
logic dmi_access;
|
| 49 |
+
logic dtmcs_select;
|
| 50 |
+
logic dmi_reset;
|
| 51 |
+
logic dmi_tdi;
|
| 52 |
+
logic dmi_tdo;
|
| 53 |
+
|
| 54 |
+
dm::dmi_req_t dmi_req;
|
| 55 |
+
logic dmi_req_ready;
|
| 56 |
+
logic dmi_req_valid;
|
| 57 |
+
|
| 58 |
+
dm::dmi_resp_t dmi_resp;
|
| 59 |
+
logic dmi_resp_valid;
|
| 60 |
+
logic dmi_resp_ready;
|
| 61 |
+
|
| 62 |
+
typedef struct packed {
|
| 63 |
+
logic [6:0] address;
|
| 64 |
+
logic [31:0] data;
|
| 65 |
+
logic [1:0] op;
|
| 66 |
+
} dmi_t;
|
| 67 |
+
|
| 68 |
+
typedef enum logic [1:0] {
|
| 69 |
+
DMINoError = 2'h0, DMIReservedError = 2'h1,
|
| 70 |
+
DMIOPFailed = 2'h2, DMIBusy = 2'h3
|
| 71 |
+
} dmi_error_e;
|
| 72 |
+
|
| 73 |
+
typedef enum logic [2:0] { Idle, Read, WaitReadValid, Write, WaitWriteValid } state_e;
|
| 74 |
+
state_e state_d, state_q;
|
| 75 |
+
|
| 76 |
+
logic [$bits(dmi_t)-1:0] dr_d, dr_q;
|
| 77 |
+
logic [6:0] address_d, address_q;
|
| 78 |
+
logic [31:0] data_d, data_q;
|
| 79 |
+
|
| 80 |
+
dmi_t dmi;
|
| 81 |
+
assign dmi = dmi_t'(dr_q);
|
| 82 |
+
assign dmi_req.addr = address_q;
|
| 83 |
+
assign dmi_req.data = data_q;
|
| 84 |
+
assign dmi_req.op = (state_q == Write) ? dm::DTM_WRITE : dm::DTM_READ;
|
| 85 |
+
// we'will always be ready to accept the data we requested
|
| 86 |
+
assign dmi_resp_ready = 1'b1;
|
| 87 |
+
|
| 88 |
+
logic error_dmi_busy;
|
| 89 |
+
dmi_error_e error_d, error_q;
|
| 90 |
+
|
| 91 |
+
always_comb begin : p_fsm
|
| 92 |
+
error_dmi_busy = 1'b0;
|
| 93 |
+
// default assignments
|
| 94 |
+
state_d = state_q;
|
| 95 |
+
address_d = address_q;
|
| 96 |
+
data_d = data_q;
|
| 97 |
+
error_d = error_q;
|
| 98 |
+
|
| 99 |
+
dmi_req_valid = 1'b0;
|
| 100 |
+
|
| 101 |
+
unique case (state_q)
|
| 102 |
+
Idle: begin
|
| 103 |
+
// make sure that no error is sticky
|
| 104 |
+
if (dmi_access && update_dr && (error_q == DMINoError)) begin
|
| 105 |
+
// save address and value
|
| 106 |
+
address_d = dmi.address;
|
| 107 |
+
data_d = dmi.data;
|
| 108 |
+
if (dm::dtm_op_e'(dmi.op) == dm::DTM_READ) begin
|
| 109 |
+
state_d = Read;
|
| 110 |
+
end else if (dm::dtm_op_e'(dmi.op) == dm::DTM_WRITE) begin
|
| 111 |
+
state_d = Write;
|
| 112 |
+
end
|
| 113 |
+
// else this is a nop and we can stay here
|
| 114 |
+
end
|
| 115 |
+
end
|
| 116 |
+
|
| 117 |
+
Read: begin
|
| 118 |
+
dmi_req_valid = 1'b1;
|
| 119 |
+
if (dmi_req_ready) begin
|
| 120 |
+
state_d = WaitReadValid;
|
| 121 |
+
end
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
WaitReadValid: begin
|
| 125 |
+
// load data into register and shift out
|
| 126 |
+
if (dmi_resp_valid) begin
|
| 127 |
+
data_d = dmi_resp.data;
|
| 128 |
+
state_d = Idle;
|
| 129 |
+
end
|
| 130 |
+
end
|
| 131 |
+
|
| 132 |
+
Write: begin
|
| 133 |
+
dmi_req_valid = 1'b1;
|
| 134 |
+
// got a valid answer go back to idle
|
| 135 |
+
if (dmi_req_ready) begin
|
| 136 |
+
state_d = Idle;
|
| 137 |
+
end
|
| 138 |
+
end
|
| 139 |
+
|
| 140 |
+
default: begin
|
| 141 |
+
// just wait for idle here
|
| 142 |
+
if (dmi_resp_valid) begin
|
| 143 |
+
state_d = Idle;
|
| 144 |
+
end
|
| 145 |
+
end
|
| 146 |
+
endcase
|
| 147 |
+
|
| 148 |
+
// update_dr means we got another request but we didn't finish
|
| 149 |
+
// the one in progress, this state is sticky
|
| 150 |
+
if (update_dr && state_q != Idle) begin
|
| 151 |
+
error_dmi_busy = 1'b1;
|
| 152 |
+
end
|
| 153 |
+
|
| 154 |
+
// if capture_dr goes high while we are in the read state
|
| 155 |
+
// or in the corresponding wait state we are not giving back a valid word
|
| 156 |
+
// -> throw an error
|
| 157 |
+
if (capture_dr && state_q inside {Read, WaitReadValid}) begin
|
| 158 |
+
error_dmi_busy = 1'b1;
|
| 159 |
+
end
|
| 160 |
+
|
| 161 |
+
if (error_dmi_busy) begin
|
| 162 |
+
error_d = DMIBusy;
|
| 163 |
+
end
|
| 164 |
+
// clear sticky error flag
|
| 165 |
+
if (dmi_reset && dtmcs_select) begin
|
| 166 |
+
error_d = DMINoError;
|
| 167 |
+
end
|
| 168 |
+
end
|
| 169 |
+
|
| 170 |
+
// shift register
|
| 171 |
+
assign dmi_tdo = dr_q[0];
|
| 172 |
+
|
| 173 |
+
always_comb begin : p_shift
|
| 174 |
+
dr_d = dr_q;
|
| 175 |
+
|
| 176 |
+
if (capture_dr) begin
|
| 177 |
+
if (dmi_access) begin
|
| 178 |
+
if (error_q == DMINoError && !error_dmi_busy) begin
|
| 179 |
+
dr_d = {address_q, data_q, DMINoError};
|
| 180 |
+
// DMI was busy, report an error
|
| 181 |
+
end else if (error_q == DMIBusy || error_dmi_busy) begin
|
| 182 |
+
dr_d = {address_q, data_q, DMIBusy};
|
| 183 |
+
end
|
| 184 |
+
end
|
| 185 |
+
end
|
| 186 |
+
|
| 187 |
+
if (shift_dr) begin
|
| 188 |
+
if (dmi_access) begin
|
| 189 |
+
dr_d = {dmi_tdi, dr_q[$bits(dr_q)-1:1]};
|
| 190 |
+
end
|
| 191 |
+
end
|
| 192 |
+
|
| 193 |
+
if (test_logic_reset) begin
|
| 194 |
+
dr_d = '0;
|
| 195 |
+
end
|
| 196 |
+
end
|
| 197 |
+
|
| 198 |
+
always_ff @(posedge tck_i or negedge trst_ni) begin : p_regs
|
| 199 |
+
if (!trst_ni) begin
|
| 200 |
+
dr_q <= '0;
|
| 201 |
+
state_q <= Idle;
|
| 202 |
+
address_q <= '0;
|
| 203 |
+
data_q <= '0;
|
| 204 |
+
error_q <= DMINoError;
|
| 205 |
+
end else begin
|
| 206 |
+
dr_q <= dr_d;
|
| 207 |
+
state_q <= state_d;
|
| 208 |
+
address_q <= address_d;
|
| 209 |
+
data_q <= data_d;
|
| 210 |
+
error_q <= error_d;
|
| 211 |
+
end
|
| 212 |
+
end
|
| 213 |
+
|
| 214 |
+
// ---------
|
| 215 |
+
// TAP
|
| 216 |
+
// ---------
|
| 217 |
+
dmi_jtag_tap #(
|
| 218 |
+
.IrLength (5),
|
| 219 |
+
.IdcodeValue(IdcodeValue)
|
| 220 |
+
) i_dmi_jtag_tap (
|
| 221 |
+
.tck_i,
|
| 222 |
+
.tms_i,
|
| 223 |
+
.trst_ni,
|
| 224 |
+
.td_i,
|
| 225 |
+
.td_o,
|
| 226 |
+
.tdo_oe_o,
|
| 227 |
+
.testmode_i,
|
| 228 |
+
.test_logic_reset_o ( test_logic_reset ),
|
| 229 |
+
.shift_dr_o ( shift_dr ),
|
| 230 |
+
.update_dr_o ( update_dr ),
|
| 231 |
+
.capture_dr_o ( capture_dr ),
|
| 232 |
+
.dmi_access_o ( dmi_access ),
|
| 233 |
+
.dtmcs_select_o ( dtmcs_select ),
|
| 234 |
+
.dmi_reset_o ( dmi_reset ),
|
| 235 |
+
.dmi_error_i ( error_q ),
|
| 236 |
+
.dmi_tdi_o ( dmi_tdi ),
|
| 237 |
+
.dmi_tdo_i ( dmi_tdo )
|
| 238 |
+
);
|
| 239 |
+
|
| 240 |
+
// ---------
|
| 241 |
+
// CDC
|
| 242 |
+
// ---------
|
| 243 |
+
dmi_cdc i_dmi_cdc (
|
| 244 |
+
// JTAG side (master side)
|
| 245 |
+
.tck_i,
|
| 246 |
+
.trst_ni,
|
| 247 |
+
.jtag_dmi_req_i ( dmi_req ),
|
| 248 |
+
.jtag_dmi_ready_o ( dmi_req_ready ),
|
| 249 |
+
.jtag_dmi_valid_i ( dmi_req_valid ),
|
| 250 |
+
.jtag_dmi_resp_o ( dmi_resp ),
|
| 251 |
+
.jtag_dmi_valid_o ( dmi_resp_valid ),
|
| 252 |
+
.jtag_dmi_ready_i ( dmi_resp_ready ),
|
| 253 |
+
// core side
|
| 254 |
+
.clk_i,
|
| 255 |
+
.rst_ni,
|
| 256 |
+
.core_dmi_req_o ( dmi_req_o ),
|
| 257 |
+
.core_dmi_valid_o ( dmi_req_valid_o ),
|
| 258 |
+
.core_dmi_ready_i ( dmi_req_ready_i ),
|
| 259 |
+
.core_dmi_resp_i ( dmi_resp_i ),
|
| 260 |
+
.core_dmi_ready_o ( dmi_resp_ready_o ),
|
| 261 |
+
.core_dmi_valid_i ( dmi_resp_valid_i )
|
| 262 |
+
);
|
| 263 |
+
|
| 264 |
+
endmodule : dmi_jtag
|
snapshots/pulp-platform_riscv-dbg_pr53/src/dmi_jtag_tap.sv
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Copyright 2018 ETH Zurich and University of Bologna.
|
| 2 |
+
* Copyright and related rights are licensed under the Solderpad Hardware
|
| 3 |
+
* License, Version 0.51 (the “License”); you may not use this file except in
|
| 4 |
+
* compliance with the License. You may obtain a copy of the License at
|
| 5 |
+
* http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
|
| 6 |
+
* or agreed to in writing, software, hardware and materials distributed under
|
| 7 |
+
* this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
|
| 8 |
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
| 9 |
+
* specific language governing permissions and limitations under the License.
|
| 10 |
+
*
|
| 11 |
+
* File: dmi_jtag_tap.sv
|
| 12 |
+
* Author: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
|
| 13 |
+
* Date: 19.7.2018
|
| 14 |
+
*
|
| 15 |
+
* Description: JTAG TAP for DMI (according to debug spec 0.13)
|
| 16 |
+
*
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
module dmi_jtag_tap #(
|
| 20 |
+
parameter int unsigned IrLength = 5,
|
| 21 |
+
// JTAG IDCODE Value
|
| 22 |
+
parameter logic [31:0] IdcodeValue = 32'h00000001
|
| 23 |
+
// xxxx version
|
| 24 |
+
// xxxxxxxxxxxxxxxx part number
|
| 25 |
+
// xxxxxxxxxxx manufacturer id
|
| 26 |
+
// 1 required by standard
|
| 27 |
+
) (
|
| 28 |
+
input logic tck_i, // JTAG test clock pad
|
| 29 |
+
input logic tms_i, // JTAG test mode select pad
|
| 30 |
+
input logic trst_ni, // JTAG test reset pad
|
| 31 |
+
input logic td_i, // JTAG test data input pad
|
| 32 |
+
output logic td_o, // JTAG test data output pad
|
| 33 |
+
output logic tdo_oe_o, // Data out output enable
|
| 34 |
+
input logic testmode_i,
|
| 35 |
+
output logic test_logic_reset_o,
|
| 36 |
+
output logic shift_dr_o,
|
| 37 |
+
output logic update_dr_o,
|
| 38 |
+
output logic capture_dr_o,
|
| 39 |
+
|
| 40 |
+
// we want to access DMI register
|
| 41 |
+
output logic dmi_access_o,
|
| 42 |
+
// JTAG is interested in writing the DTM CSR register
|
| 43 |
+
output logic dtmcs_select_o,
|
| 44 |
+
// clear error state
|
| 45 |
+
output logic dmi_reset_o,
|
| 46 |
+
input logic [1:0] dmi_error_i,
|
| 47 |
+
// test data to submodule
|
| 48 |
+
output logic dmi_tdi_o,
|
| 49 |
+
// test data in from submodule
|
| 50 |
+
input logic dmi_tdo_i
|
| 51 |
+
);
|
| 52 |
+
|
| 53 |
+
// to submodule
|
| 54 |
+
assign dmi_tdi_o = td_i;
|
| 55 |
+
|
| 56 |
+
typedef enum logic [3:0] {
|
| 57 |
+
TestLogicReset, RunTestIdle, SelectDrScan,
|
| 58 |
+
CaptureDr, ShiftDr, Exit1Dr, PauseDr, Exit2Dr,
|
| 59 |
+
UpdateDr, SelectIrScan, CaptureIr, ShiftIr,
|
| 60 |
+
Exit1Ir, PauseIr, Exit2Ir, UpdateIr
|
| 61 |
+
} tap_state_e;
|
| 62 |
+
|
| 63 |
+
tap_state_e tap_state_q, tap_state_d;
|
| 64 |
+
|
| 65 |
+
typedef enum logic [IrLength-1:0] {
|
| 66 |
+
BYPASS0 = 'h0,
|
| 67 |
+
IDCODE = 'h1,
|
| 68 |
+
DTMCSR = 'h10,
|
| 69 |
+
DMIACCESS = 'h11,
|
| 70 |
+
BYPASS1 = 'h1f
|
| 71 |
+
} ir_reg_e;
|
| 72 |
+
|
| 73 |
+
typedef struct packed {
|
| 74 |
+
logic [31:18] zero1;
|
| 75 |
+
logic dmihardreset;
|
| 76 |
+
logic dmireset;
|
| 77 |
+
logic zero0;
|
| 78 |
+
logic [14:12] idle;
|
| 79 |
+
logic [11:10] dmistat;
|
| 80 |
+
logic [9:4] abits;
|
| 81 |
+
logic [3:0] version;
|
| 82 |
+
} dtmcs_t;
|
| 83 |
+
|
| 84 |
+
// ----------------
|
| 85 |
+
// IR logic
|
| 86 |
+
// ----------------
|
| 87 |
+
|
| 88 |
+
// shift register
|
| 89 |
+
logic [IrLength-1:0] jtag_ir_shift_d, jtag_ir_shift_q;
|
| 90 |
+
// IR register -> this gets captured from shift register upon update_ir
|
| 91 |
+
ir_reg_e jtag_ir_d, jtag_ir_q;
|
| 92 |
+
logic capture_ir, shift_ir, update_ir; // pause_ir
|
| 93 |
+
|
| 94 |
+
always_comb begin : p_jtag
|
| 95 |
+
jtag_ir_shift_d = jtag_ir_shift_q;
|
| 96 |
+
jtag_ir_d = jtag_ir_q;
|
| 97 |
+
|
| 98 |
+
// IR shift register
|
| 99 |
+
if (shift_ir) begin
|
| 100 |
+
jtag_ir_shift_d = {td_i, jtag_ir_shift_q[IrLength-1:1]};
|
| 101 |
+
end
|
| 102 |
+
|
| 103 |
+
// capture IR register
|
| 104 |
+
if (capture_ir) begin
|
| 105 |
+
jtag_ir_shift_d = IrLength'(4'b0101);
|
| 106 |
+
end
|
| 107 |
+
|
| 108 |
+
// update IR register
|
| 109 |
+
if (update_ir) begin
|
| 110 |
+
jtag_ir_d = ir_reg_e'(jtag_ir_shift_q);
|
| 111 |
+
end
|
| 112 |
+
|
| 113 |
+
// synchronous test-logic reset
|
| 114 |
+
if (test_logic_reset_o) begin
|
| 115 |
+
jtag_ir_shift_d = '0;
|
| 116 |
+
jtag_ir_d = IDCODE;
|
| 117 |
+
end
|
| 118 |
+
end
|
| 119 |
+
|
| 120 |
+
always_ff @(posedge tck_i, negedge trst_ni) begin : p_jtag_ir_reg
|
| 121 |
+
if (!trst_ni) begin
|
| 122 |
+
jtag_ir_shift_q <= '0;
|
| 123 |
+
jtag_ir_q <= IDCODE;
|
| 124 |
+
end else begin
|
| 125 |
+
jtag_ir_shift_q <= jtag_ir_shift_d;
|
| 126 |
+
jtag_ir_q <= jtag_ir_d;
|
| 127 |
+
end
|
| 128 |
+
end
|
| 129 |
+
|
| 130 |
+
// ----------------
|
| 131 |
+
// TAP DR Regs
|
| 132 |
+
// ----------------
|
| 133 |
+
// - Bypass
|
| 134 |
+
// - IDCODE
|
| 135 |
+
// - DTM CS
|
| 136 |
+
logic [31:0] idcode_d, idcode_q;
|
| 137 |
+
logic idcode_select;
|
| 138 |
+
logic bypass_select;
|
| 139 |
+
dtmcs_t dtmcs_d, dtmcs_q;
|
| 140 |
+
logic bypass_d, bypass_q; // this is a 1-bit register
|
| 141 |
+
|
| 142 |
+
assign dmi_reset_o = dtmcs_q.dmireset;
|
| 143 |
+
|
| 144 |
+
always_comb begin
|
| 145 |
+
idcode_d = idcode_q;
|
| 146 |
+
bypass_d = bypass_q;
|
| 147 |
+
dtmcs_d = dtmcs_q;
|
| 148 |
+
|
| 149 |
+
if (capture_dr_o) begin
|
| 150 |
+
if (idcode_select) idcode_d = IdcodeValue;
|
| 151 |
+
if (bypass_select) bypass_d = 1'b0;
|
| 152 |
+
if (dtmcs_select_o) begin
|
| 153 |
+
dtmcs_d = '{
|
| 154 |
+
zero1 : '0,
|
| 155 |
+
dmihardreset : 1'b0,
|
| 156 |
+
dmireset : 1'b0,
|
| 157 |
+
zero0 : '0,
|
| 158 |
+
idle : 3'd1, // 1: Enter Run-Test/Idle and leave it immediately
|
| 159 |
+
dmistat : dmi_error_i, // 0: No error, 1: Op failed, 2: too fast
|
| 160 |
+
abits : 6'd7, // The size of address in dmi
|
| 161 |
+
version : 4'd1 // Version described in spec version 0.13 (and later?)
|
| 162 |
+
};
|
| 163 |
+
end
|
| 164 |
+
end
|
| 165 |
+
|
| 166 |
+
if (shift_dr_o) begin
|
| 167 |
+
if (idcode_select) idcode_d = {td_i, 31'(idcode_q >> 1)};
|
| 168 |
+
if (bypass_select) bypass_d = td_i;
|
| 169 |
+
if (dtmcs_select_o) dtmcs_d = {td_i, 31'(dtmcs_q >> 1)};
|
| 170 |
+
end
|
| 171 |
+
|
| 172 |
+
if (test_logic_reset_o) begin
|
| 173 |
+
idcode_d = IdcodeValue;
|
| 174 |
+
bypass_d = 1'b0;
|
| 175 |
+
end
|
| 176 |
+
end
|
| 177 |
+
|
| 178 |
+
// ----------------
|
| 179 |
+
// Data reg select
|
| 180 |
+
// ----------------
|
| 181 |
+
always_comb begin : p_data_reg_sel
|
| 182 |
+
dmi_access_o = 1'b0;
|
| 183 |
+
dtmcs_select_o = 1'b0;
|
| 184 |
+
idcode_select = 1'b0;
|
| 185 |
+
bypass_select = 1'b0;
|
| 186 |
+
unique case (jtag_ir_q)
|
| 187 |
+
BYPASS0: bypass_select = 1'b1;
|
| 188 |
+
IDCODE: idcode_select = 1'b1;
|
| 189 |
+
DTMCSR: dtmcs_select_o = 1'b1;
|
| 190 |
+
DMIACCESS: dmi_access_o = 1'b1;
|
| 191 |
+
BYPASS1: bypass_select = 1'b1;
|
| 192 |
+
default: bypass_select = 1'b1;
|
| 193 |
+
endcase
|
| 194 |
+
end
|
| 195 |
+
|
| 196 |
+
// ----------------
|
| 197 |
+
// Output select
|
| 198 |
+
// ----------------
|
| 199 |
+
logic tdo_mux;
|
| 200 |
+
|
| 201 |
+
always_comb begin : p_out_sel
|
| 202 |
+
// we are shifting out the IR register
|
| 203 |
+
if (shift_ir) begin
|
| 204 |
+
tdo_mux = jtag_ir_shift_q[0];
|
| 205 |
+
// here we are shifting the DR register
|
| 206 |
+
end else begin
|
| 207 |
+
unique case (jtag_ir_q)
|
| 208 |
+
IDCODE: tdo_mux = idcode_q[0]; // Reading ID code
|
| 209 |
+
DTMCSR: tdo_mux = dtmcs_q.version[0];
|
| 210 |
+
DMIACCESS: tdo_mux = dmi_tdo_i; // Read from DMI TDO
|
| 211 |
+
default: tdo_mux = bypass_q; // BYPASS instruction
|
| 212 |
+
endcase
|
| 213 |
+
end
|
| 214 |
+
end
|
| 215 |
+
|
| 216 |
+
// ----------------
|
| 217 |
+
// DFT
|
| 218 |
+
// ----------------
|
| 219 |
+
logic tck_n, tck_ni;
|
| 220 |
+
|
| 221 |
+
cluster_clock_inverter i_tck_inv (
|
| 222 |
+
.clk_i ( tck_i ),
|
| 223 |
+
.clk_o ( tck_ni )
|
| 224 |
+
);
|
| 225 |
+
|
| 226 |
+
pulp_clock_mux2 i_dft_tck_mux (
|
| 227 |
+
.clk0_i ( tck_ni ),
|
| 228 |
+
.clk1_i ( tck_i ), // bypass the inverted clock for testing
|
| 229 |
+
.clk_sel_i ( testmode_i ),
|
| 230 |
+
.clk_o ( tck_n )
|
| 231 |
+
);
|
| 232 |
+
|
| 233 |
+
// TDO changes state at negative edge of TCK
|
| 234 |
+
always_ff @(posedge tck_n, negedge trst_ni) begin : p_tdo_regs
|
| 235 |
+
if (!trst_ni) begin
|
| 236 |
+
td_o <= 1'b0;
|
| 237 |
+
tdo_oe_o <= 1'b0;
|
| 238 |
+
end else begin
|
| 239 |
+
td_o <= tdo_mux;
|
| 240 |
+
tdo_oe_o <= (shift_ir | shift_dr_o);
|
| 241 |
+
end
|
| 242 |
+
end
|
| 243 |
+
// ----------------
|
| 244 |
+
// TAP FSM
|
| 245 |
+
// ----------------
|
| 246 |
+
// Determination of next state; purely combinatorial
|
| 247 |
+
always_comb begin : p_tap_fsm
|
| 248 |
+
|
| 249 |
+
test_logic_reset_o = 1'b0;
|
| 250 |
+
|
| 251 |
+
capture_dr_o = 1'b0;
|
| 252 |
+
shift_dr_o = 1'b0;
|
| 253 |
+
update_dr_o = 1'b0;
|
| 254 |
+
|
| 255 |
+
capture_ir = 1'b0;
|
| 256 |
+
shift_ir = 1'b0;
|
| 257 |
+
// pause_ir = 1'b0; unused
|
| 258 |
+
update_ir = 1'b0;
|
| 259 |
+
|
| 260 |
+
unique case (tap_state_q)
|
| 261 |
+
TestLogicReset: begin
|
| 262 |
+
tap_state_d = (tms_i) ? TestLogicReset : RunTestIdle;
|
| 263 |
+
test_logic_reset_o = 1'b1;
|
| 264 |
+
end
|
| 265 |
+
RunTestIdle: begin
|
| 266 |
+
tap_state_d = (tms_i) ? SelectDrScan : RunTestIdle;
|
| 267 |
+
end
|
| 268 |
+
// DR Path
|
| 269 |
+
SelectDrScan: begin
|
| 270 |
+
tap_state_d = (tms_i) ? SelectIrScan : CaptureDr;
|
| 271 |
+
end
|
| 272 |
+
CaptureDr: begin
|
| 273 |
+
capture_dr_o = 1'b1;
|
| 274 |
+
tap_state_d = (tms_i) ? Exit1Dr : ShiftDr;
|
| 275 |
+
end
|
| 276 |
+
ShiftDr: begin
|
| 277 |
+
shift_dr_o = 1'b1;
|
| 278 |
+
tap_state_d = (tms_i) ? Exit1Dr : ShiftDr;
|
| 279 |
+
end
|
| 280 |
+
Exit1Dr: begin
|
| 281 |
+
tap_state_d = (tms_i) ? UpdateDr : PauseDr;
|
| 282 |
+
end
|
| 283 |
+
PauseDr: begin
|
| 284 |
+
tap_state_d = (tms_i) ? Exit2Dr : PauseDr;
|
| 285 |
+
end
|
| 286 |
+
Exit2Dr: begin
|
| 287 |
+
tap_state_d = (tms_i) ? UpdateDr : ShiftDr;
|
| 288 |
+
end
|
| 289 |
+
UpdateDr: begin
|
| 290 |
+
update_dr_o = 1'b1;
|
| 291 |
+
tap_state_d = (tms_i) ? SelectDrScan : RunTestIdle;
|
| 292 |
+
end
|
| 293 |
+
// IR Path
|
| 294 |
+
SelectIrScan: begin
|
| 295 |
+
tap_state_d = (tms_i) ? TestLogicReset : CaptureIr;
|
| 296 |
+
end
|
| 297 |
+
// In this controller state, the shift register bank in the
|
| 298 |
+
// Instruction Register parallel loads a pattern of fixed values on
|
| 299 |
+
// the rising edge of TCK. The last two significant bits must always
|
| 300 |
+
// be "01".
|
| 301 |
+
CaptureIr: begin
|
| 302 |
+
capture_ir = 1'b1;
|
| 303 |
+
tap_state_d = (tms_i) ? Exit1Ir : ShiftIr;
|
| 304 |
+
end
|
| 305 |
+
// In this controller state, the instruction register gets connected
|
| 306 |
+
// between TDI and TDO, and the captured pattern gets shifted on
|
| 307 |
+
// each rising edge of TCK. The instruction available on the TDI
|
| 308 |
+
// pin is also shifted in to the instruction register.
|
| 309 |
+
ShiftIr: begin
|
| 310 |
+
shift_ir = 1'b1;
|
| 311 |
+
tap_state_d = (tms_i) ? Exit1Ir : ShiftIr;
|
| 312 |
+
end
|
| 313 |
+
Exit1Ir: begin
|
| 314 |
+
tap_state_d = (tms_i) ? UpdateIr : PauseIr;
|
| 315 |
+
end
|
| 316 |
+
PauseIr: begin
|
| 317 |
+
// pause_ir = 1'b1; // unused
|
| 318 |
+
tap_state_d = (tms_i) ? Exit2Ir : PauseIr;
|
| 319 |
+
end
|
| 320 |
+
Exit2Ir: begin
|
| 321 |
+
tap_state_d = (tms_i) ? UpdateIr : ShiftIr;
|
| 322 |
+
end
|
| 323 |
+
// In this controller state, the instruction in the instruction
|
| 324 |
+
// shift register is latched to the latch bank of the Instruction
|
| 325 |
+
// Register on every falling edge of TCK. This instruction becomes
|
| 326 |
+
// the current instruction once it is latched.
|
| 327 |
+
UpdateIr: begin
|
| 328 |
+
update_ir = 1'b1;
|
| 329 |
+
tap_state_d = (tms_i) ? SelectDrScan : RunTestIdle;
|
| 330 |
+
end
|
| 331 |
+
default: ; // can't actually happen since case is full
|
| 332 |
+
endcase
|
| 333 |
+
end
|
| 334 |
+
|
| 335 |
+
always_ff @(posedge tck_i or negedge trst_ni) begin : p_regs
|
| 336 |
+
if (!trst_ni) begin
|
| 337 |
+
tap_state_q <= RunTestIdle;
|
| 338 |
+
idcode_q <= IdcodeValue;
|
| 339 |
+
bypass_q <= 1'b0;
|
| 340 |
+
dtmcs_q <= '0;
|
| 341 |
+
end else begin
|
| 342 |
+
tap_state_q <= tap_state_d;
|
| 343 |
+
idcode_q <= idcode_d;
|
| 344 |
+
bypass_q <= bypass_d;
|
| 345 |
+
dtmcs_q <= dtmcs_d;
|
| 346 |
+
end
|
| 347 |
+
end
|
| 348 |
+
|
| 349 |
+
endmodule : dmi_jtag_tap
|