見出し画像

Tang Nano 9K で Apple II を再現する(4)ビデオタイミング

第四章 Video Timing 後半

回路図 C-20 のビデオ信号生成部を video_generator.sv として実装します。

`default_nettype none

module a2_video_generator (
    input wire color_ref_n,
    input wire text_mode,
    input wire h2,
    input wire h3,
    input wire h4,
    input wire h5,
    input wire vc,
    input wire v0,
    input wire v1,
    input wire v2,
    input wire v3,
    input wire v4,
    input wire v5,
    input wire video_data,
    output wire color_burst,
    output wire hbl,
    output wire sync,
    output wire blanking,
    output wire [2:0] composite_video
);

logic a14_1;
logic a14_13;
logic c13_a;
logic c13_b;
logic c13_6;
logic b12_12;
logic b13_1;
logic b14_4;
logic a14_4;
logic a14_10;
logic b14_1;
logic b14_10;
logic a12_4;
logic b14_13;
logic b11_8;
logic c13_c;
logic c13_d;
logic c13_8;
logic c14_6;

assign a14_1 = ~(text_mode | color_ref_n);  // A14:74LS02
assign a14_13 = ~(h2 | h2);                 // A14:74LS02
assign b13_1 = ~(a14_1 | a14_13);           // B13:74LS02
assign c13_b = h5 & h5;                     // C13:74Ls51
assign c13_a = h4 & h3;                     // C13:74LS51
assign c13_6 = ~(c13_b | c13_a);            // C13:74LS51
assign b12_12 = b13_1 & h3 & c13_6;         // B12:74LS11
assign b14_4 = ~(h5 | h4);                  // B14:74LS02
assign a14_4 = ~(b14_4 | b14_4);            // B14:74LS02
assign a14_10 = ~(a14_4 | h3);              // A14:74LS02
assign b14_1 = ~(a14_10 | ~v2);             // B14:74LS02
assign b14_10 = ~(vc | v0);                 // B14:74LS02
assign a12_4 = ~(b14_10 | b14_10);          // A12:74LS02
assign b14_13 = ~(a12_4 | v1);              // B14:74LS02
assign b11_8 = v3 & v4;                     // B11:74LS08
assign c13_d = c13_6 & a14_13 & h3;         // C13:74LS51
assign c13_c = b14_1 & b14_13 & b11_8;      // C13:74LS51
assign c13_8 = ~(c13_d | c13_c);            // C13:74LS51
assign c14_6 = c13_6 | b11_8;               // C14:74LS32

assign color_burst = b12_12;
assign hbl = c13_6;
assign sync = c13_8;
assign blanking = c14_6;

assign composite_video = ~sync ? 0
        : (h2 & h3 & hbl) ? {1'b0, color_burst, 1'b1}
        : {video_data, 1'b1, video_data};

endmodule

`default_nettype wire

水平同期信号 HBL は、H3、H4、H5 から作られます。HBL = (/H3 + /H4)・/H5
Blanking 信号は、HBL、V3、V4 から作られます。Blanking = HBL + (V3・V4)
表示走査線は 192 ライン、垂直ブランキング期間が 70 ライン、合計 262 ラインとなります。
Sync 信号は、HBL、H2、H3 から作られる C13-D と、H3、H4、H5、および V から作られる C13-C を、合成して生成されます。
C13-D = /H2・H3・HBL
SYNC = /(C13-C + C13-D)
Color Burst 信号は、(TEXT_MODE + /COLOR_REF)・H2・H3・HBL で作られます。

Vertical retrace interval 最終表示ライン直後

コンポジットビデオ信号は、VIDEO_DATA、SYNC、COLOR_BURST から抵抗と Q3 トランジスタで生成されます。コンポジット信号を生成するアナログ部を LTspice でシミュレーションしてみました。
上記の SystemVerilog ソースでは、3 ビットのデジタル値 composite_video で表現しています。-40 IRE = 0、-20 IRE = 1、0 IRE = 2、20 IRE = 3、100 IRE = 7 に対応します。

Composite Video Output Simulation

参考文献

この記事が気に入ったらサポートをしてみませんか?