// // File: big_vga_hexdisp4.v // Date: 08-Nov-05 // Author: I. Chuang // // VGA display of string of hex digits // // This version displays 2x2 pixels for each character pixel // so we get characters twice the original size. // // 11-Nov-05 ike: now uses a font rom with only 0-9 and A-F - saves space! // 15-Nov-05 ike: moved font rom to become a shared global module // // This module has three parameters: // // NDIGITS = number of 4-bit hex digits to have in the display // N_BITS = number of bits in NDIGITS // RGB = color of digit output pixels module big_vga_hexdisp4 (vclock,pix_clk,hcount,vcount,pixel,data,cx,cy, font_addr,font_byte); parameter NDIGITS = 8; // number of 4-bit hex digits to display parameter N_BITS = 3; // number of bits in NDIGITS parameter RGB = 3'b111; // pixel color input vclock; // system synchronous clock input pix_clk; // video pixel clock input [9:0] hcount; // horizontal index of current pixel (0..639) input [9:0] vcount; // vertical index of current pixel (0..479) output [2:0] pixel; // char display's pixel input [NDIGITS*4-1:0] data; // character string to display input [9:0] cx; input [9:0] cy; output [8:0] font_addr; // address to font rom (OR together) input [11:0] font_byte; // output from font rom // 1 line x 8 character display (12 x 24 pixel-sized characters) reg [N_BITS-1:0] column; // which char in string to display wire [9:0] hoff = hcount-cx; wire [9:0] voff = vcount-cy; reg [4:0] h; // 0 .. 23 reg [5:0] v; // 0 .. 47 always @(posedge vclock) begin h <= ~pix_clk ? h : ( (hoff==0 | h==0) ? 23 : h-1 ); v <= ~pix_clk ? v : voff[5:0]; column <= ~pix_clk ? column : (hoff==0) ? (NDIGITS-1) : (h==0 ? column - 1 : column); end // look up hex value to display (from data) reg [3:0] hexdig; integer n; always @(*) for (n=0 ; n<4 ; n = n+1 ) // 4 bits per digit hexdig[n] <= data[column*4+n]; // flag to determine if we're in the display area for this hexdisp wire dispflag = ((hcount > cx) & (vcount >= cy) & (hcount <= cx+NDIGITS*24) & (vcount < cy + 48)); // look up raster row from hex digit font rom: 24 words per character wire [8:0] font_addr = dispflag ? (hexdig*24 + v[5:1]) : 9'b0; wire [11:0] font_byte; // each word has 12 bits // font1224_hex_rom f(font_addr,vclock,font_byte); // do this globally // generate character pixel if we're in the right h,v area wire [2:0] cpixel = font_byte[h[4:1]] ? RGB : 3'b0; // latch in pixel, and don't change except on pix_clk reg [2:0] pixel; always @(posedge vclock) pixel <= pix_clk ? (dispflag ? cpixel : 0) : pixel; endmodule