📄 fpga64_cone.vhd
字号:
vicAddr => vicAddr,
vicData => vicData,
-- sidData => sidData,
colorData => colorData,
cia1Data => cia1Do,
cia2Data => cia2Do,
lastVicData => lastVicDi,
systemWe => systemWe,
systemAddr(16 downto 0) => systemAddr,
dataToCpu => cpuDi,
dataToVic => vicDi,
cs_vic => cs_vic,
cs_sid => cs_sid,
cs_color => cs_color,
cs_cia1 => cs_cia1,
cs_cia2 => cs_cia2,
cs_ram => cs_ram,
cs_ioE => cs_ioE,
cs_ioF => cs_ioF,
cs_romL => cs_romL,
cs_romH => cs_romH
);
process(clk32)
begin
if rising_edge(clk32) then
pulseWrRam <= '0';
pulseWrIo <= '0';
pulseRd <= '0';
if cpuWe = '1' then
if sysCycle = CYCLE_CPUC then
pulseWrRam <= '1';
end if;
if sysCycle = CYCLE_CPUC then
pulseWrIo <= '1';
end if;
else
if sysCycle = CYCLE_CPUE then
pulseRd <= '1';
end if;
end if;
end if;
end process;
-- -----------------------------------------------------------------------
-- VIC-II video interface chip
-- -----------------------------------------------------------------------
vic: entity work.video_vicii_656x
generic map (
registeredAddress => false,
emulateRefresh => false,
emulateLightpen => true,
emulateGraphics => true
)
port map (
clk => clk32,
enaPixel => enablePixel,
enaData => enableVic,
phi => phi0_cpu,
baSync => '0',
ba => baLoc,
mode6569 => (not ntscMode),
mode6567old => '0',
mode6567R8 => ntscMode,
mode6572 => '0',
cs => cs_vic,
we => pulseWrIo,
rd => pulseRd,
lp_n => cia1_pbi(4),
aRegisters => cpuAddr(5 downto 0),
diRegisters => cpuDo,
di => vicDi,
diColor => colorData,
do => vicData,
vicAddr => vicAddr(13 downto 0),
hsync => vicHSync,
vsync => vicVSync,
colorIndex => vicColorIndex,
irq_n => irq_vic
);
-- Pixel timing
process(clk32)
begin
if rising_edge(clk32) then
enablePixel <= '0';
if sysCycle = CYCLE_VIC2
or sysCycle = CYCLE_IDLE2
or sysCycle = CYCLE_IDLE6
or sysCycle = CYCLE_IEC2
or sysCycle = CYCLE_CPU2
or sysCycle = CYCLE_CPU6
or sysCycle = CYCLE_CPUA
or sysCycle = CYCLE_CPUE then
enablePixel <= '1';
end if;
end if;
end process;
-- -----------------------------------------------------------------------
-- CIAs
-- -----------------------------------------------------------------------
cia1: entity work.cia6526
port map (
clk => clk32,
todClk => vicVSync,
reset => reset,
enable => enableCia,
cs => cs_cia1,
we => pulseWrIo,
rd => pulseRd,
addr => cpuAddr(3 downto 0),
di => cpuDo,
do => cia1Do,
ppai => cia1_pai,
ppao => cia1_pao,
ppbi => cia1_pbi,
ppbo => cia1_pbo,
flag_n => '1',
irq_n => irq_cia1
);
cia2: entity work.cia6526
port map (
clk => clk32,
todClk => vicVSync,
reset => reset,
enable => enableCia,
cs => cs_cia2,
we => pulseWrIo,
rd => pulseRd,
addr => cpuAddr(3 downto 0),
di => cpuDo,
do => cia2Do,
ppai => cia2_pai,
ppao => cia2_pao,
ppbi => cia2_pbi,
ppbo => cia2_pbo,
flag_n => '1',
irq_n => irq_cia2
);
-- -----------------------------------------------------------------------
-- 6510 CPU
-- -----------------------------------------------------------------------
cpu: entity work.cpu_6510
generic map (
pipelineOpcode => false,
pipelineAluMux => false,
pipelineAluOut => false
)
port map (
clk => clk32,
reset => reset,
enable => enableCpu,
nmi_n => nmiLoc,
irq_n => irqLoc,
di => cpuDi,
addr => cpuAddr,
do => cpuDo,
we => cpuWe,
diIO => "00010111",
doIO => cpuIO,
debugOpcode => cpuDebugOpcode,
debugPc => cpuDebugPc,
debugA => cpuDebugA,
debugX => cpuDebugX,
debugY => cpuDebugY,
debugS => cpuDebugS
);
-- -----------------------------------------------------------------------
-- Keyboard
-- -----------------------------------------------------------------------
myKeyboard: entity work.io_ps2_keyboard
port map (
clk => clk32,
kbd_clk => kbd_clk,
kbd_dat => kbd_dat,
interrupt => newScanCode,
scanCode => theScanCode
);
myKeyboardMatrix: entity work.fpga64_keyboard_matrix
port map (
clk => clk32,
theScanCode => theScanCode,
newScanCode => newScanCode,
joyA => (not joyA(4 downto 0)),
joyB => (not joyB(4 downto 0)),
pai => cia1_pao,
pbi => cia1_pbo,
pao => cia1_pai,
pbo => cia1_pbi,
videoKey => videoKey,
traceKey => traceKey,
trace2Key => trace2Key,
backwardsReadingEnabled => '0'
);
-- -----------------------------------------------------------------------
-- Reset button
-- -----------------------------------------------------------------------
calcReset: process(clk32)
begin
if rising_edge(clk32) then
if sysCycle = sysCycleDef'high then
if reset_cnt = resetCycles then
reset <= '0';
else
reset <= '1';
reset_cnt <= reset_cnt + 1;
end if;
end if;
if reset_n = '0'
or dma_n = '0' then -- temp reset fix
reset_cnt <= 0;
end if;
end if;
end process;
-- Video modes
process(clk32)
begin
if rising_edge(clk32) then
if videoKey = '1' then
ntscMode <= not ntscMode;
end if;
end if;
end process;
-- Video config display (disabled)
-- process(clk32)
-- begin
-- if rising_edge(clk32) then
-- if videoKey = '1' then
-- videoConfigTimeout <= (others => '1');
-- end if;
-- if endOfCycle = '1' then
-- videoConfigShow <= '0';
-- if videoConfigTimeout /= 0 then
-- videoConfigTimeout <= videoConfigTimeout - 1;
-- videoConfigShow <= '1';
-- end if;
-- end if;
-- end if;
-- end process;
displayVideoConfig: entity work.fpga64_hexy_vmode
generic map (
xoffset => 200
)
port map (
clk => clk32,
vSync => vgaVSync,
hSync => vgaHSync,
video => videoConfigVideo,
dim => videoConfigDim,
ntscMode => ntscMode,
hSyncPolarity => '0',
vSyncPolarity => '0'
);
mainMemoryBus: process(sysCycle, cpuDo, cs_ram, phi0_cpu, phi0_vic, cpuWe, systemWe, systemAddr)
begin
ramAddr <= (others => '0');
if (phi0_cpu = '1') or (phi0_vic = '1') then
ramAddr <= systemAddr;
end if;
ramData <= (others => 'Z');
if (phi0_cpu = '1') and (cpuWe = '1') then
ramData <= cpuDo;
-- if (cs_sid = '1') and
-- (sysCycle = CYCLE_CPU8 or
-- sysCycle = CYCLE_CPU9 or
-- sysCycle = CYCLE_CPUA or
-- sysCycle = CYCLE_CPUB or
-- sysCycle = CYCLE_CPUC or
-- sysCycle = CYCLE_CPUD or
-- sysCycle = CYCLE_CPUE or
-- sysCycle = CYCLE_CPUF) then
-- for i in 0 to 7 loop
-- ramdata(i) <= 'Z';
-- if cpuDo(i) = '0' then
-- ramData(i) <= '0';
-- end if;
-- end loop;
-- end if;
elsif sysCycle >= CYCLE_IEC0 and sysCycle <= CYCLE_IEC3 then --IEC write
ramdata(5)<= cia2_pao(5);
ramdata(4)<= cia2_pao(4);
ramdata(3)<= cia2_pao(3);
ramdata(2)<= '0'; --lptstrobe
end if;
ramCE <= '1';
ramWe <= not systemWe;
if sysCycle = CYCLE_IEC2 or sysCycle = CYCLE_IEC3 then
ramWe <= '0';
elsif cs_ram = '1' then
if sysCycle /= CYCLE_CPU0 and sysCycle /= CYCLE_CPU1 and sysCycle /= CYCLE_CPUF then
ramCE <= '0';
end if;
end if;
end process;
process(clk32)
begin
if rising_edge(clk32) then
if sysCycle = CYCLE_CPUD
or sysCycle = CYCLE_VIC2 then
ramDataReg <= ramData;
end if;
end if;
end process;
--serialBus and SID
serialBus: process(clk32, sysCycle, cs_sid, cs_ioE, cs_ioF, cs_romL, cs_romH, cpuWe)
begin
ces <= "1111";
if sysCycle = CYCLE_IEC0
or sysCycle = CYCLE_IEC1
or sysCycle = CYCLE_IEC2
or sysCycle = CYCLE_IEC3 then
ces <= "1011";--iec port
end if;
if cs_sid = '1' then
ces <= "0011"; --SID 1
end if;
if cs_romL = '1' then
ces <= "0000";
end if;
if cs_romH = '1' then
ces <= "0100";
end if;
if sysCycle /= CYCLE_CPU0
and sysCycle /= CYCLE_CPU1
and sysCycle /= CYCLE_CPUF then
if cs_ioE = '1' then
ces <= "0101";
end if;
if cs_ioF = '1' then
ces <= "0001";
end if;
end if;
if rising_edge(clk32) then
if sysCycle = CYCLE_IEC1 then
cia2_pai(7) <= ramdata(7);
cia2_pai(6) <= ramdata(6);
end if;
end if;
end process;
-- debugBasicScreen: process(systemWe, cpuHasBus, systemData, systemAddr)
-- begin
-- if (pulseWrRam = '1') and (cpuHasBus = '1') and (systemAddr(15 downto 11)="00000") then
-- debugWe <= '1';
-- else
-- debugWe <= '0';
-- end if;
-- debugAddr <= to_integer(systemAddr(10 downto 0));
-- debugData <= systemData;
-- end process;
process(clk32)
begin
if rising_edge(clk32) then
if phi0_vic = '1' then
lastVicDi <= vicDi;
end if;
end if;
end process;
process(clk32)
begin
if rising_edge(clk32) then
if trace2Key = '1' then
debuggerOn <= not debuggerOn;
end if;
end if;
end process;
hexyInstance : entity work.fpga64_hexy
generic map (
xoffset => 200,
yoffset => 110
)
port map (
clk => clk32,
vSync => vgaVSync,
hSync => vgaHSync,
video => vgaDebug,
dim => vgaDebugDim,
spyAddr => cpuAddr,
spyPc => cpuDebugPc,
spyDo => cpuDo,
spyOpcode => cpuDebugOpcode,
spyA => cpuDebugA,
spyX => cpuDebugX,
spyY => cpuDebugY,
spyS => cpuDebugS
);
cia2_pai(5 downto 0) <= cia2_pao(5 downto 0);
cia2_pbi(7 downto 0) <= cia2_pbo;
-- -----------------------------------------------------------------------
-- VIC bank to address lines
-- -----------------------------------------------------------------------
vicAddr(14) <= (not cia2_pao(0));
vicAddr(15) <= (not cia2_pao(1));
-- -----------------------------------------------------------------------
-- Interrupt lines
-- -----------------------------------------------------------------------
irq_n <= 'Z';
nmi_n <= 'Z';
irqLoc <= irq_cia1 and irq_vic and irq_n;
nmiLoc <= irq_cia2 and nmi_n;
-- -----------------------------------------------------------------------
-- Dummy silence audio output
-- -----------------------------------------------------------------------
still <= X"4000";
end architecture;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -