Verilog を使用して、Lattice CPLD から VGA コントローラーを構築しています。私は過去にかなりの量の Verilog に触れていましたが、しばらく経ち、モニターを制御するために必要な同期ラインが駆動されていない点に錆びていて (O.Scope で確認)、なぜだかわかりません。
Active-HDL でコードをシミュレートしようとしましたが、奇妙なエラー メッセージ (非ブロッキング トランザクションにメモリを割り当てられませんでした) が表示され、カウンターに負荷がないという警告が表示されます (この場合は無視できると思いますか? ) コードは以下のとおりです。
module CtrlLines(NRST, CLK, H_SYNC, V_SYNC);
input wire CLK; /*< CLK input from Top module >*/
input wire NRST; /*< Reset input from Top module >*/
output reg H_SYNC;
output reg V_SYNC;
reg [10:0] h_counter; /*< Tracks amount of pulses from CLK >*/
reg [10:0] v_counter; /*< Tracks amount of pulses from H_SYNC >*/
`define H_FRONT_PORCH 10'd95
`define H_BACK_PORCH 10'd720
`define H_COUNT_MAX 10'd800
`define V_FRONT_PORCH 10'd2
`define V_BACK_PORCH 10'd514
`define V_COUNT_MAX 10'd528
always @(negedge NRST, posedge CLK) begin
if (!NRST) begin
h_counter <= 10'b00;
end
else begin
h_counter <= h_counter + 1'b1;
case (h_counter)
`H_FRONT_PORCH: H_SYNC <= 1; /*< If the counter has reached Front Porch, go High >*/
`H_BACK_PORCH : H_SYNC <= 0; /*< If the counter has reached Back Porch, go Low >*/
`H_COUNT_MAX : h_counter <= 0; /*< If the counter has reached Max, Reset >*/
endcase /*< Else, remain at current level >*/
end
end
always @(negedge NRST, negedge H_SYNC) begin
if (!NRST) begin
v_counter <= 10'b00;
end
else begin
v_counter <= v_counter +1'b1;
case (v_counter)
`V_FRONT_PORCH : V_SYNC <= 1;
`V_BACK_PORCH : V_SYNC <= 0;
`V_COUNT_MAX : v_counter <= 0;
endcase
end
end
endmodule