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

Subversion Repositories t80

[/] [t80/] [trunk/] [rtl/] [vhdl/] [T80.vhd] - Diff between revs 8 and 15

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

Rev 8 Rev 15
Line 1... Line 1...
--
--
-- Z80 compatible microprocessor core
-- Z80 compatible microprocessor core
--
--
-- Version : 0232
-- Version : 0235
--
--
-- 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 54... Line 54...
--      0211 : Fixed Refresh addition and IM 1
--      0211 : Fixed Refresh addition and IM 1
--
--
--      0214 : Fixed mostly flags, only the block instructions now fail the zex regression test
--      0214 : Fixed mostly flags, only the block instructions now fail the zex regression test
--
--
--      0232 : Removed refresh address output for Mode > 1 and added DJNZ M1_n fix by Mike Johnson
--      0232 : Removed refresh address output for Mode > 1 and added DJNZ M1_n fix by Mike Johnson
 
--
 
--      0235 : Added clock enable and IM 2 fix by Mike Johnson
 
--
 
 
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 67... Line 70...
                Mode : integer := 0      -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
                Mode : integer := 0      -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
        );
        );
        port(
        port(
                RESET_n         : in std_logic;
                RESET_n         : in std_logic;
                CLK_n           : in std_logic;
                CLK_n           : in std_logic;
 
                CEN                     : in std_logic;
                WAIT_n          : in std_logic;
                WAIT_n          : in std_logic;
                INT_n           : in std_logic;
                INT_n           : in std_logic;
                NMI_n           : in std_logic;
                NMI_n           : in std_logic;
                BUSRQ_n         : in std_logic;
                BUSRQ_n         : in std_logic;
                M1_n            : out std_logic;
                M1_n            : out std_logic;
Line 310... Line 314...
                        AALU_OP_r <= "000";
                        AALU_OP_r <= "000";
                        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
 
 
                        Arith16_r <= '0';
                        Arith16_r <= '0';
                        ALU_Op_r <= "0000";
                        ALU_Op_r <= "0000";
                        Rot_Op_r <= '0';
                        Rot_Op_r <= '0';
                        Bit_Op_r <= "00";
                        Bit_Op_r <= "00";
                        Save_ALU_r <= '0';
                        Save_ALU_r <= '0';
Line 401... Line 407...
                                                A <= TmpAddr;
                                                A <= TmpAddr;
                                                PC <= unsigned(TmpAddr);
                                                PC <= unsigned(TmpAddr);
                                        elsif MCycle = MCycles and NMICycle = '1' then
                                        elsif MCycle = MCycles and NMICycle = '1' then
                                                A <= "0000000001100110";
                                                A <= "0000000001100110";
                                                PC <= "0000000001100110";
                                                PC <= "0000000001100110";
                                        elsif MCycle = MCycles and IntCycle = '1' and IStatus = "10" then
                                        elsif MCycle = "011" and IntCycle = '1' and IStatus = "10" then
                                                A(15 downto 8) <= I;
                                                A(15 downto 8) <= I;
                                                A(7 downto 1) <= TmpAddr(7 downto 1);
                                                A(7 downto 0) <= TmpAddr(7 downto 0);
                                                A(0) <= '0';
 
                                                PC(15 downto 8) <= unsigned(I);
                                                PC(15 downto 8) <= unsigned(I);
                                                PC(7 downto 0) <= unsigned(TmpAddr(7 downto 0));
                                                PC(7 downto 0) <= unsigned(TmpAddr(7 downto 0));
                                        else
                                        else
                                                case Set_Addr_To is
                                                case Set_Addr_To is
                                                when aXY =>
                                                when aXY =>
Line 752... Line 757...
                                end case;
                                end case;
                        end if;
                        end if;
 
 
                end if;
                end if;
 
 
 
                end if;
 
 
        end process;
        end process;
 
 
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--
--
-- Buses
-- Buses
--
--
---------------------------------------------------------------------------
---------------------------------------------------------------------------
        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
                        case Set_BusB_To is
                        case Set_BusB_To is
                        when "0111" =>
                        when "0111" =>
                                BusB <= ACC;
                                BusB <= ACC;
                        when "0000" =>
                        when "0000" =>
                                BusB <= B;
                                BusB <= B;
Line 869... Line 877...
                        when others =>
                        when others =>
                                BusB <= "--------";
                                BusB <= "--------";
                        end case;
                        end case;
 
 
                end if;
                end if;
 
                end if;
        end process;
        end process;
 
 
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--
--
-- Generate external control signals
-- Generate external control signals
Line 882... Line 891...
        process (RESET_n,CLK_n)
        process (RESET_n,CLK_n)
        begin
        begin
                if RESET_n = '0' then
                if RESET_n = '0' then
                        RFSH_n <= '1';
                        RFSH_n <= '1';
                elsif CLK_n'event and CLK_n = '1' then
                elsif CLK_n'event and CLK_n = '1' then
 
                        if CEN = '1' then
                        if MCycle = "001" and ((TState = 2  and Wait_n = '1') or TState = 3) then
                        if MCycle = "001" and ((TState = 2  and Wait_n = '1') or TState = 3) then
                                RFSH_n <= '0';
                                RFSH_n <= '0';
                        else
                        else
                                RFSH_n <= '1';
                                RFSH_n <= '1';
                        end if;
                        end if;
                end if;
                end if;
 
                end if;
        end process;
        end process;
 
 
        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;
Line 902... Line 913...
        process (RESET_n,CLK_n)
        process (RESET_n,CLK_n)
        begin
        begin
                if RESET_n = '0' then
                if RESET_n = '0' then
                        M1_n <= '0';
                        M1_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 T_Res = '1' and (MCycle = MCycles or (MCycle = "010" and I_DJNZ = '1' and B = "00000000")) then
                        if T_Res = '1' and (MCycle = MCycles or (MCycle = "010" and I_DJNZ = '1' and B = "00000000")) then
                                M1_n <= '0';
                                M1_n <= '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;
                end if;
                end if;
 
                end if;
        end process;
        end process;
 
 
-------------------------------------------------------------------------
-------------------------------------------------------------------------
--
--
-- Syncronise inputs
-- Syncronise inputs
Line 924... Line 937...
                if RESET_n = '0' then
                if RESET_n = '0' then
                        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
                        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';
                        end if;
                        end if;
                        OldNMI_n := NMI_n;
                        OldNMI_n := NMI_n;
                end if;
                end if;
 
                end if;
        end process;
        end process;
 
 
-------------------------------------------------------------------------
-------------------------------------------------------------------------
--
--
-- Main state machine
-- Main state machine
Line 953... Line 968...
                        IntCycle <= '0';
                        IntCycle <= '0';
                        XY_Fetch <= '0';
                        XY_Fetch <= '0';
                        IntE_FF1 <= '0';
                        IntE_FF1 <= '0';
                        IntE_FF2 <= '0';
                        IntE_FF2 <= '0';
                elsif CLK_n'event and CLK_n = '1' then   -- CLK_n is the clock signal
                elsif CLK_n'event and CLK_n = '1' then   -- CLK_n is the clock signal
 
                        if CEN = '1' then
                        if TState = 2 then
                        if TState = 2 then
                                if SetEI = '1' then
                                if SetEI = '1' then
                                        IntE_FF1 <= '1';
                                        IntE_FF1 <= '1';
                                        IntE_FF2 <= '1';
                                        IntE_FF2 <= '1';
                                end if;
                                end if;
Line 1011... Line 1027...
                                else
                                else
                                        TState <= TState + 1;
                                        TState <= TState + 1;
                                end if;
                                end if;
                        end if;
                        end if;
                end if;
                end if;
 
                end if;
        end process;
        end process;
 
 
end;
end;
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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