OpenCores
URL https://opencores.org/ocsvn/t80/t80/trunk

Subversion Repositories t80

[/] [t80/] [trunk/] [rtl/] [vhdl/] [T80.vhd] - Diff between revs 35 and 42

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 35 Rev 42
Line 1... Line 1...
--
--
-- Z80 compatible microprocessor core
-- Z80 compatible microprocessor core
--
--
-- Version : 0242
-- Version : 0247
--
--
-- Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
-- Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
--
--
-- All rights reserved
-- All rights reserved
--
--
Line 62... Line 62...
--
--
--      0240 : Added interrupt ack fix by Mike Johnson, changed (IX/IY+d) timing and changed flags in GB mode
--      0240 : Added interrupt ack fix by Mike Johnson, changed (IX/IY+d) timing and changed flags in GB mode
--
--
--      0242 : Added I/O wait, fixed refresh address, moved some registers to RAM
--      0242 : Added I/O wait, fixed refresh address, moved some registers to RAM
--
--
 
--      0247 : Fixed bus req/ack cycle
 
--
 
 
library IEEE;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use IEEE.numeric_std.all;
use work.T80_Pack.all;
use work.T80_Pack.all;
Line 149... Line 151...
        signal ID16                             : signed(15 downto 0);
        signal ID16                             : signed(15 downto 0);
        signal Save_Mux                 : std_logic_vector(7 downto 0);
        signal Save_Mux                 : std_logic_vector(7 downto 0);
 
 
        signal TState                   : unsigned(2 downto 0);
        signal TState                   : unsigned(2 downto 0);
        signal MCycle                   : std_logic_vector(2 downto 0);
        signal MCycle                   : std_logic_vector(2 downto 0);
        signal BReq_FF                  : std_logic;
 
        signal IntE_FF1                 : std_logic;
        signal IntE_FF1                 : std_logic;
        signal IntE_FF2                 : std_logic;
        signal IntE_FF2                 : std_logic;
        signal Halt_FF                  : std_logic;
        signal Halt_FF                  : std_logic;
 
        signal BusReq_s                 : std_logic;
 
        signal BusAck                   : std_logic;
 
        signal ClkEn                    : std_logic;
        signal NMI_s                    : std_logic;
        signal NMI_s                    : std_logic;
        signal INT_s                    : std_logic;
        signal INT_s                    : std_logic;
        signal IStatus                  : std_logic_vector(1 downto 0);
        signal IStatus                  : std_logic_vector(1 downto 0);
 
 
        signal DI_Reg                   : std_logic_vector(7 downto 0);
        signal DI_Reg                   : std_logic_vector(7 downto 0);
Line 323... Line 327...
                        BusB => BusB,
                        BusB => BusB,
                        F_In => F,
                        F_In => F,
                        Q => ALU_Q,
                        Q => ALU_Q,
                        F_Out => F_Out);
                        F_Out => F_Out);
 
 
 
        ClkEn <= CEN and not BusAck;
 
 
        T_Res <= '1' when TState = unsigned(TStates) else '0';
        T_Res <= '1' when TState = unsigned(TStates) else '0';
 
 
        NextIs_XY_Fetch <= '1' when XY_State /= "00" and XY_Ind = '0' and
        NextIs_XY_Fetch <= '1' when XY_State /= "00" and XY_Ind = '0' and
                                                        ((Set_Addr_To = aXY) or
                                                        ((Set_Addr_To = aXY) or
                                                        (MCycle = "001" and IR = "11001011") or
                                                        (MCycle = "001" and IR = "11001011") or
Line 368... Line 374...
                        PreserveC_r <= '0';
                        PreserveC_r <= '0';
                        XY_Ind <= '0';
                        XY_Ind <= '0';
 
 
                elsif CLK_n'event and CLK_n = '1' then
                elsif CLK_n'event and CLK_n = '1' then
 
 
                        if CEN = '1' then
                        if ClkEn = '1' then
 
 
                        ALU_Op_r <= "0000";
                        ALU_Op_r <= "0000";
                        Save_ALU_r <= '0';
                        Save_ALU_r <= '0';
                        Read_To_Reg_r <= "00000";
                        Read_To_Reg_r <= "00000";
 
 
Line 697... Line 703...
--
--
---------------------------------------------------------------------------
---------------------------------------------------------------------------
        process (CLK_n)
        process (CLK_n)
        begin
        begin
                if CLK_n'event and CLK_n = '1' then
                if CLK_n'event and CLK_n = '1' then
                        if CEN = '1' then
                        if ClkEn = '1' then
                                -- Bus A / Write
                                -- Bus A / Write
                                RegAddrA_r <= Alternate & Set_BusA_To(2 downto 1);
                                RegAddrA_r <= Alternate & Set_BusA_To(2 downto 1);
                                if XY_Ind = '0' and XY_State /= "00" and Set_BusA_To(2 downto 1) = "10" then
                                if XY_Ind = '0' and XY_State /= "00" and Set_BusA_To(2 downto 1) = "10" then
                                        RegAddrA_r <= XY_State(1) & "11";
                                        RegAddrA_r <= XY_State(1) & "11";
                                end if;
                                end if;
Line 811... Line 817...
        end process;
        end process;
 
 
        Regs : T80_Reg
        Regs : T80_Reg
                port map(
                port map(
                        Clk => CLK_n,
                        Clk => CLK_n,
                        CEN => CEN,
                        CEN => ClkEn,
                        WEH => RegWEH,
                        WEH => RegWEH,
                        WEL => RegWEL,
                        WEL => RegWEL,
                        AddrA => RegAddrA,
                        AddrA => RegAddrA,
                        AddrB => RegAddrB,
                        AddrB => RegAddrB,
                        AddrC => RegAddrC,
                        AddrC => RegAddrC,
Line 834... Line 840...
--
--
---------------------------------------------------------------------------
---------------------------------------------------------------------------
        process (CLK_n)
        process (CLK_n)
        begin
        begin
                if CLK_n'event and CLK_n = '1' then
                if CLK_n'event and CLK_n = '1' then
                        if CEN = '1' then
                        if ClkEn = '1' then
                        case Set_BusB_To is
                        case Set_BusB_To is
                        when "0111" =>
                        when "0111" =>
                                BusB <= ACC;
                                BusB <= ACC;
                        when "0000" | "0001" | "0010" | "0011" | "0100" | "0101" =>
                        when "0000" | "0001" | "0010" | "0011" | "0100" | "0101" =>
                                if Set_BusB_To(0) = '1' then
                                if Set_BusB_To(0) = '1' then
Line 912... Line 918...
 
 
        MC <= std_logic_vector(MCycle);
        MC <= std_logic_vector(MCycle);
        TS <= std_logic_vector(TState);
        TS <= std_logic_vector(TState);
        DI_Reg <= DI;
        DI_Reg <= DI;
        HALT_n <= not Halt_FF;
        HALT_n <= not Halt_FF;
 
        BUSAK_n <= not BusAck;
        IntCycle_n <= not IntCycle;
        IntCycle_n <= not IntCycle;
        IntE <= IntE_FF1;
        IntE <= IntE_FF1;
        IORQ <= IORQ_i;
        IORQ <= IORQ_i;
        Stop <= I_DJNZ;
        Stop <= I_DJNZ;
 
 
Line 926... Line 933...
-------------------------------------------------------------------------
-------------------------------------------------------------------------
        process (RESET_n, CLK_n)
        process (RESET_n, CLK_n)
                variable OldNMI_n : std_logic;
                variable OldNMI_n : std_logic;
        begin
        begin
                if RESET_n = '0' then
                if RESET_n = '0' then
 
                        BusReq_s <= '0';
                        INT_s <= '0';
                        INT_s <= '0';
                        NMI_s <= '0';
                        NMI_s <= '0';
                        OldNMI_n := '0';
                        OldNMI_n := '0';
                elsif CLK_n'event and CLK_n = '1' then
                elsif CLK_n'event and CLK_n = '1' then
                        if CEN = '1' then
                        if CEN = '1' then
 
                        BusReq_s <= not BUSRQ_n;
                        INT_s <= not INT_n;
                        INT_s <= not INT_n;
                        if NMICycle = '1' then
                        if NMICycle = '1' then
                                NMI_s <= '0';
                                NMI_s <= '0';
                        elsif NMI_n = '0' and OldNMI_n = '1' then
                        elsif NMI_n = '0' and OldNMI_n = '1' then
                                NMI_s <= '1';
                                NMI_s <= '1';
Line 953... Line 962...
        begin
        begin
                if RESET_n = '0' then
                if RESET_n = '0' then
                        MCycle <= "001";
                        MCycle <= "001";
                        TState <= "000";
                        TState <= "000";
                        Pre_XY_F_M <= "000";
                        Pre_XY_F_M <= "000";
                        BReq_FF <= '0';
 
                        Halt_FF <= '0';
                        Halt_FF <= '0';
                        BUSAK_n <= '1';
                        BusAck <= '0';
                        NMICycle <= '0';
                        NMICycle <= '0';
                        IntCycle <= '0';
                        IntCycle <= '0';
                        IntE_FF1 <= '0';
                        IntE_FF1 <= '0';
                        IntE_FF2 <= '0';
                        IntE_FF2 <= '0';
                        No_BTR <= '0';
                        No_BTR <= '0';
                        Auto_Wait_t1 <= '0';
                        Auto_Wait_t1 <= '0';
                        Auto_Wait_t2 <= '0';
                        Auto_Wait_t2 <= '0';
                        M1_n <= '1';
                        M1_n <= '1';
                elsif CLK_n'event and CLK_n = '1' then   -- CLK_n is the clock signal
                elsif CLK_n'event and CLK_n = '1' then
                        if CEN = '1' then
                        if CEN = '1' then
                        if T_Res = '1' then
                        if T_Res = '1' then
                                Auto_Wait_t1 <= '0';
                                Auto_Wait_t1 <= '0';
                        else
                        else
                                Auto_Wait_t1 <= Auto_Wait or IORQ_i;
                                Auto_Wait_t1 <= Auto_Wait or IORQ_i;
Line 996... Line 1004...
                                Halt_FF <= '0';
                                Halt_FF <= '0';
                        end if;
                        end if;
                        if MCycle = "001" and TState = 2 and Wait_n = '1' then
                        if MCycle = "001" and TState = 2 and Wait_n = '1' then
                                M1_n <= '1';
                                M1_n <= '1';
                        end if;
                        end if;
                        if BReq_FF = '1' then
                        if BusReq_s = '1' and BusAck = '1' then
                                if BUSRQ_n = '1' then
 
                                        BReq_FF <= '0';
 
                                        BUSAK_n <= '1';
 
                                end if;
 
                        else
                        else
 
                                BusAck <= '0';
                                if TState = 2 and Wait_n = '0' then
                                if TState = 2 and Wait_n = '0' then
                                elsif T_Res = '1' then
                                elsif T_Res = '1' then
                                        if Halt = '1' then
                                        if Halt = '1' then
                                                Halt_FF <= '1';
                                                Halt_FF <= '1';
                                        end if;
                                        end if;
                                        if BUSRQ_n = '0' then
                                        if BusReq_s = '1' then
                                                BReq_FF <= '1';
                                                BusAck <= '1';
                                                BUSAK_n <= '0';
 
                                        else
                                        else
                                                TState <= "001";
                                                TState <= "001";
                                                if NextIs_XY_Fetch = '1' then
                                                if NextIs_XY_Fetch = '1' then
                                                        MCycle <= "110";
                                                        MCycle <= "110";
                                                        Pre_XY_F_M <= MCycle;
                                                        Pre_XY_F_M <= MCycle;

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.