Add support for fg/bg color palette, underline, bold

This commit is contained in:
jaseg 2021-06-18 11:48:30 +02:00
parent 579f5a7f92
commit 28c3f7df61
11 changed files with 64811 additions and 73 deletions

View file

@ -42,7 +42,7 @@
<Option Name="IPUserFilesDir" Val="$PIPUSERFILESDIR"/>
<Option Name="IPStaticSourceDir" Val="$PIPUSERFILESDIR/ipstatic"/>
<Option Name="EnableBDX" Val="FALSE"/>
<Option Name="WTXSimLaunchSim" Val="269"/>
<Option Name="WTXSimLaunchSim" Val="301"/>
<Option Name="WTModelSimLaunchSim" Val="0"/>
<Option Name="WTQuestaLaunchSim" Val="0"/>
<Option Name="WTIesLaunchSim" Val="0"/>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,136 @@
module gen_charmap_is_printable_bold(input glyph[15:0], output reg is_printable) begin
always @(glyph) begin
case(glyph)
16'h0000: is_printable <= 1;
16'h0001: is_printable <= 1;
16'h0002: is_printable <= 1;
16'h0003: is_printable <= 1;
16'h0004: is_printable <= 1;
16'h0005: is_printable <= 1;
16'h0006: is_printable <= 1;
16'h0007: is_printable <= 1;
16'h0008: is_printable <= 1;
16'h0009: is_printable <= 1;
16'h000a: is_printable <= 1;
16'h000b: is_printable <= 1;
16'h000c: is_printable <= 1;
16'h000d: is_printable <= 1;
16'h000e: is_printable <= 1;
16'h000f: is_printable <= 1;
16'h0010: is_printable <= 1;
16'h0011: is_printable <= 1;
16'h0012: is_printable <= 1;
16'h0013: is_printable <= 1;
16'h0014: is_printable <= 1;
16'h0015: is_printable <= 1;
16'h0016: is_printable <= 1;
16'h0017: is_printable <= 1;
16'h0018: is_printable <= 1;
16'h0019: is_printable <= 1;
16'h001a: is_printable <= 1;
16'h001b: is_printable <= 1;
16'h001c: is_printable <= 1;
16'h001d: is_printable <= 1;
16'h001e: is_printable <= 1;
16'h001f: is_printable <= 1;
16'h0020: is_printable <= 1;
16'h0021: is_printable <= 1;
16'h0022: is_printable <= 1;
16'h0023: is_printable <= 1;
16'h0024: is_printable <= 1;
16'h0025: is_printable <= 1;
16'h0026: is_printable <= 1;
16'h0027: is_printable <= 1;
16'h0028: is_printable <= 1;
16'h0029: is_printable <= 1;
16'h002a: is_printable <= 1;
16'h002b: is_printable <= 1;
16'h002c: is_printable <= 1;
16'h002d: is_printable <= 1;
16'h002e: is_printable <= 1;
16'h002f: is_printable <= 1;
16'h0030: is_printable <= 1;
16'h0031: is_printable <= 1;
16'h0032: is_printable <= 1;
16'h0033: is_printable <= 1;
16'h0034: is_printable <= 1;
16'h0035: is_printable <= 1;
16'h0036: is_printable <= 1;
16'h0037: is_printable <= 1;
16'h0038: is_printable <= 1;
16'h0039: is_printable <= 1;
16'h003a: is_printable <= 1;
16'h003b: is_printable <= 1;
16'h003c: is_printable <= 1;
16'h003d: is_printable <= 1;
16'h003e: is_printable <= 1;
16'h003f: is_printable <= 1;
16'h0040: is_printable <= 1;
16'h0041: is_printable <= 1;
16'h0042: is_printable <= 1;
16'h0043: is_printable <= 1;
16'h0044: is_printable <= 1;
16'h0045: is_printable <= 1;
16'h0046: is_printable <= 1;
16'h0047: is_printable <= 1;
16'h0048: is_printable <= 1;
16'h0049: is_printable <= 1;
16'h004a: is_printable <= 1;
16'h004b: is_printable <= 1;
16'h004c: is_printable <= 1;
16'h004d: is_printable <= 1;
16'h004e: is_printable <= 1;
16'h004f: is_printable <= 1;
16'h0050: is_printable <= 1;
16'h0051: is_printable <= 1;
16'h0052: is_printable <= 1;
16'h0053: is_printable <= 1;
16'h0054: is_printable <= 1;
16'h0055: is_printable <= 1;
16'h0056: is_printable <= 1;
16'h0057: is_printable <= 1;
16'h0058: is_printable <= 1;
16'h0059: is_printable <= 1;
16'h005a: is_printable <= 1;
16'h005b: is_printable <= 1;
16'h005c: is_printable <= 1;
16'h005d: is_printable <= 1;
16'h005e: is_printable <= 1;
16'h005f: is_printable <= 1;
16'h0060: is_printable <= 1;
16'h0061: is_printable <= 1;
16'h0062: is_printable <= 1;
16'h0063: is_printable <= 1;
16'h0064: is_printable <= 1;
16'h0065: is_printable <= 1;
16'h0066: is_printable <= 1;
16'h0067: is_printable <= 1;
16'h0068: is_printable <= 1;
16'h0069: is_printable <= 1;
16'h006a: is_printable <= 1;
16'h006b: is_printable <= 1;
16'h006c: is_printable <= 1;
16'h006d: is_printable <= 1;
16'h006e: is_printable <= 1;
16'h006f: is_printable <= 1;
16'h0070: is_printable <= 1;
16'h0071: is_printable <= 1;
16'h0072: is_printable <= 1;
16'h0073: is_printable <= 1;
16'h0074: is_printable <= 1;
16'h0075: is_printable <= 1;
16'h0076: is_printable <= 1;
16'h0077: is_printable <= 1;
16'h0078: is_printable <= 1;
16'h0079: is_printable <= 1;
16'h007a: is_printable <= 1;
16'h007b: is_printable <= 1;
16'h007c: is_printable <= 1;
16'h007d: is_printable <= 1;
16'h007e: is_printable <= 1;
16'h007f: is_printable <= 1;
default: is_printable <= 0;
endcase
end
end

View file

@ -0,0 +1,3 @@
`define GEN_FONT_GLYPH_W_bold 8
`define GEN_FONT_GLYPH_H_bold 16
`define GEN_FONT_GLYPH_COUNT_bold 128

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@ input rst, clk,
input in_vsync, in_hsync,
input [15:0] glyphmem_data,
input [19:0] glyphmem_data,
output [15:0] glyphmem_r_addr,
output out_hsync, out_vsync,
@ -25,6 +25,37 @@ localparam FONT_GLYPH_COUNT = `GEN_FONT_GLYPH_COUNT_default;
reg [FONT_GLYPH_W-1:0] glyph_table_default [0:FONT_GLYPH_COUNT*FONT_GLYPH_H-1];
initial $readmemh("../../../../src/gen/gen_glyphtable_default.hex", glyph_table_default);
`include "gen/gen_font_params_bold.vh"
/* NOTE: Bold font must have same glyph w/h, glyph count as regular font above */
reg [FONT_GLYPH_W-1:0] glyph_table_bold [0:FONT_GLYPH_COUNT*FONT_GLYPH_H-1];
initial $readmemh("../../../../src/gen/gen_glyphtable_bold.hex", glyph_table_bold);
/* Color palette */
function [23:0] color_palette;
input [3:0] index;
begin
/* Nord color palette: https://github.com/arcticicestudio/nord */
case (index)
default: color_palette = 24'h2e3440;
(1): color_palette = 24'h3b4252;
(2): color_palette = 24'h434c5e;
(3): color_palette = 24'h4c566a;
(4): color_palette = 24'hd8dee9;
(5): color_palette = 24'he5e9f0;
(6): color_palette = 24'heceff4;
(7): color_palette = 24'h8fbcbb;
(8): color_palette = 24'h88c0d0;
(9): color_palette = 24'h81a1c1;
(10): color_palette = 24'h5e81ac;
(11): color_palette = 24'hbf616a;
(12): color_palette = 24'hd08770;
(13): color_palette = 24'hebcb8b;
(14): color_palette = 24'ha3be8c;
(15): color_palette = 24'hb48ead;
endcase
end
endfunction
/* Glyph x/y synchronization logic */
reg [11:0] glyph_x;
reg [11:0] glyph_y;
@ -33,15 +64,22 @@ reg [5:0] px_x;
reg [5:0] px_y;
reg in_hsync_last, in_vsync_last;
wire [7:0] gm_data_glyph = glyphmem_data[7:0];
wire [11:0] gm_data_style = glyphmem_data[19:8];
reg [11:0] glyphmem_style_reg;
wire [3:0] gm_data_fgcolor = glyphmem_style_reg[3:0];
wire [3:0] gm_data_bgcolor = glyphmem_style_reg[7:4];
wire gm_data_bold = gm_data_style[10];
wire gm_data_underline = glyphmem_style_reg[11];
assign out_vsync = in_vsync_last;
assign out_hsync = in_hsync_last;
assign glyphmem_r_addr = (GLYPHMEM_W*glyph_y) + glyph_x;
assign out_red = {8{glyph_sreg_out[FONT_GLYPH_W-1]}};
assign out_green = {8{glyph_sreg_out[FONT_GLYPH_W-1]}};
assign out_blue = {8{glyph_sreg_out[FONT_GLYPH_W-1]}};
/* TODO: fg/bg color, bold, italic, underline, blink */
wire px_data = glyph_sreg_out[FONT_GLYPH_W-1] || (gm_data_underline && px_y == FONT_GLYPH_H-2);
assign {out_red, out_green, out_blue} = color_palette(px_data ? gm_data_fgcolor : gm_data_bgcolor);
/* Core logic */
always @(posedge clk) begin
if (rst) begin
glyph_x <= 0;
@ -51,6 +89,7 @@ always @(posedge clk) begin
in_hsync_last <= 0;
in_vsync_last <= 0;
glyph_sreg_out <= 0;
glyphmem_style_reg <= 0;
end else begin
in_hsync_last <= in_hsync;
@ -76,7 +115,12 @@ always @(posedge clk) begin
end
if (px_x == 0) begin
glyph_sreg_out <= glyph_table_default[glyphmem_data[7:0]*FONT_GLYPH_H + px_y];
if (gm_data_bold) begin
glyph_sreg_out <= glyph_table_bold[gm_data_glyph*FONT_GLYPH_H + px_y];
end else begin
glyph_sreg_out <= glyph_table_default[gm_data_glyph*FONT_GLYPH_H + px_y];
end
glyphmem_style_reg <= gm_data_style;
glyph_x <= glyph_x + 1;
end else begin
@ -85,6 +129,7 @@ always @(posedge clk) begin
end else if (!in_hsync_last) begin
glyph_sreg_out <= 0;
glyphmem_style_reg <= 0;
end
if (in_vsync_last && !in_vsync) begin
@ -94,4 +139,5 @@ always @(posedge clk) begin
end
end
endmodule

View file

@ -11,15 +11,15 @@
</db_ref>
</db_ref_list>
<zoom_setting>
<ZoomStartTime time="2811200fs"></ZoomStartTime>
<ZoomEndTime time="3072701fs"></ZoomEndTime>
<Cursor1Time time="2905300fs"></Cursor1Time>
<ZoomStartTime time="233513333fs"></ZoomStartTime>
<ZoomEndTime time="1634593334fs"></ZoomEndTime>
<Cursor1Time time="1401080000fs"></Cursor1Time>
</zoom_setting>
<column_width_setting>
<NameColumnWidth column_width="175"></NameColumnWidth>
<ValueColumnWidth column_width="158"></ValueColumnWidth>
</column_width_setting>
<WVObjectSize size="22" />
<WVObjectSize size="26" />
<wvobject fp_name="/term_renderer_tb/testcase_id" type="array">
<obj_property name="ElementShortName">testcase_id[31:0]</obj_property>
<obj_property name="ObjectShortName">testcase_id[31:0]</obj_property>
@ -44,8 +44,8 @@
<obj_property name="ObjectShortName">in_hsync</obj_property>
</wvobject>
<wvobject fp_name="/term_renderer_tb/term_renderer_dut/glyphmem_data" type="array">
<obj_property name="ElementShortName">glyphmem_data[15:0]</obj_property>
<obj_property name="ObjectShortName">glyphmem_data[15:0]</obj_property>
<obj_property name="ElementShortName">glyphmem_data[19:0]</obj_property>
<obj_property name="ObjectShortName">glyphmem_data[19:0]</obj_property>
</wvobject>
<wvobject fp_name="/term_renderer_tb/term_renderer_dut/glyphmem_r_addr" type="array">
<obj_property name="ElementShortName">glyphmem_r_addr[15:0]</obj_property>
@ -123,4 +123,20 @@
<obj_property name="ElementShortName">FONT_GLYPH_COUNT[31:0]</obj_property>
<obj_property name="ObjectShortName">FONT_GLYPH_COUNT[31:0]</obj_property>
</wvobject>
<wvobject fp_name="/term_renderer_tb/term_renderer_dut/gm_data_fgcolor" type="array">
<obj_property name="ElementShortName">gm_data_fgcolor[3:0]</obj_property>
<obj_property name="ObjectShortName">gm_data_fgcolor[3:0]</obj_property>
</wvobject>
<wvobject fp_name="/term_renderer_tb/term_renderer_dut/gm_data_bgcolor" type="array">
<obj_property name="ElementShortName">gm_data_bgcolor[3:0]</obj_property>
<obj_property name="ObjectShortName">gm_data_bgcolor[3:0]</obj_property>
</wvobject>
<wvobject fp_name="/term_renderer_tb/term_renderer_dut/gm_data_bold" type="logic">
<obj_property name="ElementShortName">gm_data_bold</obj_property>
<obj_property name="ObjectShortName">gm_data_bold</obj_property>
</wvobject>
<wvobject fp_name="/term_renderer_tb/term_renderer_dut/gm_data_underline" type="logic">
<obj_property name="ElementShortName">gm_data_underline</obj_property>
<obj_property name="ObjectShortName">gm_data_underline</obj_property>
</wvobject>
</wave_config>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -26,11 +26,11 @@ parameter GLYPHMEM_W = 256; /* glyphs */
parameter GLYPHMEM_H = 128; /* glyphs */
localparam period = 4;
localparam REC_MAXLEN = 1000000;
localparam REC_MAXLEN = 200000;
reg rst, clk;
reg vsync, hsync;
reg [15:0] glyphmem_data;
reg [19:0] glyphmem_data;
wire [15:0] glyphmem_r_addr;
wire [7:0] out_red;
wire [7:0] out_green;
@ -44,7 +44,7 @@ initial begin
forever #period clk = ~clk;
end
reg [23:0] data_recording [0:100000];
reg [23:0] data_recording [0:REC_MAXLEN];
integer testcase_id;
integer rec_pos;
initial begin
@ -70,7 +70,7 @@ always @(posedge clk) begin
end
end
reg [15:0] glyphmem [0:GLYPHMEM_W*GLYPHMEM_H-1];
reg [19:0] glyphmem [0:GLYPHMEM_W*GLYPHMEM_H-1];
initial $readmemh("../../../../test_bench/test_data/test_glyphmem_data.hex", glyphmem);
always @(posedge clk) begin