feat(tools): 仿真调试台适配新版显存,并修好 xsim 里跑 python 的环境问题
tb_saolei.v / tb_saolei_play.v: - dump 从 1200 字节(1 字节/格)改成 2400 字节(每格 2 字节) - 变量地址按新 ELF 更新(g_state 0x7AC、mine_bm 0x86C、g_ncells 0x8B4 ...) - 已揭开格数直接读 opened_cnt(0x7B4),通关目标改成 g_ncells - g_mines fb2png.py: - 支持每格 2 字节(byte0 字形[5:0] / byte1 颜色[2:0]) - 字库不再手工抄表,改成直接解析 cpu21_vga.v 的 font_row(),RTL 加字模会自动跟随 - 字形 16..41 显示成 A-Z play_saolei.tcl: - 用绝对路径找系统 Python:xsim 的环境里 py 会选中 Vivado 自带的 python3.8, 报 SRE module mismatch - 清掉 PYTHONHOME/PYTHONPATH,否则系统 python 也会去 Vivado 的 lib 找模块 - render/save_shot 补 global python 实测:hard 模式 30x16 棋盘在终端正常显示,点击展开的区域横跨屏幕第 13~22 行 (含中线以下的 8 行)-> 证实 FB_WORDS 那个"只能写前 15 行"的 bug 已修好
This commit is contained in:
@@ -34,6 +34,22 @@
|
||||
set script_dir [file dirname [file normalize [info script]]]
|
||||
set fb2png [file normalize [file join $script_dir .. .. saolei tools fb2png.py]]
|
||||
|
||||
# 找系统 Python:xsim 的 PATH 里带着 Vivado 自带的 python3.8,直接 exec py 会撞上它
|
||||
# (SRE module mismatch),所以用绝对路径优先。
|
||||
proc find_python {} {
|
||||
foreach ver {314 313 312 311 310} {
|
||||
set c [file join $::env(LOCALAPPDATA) Programs Python "Python$ver" python.exe]
|
||||
if {[file exists $c]} { return $c }
|
||||
}
|
||||
return "py"
|
||||
}
|
||||
set python [find_python]
|
||||
# xsim 的进程环境里带着 Vivado 的 PYTHONHOME,会让**系统 python** 也去 Vivado 的
|
||||
# lib 里找模块(SRE module mismatch)。清掉它,子进程才不会继承。
|
||||
catch { unset ::env(PYTHONHOME) }
|
||||
catch { unset ::env(PYTHONPATH) }
|
||||
puts " (python: $python)"
|
||||
|
||||
# 按键字符 -> 人类可读的动作(只用于回显)
|
||||
array set KEYNAME {
|
||||
c "左键点击" u "上" w "上" d "下" s "下"
|
||||
@@ -56,12 +72,12 @@ if {![file exists "cmd.txt"]} {
|
||||
|
||||
# 把 now.txt 渲染到终端(ANSI 彩色棋盘)
|
||||
proc render {} {
|
||||
global fb2png
|
||||
global fb2png python
|
||||
if {![file exists "now.txt"]} {
|
||||
puts " (now.txt not ready yet - run a bit first)"
|
||||
return
|
||||
}
|
||||
if {[catch { exec py $fb2png --term now.txt >@stdout 2>@stderr } err]} {
|
||||
if {[catch { exec $python $fb2png --term now.txt >@stdout 2>@stderr } err]} {
|
||||
puts " render failed: $err"
|
||||
puts " try manually: py \"$fb2png\" --term now.txt"
|
||||
}
|
||||
@@ -85,11 +101,11 @@ file mkdir $shot_dir
|
||||
set shot_n 0
|
||||
|
||||
proc save_shot {tag} {
|
||||
global fb2png shot_dir
|
||||
global fb2png shot_dir python
|
||||
if {![file exists "now.txt"]} { return }
|
||||
incr ::shot_n
|
||||
set name [format "%s/%03d_%s.png" $shot_dir $::shot_n $tag]
|
||||
if {[catch { exec py $fb2png --quiet now.txt $name } err]} {
|
||||
if {[catch { exec $python $fb2png --quiet now.txt $name } err]} {
|
||||
puts " (screenshot failed: $err)"
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user