Glyph renderer WIP

This commit is contained in:
jaseg 2021-06-17 16:55:02 +02:00
parent 0de373c3af
commit a7953cfb89
6 changed files with 1882 additions and 35 deletions

149
charmap_gen.ipynb Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,103 @@
module gen_charmap_is_printable_default(input glyph[15:0], output reg is_printable) begin
always @(glyph) begin
case(glyph)
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'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'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'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'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'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'h007b: is_printable <= 1;
16'h007c: is_printable <= 1;
16'h007d: is_printable <= 1;
16'h007e: is_printable <= 1;
16'h0020: is_printable <= 1;
default: is_printable <= 0;
endcase
end
end

View file

@ -0,0 +1,3 @@
`define GEN_FONT_GLYPH_W_default 8
`define GEN_FONT_GLYPH_H_default 16
`define GEN_FONT_GLYPH_COUNT_default 95

File diff suppressed because it is too large Load diff

79
src/term_renderer.v Normal file
View file

@ -0,0 +1,79 @@
`timescale 1ns / 1ps
module term_renderer(
input rst, clk,
input in_vsync, in_hsync,
input [15:0] glyphmem_data,
output [15:0] glyphmem_r_addr,
output [7:0] out_red,
output [7:0] out_green,
output [7:0] out_blue
);
parameter GLYPHMEM_W = 512; /* glyphs */
parameter GLYPHMEM_H = 256; /* glyphs */
/* Glyph table instantiation */
`include "gen/gen_font_params_default.vh"
`define FONT_GLYPH_W GEN_FONT_GLYPH_W_default
`define FONT_GLYPH_H GEN_FONT_GLYPH_H_default
`define FONT_GLYPH_COUNT GEN_FONT_GLYPH_COUNT_default
reg [FONT_GLYPH_W-1:0] glyph_table [0:FONT_GLYPH_COUNT-1];
initial $readmemh("../../../../src/gen/gen_glyphtable_default.hex", glyph_table_deault);
/* Glyph x/y synchronization logic */
reg [11:0] glyph_x;
reg [11:0] glyph_y;
reg [FONT_GLYPH_W-1:0] glyph_sreg_out;
reg [5:0] px_x;
reg [5:0] px_y;
reg in_hsync_last, in_vsync_last;
assign glyphmem_r_addr = (GLYPHMEM_W*glyph_y) + glyph_x;
always @(posedge clk) begin
if (rst) begin
glyph_x <= 0;
glyph_y <= 0;
px_x <= 0;
px_y <= 0;
in_hsync_last <= 0;
in_vsync_last <= 0;
end else begin
in_hsync_last <= in_hsync;
in_vsync_last <= in_vsync;
if (in_hsync_last && !in_hsync) begin
glyph_x <= 0;
px_x <= 0;
if (px_y != FONT_GLYPH_H-1) begin
px_y <= px_y + 1;
end else begin
glyph_y <= glyph_y + 1;
end
end else if (in_hsync) begin
if (px_x != FONT_GLYPH_W-1) begin
px_x <= px_x + 1;
glyph_sreg_out <= {glyph_sreg_out[FONT_GLYPH_W-2:0], 0};
end else begin
px_x <= 0;
glyph_sreg_out <= glyph_table[glyphmem_data[7:0]];
glyph_x <= glyph_x + 1;
end
end
if (in_vsync_last && !in_vsync) begin
glyph_y <= 0;
px_y <= 0;
end
end
end
endmodule

File diff suppressed because one or more lines are too long