Refactor: 2nd stage - bug fixes

Change-Id: Ic3bd520d0cc8b74f33068c53085229506d6968b2
This commit is contained in:
David Banks 2015-10-31 18:31:41 +00:00
parent 99c5f951d1
commit 6aeb0c7b8a
3 changed files with 66 additions and 51 deletions

View File

@ -10,7 +10,7 @@
* VERSION and NAME are used in the start-up message * VERSION and NAME are used in the start-up message
********************************************************/ ********************************************************/
#define VERSION "0.66" #define VERSION "0.70"
#if (CPU == Z80) #if (CPU == Z80)
#define NAME "ICE-T80" #define NAME "ICE-T80"

View File

@ -99,34 +99,40 @@ begin
CLK2X_OUT => open CLK2X_OUT => open
); );
core : entity work.MOS6502CpuMonCore port map( core : entity work.MOS6502CpuMonCore
clock_avr => clock_avr, generic map (
busmon_clk => busmon_clk, UseT65Core => UseT65Core,
busmon_clken => '1', UseAlanDCore => UseAlanDCore
cpu_clk => cpu_clk, )
cpu_clken => '1', port map (
IRQ_n => IRQ_n_sync, clock_avr => clock_avr,
NMI_n => NMI_n_sync, busmon_clk => busmon_clk,
Sync => Sync, busmon_clken => '1',
Addr => Addr_int, cpu_clk => cpu_clk,
R_W_n => R_W_n_int, cpu_clken => '1',
Din => Din, IRQ_n => IRQ_n_sync,
Dout => Dout, NMI_n => NMI_n_sync,
SO_n => SO_n, Sync => Sync,
Res_n => Res_n, Addr => Addr_int,
R_W_n => R_W_n_int,
Din => Din,
Dout => Dout,
SO_n => SO_n,
Res_n_in => Res_n,
Res_n_out => Res_n,
Rdy => Rdy, Rdy => Rdy,
trig => trig, trig => trig,
avr_RxD => avr_RxD, avr_RxD => avr_RxD,
avr_TxD => avr_TxD, avr_TxD => avr_TxD,
sw1 => sw1, sw1 => sw1,
nsw2 => nsw2, nsw2 => nsw2,
led3 => led3, led3 => led3,
led6 => led6, led6 => led6,
led8 => led8, led8 => led8,
tmosi => tmosi, tmosi => tmosi,
tdin => tdin, tdin => tdin,
tcclk => tcclk tcclk => tcclk
); );
sync_gen : process(cpu_clk) sync_gen : process(cpu_clk)
begin begin

View File

@ -21,11 +21,10 @@ use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all; use ieee.numeric_std.all;
use work.OhoPack.all ; use work.OhoPack.all ;
entity MOS6502CpuMonCore is entity MOS6502CpuMonCore is
generic ( generic (
UseT65Core : boolean := true; UseT65Core : boolean;
UseAlanDCore : boolean := false UseAlanDCore : boolean
); );
port ( port (
clock_avr : in std_logic; clock_avr : in std_logic;
@ -44,7 +43,8 @@ entity MOS6502CpuMonCore is
Din : in std_logic_vector(7 downto 0); Din : in std_logic_vector(7 downto 0);
Dout : out std_logic_vector(7 downto 0); Dout : out std_logic_vector(7 downto 0);
SO_n : in std_logic; SO_n : in std_logic;
Res_n : inout std_logic; Res_n_in : in std_logic;
Res_n_out : out std_logic;
Rdy : in std_logic; Rdy : in std_logic;
-- External trigger inputs -- External trigger inputs
@ -72,6 +72,7 @@ end MOS6502CpuMonCore;
architecture behavioral of MOS6502CpuMonCore is architecture behavioral of MOS6502CpuMonCore is
signal cpu_clken_ss : std_logic;
signal Data : std_logic_vector(7 downto 0); signal Data : std_logic_vector(7 downto 0);
signal Dout_int : std_logic_vector(7 downto 0); signal Dout_int : std_logic_vector(7 downto 0);
signal R_W_n_int : std_logic; signal R_W_n_int : std_logic;
@ -106,9 +107,9 @@ begin
mon : entity work.BusMonCore port map ( mon : entity work.BusMonCore port map (
clock_avr => clock_avr, clock_avr => clock_avr,
busmon_clk => busmon_clk, busmon_clk => busmon_clk,
busmon_clken => '1', busmon_clken => busmon_clken,
cpu_clk => cpu_clk, cpu_clk => cpu_clk,
cpu_clken => '1', cpu_clken => cpu_clken,
Addr => Addr_int, Addr => Addr_int,
Data => Data, Data => Data,
Rd_n => not R_W_n_int, Rd_n => not R_W_n_int,
@ -117,8 +118,8 @@ begin
WrIO_n => '1', WrIO_n => '1',
Sync => Sync_int, Sync => Sync_int,
Rdy => open, Rdy => open,
nRSTin => Res_n, nRSTin => Res_n_in,
nRSTout => Res_n, nRSTout => Res_n_out,
CountCycle => CountCycle, CountCycle => CountCycle,
trig => trig, trig => trig,
lcd_rs => open, lcd_rs => open,
@ -164,8 +165,10 @@ begin
last_pc_gen : process(cpu_clk) last_pc_gen : process(cpu_clk)
begin begin
if rising_edge(cpu_clk) then if rising_edge(cpu_clk) then
if (hold = '0') then if (cpu_clken = '1') then
last_PC <= Regs(63 downto 48); if (hold = '0') then
last_PC <= Regs(63 downto 48);
end if;
end if; end if;
end if; end if;
end process; end process;
@ -174,13 +177,15 @@ begin
Regs1( 63 downto 48) <= last_PC; Regs1( 63 downto 48) <= last_PC;
Regs1(255 downto 64) <= (others => '0'); Regs1(255 downto 64) <= (others => '0');
cpu_clken_ss <= (not hold) and cpu_clken;
GenT65Core: if UseT65Core generate GenT65Core: if UseT65Core generate
inst_t65: entity work.T65 port map ( inst_t65: entity work.T65 port map (
mode => "00", mode => "00",
Abort_n => '1', Abort_n => '1',
SO_n => SO_n, SO_n => SO_n,
Res_n => Res_n, Res_n => Res_n_in,
Enable => not hold, Enable => cpu_clken_ss,
Clk => cpu_clk, Clk => cpu_clk,
Rdy => '1', Rdy => '1',
IRQ_n => IRQ_n, IRQ_n => IRQ_n,
@ -197,9 +202,9 @@ begin
GenAlanDCore: if UseAlanDCore generate GenAlanDCore: if UseAlanDCore generate
inst_r65c02: entity work.r65c02 port map ( inst_r65c02: entity work.r65c02 port map (
reset => RES_n, reset => Res_n_in,
clk => cpu_clk, clk => cpu_clk,
enable => not hold, enable => cpu_clken_ss,
nmi_n => NMI_n, nmi_n => NMI_n,
irq_n => IRQ_n, irq_n => IRQ_n,
di => unsigned(Din), di => unsigned(Din),
@ -220,12 +225,14 @@ begin
hold_gen : process(cpu_clk) hold_gen : process(cpu_clk)
begin begin
if rising_edge(cpu_clk) then if rising_edge(cpu_clk) then
if (Sync_int = '1') then if (cpu_clken = '1') then
-- stop after the opcode has been fetched if (Sync_int = '1') then
hold <= SS_Single; -- stop after the opcode has been fetched
elsif (SS_Step = '1') then hold <= SS_Single;
-- start again when the single step command is issues elsif (SS_Step = '1') then
hold <= '0'; -- start again when the single step command is issues
hold <= '0';
end if;
end if; end if;
end if; end if;
end process; end process;
@ -239,9 +246,11 @@ begin
mem_gen : process(cpu_clk) mem_gen : process(cpu_clk)
begin begin
if rising_edge(cpu_clk) then if rising_edge(cpu_clk) then
memory_rd1 <= memory_rd; if (cpu_clken = '1') then
memory_wr1 <= memory_wr; memory_rd1 <= memory_rd;
memory_addr1 <= memory_addr; memory_wr1 <= memory_wr;
memory_addr1 <= memory_addr;
end if;
end if; end if;
end process; end process;