Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hardware debug support #883

Open
wants to merge 129 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
77ec3d5
seed debug module for Wally
stineje Jun 3, 2024
6a7f145
fix name of DSCR that I mistakenly made
stineje Jun 3, 2024
f5e01be
delete duplicate
stineje Jun 3, 2024
0bb6a88
fix missing input/output on debug module for lsu
stineje Jun 3, 2024
36c77af
fix missing config-shared.vh
stineje Jun 3, 2024
2c2d5d8
fix missing paramter-defs.vh
stineje Jun 3, 2024
5a03fbe
add flopenrs back
stineje Jun 3, 2024
3864a7f
missing privileged.sv
stineje Jun 3, 2024
fc45fb8
fix csr.sv
stineje Jun 3, 2024
45af939
update ieu
stineje Jun 3, 2024
e49ca99
fix controller typo
stineje Jun 3, 2024
bc36ede
clean up repo
Matthew-Otto Jun 4, 2024
0a6e708
Merge branch 'main' of https://github.com/stineje/cvw
Matthew-Otto Jun 4, 2024
2e0c286
cleanup, rename python scripts
Matthew-Otto Jun 4, 2024
5b50fcd
update two files tha thad repeated lines in them
stineje Jun 4, 2024
1deb44b
fix operator for tap.sv
stineje Jun 4, 2024
bdbd310
fix operator for dm.sv
stineje Jun 4, 2024
ae49006
fix operator for ir and rad
stineje Jun 4, 2024
345c8ce
temporary assignment of JTAG ID
stineje Jun 4, 2024
d900f68
make requested changes
Matthew-Otto Jun 4, 2024
ba9d351
Merge branch 'main' of https://github.com/stineje/cvw
Matthew-Otto Jun 4, 2024
61defc7
update jtag id in openocd.cfg
stineje Jun 4, 2024
ac6f65d
add header to other python file
stineje Jun 4, 2024
9b8aa18
fix double quotes in fstrings
stineje Jun 4, 2024
c565ae3
cleanup of cvw top
stineje Jun 4, 2024
d686176
add items that may be useful as caused error on Ubuntu 22.04 LTS inst…
stineje Jun 4, 2024
6b03e41
fix random data len bug
Matthew-Otto Jun 4, 2024
be0199f
Merge branch 'main' of https://github.com/stineje/cvw
Matthew-Otto Jun 4, 2024
07f010f
turn off DEBUG_SUPPORTED as default
stineje Jun 4, 2024
8485125
fix tap operator for OR
stineje Jun 4, 2024
dc06542
fix E_SUPPORTED inversion bug
Matthew-Otto Jun 5, 2024
2f1c191
Merge branch 'main' of https://github.com/stineje/cvw
Matthew-Otto Jun 5, 2024
6ba6595
Update DEBUG_SUPPORTED to individual configs
stineje Jun 5, 2024
f92783e
change JTAGID again
stineje Jun 5, 2024
5cdd423
config for rv32gc
stineje Jun 5, 2024
9e430be
change JTAG ID in cfg for openocd
stineje Jun 5, 2024
e8f0616
remove unused file
Matthew-Otto Jun 5, 2024
4156c5a
minor tweaks to python file
stineje Jun 6, 2024
130715a
mod debug.sh to have FP regs
stineje Jun 6, 2024
1d5ce9d
update fpu debug
stineje Jun 6, 2024
cd7624f
mod wallypipelinedcore/soc for FP debug of regs
stineje Jun 6, 2024
12a4f2b
initial work on dm for FP regs in debug spec
stineje Jun 6, 2024
0d4e0f8
fix silly typo with comment in hw_debug_test.py
stineje Jun 6, 2024
5f5938f
add FP registers to debug scan chain
Matthew-Otto Jun 8, 2024
4fad0b0
change names of debug/chain output
stineje Jun 8, 2024
c3243ca
add simple debug test for riscv-none-elf-gdb
stineje Jun 8, 2024
97cf2fd
update some comments on debug
stineje Jun 9, 2024
42af10d
minor fix of DSCR naming comment
stineje Jun 9, 2024
67a6e3a
comment update in csrm.sv
stineje Jun 9, 2024
7f63daa
convert debug script to TCL interface, remove telnetlib dependency
Matthew-Otto Jun 9, 2024
95df21f
improve hart status signalling
Matthew-Otto Jun 9, 2024
8e9b245
Merge branch 'main' of https://github.com/stineje/cvw
Matthew-Otto Jun 9, 2024
fb81f03
update sample program
stineje Jun 9, 2024
f488cd7
remove bad jlink command from openocd.cfg
stineje Jun 9, 2024
74a7f47
Merge branch 'main' of github.com:stineje/cvw
stineje Jun 9, 2024
2fc214b
Merge branch 'openhwgroup:main' into main
Matthew-Otto Jun 9, 2024
5ba6e4d
DM accesses to DPC address point to PCM
Matthew-Otto Jun 9, 2024
cb37bea
minor comments
stineje Jun 9, 2024
d2f55b4
update csrs so there is a record of them
stineje Jun 10, 2024
4675614
another csr debug.vh update
stineje Jun 10, 2024
f5e22fc
update csrm to add dpc and dcsr
stineje Jun 10, 2024
abff0bb
(WIP) make all CSRs scannable by DM
Matthew-Otto Jun 12, 2024
c8e5a33
cleanup repo, still WIP
Matthew-Otto Jun 12, 2024
31f437b
fixed GPR/FPR scan regression
Matthew-Otto Jun 12, 2024
6f1f3b7
Alls CSRS tested (Read only)
Matthew-Otto Jun 12, 2024
61eba04
fix whitespace in fregfile.sv
Matthew-Otto Jun 13, 2024
d21e5b1
fix scanning when XLEN != FLEN
Matthew-Otto Jun 13, 2024
f3ff671
Merge branch 'openhwgroup:main' into main
Matthew-Otto Jun 13, 2024
d319703
update jtag id
Matthew-Otto Jun 14, 2024
6ae7ac9
Implement DCSR (Writes are broken)
Matthew-Otto Jun 14, 2024
be7d657
Fix CSR writes from DM
Matthew-Otto Jun 14, 2024
d0deb1b
Add DPC support (does not write on resume)
Matthew-Otto Jun 14, 2024
60f12a6
Fix DPC write and DCSR Cause
Matthew-Otto Jun 14, 2024
679ff34
Improved permissions for CSR access
Matthew-Otto Jun 15, 2024
3a2e8ae
just in case: add rad.sv with comment + new cfg for openocd
stineje Jun 16, 2024
d6256d1
cleanup, dont update Prv in DCSR
Matthew-Otto Jun 16, 2024
c853eee
fix typo in csrd
Matthew-Otto Jun 16, 2024
7dd0182
add progbuff write logic stub
Matthew-Otto Jun 16, 2024
5c593c3
Fix step timing, rewrite jtag to include explicit reset
Matthew-Otto Jun 17, 2024
9514eab
Implement progbuf and attempt to halt/resume using existing trap logi…
Matthew-Otto Jun 20, 2024
2a64f52
change where DPC is muxed into pipe
Matthew-Otto Jun 21, 2024
4626037
Merge branch 'main' into main
Matthew-Otto Jun 21, 2024
636501e
Fix missing comma in merge
Matthew-Otto Jun 21, 2024
21a51a1
fix bug with resuming from debug mode
Matthew-Otto Jun 23, 2024
372904c
Fix progbuf addressing, fix various syntax errors
Matthew-Otto Jun 25, 2024
bf4bdd4
Block traps in debug mode
Matthew-Otto Jun 25, 2024
8bd674b
fix many linting errors
Matthew-Otto Jun 25, 2024
e919439
Fix many more lint errors
Matthew-Otto Jun 25, 2024
a91dcd8
Fix progbufaddr size
Matthew-Otto Jun 25, 2024
dcff039
Fix FSM bug
Matthew-Otto Jun 25, 2024
1c58b20
Cleanup DM module
Matthew-Otto Jun 27, 2024
44335fd
Update IR to make synth happy
Matthew-Otto Jun 27, 2024
27256ff
Update DCSR to include more bits
Matthew-Otto Jun 27, 2024
b259324
Merge branch 'openhwgroup:main' into main
Matthew-Otto Jun 27, 2024
a72a49f
Remove duplicate driver for DebugStopTime_REGW
Matthew-Otto Jun 28, 2024
4c0ab90
Add JTAG simulation driver
Matthew-Otto Jul 3, 2024
5d34c4e
merge
Matthew-Otto Jul 5, 2024
028cdde
Merge pull request #1 from openhwgroup/main
Matthew-Otto Jul 5, 2024
fd54731
Update SVF test
Matthew-Otto Jul 5, 2024
05140ae
fix error in idreg
Matthew-Otto Jul 5, 2024
3ac7ff3
add compile testbench/jtag/* to sim configs
Matthew-Otto Jul 5, 2024
c62f146
fix lint errors in jtag_driver
Matthew-Otto Jul 5, 2024
c01456f
add license
Matthew-Otto Jul 5, 2024
da36cb4
fix minor bug
Matthew-Otto Jul 5, 2024
3512c33
Add jtag option to WSIM/testbench
Matthew-Otto Jul 8, 2024
c3fd9d8
update svf_convert to facilitate scripting
Matthew-Otto Jul 9, 2024
35b6643
Create python to SVF "self-compiling" JTAG tests
Matthew-Otto Jul 9, 2024
d67221b
add runtest/idle wait to some SVF_Generator instructions
Matthew-Otto Jul 9, 2024
c9dc0e3
add basic jtag tests
Matthew-Otto Jul 10, 2024
e00b2f0
Merge branch 'main' of https://github.com/openhwgroup/cvw into openhw…
Matthew-Otto Jul 10, 2024
5d5121e
fix merge conflicts
Matthew-Otto Jul 10, 2024
093bd60
Merge remote-tracking branch 'origin/openhwgroup-main'
Matthew-Otto Jul 10, 2024
a7816dc
add jtag arg to wsim, fix error in openocd_tcl_wrapper
Matthew-Otto Jul 10, 2024
443d714
add reset to sensitivity list
Matthew-Otto Jul 10, 2024
db965b8
rename genblock to avoid conflict
Matthew-Otto Jul 10, 2024
72874a5
update test, add waves to aid debugging
Matthew-Otto Jul 11, 2024
8949978
fix bug in halt()
Matthew-Otto Jul 11, 2024
8e2656e
Merge branch 'openhwgroup:main' into main
Matthew-Otto Jul 15, 2024
9f893bc
add jtag tests to sim makefile
Matthew-Otto Jul 15, 2024
8b4c40b
update debug step logic
Matthew-Otto Jul 16, 2024
5fa43f8
Fix debug step control
Matthew-Otto Jul 16, 2024
ad23104
add DPC to wave.do
Matthew-Otto Jul 16, 2024
5ef76fc
Merge remote-tracking branch 'upstream/main'
Matthew-Otto Jul 22, 2024
6ef9696
Traps in program buffer return to debug mode
Matthew-Otto Jul 22, 2024
1aa90bf
Merge remote-tracking branch 'upstream/main'
Matthew-Otto Jul 27, 2024
a2002d1
Fix missing signal from merge in hazard.sv
Matthew-Otto Jul 27, 2024
59429ab
Have make create jtag work directory
Matthew-Otto Jul 27, 2024
210a027
update permissions
stineje Jul 27, 2024
d9b45ac
fix fpgatop hierarchy with debug modules
Matthew-Otto Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions bin/hw_debug_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
#!/usr/bin/env python3

#########################################################################################
# hw_debug_test.py
#
# Written: [email protected]
# Created: 19 April 2024
#
# Purpose: script to automate testing of hardware debug interface
#
# A component of the CORE-V-WALLY configurable RISC-V project.
# https:#github.com/openhwgroup/cvw
#
# Copyright (C) 2021-24 Harvey Mudd College & Oklahoma State University
#
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
#
# Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file
# except in compliance with the License, or, at your option, the Apache License version 2.0. You
# may obtain a copy of the License at
#
# https:#solderpad.org/licenses/SHL-2.1/
#
# Unless required by applicable law or agreed to in writing, any work distributed under the
# License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific language governing permissions
# and limitations under the License.
#########################################################################################

import random
import time

from openocd_tcl_wrapper import OpenOCD

random_stimulus = True
random_order = False


def prog_buff_test(cvw):
cvw.halt()
pb = ["0x00840413", "0xd2e3ca40", "0x00100073"]
cvw.write_data("DCSR", hex(0x1 << 15))
cvw.write_progbuf(pb)
cvw.exec_progbuf()

cvw.resume()
print()


def flow_control_test(cvw):
#time.sleep(200) # wait for full boot

#cvw.halt()
for _ in range(5):
time.sleep(random.randint(5,10))
cvw.halt()
cvw.step()
cvw.step()
cvw.resume()
return

time.sleep(1)
#cvw.read_data("DCSR")
for _ in range(100):
time.sleep(random.randint(5,10))
print("Halting")
cvw.halt()
cvw.resume()
#cvw.step()
#print(cvw.read_data("PCM"))
#cvw.resume()


def register_rw_test(cvw):
registers = dict.fromkeys(cvw.register_translations.keys(),[])
reg_addrs = list(registers.keys())

global XLEN
XLEN = cvw.LLEN
global nonstandard_register_lengths
nonstandard_register_lengths = cvw.nonstandard_register_lengths

#time.sleep(70) # wait for OpenSBI

cvw.halt()

# dump data in all registers
for r in reg_addrs:
try:
data = cvw.read_data(r)
registers[r] = data
print(f"{r}: {data}")
except Exception as e:
if e.args[0] == "exception": # Invalid register (not implemented)
del registers[r]
cvw.clear_abstrcmd_err()
else:
raise e
input("Compare values to ILA, press any key to continue")

# Write random data to all registers
reg_addrs = list(registers.keys())
if random_order:
random.shuffle(reg_addrs)
test_reg_data = {}
for r in reg_addrs:
test_data = random_hex(r)
try:
cvw.write_data(r, test_data)
test_reg_data[r] = test_data
print(f"Writing {test_data} to {r}")
except Exception as e:
if e.args[0] == "not supported": # Register is read only
del registers[r]
cvw.clear_abstrcmd_err()
else:
raise e

# GPR X0 is always 0
test_reg_data["x0"] = "0x" + "0"*(cvw.LLEN//4)

# Confirm data was written correctly
reg_addrs = list(registers.keys())
if random_order:
random.shuffle(reg_addrs)
for r in reg_addrs:
try:
rdata = cvw.read_data(r)
except Exception as e:
raise e
if rdata != test_reg_data[r]:
print(f"Error: register {r} read did not return correct data: {rdata} != {test_reg_data[r]}")
else:
print(f"Reading {rdata} from {r}")

# Return all registers to original state
reg_addrs = list(registers.keys())
for r in reg_addrs:
print(f"Writing {registers[r]} to {r}")
try:
cvw.write_data(r, registers[r])
except Exception as e:
raise e

# Confirm data was written correctly
for r in reg_addrs:
try:
rdata = cvw.read_data(r)
except Exception as e:
raise e
if rdata != registers[r]:
raise Exception(f"Register {r} read did not return correct data: {rdata} != {registers[r]}")
print("All writes successful")

cvw.resume()


def random_hex(reg_name):
pad = XLEN // 4
if reg_name in nonstandard_register_lengths:
size = nonstandard_register_lengths[reg_name]
else:
size = XLEN

# Reset ReadDataM to a value
nonstandard_register_lengths["READDATAM"] = XLEN
if random_stimulus:
return "0x" + f"{random.getrandbits(size):x}".rjust(pad, "0")
else:
data = 0xa5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5
return "0x" + f"{(data & (2**size-1)):x}".rjust(pad, "0")


with OpenOCD() as cvw:
#cvw.trst()
cvw.reset_dm()
time.sleep(1)
cvw.reset_hart()
time.sleep(1)
#register_rw_test(cvw)
#flow_control_test(cvw)
prog_buff_test(cvw)
Loading