fix(saolei): 修好鼠标事件链路三处 RTL bug —— 仿真里扫雷已能正常游玩
1) cpu21_pointer.v: sel 的位映射写错了(pend[2]->bit1, pend[1]->bit0, pend[0]->bit2), 而输出读的是 sel[1]=-dx / sel[2]=+dy / sel[3]=-dy / sel[0]=+dx。 后果:方向全乱(按下变左移、按右变下移),更致命的是清除逻辑 press_pend_q <= pend_next & ~sel 清不掉被选中的那一位 -> ev_valid_o 永久为 1 -> 鼠标中断线一直挂着 -> CPU 只收到一个上升沿、之后再无事件。改成一一对应。 2) cpu21_board_top.v: 鼠标中断与 LEVEL 软件中断的接线正好对调 (mouse 接 irq_vec[0]=IRQ1=0x100=关卡入口, level 接 irq_vec[1]=IRQ2=0x200=鼠标)。 后果:第一个鼠标事件把关卡叫起来画棋盘, 而鼠标 ISR 永不执行 -> FIFO 不弹空。 按 linker.ld/mmio.h 约定交换;拨码开关 SW[2:0] 仍按位 OR 进来。 3) cpu21_mmio.v: 同步中断线注释。 仿真验证(tb_saolei + fb2png): 事件队列正常出入(h/t 同步增长)、光标方向正确、 点击 START 进关卡、关卡内点击揭开格子(fb_we +90)、数字场 1/2/3 与大片 BFS 展开均正确
This commit is contained in:
@@ -76,16 +76,20 @@ module cpu21_pointer #(
|
||||
reg [4:0] sel;
|
||||
always @* begin
|
||||
sel = 5'b0;
|
||||
// 注意:sel 的每一位必须和下面的输出一致,也必须和 pend_next 一一对应!
|
||||
// sel[4]=点击 sel[3]=上(-dy) sel[2]=下(+dy) sel[1]=左(-dx) sel[0]=右(+dx)
|
||||
// 而且 press_pend_q <= pend_next & ~sel 要求 sel 的位数与 pend_next 同域,
|
||||
// 否则被选中的那一位清不掉、ev_valid_o 会永久为 1(中断线一直挂着)。
|
||||
if (pend_next[4])
|
||||
sel = 5'b10000; // BTNC:点击
|
||||
else if (pend_next[3])
|
||||
sel = 5'b01000; // BTNU:上
|
||||
sel = 5'b01000; // BTNU:上
|
||||
else if (pend_next[2])
|
||||
sel = 5'b00010; // BTND:下
|
||||
sel = 5'b00100; // BTND:下
|
||||
else if (pend_next[1])
|
||||
sel = 5'b00001; // BTNL:左
|
||||
sel = 5'b00010; // BTNL:左
|
||||
else if (pend_next[0])
|
||||
sel = 5'b00100; // BTNR:右
|
||||
sel = 5'b00001; // BTNR:右
|
||||
end
|
||||
|
||||
always @(posedge clk or posedge reset) begin
|
||||
|
||||
Reference in New Issue
Block a user