Debugger generalized/improved

master
kaqu 1 year ago
parent c13677c1b6
commit 0efb546fde
  1. 82
      debugger/qt5dbg.py
  2. 12
      software/source/flwstw.c

@ -37,7 +37,8 @@ class dbgWindow(QMainWindow):
self.widget = QWidget() # Central layout widget
# Prepare x<n> regs displays
self.MAXLABEL = 4 # 32 regs/fregs originally! But won't fit on ColorLight ...
self.MAXLABELUSED = 4 # Active, 32 won't fit on ColorLight ...
self.MAXLABEL = 32 # Yet 32 regs X/F in use
self.lblList = list() # All input/output fields
self.txtList = list()
self.lblFList = list() # F-Extension float registers
@ -56,12 +57,13 @@ class dbgWindow(QMainWindow):
q = QLabel("{0}(f{1})".format(f_description[i], i)) # For now, may become entry field later ...
q.setFixedWidth(80)
self.lblFList.append(q)
q2 = QLineEdit("0x00000000")
q2 = QLineEdit("0.000000")
q2.setFixedWidth(160)
q2.returnPressed.connect(lambda i=i: self.on_returnFPressed(i)) # Nice trick! (Or awkward solution rather)
q2.textEdited.connect(lambda msg=str(i),i=i: self.on_textEdited(msg,i))
self.txtFList.append(q2)
self.txtFList[i].setStyleSheet("background-color: lightyellow; border: 1px solid black;")
self.vbox1 = QVBoxLayout()
self.vbox1.setAlignment(Qt.AlignTop) # Won't move w/ resize!
@ -130,6 +132,48 @@ class dbgWindow(QMainWindow):
for i in range(28, 32):
self.hbox8.addWidget(self.lblList[i])
self.hbox8.addWidget(self.txtList[i])
# F-Extension: 32 float registers
self.hbox1F = QHBoxLayout() # Row of regs (x4 .. x7)
self.hbox1F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(0, 4):
self.hbox1F.addWidget(self.lblFList[i])
self.hbox1F.addWidget(self.txtFList[i])
self.hbox2F = QHBoxLayout() # Row of regs (x4 .. x7)
self.hbox2F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(4, 8):
self.hbox2F.addWidget(self.lblFList[i])
self.hbox2F.addWidget(self.txtFList[i])
self.hbox3F = QHBoxLayout() # Row of regs (x8 .. x11)
self.hbox3F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(8, 12):
self.hbox3F.addWidget(self.lblFList[i])
self.hbox3F.addWidget(self.txtFList[i])
self.hbox4F = QHBoxLayout() # Row of regs (f12 .. f15)
self.hbox4F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(12, 16):
self.hbox4F.addWidget(self.lblFList[i])
self.hbox4F.addWidget(self.txtFList[i])
self.hbox5F = QHBoxLayout() # Row of regs (x16 .. x19)
self.hbox5F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(16, 20):
self.hbox5F.addWidget(self.lblFList[i])
self.hbox5F.addWidget(self.txtFList[i])
self.hbox6F = QHBoxLayout() # Row of regs (x20 .. x23)
self.hbox6F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(20, 24):
self.hbox6F.addWidget(self.lblFList[i])
self.hbox6F.addWidget(self.txtFList[i])
self.hbox7F = QHBoxLayout() # Row of regs (x24 .. x27)
self.hbox7F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(24, 28):
self.hbox7F.addWidget(self.lblFList[i])
self.hbox7F.addWidget(self.txtFList[i])
self.hbox8F = QHBoxLayout() # Row of regs (x28 .. x31)
self.hbox8F.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
for i in range(28, 32):
self.hbox8F.addWidget(self.lblFList[i])
self.hbox8F.addWidget(self.txtFList[i])
else:
self.hbox2 = QHBoxLayout() # Row of regs (x4 .. x7)
self.hbox2.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
@ -137,6 +181,7 @@ class dbgWindow(QMainWindow):
self.hbox2.addWidget(self.lblFList[i])
self.hbox2.addWidget(self.txtFList[i])
self.hbox9 = QHBoxLayout() # Buttons, row #1
self.hbox9.setAlignment(Qt.AlignLeft) # Won't move w/ resize!
self.qpbPC = QLabel("PC")
@ -220,6 +265,15 @@ class dbgWindow(QMainWindow):
self.vbox1.addLayout(self.hbox6, 1)
self.vbox1.addLayout(self.hbox7, 1)
self.vbox1.addLayout(self.hbox8, 1)
self.vbox1.addLayout(self.hbox1F, 1)
self.vbox1.addLayout(self.hbox2F, 1)
self.vbox1.addLayout(self.hbox3F, 1)
self.vbox1.addLayout(self.hbox4F, 1)
self.vbox1.addLayout(self.hbox5F, 1)
self.vbox1.addLayout(self.hbox6F, 1)
self.vbox1.addLayout(self.hbox7F, 1)
self.vbox1.addLayout(self.hbox8F, 1)
self.vbox1.addLayout(self.hbox10, 2)
self.vbox1.addLayout(self.hbox11, 2)
self.vbox1.addLayout(self.hbox12, 2)
@ -313,13 +367,13 @@ class dbgWindow(QMainWindow):
i32NextPC = self.wb.regs.risq5ext_b32_next_pc.read()
self.txtNextPC.setText("0x{:08X}".format(i32NextPC))
for i in range(self.MAXLABEL): # Walk x<n> register file
for i in range(self.MAXLABELUSED): # Walk x<n> register file
self.wb.regs.risq5ext_b5_wb_reg_no.write(i) # Select register
val = self.wb.regs.risq5ext_b32_wb_reg_value_r.read() # Pick actual register risq5_b32_wb_reg_value_r
self.txtList[i].setText("0x{:08X}".format(val))
# F-Extension float registers
for i in range(self.MAXLABEL): # Walk f<n> register file
for i in range(self.MAXLABELUSED): # Walk f<n> register file
self.wb.regs.risq5ext_b5_wb_reg_no.write(i) # Select register
val = self.wb.regs.risq5ext_b32_wb_freg_value_r.read() # Pick actual register risq5_b32_wb_reg_value_r
p = struct.pack("I",val) # Translate 32-bit value -> decimal float!
@ -362,9 +416,12 @@ class dbgWindow(QMainWindow):
try:
b32Value = int(sender.text(),16) # Get hex value
#print("x{0} new value: {1}".format(index, b32Value))
self.wb.regs.risq5ext_b5_wb_reg_no.write(index) # Write index
self.wb.regs.risq5ext_b32_wb_reg_value_w.write(b32Value) # New value
self.wb.regs.risq5ext_b1_wb_reg_we.write(1) # Write request (pulse)
if self.MAXLABELUSED > index:
self.wb.regs.risq5ext_b5_wb_reg_no.write(index) # Write index
self.wb.regs.risq5ext_b32_wb_reg_value_w.write(b32Value) # New value
self.wb.regs.risq5ext_b1_wb_reg_we.write(1) # Write request (pulse)
else: # 'Dead' register update
self.txtList[index].setText("0x{:08X}".format(b32Value))
time.sleep(0.05) # Just make sure ...
except:
pass
@ -382,9 +439,12 @@ class dbgWindow(QMainWindow):
dz = struct.pack("f", fval)
b32Value = struct.unpack("I", dz)
print("f{0} new value: {1} (0x{2:08X})".format(index, fval, b32Value[0]))
self.wb.regs.risq5ext_b5_wb_reg_no.write(index) # Write index
self.wb.regs.risq5ext_b32_wb_reg_value_w.write(b32Value[0]) # New value
self.wb.regs.risq5ext_b1_wb_freg_we.write(1) # Write float request (pulse)
if self.MAXLABELUSED > index:
self.wb.regs.risq5ext_b5_wb_reg_no.write(index) # Write index
self.wb.regs.risq5ext_b32_wb_reg_value_w.write(b32Value[0]) # New value
self.wb.regs.risq5ext_b1_wb_freg_we.write(1) # Write float request (pulse)
else: # 'Dead' float register update
self.txtFList[index].setText("{:6f}".format(fval))
time.sleep(0.05) # Just make sure ...
except:
print("returnFPressed(): conversion fault?!")

@ -32,7 +32,6 @@ static void start(void)
frcsr x3 # 003 x3=fcs (csrrs rd,fcsr,x0) \n\
frflags x3 # 001 x3=exception flags (OF etc., csrrs rd,fflags,x0) \n\
frrm x3 # 002 x3=rounding mode (rtz etc., csrrs rd,frm,x0) \n\
#fscsr x3,x0 # 003 x3=fcs,fcs=x0 (csrrw rd,fcsr,rs1) \n\
fsrmi x0,3 # 002 x3=round.mod., rm=3 (csrrwi rd,frm,rs1) \n\
frrm x3 # 002 x3=rounding mode (rtz etc., csrrs rd,frm,x0) \n\
fsflagsi x0,0x18 # FEHLER!!! 001 x3=except.flags, (csrrwi rd,frm,rs1) \n\
@ -70,17 +69,17 @@ repeat: lui x3,%hi(0xFF800000) # -INF \n\
lui x3,%hi(0x7FC00000) # NaN Canonical \n\
fmv.s.x f3,x3 # x3 -> f3 \n\
fclass.s x3,f3 # x3 = fclass(f3) \n\
j repeat # Loop ... \n\
#j repeat # Loop ... \n\
feq.s x3,f0,f1 # x3 = (f0 == f1) \n\
flt.s x3,f0,f1 # x3 = (f0 < f1) \n\
fle.s x3,f0,f1 # x3 = (f0 < f1) \n\
j repeat # Loop ... \n\
#j repeat # Loop ... \n\
fcvt.s.w f3,x3 # f3 = float((signed)x3) \n\
fcvt.s.wu f3,x3 # f3 = float((unsigned)x3) \n\
j repeat # Loop ... \n\
#j repeat # Loop ... \n\
fcvt.w.s x3,f3 # x3 = int(f3) \n\
fcvt.wu.s x3,f3 # x3 = uint(f3) \n\
j repeat # Loop ... \n\
#j repeat # Loop ... \n\
fmin.s f2,f0,f1 # f2 = min(f0,f1) \n\
fmax.s f2,f0,f1 # f2 = max(f0,f1) \n\
fadd.s f2,f0,f1 # f2 = f0 + f1 \n\
@ -92,7 +91,7 @@ repeat: lui x3,%hi(0xFF800000) # -INF \n\
fmsub.s f3,f0,f1,f2 # f3 = f0*f1-f2 \n\
fnmadd.s f3,f0,f1,f2 # f3 = -(f0*f1)+f2 \n\
fnmsub.s f3,f0,f1,f2 # f3 = -(f0*f1)-f2 \n\
j repeat # Loop ... \n\
#j repeat # Loop ... \n\
lw x3,0(sp) # Load float from stack (test) \n\
lw x3,4(sp) # Load float from stack (test) \n\
nop \n\
@ -140,6 +139,7 @@ repeat: lui x3,%hi(0xFF800000) # -INF \n\
lw x3,4(sp) \n\
lw x3,8(sp) \n\
lw x3,12(sp) \n\
j repeat \n\
");
#include "onek_nops.c"

Loading…
Cancel
Save