mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
cleanup, rename python scripts
This commit is contained in:
parent
0a6e7080dc
commit
2e0c286017
@ -29,44 +29,14 @@
|
|||||||
# OpenOCD also supports tcl commands directly
|
# OpenOCD also supports tcl commands directly
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
from telnetlib import Telnet
|
from telnetlib import Telnet
|
||||||
|
|
||||||
debug = False
|
debug = False
|
||||||
XLEN = 64 # TODO: infer this value from the MISA
|
|
||||||
|
|
||||||
tapname = "cvw.cpu" # this is set via the openocd config. It can be found by running `scan_chain`
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: if JTAG clk is fast enough, need to check for busy between absract commands
|
# TODO: if JTAG clk is fast enough, need to check for busy between absract commands
|
||||||
|
|
||||||
def main():
|
|
||||||
global tn
|
|
||||||
with Telnet("127.0.0.1", 4444) as tn:
|
|
||||||
read() # clear welcome message from read buffer
|
|
||||||
activate_dm() # necessary if openocd init is disabled
|
|
||||||
status()
|
|
||||||
halt()
|
|
||||||
GPR = dump_GPR()
|
|
||||||
print(GPR)
|
|
||||||
check_errors()
|
|
||||||
print(f"PCM: '{read_data("PCM")}'")
|
|
||||||
resume()
|
|
||||||
status()
|
|
||||||
#clear_abstrcmd_err()
|
|
||||||
#write_data("READDATAM", "0xAA0987210000FFFF")
|
|
||||||
#print(f"READDATAM'{read_data("READDATAM")}'")
|
|
||||||
#print(f"WRITEDATAM: '{read_data("WRITEDATAM")}'")
|
|
||||||
#print(f"IEUADRM: '{read_data("IEUADRM")}'")
|
|
||||||
#write_data("TRAPM", "0x0")
|
|
||||||
#print(f"INSTRVALIDM: '{read_data("INSTRVALIDM")}'")
|
|
||||||
#print(f"MEMRWM: '{read_data("MEMRWM")}'")
|
|
||||||
#write_data("MEMRWM", "0x3")
|
|
||||||
#write_data("PCM", "0x100000")
|
|
||||||
#dmi_reset()
|
|
||||||
#clear_abstrcmd_err()
|
|
||||||
|
|
||||||
|
|
||||||
def dump_GPR():
|
def dump_GPR():
|
||||||
gpr = {}
|
gpr = {}
|
||||||
for i in range(1,32):
|
for i in range(1,32):
|
||||||
@ -303,18 +273,42 @@ def read():
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def interrogate():
|
||||||
|
global XLEN
|
||||||
|
global tapname
|
||||||
|
write("scan_chain")
|
||||||
|
raw = tn.read_until(b"> ").decode('ascii')
|
||||||
|
scan_chain = raw.replace("\r", "").replace("> ", "")
|
||||||
|
scan_chain = [tap for tap in scan_chain.split("\n")[2:] if tap]
|
||||||
|
if len(scan_chain) > 1:
|
||||||
|
print(f"Found multiple taps. Selecting tap #0\n{raw}")
|
||||||
|
scan_chain = scan_chain[0]
|
||||||
|
tapname = re.search("\d\s+(.+?)\s+", scan_chain).group(1)
|
||||||
|
print(f"DM tapname: {tapname}")
|
||||||
|
|
||||||
|
write("riscv info")
|
||||||
|
info = tn.read_until(b"> ").decode('ascii').replace("\r", "").replace("> ", "").split("\n")
|
||||||
|
for line in info:
|
||||||
|
if XLEN := re.search("hart.xlen\s+(\d+)", line).group(1):
|
||||||
|
XLEN = int(XLEN)
|
||||||
|
break
|
||||||
|
print(f"XLEN: {XLEN}")
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
global tn
|
global tn
|
||||||
tn = Telnet("127.0.0.1", 4444)
|
tn = Telnet("127.0.0.1", 4444)
|
||||||
atexit.register(cleanup)
|
atexit.register(cleanup)
|
||||||
read() # clear welcome message from read buffer
|
read() # clear welcome message from read buffer
|
||||||
|
interrogate()
|
||||||
activate_dm()
|
activate_dm()
|
||||||
# TODO: query misa and get gpr count
|
# TODO: query gpr count
|
||||||
|
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
tn.close()
|
tn.close()
|
||||||
|
|
||||||
|
|
||||||
# 6.1.4 dtmcs errinfo translation table
|
# 6.1.4 dtmcs errinfo translation table
|
||||||
errinfo_translations = {
|
errinfo_translations = {
|
||||||
0 : "not implemented",
|
0 : "not implemented",
|
||||||
@ -397,8 +391,5 @@ nonstandard_register_lengths = {
|
|||||||
"INSTRM" : 32,
|
"INSTRM" : 32,
|
||||||
"MEMRWM" : 2,
|
"MEMRWM" : 2,
|
||||||
"INSTRVALIDM" : 1,
|
"INSTRVALIDM" : 1,
|
||||||
#"READDATAM" : P.LLEN
|
#"READDATAM" : P.LLEN # TODO: find LLEN
|
||||||
}
|
}
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
@ -1,7 +1,8 @@
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from hw_interface import *
|
import hw_debug_interface
|
||||||
|
from hw_debug_interface import *
|
||||||
|
|
||||||
random_stimulus = False
|
random_stimulus = False
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ def main():
|
|||||||
reg_addrs = list(registers.keys())
|
reg_addrs = list(registers.keys())
|
||||||
|
|
||||||
init()
|
init()
|
||||||
|
global XLEN
|
||||||
|
XLEN = hw_debug_interface.XLEN
|
||||||
reset_dm()
|
reset_dm()
|
||||||
reset_hart()
|
reset_hart()
|
||||||
|
|
||||||
@ -65,7 +68,7 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
if rdata != test_reg_data[r]:
|
if rdata != test_reg_data[r]:
|
||||||
raise Exception(f"Register {r} read did not return correct data: {rdata} != {test_reg_data[r]}")
|
print(f"Error: register {r} read did not return correct data: {rdata} != {test_reg_data[r]}")
|
||||||
else:
|
else:
|
||||||
print(f"Read {rdata} from {r}")
|
print(f"Read {rdata} from {r}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user