VGAコントローラ

  • タグ:
  • タグはありません
circuit vga_ctrl
{
	instrin htimming; // 25MHz
	output h_sync, v_sync;
	output h_en, v_en;
	output h_count<10>, v_count<10>;

	input iR<4>, iG<4>, iB<4>;
	output oR<4>, oG<4>, oB<4>;

	reg_wr h_tim<10>, v_tim<10>;
	reg_ws h_sync_reg, v_sync_reg;
	reg_wr h_en_reg, v_en_reg;

	instrself vtimming;

	par{
		h_sync = h_sync_reg;
		v_sync = v_sync_reg;

		h_en = h_en_reg;
		v_en = v_en_reg;

		h_count = h_tim - (96+48+1);
		v_count = v_tim - (2+33+1);

		if(h_en & v_en){
			oR = iR; oG = iG; oB = iB;
		}
		else{
			oR = 0; oG = 0; oB = 0;
		}
	}

	instruct htimming par{

		any{
			h_tim==0  : h_sync_reg := 0;
			h_tim==96 : par{
				h_sync_reg := 1;
				vtimming();
			}
			h_tim==(96+48)     : h_en_reg := 1;
			h_tim==(96+48+640) : h_en_reg := 0;
		}

		if(h_tim==(800-1)) h_tim := 0;
		else h_tim++;
	}

	instruct vtimming par{

		any{
			v_tim==0 : v_sync_reg := 0;
			v_tim==2 : v_sync_reg := 1;
			v_tim==(2+33)     : v_en_reg := 1;
			v_tim==(2+33+480) : v_en_reg := 0;
		}

		if(v_tim==(525-1)) v_tim := 0;
		else v_tim++;
	}
}