LoginSignup
1
0

More than 1 year has passed since last update.

21-09-23 PYNQ > Pmod VGA > 16x16の文字を表示する (「FPGAプログラミング大全 Xilinx編」をベースに変更) + Godotツール

Last updated at Posted at 2021-09-23
PYNQ-Z1
Windows 10 Pro v21H1
Vivado v2019.1
Pmod VGA

参考

概要

  • 7章の8x8ドットのアルファベット表示を16x16にしたい
    • 16x16のCGROMデータ (COEファイル)の用意
    • chardisp.vの16x16対応

CGROMデータ

COE形式の16x16ファイルはGodotで作ったツールで生成したテキストを128文字分張り付けて用意した。
すべてが「A」というファイルでいったん用意 (将来差し替えるだろう)。

CGDATA_16.coe
memory_initialization_radix=2;
memory_initialization_vector=
;
; 00H
;
0000000010000000,
0000000101000000,
0000001000100000,
0000001000100000,
0000010000010000,
0000010000010000,
0000100000001000,
0000100000001000,
0001000000000100,
0001000000000100,
0010111111111010,
0010000000000010,
0100000000000001,
0100000000000001,
0100000000000001,
0000000000000000,
;
; 01H
;
0000000010000000,
0000000101000000,
0000001000100000,
0000001000100000,
0000010000010000,
0000010000010000,
...
(以下略)

IP作成時の指定

CGROMの方は8x8から16x16に対応するため、Port A Widthを16に、Port A Depthを2048にした。

image.png

chardisp.vの16x16対応

chardisp.vをのうち、変更した部分だけを以下に示す。
(C:\ip_200902\chardisp_16\chardisp_16_ip\HDL\chardisp.v)

chardisp.v
wire [3:0] vdotcnt; // <- wire [2:0] vdotcnt; **************
wire [15:0] cgout; // <- wire [7:0] cgout; **************
chardisp.v
/* シフトレジスタ */
reg [15:0] sreg; // <- reg [7:0] sreg; **************
wire sregld = (hdotcnt==4'h14 && iHCNT<10'd640); // <- wire sregld = (hdotcnt==3'h6 && iHCNT<10'd640); **************
chardisp.v
always @( posedge PCK ) begin
    if ( RST )
        sreg <= 16'h00; // <- 8'h00  **************
    else if ( sregld )
        sreg <= cgout;
    else
        sreg <= {sreg[14:0], 1'b0}; // <- sreg[6:0]  **************
end
chardisp.v
always @( posedge PCK ) begin
    if ( RST )
        vga_rgb <= 12'h000;
    else
        vga_rgb <= color & {12{hdispen & vdispen & sreg[15]}}; // <- sreg[7]  **************
end

実行例

XSDKにてchar_test.cを実行した。

f2e8d8bc566f69ee.jpeg

16x16のAが表示された。

備考

まだ学習の途上なので、勘違いした変更をしているかもしれない。

余談

Godotで作った16x16のテキストを出力するツール

TileMapで文字を描く。
マウスクリック時にその文字の配置をテキストとして出力する。

image.png

TileMap.gd
extends TileMap

func _ready():
    pass # Replace with function body.

func _input(event):
    if event is InputEventMouseButton:
        if event.pressed == false:
            return
        if event.button_index != 1:
            return
        for ypos in range(16):
            var res = ""
            for xpos in range(16):
                var atile = get_cell(xpos, ypos)
                res += str(atile)
            print(res + ",")

以下のような出力を得られるので、COEファイルの一文字として使う。
(今回は128文字全て「A」としてファイル作成した。。。)

--- Debugging process started ---
Godot Engine v3.3.2.stable.official - https://godotengine.org
OpenGL ES 3.0 Renderer: GeForce GTX 1070/PCIe/SSE2
OpenGL ES Batching: ON

0000000010000000,
0000000101000000,
0000001000100000,
0000001000100000,
0000010000010000,
0000010000010000,
0000100000001000,
0000100000001000,
0001000000000100,
0001000000000100,
0010111111111010,
0010000000000010,
0100000000000001,
0100000000000001,
0100000000000001,
0000000000000000,

関連

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0