[新連載]CPLD入門!
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
いつか使うことになるだろうと思ってはいたのですが。
何を今頃になって、というようなものですが。
ようやく本気で、CPLDと四つに取り組みます。
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜
[第56回]
●垂直同期信号
垂直同期信号もVGAIFとCRTIFとでは規格が異なっています。
まずはVGAIF用のVHDLプログラムです。
cntr3は垂直ブランキング信号と垂直同期信号を生成するための9ビットのカウンタです。
--cntr3
process(hblnkwk)
begin
if hblnkwk'event and hblnkwk = '1' then
cntr3 <= cntr3 +"000000001";
end if;
if cntr3="111000001" then --(1)
cntr3<="000000000";
end if;
end process;
|
--cntr3
process(hblnkwk)
begin
if hblnkwk'event and hblnkwk = '1' then
cntr3 <= cntr3 +"000000001";
end if;
if cntr3(8)='1' then --(1)
cntr3<="000000000";
end if;
end process;
|
-- vblnk,vsync
process(cntr3)
begin
--vblnkwk
if cntr3(8)='0' then
vblnkwk<='1';
elsif cntr3(8 downto 4)="11001" then
vblnkwk<='0';
end if;
--vsyncwk
if cntr3="110011100" then
vsyncwk<='0';
elsif cntr3="110011110" then
vsyncwk<='1';
end if;
end process;
|
-- vblnk,vsync
process(cntr3)
begin
--vblnkwk
if cntr3(7)='0' then
vblnkwk<='1';
elsif cntr3(7 downto 3)="11001" then
vblnkwk<='0';
end if;
--vsyncwk
if cntr3(7 downto 3)="11011" then
vsyncwk<='0';
elsif cntr3(7 downto 4)="1110" then
vsyncwk<='1';
end if;
end process;
|
--ramadrs
process(cntr2,cntr3,vblnkwk)
begin
if vblnkwk='0' then
ramadrswk<="0000000";
ramadrswk0<="0000000";
elsif cntr3(3 downto 0)="1111" and hblnkwk = '0' then --(1)
ramadrswk0 <= ramadrswk;
elsif cntr2="1010000" and cntr1(0)='1' then
ramadrswk <= ramadrswk0;
elsif cntr2(3)'event and cntr2(3)='0' and hblnkwk='1' then
ramadrswk<=ramadrswk+"0000001";
end if;
end process;
|
--ramadrs
process(cntr2,cntr3,vblnkwk)
begin
if vblnkwk='0' then
ramadrswk<="0000000";
ramadrswk0<="0000000";
elsif cntr3(2 downto 0)="111" and hblnkwk = '0' then --(1)
ramadrswk0 <= ramadrswk;
elsif cntr2="1010000" and cntr1(0)='1' then
ramadrswk <= ramadrswk0;
elsif cntr2(3)'event and cntr2(3)='0' and hblnkwk='1' then
ramadrswk<=ramadrswk+"0000001";
end if;
end process;
|
rgbout<=sftrgstr(7) and hblnkwk2 and vblnkwk and vactive;
RGB_ROUT<=rgbout;
RGB_GOUT<=rgbout;
RGB_BOUT<=rgbout;
ROMadrs<=cntr3( 3 downto 1);
|
Hsync<=hsyncwk;
Vsync<=vsyncwk;
|
rgbout<=sftrgstr(7) and hblnkwk2 and vblnkwk and vactive;
--RGB_ROUT<=rgbout;
--RGB_GOUT<=rgbout;
--RGB_BOUT<=rgbout;
ROMadrs<=cntr3(2 downto 0);
--crt out
process(rgbout)
begin
if rgbout='0' then
CRTDSP<='0';
else
CRTDSP<='Z';
end if;
end process;
process(hsyncwk,vsyncwk)
begin
if hsyncwk='0' or vsyncwk='0' then
CRTVHSYNC<='0';
else
CRTVHSYNC<='Z';
end if;
end process;
|