feat(saolei): 交互玩扫雷每一步自动出 PNG
- play_saolei.tcl: k 每执行一个按键动作就存 shots/NNN_<按键>.png,并覆盖 shots/latest.png(在 VS Code 里开着 latest.png 即可每步自动刷新);新增 view 命令 - fb2png.py: 新增 --quiet(只写 PNG 不打印,供脚本批量截图) - tb_saolei*.v: 仅格式调整(case 分支拆行),无语义变化 实测:k cuuuuc -> shots/001_c.png ... 006_c.png,每张 640x480 正常
This commit is contained in:
@@ -127,12 +127,16 @@ module tb_saolei;
|
||||
// irq_rise: 该线的上升沿次数(CPU 按上升沿响应中断)
|
||||
integer ptr_ev = 0, irq_hi = 0, irq_rise = 0;
|
||||
reg irq_prev_q;
|
||||
initial irq_prev_q = 1'b0;
|
||||
initial
|
||||
irq_prev_q = 1'b0;
|
||||
always @(posedge dut.clk_cpu) begin
|
||||
if (dut.g_btn.u_ptr.ev_valid_o) ptr_ev = ptr_ev + 1;
|
||||
if (dut.irq_vec[0]) irq_hi = irq_hi + 1;
|
||||
if (dut.g_btn.u_ptr.ev_valid_o)
|
||||
ptr_ev = ptr_ev + 1;
|
||||
if (dut.irq_vec[0])
|
||||
irq_hi = irq_hi + 1;
|
||||
irq_prev_q <= dut.irq_vec[0];
|
||||
if (dut.irq_vec[0] && !irq_prev_q) irq_rise = irq_rise + 1;
|
||||
if (dut.irq_vec[0] && !irq_prev_q)
|
||||
irq_rise = irq_rise + 1;
|
||||
end
|
||||
|
||||
// 每毫秒打一行,观察事件链路
|
||||
@@ -171,7 +175,7 @@ module tb_saolei;
|
||||
jmp_log = jmp_log + 1;
|
||||
end
|
||||
if ((dut.u_cpu.pc_q >= 32'h0000_0194 && dut.u_cpu.pc_q < 32'h0000_0200) ||
|
||||
(dut.u_cpu.pc_q >= 32'h0000_0218 && dut.u_cpu.pc_q < 32'h0000_0300))
|
||||
(dut.u_cpu.pc_q >= 32'h0000_0218 && dut.u_cpu.pc_q < 32'h0000_0300))
|
||||
$display("[gap] %0t ns: PC 0x%03h -> 0x%03h (跳进空洞)", $time, pc_prev, dut.u_cpu.pc_q);
|
||||
end
|
||||
end
|
||||
@@ -284,19 +288,29 @@ module tb_saolei;
|
||||
input integer gap_us;
|
||||
begin
|
||||
case (which)
|
||||
0: go = 1'b1;
|
||||
1: btnu = 1'b1;
|
||||
2: btnd = 1'b1;
|
||||
3: btnl = 1'b1;
|
||||
default: btnr = 1'b1;
|
||||
0:
|
||||
go = 1'b1;
|
||||
1:
|
||||
btnu = 1'b1;
|
||||
2:
|
||||
btnd = 1'b1;
|
||||
3:
|
||||
btnl = 1'b1;
|
||||
default:
|
||||
btnr = 1'b1;
|
||||
endcase
|
||||
#(hold_us * 1000);
|
||||
case (which)
|
||||
0: go = 1'b0;
|
||||
1: btnu = 1'b0;
|
||||
2: btnd = 1'b0;
|
||||
3: btnl = 1'b0;
|
||||
default: btnr = 1'b0;
|
||||
0:
|
||||
go = 1'b0;
|
||||
1:
|
||||
btnu = 1'b0;
|
||||
2:
|
||||
btnd = 1'b0;
|
||||
3:
|
||||
btnl = 1'b0;
|
||||
default:
|
||||
btnr = 1'b0;
|
||||
endcase
|
||||
#(gap_us * 1000);
|
||||
end
|
||||
|
||||
@@ -84,19 +84,29 @@ module tb_saolei_play;
|
||||
input integer hold_us;
|
||||
begin
|
||||
case (which)
|
||||
1: btnu = 1'b1;
|
||||
2: btnd = 1'b1;
|
||||
3: btnl = 1'b1;
|
||||
4: btnr = 1'b1;
|
||||
default: go = 1'b1;
|
||||
1:
|
||||
btnu = 1'b1;
|
||||
2:
|
||||
btnd = 1'b1;
|
||||
3:
|
||||
btnl = 1'b1;
|
||||
4:
|
||||
btnr = 1'b1;
|
||||
default:
|
||||
go = 1'b1;
|
||||
endcase
|
||||
#(hold_us * 1000);
|
||||
case (which)
|
||||
1: btnu = 1'b0;
|
||||
2: btnd = 1'b0;
|
||||
3: btnl = 1'b0;
|
||||
4: btnr = 1'b0;
|
||||
default: go = 1'b0;
|
||||
1:
|
||||
btnu = 1'b0;
|
||||
2:
|
||||
btnd = 1'b0;
|
||||
3:
|
||||
btnl = 1'b0;
|
||||
4:
|
||||
btnr = 1'b0;
|
||||
default:
|
||||
go = 1'b0;
|
||||
endcase
|
||||
#(200 * 1000);
|
||||
end
|
||||
@@ -109,12 +119,18 @@ module tb_saolei_play;
|
||||
input [7:0] ch;
|
||||
begin
|
||||
case (ch)
|
||||
8'h75, 8'h77: pulse(1, 20); // u / w 上
|
||||
8'h64, 8'h73: pulse(2, 20); // d / s 下
|
||||
8'h6C, 8'h61: pulse(3, 20); // l / a 左
|
||||
8'h72: pulse(4, 20); // r 右
|
||||
8'h63: pulse(0, 30); // c 左键点击
|
||||
8'h67: pulse(0, 30); // g go 键(同一次点击)
|
||||
8'h75, 8'h77:
|
||||
pulse(1, 20); // u / w 上
|
||||
8'h64, 8'h73:
|
||||
pulse(2, 20); // d / s 下
|
||||
8'h6C, 8'h61:
|
||||
pulse(3, 20); // l / a 左
|
||||
8'h72:
|
||||
pulse(4, 20); // r 右
|
||||
8'h63:
|
||||
pulse(0, 30); // c 左键点击
|
||||
8'h67:
|
||||
pulse(0, 30); // g go 键(同一次点击)
|
||||
8'h66: begin // f 插旗模式点击
|
||||
sw_flag = 1'b1;
|
||||
#(30 * 1000);
|
||||
@@ -133,7 +149,8 @@ module tb_saolei_play;
|
||||
rst_n = 1'b1;
|
||||
#(500 * 1000);
|
||||
end
|
||||
default: ; // 其它字符忽略
|
||||
default:
|
||||
; // 其它字符忽略
|
||||
endcase
|
||||
end
|
||||
endtask
|
||||
@@ -152,7 +169,8 @@ module tb_saolei_play;
|
||||
chc = $fgetc(cfp);
|
||||
$fclose(cfp);
|
||||
cfp = $fopen("cmd.txt", "w"); // 处理掉就清空,避免重复执行
|
||||
if (cfp != 0) $fclose(cfp);
|
||||
if (cfp != 0)
|
||||
$fclose(cfp);
|
||||
if ((chc > 0) && (chc != 8'h0A) && (chc != 8'h0D) && (chc != 8'h20))
|
||||
do_key(chc[7:0]);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user