Subversion Repositories KoE_projects

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. -- ****
  2. -- T80(b) core. In an effort to merge and maintain bug fixes ....
  3. --
  4. --
  5. -- Ver 303 add undocumented DDCB and FDCB opcodes by TobiFlex 20.04.2010
  6. -- Ver 300 started tidyup
  7. -- MikeJ March 2005
  8. -- Latest version from www.fpgaarcade.com (original www.opencores.org)
  9. --
  10. -- ****
  11. --
  12. -- Z80 compatible microprocessor core
  13. --
  14. -- Version : 0242
  15. --
  16. -- Copyright (c) 2001-2002 Daniel Wallner (jesus@opencores.org)
  17. --
  18. -- All rights reserved
  19. --
  20. -- Redistribution and use in source and synthezised forms, with or without
  21. -- modification, are permitted provided that the following conditions are met:
  22. --
  23. -- Redistributions of source code must retain the above copyright notice,
  24. -- this list of conditions and the following disclaimer.
  25. --
  26. -- Redistributions in synthesized form must reproduce the above copyright
  27. -- notice, this list of conditions and the following disclaimer in the
  28. -- documentation and/or other materials provided with the distribution.
  29. --
  30. -- Neither the name of the author nor the names of other contributors may
  31. -- be used to endorse or promote products derived from this software without
  32. -- specific prior written permission.
  33. --
  34. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  35. -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  36. -- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  37. -- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
  38. -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  39. -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  40. -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  41. -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  42. -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  43. -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  44. -- POSSIBILITY OF SUCH DAMAGE.
  45. --
  46. -- Please report bugs to the author, but before you do so, please
  47. -- make sure that this is not a derivative work and that
  48. -- you have the latest version of this file.
  49. --
  50. -- The latest version of this file can be found at:
  51. --      http://www.opencores.org/cvsweb.shtml/t80/
  52. --
  53. -- Limitations :
  54. --
  55. -- File history :
  56. --
  57.  
  58. library IEEE;
  59. use IEEE.std_logic_1164.all;
  60.  
  61. package T80_Pack is
  62.  
  63.         constant aNone      : std_logic_vector(2 downto 0) := "111";
  64.         constant aBC        : std_logic_vector(2 downto 0) := "000";
  65.         constant aDE        : std_logic_vector(2 downto 0) := "001";
  66.         constant aXY        : std_logic_vector(2 downto 0) := "010";
  67.         constant aIOA       : std_logic_vector(2 downto 0) := "100";
  68.         constant aSP        : std_logic_vector(2 downto 0) := "101";
  69.         constant aZI        : std_logic_vector(2 downto 0) := "110";
  70.  
  71.         component T80
  72.         generic(
  73.                 Mode : integer := 0;    -- 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
  74.                 IOWait : integer := 0;  -- 1 => Single cycle I/O, 1 => Std I/O cycle
  75.                 Flag_C : integer := 0;
  76.                 Flag_N : integer := 1;
  77.                 Flag_P : integer := 2;
  78.                 Flag_X : integer := 3;
  79.                 Flag_H : integer := 4;
  80.                 Flag_Y : integer := 5;
  81.                 Flag_Z : integer := 6;
  82.                 Flag_S : integer := 7
  83.         );
  84.         port(
  85.                 RESET_n         : in std_logic;
  86.                 CLK_n           : in std_logic;
  87.                 CEN                     : in std_logic;
  88.                 WAIT_n          : in std_logic;
  89.                 INT_n           : in std_logic;
  90.                 NMI_n           : in std_logic;
  91.                 BUSRQ_n         : in std_logic;
  92.                 M1_n            : out std_logic;
  93.                 IORQ            : out std_logic;
  94.                 NoRead          : out std_logic;
  95.                 Write           : out std_logic;
  96.                 RFSH_n          : out std_logic;
  97.                 HALT_n          : out std_logic;
  98.                 BUSAK_n         : out std_logic;
  99.                 A                       : out std_logic_vector(15 downto 0);
  100.                 DInst           : in std_logic_vector(7 downto 0);
  101.                 DI                      : in std_logic_vector(7 downto 0);
  102.                 DO                      : out std_logic_vector(7 downto 0);
  103.                 MC                      : out std_logic_vector(2 downto 0);
  104.                 TS                      : out std_logic_vector(2 downto 0);
  105.                 IntCycle_n      : out std_logic;
  106.                 IntE            : out std_logic;
  107.                 Stop            : out std_logic
  108.         );
  109.         end component;
  110.  
  111.         component T80_Reg
  112.         port(
  113.                 Clk                     : in std_logic;
  114.                 CEN                     : in std_logic;
  115.                 WEH                     : in std_logic;
  116.                 WEL                     : in std_logic;
  117.                 AddrA           : in std_logic_vector(2 downto 0);
  118.                 AddrB           : in std_logic_vector(2 downto 0);
  119.                 AddrC           : in std_logic_vector(2 downto 0);
  120.                 DIH                     : in std_logic_vector(7 downto 0);
  121.                 DIL                     : in std_logic_vector(7 downto 0);
  122.                 DOAH            : out std_logic_vector(7 downto 0);
  123.                 DOAL            : out std_logic_vector(7 downto 0);
  124.                 DOBH            : out std_logic_vector(7 downto 0);
  125.                 DOBL            : out std_logic_vector(7 downto 0);
  126.                 DOCH            : out std_logic_vector(7 downto 0);
  127.                 DOCL            : out std_logic_vector(7 downto 0)
  128.         );
  129.         end component;
  130.  
  131.         component T80_MCode
  132.         generic(
  133.                 Mode   : integer := 0;
  134.                 Flag_C : integer := 0;
  135.                 Flag_N : integer := 1;
  136.                 Flag_P : integer := 2;
  137.                 Flag_X : integer := 3;
  138.                 Flag_H : integer := 4;
  139.                 Flag_Y : integer := 5;
  140.                 Flag_Z : integer := 6;
  141.                 Flag_S : integer := 7
  142.         );
  143.         port(
  144.                 IR                      : in  std_logic_vector(7 downto 0);
  145.                 ISet                    : in  std_logic_vector(1 downto 0);
  146.                 MCycle                  : in  std_logic_vector(2 downto 0);
  147.                 F                       : in  std_logic_vector(7 downto 0);
  148.                 NMICycle                : in  std_logic;
  149.                 IntCycle                : in  std_logic;
  150.                 XY_State                : in  std_logic_vector(1 downto 0);
  151.                 MCycles                 : out std_logic_vector(2 downto 0);
  152.                 TStates                 : out std_logic_vector(2 downto 0);
  153.                 Prefix                  : out std_logic_vector(1 downto 0); -- None,BC,ED,DD/FD
  154.                 Inc_PC                  : out std_logic;
  155.                 Inc_WZ                  : out std_logic;
  156.                 IncDec_16               : out std_logic_vector(3 downto 0); -- BC,DE,HL,SP   0 is inc
  157.                 Read_To_Reg             : out std_logic;
  158.                 Read_To_Acc             : out std_logic;
  159.                 Set_BusA_To             : out std_logic_vector(3 downto 0); -- B,C,D,E,H,L,DI/DB,A,SP(L),SP(M),0,F
  160.                 Set_BusB_To             : out std_logic_vector(3 downto 0); -- B,C,D,E,H,L,DI,A,SP(L),SP(M),1,F,PC(L),PC(M),0
  161.                 ALU_Op                  : out std_logic_vector(3 downto 0);
  162.                         -- ADD, ADC, SUB, SBC, AND, XOR, OR, CP, ROT, BIT, SET, RES, DAA, RLD, RRD, None
  163.                 Save_ALU                : out std_logic;
  164.                 PreserveC               : out std_logic;
  165.                 Arith16                 : out std_logic;
  166.                 Set_Addr_To             : out std_logic_vector(2 downto 0); -- aNone,aXY,aIOA,aSP,aBC,aDE,aZI
  167.                 IORQ                    : out std_logic;
  168.                 Jump                    : out std_logic;
  169.                 JumpE                   : out std_logic;
  170.                 JumpXY                  : out std_logic;
  171.                 Call                    : out std_logic;
  172.                 RstP                    : out std_logic;
  173.                 LDZ                     : out std_logic;
  174.                 LDW                     : out std_logic;
  175.                 LDSPHL                  : out std_logic;
  176.                 LDHLSP                  : out std_logic;
  177.                 ADDSPdd                                         : out std_logic;
  178.                 Special_LD              : out std_logic_vector(2 downto 0); -- A,I;A,R;I,A;R,A;None
  179.                 ExchangeDH              : out std_logic;
  180.                 ExchangeRp              : out std_logic;
  181.                 ExchangeAF              : out std_logic;
  182.                 ExchangeRS              : out std_logic;
  183.                 I_DJNZ                  : out std_logic;
  184.                 I_CPL                   : out std_logic;
  185.                 I_CCF                   : out std_logic;
  186.                 I_SCF                   : out std_logic;
  187.                 I_RETN                  : out std_logic;
  188.                 I_BT                    : out std_logic;
  189.                 I_BC                    : out std_logic;
  190.                 I_BTR                   : out std_logic;
  191.                 I_RLD                   : out std_logic;
  192.                 I_RRD                   : out std_logic;
  193.                 I_INRC                  : out std_logic;
  194.                 SetDI                   : out std_logic;
  195.                 SetEI                   : out std_logic;
  196.                 IMode                   : out std_logic_vector(1 downto 0);
  197.                 Halt                    : out std_logic;
  198.                 NoRead                  : out std_logic;
  199.                 Write                   : out std_logic;
  200.                 XYbit_undoc             : out std_logic
  201.         );
  202.         end component;
  203.  
  204.         component T80_ALU
  205.         generic(
  206.                 Mode   : integer := 0;
  207.                 Flag_C : integer := 0;
  208.                 Flag_N : integer := 1;
  209.                 Flag_P : integer := 2;
  210.                 Flag_X : integer := 3;
  211.                 Flag_H : integer := 4;
  212.                 Flag_Y : integer := 5;
  213.                 Flag_Z : integer := 6;
  214.                 Flag_S : integer := 7
  215.         );
  216.         port(
  217.                 Arith16         : in  std_logic;
  218.                 Z16             : in  std_logic;
  219.                 ALU_Op          : in  std_logic_vector(3 downto 0);
  220.                 IR              : in  std_logic_vector(5 downto 0);
  221.                 ISet            : in  std_logic_vector(1 downto 0);
  222.                 BusA            : in  std_logic_vector(7 downto 0);
  223.                 BusB            : in  std_logic_vector(7 downto 0);
  224.                 F_In            : in  std_logic_vector(7 downto 0);
  225.                 Q               : out std_logic_vector(7 downto 0);
  226.                 F_Out           : out std_logic_vector(7 downto 0)
  227.         );
  228.         end component;
  229.  
  230. end;
  231.