1280x1024 display: 80x32 big font or 132x64 (DECCOLM)

The display runs at 1280x1024 60 Hz from a second MMCM (108 MHz pixel
clock), one pixel per clock through a four-stage pipeline. 80 columns
show 80x32 cells of 16x32 pixels (the 8x16 font doubled); CSI ?3 h
switches to 132x64 cells of 8x16 pixels, centred, and CSI ?3 l back,
both clearing the screen and margins as a VT100 does. The 320x240
graphics layer is drawn 4x4 in the top 960 lines, so 80-column row r
still meets graphics line 8(r-1).

The terminal engine has 6-bit rows and 8-bit columns, a 132-cell row
stride in both layouts (so the copy engine is unchanged), 132 tab stops
and 3-digit cursor reports. The character RAM holds two 132x64 pages
(normal and alternate) and is read on the pixel clock.

BASIC's LOCATE takes rows up to 64 and columns up to 132. terminfo has
basys3 (80x32) and basys3-w (132x64). The testbench reads the 132-cell
layout, checks 1280x1024 sync timing, captures 1280x1024 frames and
tests DECCOLM both ways.

Timing met (0.044 ns at 90 MHz CPU, 108 MHz pixel); 46 of 50 BRAMs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-28 12:24:21 -08:00
1 parent 634e314010
commit 88b5942da5
12 files changed
+354 -220

No files matched your search

+119 -99
View File
@@ -1,7 +1,9 @@
`timescale 1ns / 1ps
// VT220 terminal engine with ANSI colour. Consumes received bytes and keeps
// the 80x30 new_cell buffer (row-major, address = row*80 + col) up to date.
// the character buffer up to date: 80x32, or 132x64 after DECCOLM (CSI ?3h).
// The buffer is row-major with a 132-cell stride in both (address = row*132 +
// col), so scrolling copies whole 132-cell rows either way.
//
// Cell format: {blink, underline, bg[3:0], fg[3:0], CP437 code}. Reverse,
// bold and concealed text are resolved into the colours when a new_cell is written.
@@ -10,7 +12,8 @@
// ESC 7 8 D E H M Z c = > ESC ( ) <0|A|B> ESC # 8
// CSI A B C D E F G H I J K L M P S T X Z @ ` a d e f g h l m n q r s u c
// CSI ? J K h l n CSI > c CSI ! p
// Modes: IRM(4) LNM(20) DECCKM(?1) DECSCLM(?4) DECOM(?6) DECAWM(?7) DECTCEM(?25)
// Modes: IRM(4) LNM(20) DECCKM(?1) DECCOLM(?3) DECSCLM(?4) DECOM(?6) DECAWM(?7)
// DECTCEM(?25)
// alternate screen ?47 (parameters stop at 255, so not ?1047/?1049)
// SGR 0 1 4 5 7 8 21-28 30-49 90-107, 38/48;5;n and 38/48;2;r;g;b (approximated)
// DECLL (CSI n q) drives four LEDs.
@@ -31,16 +34,16 @@ module term_ctrl (
input smooth_fast,
input frame_tick, // start of vertical blanking
// character RAM port
output reg [11:0] addr,
output reg [13:0] addr,
output reg we,
output reg [17:0] wdata,
input [17:0] rdata,
// to the display
output reg [4:0] row,
output reg [6:0] col,
output reg [5:0] row,
output reg [7:0] col,
output reg cur_vis,
output reg [4:0] stop, // scroll region, inclusive
output reg [4:0] sbot,
output reg [5:0] stop, // scroll region, inclusive
output reg [5:0] sbot,
output reg sm_on,
output reg sm_dir, // 0 = scrolling up, 1 = down
output reg [4:0] sm_off,
@@ -54,11 +57,16 @@ module term_ctrl (
output reg lnm,
output reg [3:0] dec_leds,
output reg bell,
output reg alt_scr // showing and writing the alternate screen
output reg alt_scr, // showing and writing the alternate screen
output reg wide // 132 columns (DECCOLM)
);
localparam [4:0] LAST_ROW = 5'd29;
localparam [6:0] LAST_COL = 7'd79;
localparam [11:0] CELLS = 12'd2400;
localparam [13:0] STRIDE = 14'd132;
localparam [13:0] ALL = 14'd8448; // 132 x 64: clears either layout
wire [5:0] LAST_ROW = wide ? 6'd63 : 6'd31;
wire [7:0] LAST_COL = wide ? 8'd131 : 8'd79;
wire [7:0] NCOLS = wide ? 8'd132 : 8'd80;
wire [6:0] NROWS = wide ? 7'd64 : 7'd32;
wire [13:0] CELLS = wide ? 14'd8448 : 14'd4224;
localparam [3:0] S_IDLE = 4'd0, S_DISP = 4'd1, S_FILL = 4'd2, S_CRD = 4'd3,
S_CWAIT = 4'd4, S_CWR = 4'd5, S_PLOOP = 4'd6, S_RESP = 4'd7,
@@ -77,11 +85,12 @@ module term_ctrl (
reg [3:0] fg, bg;
reg [1:0] g0, g1; // 0 ASCII, 1 DEC special graphics, 2 UK
reg gl; // 0 = G0 active, 1 = G1 (SO)
reg [79:0] tabs;
reg [131:0] tabs;
reg colm_clr; // DECCOLM: clear the screen when idle
// saved cursor (DECSC)
reg [4:0] sv_row;
reg [6:0] sv_col;
reg [5:0] sv_row;
reg [7:0] sv_col;
reg sv_pend, sv_om, sv_gl, sv_bold, sv_ul, sv_blink, sv_rev, sv_conceal;
reg [3:0] sv_fg, sv_bg;
reg [1:0] sv_g0, sv_g1;
@@ -94,12 +103,12 @@ module term_ctrl (
// scroll request
reg sc_dir;
reg [4:0] sc_t, sc_b;
reg [5:0] sc_t, sc_b;
reg [7:0] sc_n;
reg [5:0] sc_h, sc_k; // region height, lines to move
reg [6:0] sc_h, sc_k; // region height, lines to move
// memory copy / fill engine
reg [11:0] c_src, c_dst, c_cnt, f_addr, f_cnt;
reg [13:0] c_src, c_dst, c_cnt, f_addr, f_cnt;
reg c_dir;
reg [17:0] f_cell;
@@ -119,12 +128,12 @@ module term_ctrl (
integer i;
// ------------------------------------------------------------ helpers
function [11:0] rc(input [4:0] r, input [6:0] cc);
rc = {1'b0, r, 6'b0} + {3'b0, r, 4'b0} + {5'b0, cc};
function [13:0] rc(input [5:0] r, input [7:0] cc);
rc = {1'b0, r, 7'b0} + {6'b0, r, 2'b0} + {6'b0, cc};
endfunction
function [11:0] rows80(input [5:0] n);
rows80 = {n, 6'b0} + {2'b0, n, 4'b0};
function [13:0] rows(input [6:0] n); // n whole rows of cells
rows = {n, 7'b0} + {5'b0, n, 2'b0};
endfunction
function [7:0] acc(input [7:0] p, input [7:0] d);
@@ -187,20 +196,20 @@ module term_ctrl (
end
endfunction
function [6:0] next_tab(input [79:0] t, input [6:0] cc);
function [7:0] next_tab(input [131:0] t, input [7:0] cc, input [7:0] last);
integer k;
begin
next_tab = LAST_COL;
for (k = 79; k >= 0; k = k - 1)
if (k > cc && t[k]) next_tab = k;
next_tab = last;
for (k = 131; k >= 0; k = k - 1)
if (k > cc && k < last && t[k]) next_tab = k;
end
endfunction
function [6:0] prev_tab(input [79:0] t, input [6:0] cc);
function [7:0] prev_tab(input [131:0] t, input [7:0] cc);
integer k;
begin
prev_tab = 7'd0;
for (k = 0; k < 80; k = k + 1)
prev_tab = 8'd0;
for (k = 0; k < 132; k = k + 1)
if (k < cc && t[k]) prev_tab = k;
end
endfunction
@@ -210,12 +219,12 @@ module term_ctrl (
wire [7:0] p0 = par[0];
wire [7:0] p1 = par[1];
reg [7:0] n8; // count parameter (default 1), registered
reg [6:0] nc; // ... clamped to the rest of the line
wire [6:0] room = 7'd80 - col; // cells from cursor to end of line
reg [7:0] nc; // ... clamped to the rest of the line
wire [7:0] room = NCOLS - col; // cells from cursor to end of line
wire [7:0] n8_c = p0 == 0 ? 8'd1 : p0;
always @(posedge clk) begin
n8 <= n8_c;
nc <= n8_c > room ? room : n8_c[6:0];
nc <= n8_c > room ? room : n8_c;
end
wire [3:0] fgb = bold ? (fg | 4'd8) : fg;
@@ -229,29 +238,29 @@ module term_ctrl (
wire smooth = sclm | smooth_sw;
wire [4:0] sm_step = smooth_fast ? 5'd4 : 5'd2;
wire [4:0] up_lim = row >= stop ? stop : 5'd0;
wire [4:0] dn_lim = row <= sbot ? sbot : LAST_ROW;
wire [4:0] row_up = (row - up_lim > n8) ? row - n8 : up_lim;
wire [4:0] row_dn = (dn_lim - row > n8) ? row + n8 : dn_lim;
wire [6:0] col_rt = (LAST_COL - col > n8) ? col + n8 : LAST_COL;
wire [6:0] col_lt = (col > n8) ? col - n8 : 7'd0;
wire [5:0] up_lim = row >= stop ? stop : 6'd0;
wire [5:0] dn_lim = row <= sbot ? sbot : LAST_ROW;
wire [5:0] row_up = (row - up_lim > n8) ? row - n8 : up_lim;
wire [5:0] row_dn = (dn_lim - row > n8) ? row + n8 : dn_lim;
wire [7:0] col_rt = (LAST_COL - col > n8) ? col + n8 : LAST_COL;
wire [7:0] col_lt = (col > n8) ? col - n8 : 8'd0;
wire [7:0] r_rel = p0 == 0 ? 8'd0 : p0 - 1'b1;
wire [8:0] r_abs = (om ? stop : 5'd0) + r_rel;
wire [4:0] r_max = om ? sbot : LAST_ROW;
wire [4:0] row_p0 = r_abs > r_max ? r_max : r_abs[4:0];
wire [6:0] col_p0 = p0 == 0 ? 7'd0 : p0 > 80 ? LAST_COL : p0 - 1'b1;
wire [6:0] col_p1 = p1 == 0 ? 7'd0 : p1 > 80 ? LAST_COL : p1 - 1'b1;
wire [8:0] r_abs = (om ? stop : 6'd0) + r_rel;
wire [5:0] r_max = om ? sbot : LAST_ROW;
wire [5:0] row_p0 = r_abs > r_max ? r_max : r_abs[5:0];
wire [7:0] col_p0 = p0 == 0 ? 8'd0 : p0 > NCOLS ? LAST_COL : p0 - 1'b1;
wire [7:0] col_p1 = p1 == 0 ? 8'd0 : p1 > NCOLS ? LAST_COL : p1 - 1'b1;
wire [11:0] here = rc(row, col);
wire [4:0] rep_row = (om ? row - stop : row) + 1'b1;
wire [6:0] rep_col = col + 1'b1;
wire [13:0] here = rc(row, col);
wire [6:0] rep_row = (om ? row - stop : row) + 1'b1;
wire [7:0] rep_col = col + 1'b1;
reg [7:0] pv; // parameter being processed, registered
reg pv_ok;
// ------------------------------------------------------------ tasks
task op(input [11:0] src, input [11:0] dst, input [11:0] ccnt, input dir,
input [11:0] fa, input [11:0] fcnt, input [17:0] fcell, input [3:0] rs);
task op(input [13:0] src, input [13:0] dst, input [13:0] ccnt, input dir,
input [13:0] fa, input [13:0] fcnt, input [17:0] fcell, input [3:0] rs);
begin
c_src <= src; c_dst <= dst; c_cnt <= ccnt; c_dir <= dir;
f_addr <= fa; f_cnt <= fcnt; f_cell <= fcell;
@@ -260,14 +269,14 @@ module term_ctrl (
end
endtask
task fill(input [11:0] fa, input [11:0] fcnt);
op(12'd0, 12'd0, 12'd0, 1'b0, fa, fcnt, BLANK, S_IDLE);
task fill(input [13:0] fa, input [13:0] fcnt);
op(14'd0, 14'd0, 14'd0, 1'b0, fa, fcnt, BLANK, S_IDLE);
endtask
// scroll rows t..b up (dir 0) or down (dir 1) by n lines
// scroll rows t..b up (dir 0) or down (dir 1) by n lines; the copy and fill
// ranges are worked out over the next two clocks (S_SCR1, S_SCR2)
task scroll(input dir, input [4:0] t, input [4:0] b, input [7:0] n, input [3:0] rs);
task scroll(input dir, input [5:0] t, input [5:0] b, input [7:0] n, input [3:0] rs);
begin
sc_dir <= dir;
sc_t <= t;
@@ -322,7 +331,7 @@ module term_ctrl (
awm <= 1'b1;
cur_vis <= 1'b1;
alt_scr <= 1'b0;
stop <= 5'd0;
stop <= 6'd0;
sbot <= LAST_ROW;
{sv_row, sv_col, sv_pend, sv_om, sv_gl, sv_bold, sv_ul, sv_blink, sv_rev, sv_conceal} <= 0;
{sv_g0, sv_g1, sv_bg} <= 0;
@@ -334,13 +343,14 @@ module term_ctrl (
begin
soft_reset;
{row, col} <= 0;
{sclm, lnm} <= 2'b0;
{sclm, lnm, wide, colm_clr} <= 4'b0;
sbot <= 6'd31;
dec_leds <= 4'd0;
sm_on <= 1'b0;
sm_off <= 5'd0;
ps <= P_NORM;
for (i = 0; i < 80; i = i + 1) tabs[i] <= i != 0 && i % 8 == 0;
fill(12'd0, CELLS);
for (i = 0; i < 132; i = i + 1) tabs[i] <= i != 0 && i % 8 == 0;
fill(14'd0, ALL);
end
endtask
@@ -352,17 +362,22 @@ module term_ctrl (
end
endtask
function [7:0] tens(input [6:0] v);
tens = "0" + v / 7'd10;
function [7:0] tens(input [7:0] v);
tens = "0" + (v / 8'd10) % 8'd10;
endfunction
function [7:0] ones(input [6:0] v);
ones = "0" + v % 7'd10;
function [7:0] ones(input [7:0] v);
ones = "0" + v % 8'd10;
endfunction
// ESC [ rr ; cc R, or ESC [ rr ; 1cc R past column 99
task cursor_report;
respond({8'h1B, "[", tens(rep_row), ones(rep_row), ";",
tens(rep_col), ones(rep_col), "R", 32'd0}, 4'd8);
if (rep_col >= 100)
respond({8'h1B, "[", tens(rep_row), ones(rep_row), ";", "1",
tens(rep_col), ones(rep_col), "R", 24'd0}, 4'd9);
else
respond({8'h1B, "[", tens(rep_row), ones(rep_row), ";",
tens(rep_col), ones(rep_col), "R", 32'd0}, 4'd8);
endtask
// one SGR parameter
@@ -414,8 +429,13 @@ module term_ctrl (
begin
if (priv) begin
if (v == 1) cursor_app <= on;
if (v == 3) begin // DECCOLM: 80x32 / 132x64, cleared
wide <= on; colm_clr <= 1'b1;
{row, col, pend, om, stop} <= 0;
sbot <= on ? 6'd63 : 6'd31;
end
if (v == 4) sclm <= on;
if (v == 6) begin om <= on; row <= on ? stop : 5'd0; col <= 7'd0; pend <= 1'b0; end
if (v == 6) begin om <= on; row <= on ? stop : 6'd0; col <= 8'd0; pend <= 1'b0; end
if (v == 7) awm <= on;
if (v == 25) cur_vis <= on;
if (v == 47) alt_scr <= on;
@@ -447,9 +467,9 @@ module term_ctrl (
cursor_app <= 1'b0;
end else case (st)
S_IDLE:
if (clear_req) begin
{row, col, pend} <= 0;
fill(12'd0, CELLS);
if (clear_req || colm_clr) begin
{row, col, pend, colm_clr} <= 0;
fill(14'd0, ALL);
end else if (!in_empty && !in_rd) begin
c <= in_byte;
in_rd <= 1'b1;
@@ -459,16 +479,16 @@ module term_ctrl (
// ---- scroll: size the move, then set up the copy and fill
S_SCR1: begin
sc_h <= sc_b - sc_t + 1'b1;
sc_k <= sc_n > sc_b - sc_t ? sc_b - sc_t + 1'b1 : sc_n[5:0];
sc_k <= sc_n > sc_b - sc_t ? sc_b - sc_t + 1'b1 : sc_n[6:0];
st <= S_SCR2;
end
S_SCR2:
if (!sc_dir)
op(rc(sc_t + sc_k, 0), rc(sc_t, 0), rows80(sc_h - sc_k), 1'b0,
rc(sc_b - sc_k + 1'b1, 0), rows80(sc_k), BLANK, ret_st);
op(rc(sc_t + sc_k, 0), rc(sc_t, 0), rows(sc_h - sc_k), 1'b0,
rc(sc_b - sc_k + 1'b1, 0), rows(sc_k), BLANK, ret_st);
else
op(rc(sc_b - sc_k + 1'b1, 0) - 1'b1, rc(sc_b + 1'b1, 0) - 1'b1, rows80(sc_h - sc_k), 1'b1,
rc(sc_t, 0), rows80(sc_k), BLANK, ret_st);
op(rc(sc_b - sc_k + 1'b1, 0) - 1'b1, rc(sc_b + 1'b1, 0) - 1'b1, rows(sc_h - sc_k), 1'b1,
rc(sc_t, 0), rows(sc_k), BLANK, ret_st);
// ---- copy c_cnt cells, then fill f_cnt cells, then go to ret_st
S_OP:
@@ -521,7 +541,7 @@ module term_ctrl (
end
S_TAB: begin
col <= tdir ? prev_tab(tabs, col) : next_tab(tabs, col);
col <= tdir ? prev_tab(tabs, col) : next_tab(tabs, col, LAST_COL);
rep <= rep - 1'b1;
if (rep == 1) st <= S_IDLE;
end
@@ -569,13 +589,13 @@ module term_ctrl (
case (c)
8'h07: bell <= 1'b1;
8'h08: begin pend <= 1'b0; if (col != 0) col <= col - 1'b1; end
8'h09: begin pend <= 1'b0; col <= next_tab(tabs, col); end
8'h09: begin pend <= 1'b0; col <= next_tab(tabs, col, LAST_COL); end
8'h0A, 8'h0B, 8'h0C: begin
pend <= 1'b0;
if (lf_cr || lnm) col <= 7'd0;
if (lf_cr || lnm) col <= 8'd0;
line_feed(S_IDLE);
end
8'h0D: begin pend <= 1'b0; col <= 7'd0; end
8'h0D: begin pend <= 1'b0; col <= 8'd0; end
8'h0E: gl <= 1'b1;
8'h0F: gl <= 1'b0;
default: ;
@@ -586,12 +606,12 @@ module term_ctrl (
P_NORM:
if (pend && awm) begin
pend <= 1'b0;
col <= 7'd0;
col <= 8'd0;
line_feed(S_DISP); // wrap, then print this byte
end else if (irm && col != LAST_COL)
// insert mode: shift the rest of the line right first
op(rc(row, LAST_COL - 1'b1), rc(row, LAST_COL), {5'd0, LAST_COL - col}, 1'b1,
12'd0, 12'd0, BLANK, S_PUT);
op(rc(row, LAST_COL - 1'b1), rc(row, LAST_COL), {6'd0, LAST_COL - col}, 1'b1,
14'd0, 14'd0, BLANK, S_PUT);
else
st <= S_PUT;
@@ -610,7 +630,7 @@ module term_ctrl (
cint <= 8'd0;
end
"D": begin pend <= 1'b0; line_feed(S_IDLE); end
"E": begin pend <= 1'b0; col <= 7'd0; line_feed(S_IDLE); end
"E": begin pend <= 1'b0; col <= 8'd0; line_feed(S_IDLE); end
"M": begin pend <= 1'b0; reverse_index; end
"H": tabs[col] <= 1'b1;
"7": begin
@@ -641,7 +661,7 @@ module term_ctrl (
"#": if (c == "8") begin // DECALN: fill the screen with E
{row, col, pend, stop} <= 0;
sbot <= LAST_ROW;
op(12'd0, 12'd0, 12'd0, 1'b0, 12'd0, CELLS, {2'b00, 4'd0, def_fg, "E"}, S_IDLE);
op(14'd0, 14'd0, 14'd0, 1'b0, 14'd0, CELLS, {2'b00, 4'd0, def_fg, "E"}, S_IDLE);
end
default: ;
endcase
@@ -684,14 +704,14 @@ module term_ctrl (
"J": begin
pend <= 1'b0;
if (p0 == 0) fill(here, CELLS - here);
else if (p0 == 1) fill(12'd0, here + 1'b1);
else if (p0 == 2) fill(12'd0, CELLS);
else if (p0 == 1) fill(14'd0, here + 1'b1);
else if (p0 == 2) fill(14'd0, CELLS);
end
"K": begin
pend <= 1'b0;
if (p0 == 0) fill(here, room);
else if (p0 == 1) fill(rc(row, 0), col + 1'b1);
else if (p0 == 2) fill(rc(row, 0), 12'd80);
else if (p0 == 2) fill(rc(row, 0), STRIDE);
end
"n": if (p0 == 6) cursor_report;
default: ;
@@ -701,8 +721,8 @@ module term_ctrl (
"B", "e": begin pend <= 1'b0; row <= row_dn; end
"C", "a": begin pend <= 1'b0; col <= col_rt; end
"D": begin pend <= 1'b0; col <= col_lt; end
"E": begin pend <= 1'b0; row <= row_dn; col <= 7'd0; end
"F": begin pend <= 1'b0; row <= row_up; col <= 7'd0; end
"E": begin pend <= 1'b0; row <= row_dn; col <= 8'd0; end
"F": begin pend <= 1'b0; row <= row_up; col <= 8'd0; end
"G", "`": begin pend <= 1'b0; col <= col_p0; end
"d": begin pend <= 1'b0; row <= row_p0; end
"H", "f": begin pend <= 1'b0; row <= row_p0; col <= col_p1; end
@@ -711,47 +731,47 @@ module term_ctrl (
"J": begin
pend <= 1'b0;
if (p0 == 0) fill(here, CELLS - here);
else if (p0 == 1) fill(12'd0, here + 1'b1);
else if (p0 == 2 || p0 == 3) fill(12'd0, CELLS);
else if (p0 == 1) fill(14'd0, here + 1'b1);
else if (p0 == 2 || p0 == 3) fill(14'd0, CELLS);
end
"K": begin
pend <= 1'b0;
if (p0 == 0) fill(here, room);
else if (p0 == 1) fill(rc(row, 0), col + 1'b1);
else if (p0 == 2) fill(rc(row, 0), 12'd80);
else if (p0 == 2) fill(rc(row, 0), STRIDE);
end
"L": if (row >= stop && row <= sbot) begin
pend <= 1'b0; col <= 7'd0;
pend <= 1'b0; col <= 8'd0;
scroll(1'b1, row, sbot, n8, S_IDLE);
end
"M": if (row >= stop && row <= sbot) begin
pend <= 1'b0; col <= 7'd0;
pend <= 1'b0; col <= 8'd0;
scroll(1'b0, row, sbot, n8, S_IDLE);
end
"@": begin
pend <= 1'b0;
op(rc(row, LAST_COL - nc), rc(row, LAST_COL), room - nc, 1'b1,
here, nc, BLANK, S_IDLE);
op(rc(row, LAST_COL - nc), rc(row, LAST_COL), {6'd0, room - nc}, 1'b1,
here, {6'd0, nc}, BLANK, S_IDLE);
end
"P": begin
pend <= 1'b0;
op(rc(row, col + nc), here, room - nc, 1'b0,
rc(row, 7'd80 - nc), nc, BLANK, S_IDLE);
op(rc(row, col + nc), here, {6'd0, room - nc}, 1'b0,
rc(row, NCOLS - nc), {6'd0, nc}, BLANK, S_IDLE);
end
"X": begin pend <= 1'b0; fill(here, nc); end
"X": begin pend <= 1'b0; fill(here, {6'd0, nc}); end
"S": scroll(1'b0, stop, sbot, n8, S_IDLE);
"T": scroll(1'b1, stop, sbot, n8, S_IDLE);
"g": if (p0 == 0) tabs[col] <= 1'b0; else if (p0 == 3) tabs <= 80'd0;
"g": if (p0 == 0) tabs[col] <= 1'b0; else if (p0 == 3) tabs <= 132'd0;
"h": plist(K_SET);
"l": plist(K_RST);
"m": plist(K_SGR);
"q": plist(K_LL);
"r": begin
if ((p0 == 0 ? 8'd1 : p0) < (p1 == 0 || p1 > 30 ? 8'd30 : p1)) begin
stop <= p0 == 0 ? 5'd0 : p0 - 1'b1;
sbot <= p1 == 0 || p1 > 30 ? LAST_ROW : p1 - 1'b1;
row <= om ? (p0 == 0 ? 5'd0 : p0 - 1'b1) : 5'd0;
col <= 7'd0;
if ((p0 == 0 ? 8'd1 : p0) < (p1 == 0 || p1 > NROWS ? {1'b0, NROWS} : p1)) begin
stop <= p0 == 0 ? 6'd0 : p0 - 1'b1;
sbot <= p1 == 0 || p1 > NROWS ? LAST_ROW : p1 - 1'b1;
row <= om ? (p0 == 0 ? 6'd0 : p0 - 1'b1) : 6'd0;
col <= 8'd0;
pend <= 1'b0;
end
end