Subversion Repositories KoE_projects

Rev

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

  1. --------------------------------------------------------------------------------
  2. -- ****
  3. -- T80(c) core. Attempt to finish all undocumented features and provide
  4. --              accurate timings.
  5. -- Version 350.
  6. -- Copyright (c) 2018 Sorgelig
  7. --  Test passed: ZEXDOC, ZEXALL, Z80Full(*), Z80memptr
  8. --  (*) Currently only SCF and CCF instructions aren't passed X/Y flags check as
  9. --      correct implementation is still unclear.
  10. --
  11. -- ****
  12. -- T80(b) core. In an effort to merge and maintain bug fixes ....
  13. --
  14. --
  15. -- Ver 300 started tidyup
  16. -- MikeJ March 2005
  17. -- Latest version from www.fpgaarcade.com (original www.opencores.org)
  18. --
  19. -- ****
  20. --
  21. -- T80 Registers, technology independent
  22. --
  23. -- Version : 0244
  24. --
  25. -- Copyright (c) 2002 Daniel Wallner (jesus@opencores.org)
  26. --
  27. -- All rights reserved
  28. --
  29. -- Redistribution and use in source and synthezised forms, with or without
  30. -- modification, are permitted provided that the following conditions are met:
  31. --
  32. -- Redistributions of source code must retain the above copyright notice,
  33. -- this list of conditions and the following disclaimer.
  34. --
  35. -- Redistributions in synthesized form must reproduce the above copyright
  36. -- notice, this list of conditions and the following disclaimer in the
  37. -- documentation and/or other materials provided with the distribution.
  38. --
  39. -- Neither the name of the author nor the names of other contributors may
  40. -- be used to endorse or promote products derived from this software without
  41. -- specific prior written permission.
  42. --
  43. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  44. -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  45. -- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  46. -- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
  47. -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  48. -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  49. -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  50. -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  51. -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  53. -- POSSIBILITY OF SUCH DAMAGE.
  54. --
  55. -- Please report bugs to the author, but before you do so, please
  56. -- make sure that this is not a derivative work and that
  57. -- you have the latest version of this file.
  58. --
  59. -- The latest version of this file can be found at:
  60. --      http://www.opencores.org/cvsweb.shtml/t51/
  61. --
  62. -- Limitations :
  63. --
  64. -- File history :
  65. --
  66. --      0242 : Initial release
  67. --
  68. --      0244 : Changed to single register file
  69. --
  70.  
  71. library IEEE;
  72. use IEEE.std_logic_1164.all;
  73. use IEEE.numeric_std.all;
  74.  
  75. entity T80_Reg is
  76.         port(
  77.                 Clk     : in  std_logic;
  78.                 CEN     : in  std_logic;
  79.                 WEH     : in  std_logic;
  80.                 WEL     : in  std_logic;
  81.                 AddrA   : in  std_logic_vector(2 downto 0);
  82.                 AddrB   : in  std_logic_vector(2 downto 0);
  83.                 AddrC   : in  std_logic_vector(2 downto 0);
  84.                 DIH     : in  std_logic_vector(7 downto 0);
  85.                 DIL     : in  std_logic_vector(7 downto 0);
  86.                 DOAH    : out std_logic_vector(7 downto 0);
  87.                 DOAL    : out std_logic_vector(7 downto 0);
  88.                 DOBH    : out std_logic_vector(7 downto 0);
  89.                 DOBL    : out std_logic_vector(7 downto 0);
  90.                 DOCH    : out std_logic_vector(7 downto 0);
  91.                 DOCL    : out std_logic_vector(7 downto 0);
  92.                 DOR     : out std_logic_vector(127 downto 0);
  93.                 DIRSet  : in  std_logic;
  94.                 DIR     : in  std_logic_vector(127 downto 0)
  95.         );
  96. end T80_Reg;
  97.  
  98. architecture rtl of T80_Reg is
  99.  
  100.         type Register_Image is array (natural range <>) of std_logic_vector(7 downto 0);
  101.         signal RegsH : Register_Image(0 to 7);
  102.         signal RegsL : Register_Image(0 to 7);
  103.  
  104. begin
  105.  
  106.         process (Clk)
  107.         begin
  108.                 if rising_edge(Clk) then
  109.                         if DIRSet = '1' then
  110.                                 RegsL(0) <= DIR(  7 downto   0);
  111.                                 RegsH(0) <= DIR( 15 downto   8);
  112.  
  113.                                 RegsL(1) <= DIR( 23 downto  16);
  114.                                 RegsH(1) <= DIR( 31 downto  24);
  115.  
  116.                                 RegsL(2) <= DIR( 39 downto  32);
  117.                                 RegsH(2) <= DIR( 47 downto  40);
  118.  
  119.                                 RegsL(3) <= DIR( 55 downto  48);
  120.                                 RegsH(3) <= DIR( 63 downto  56);
  121.  
  122.                                 RegsL(4) <= DIR( 71 downto  64);
  123.                                 RegsH(4) <= DIR( 79 downto  72);
  124.  
  125.                                 RegsL(5) <= DIR( 87 downto  80);
  126.                                 RegsH(5) <= DIR( 95 downto  88);
  127.  
  128.                                 RegsL(6) <= DIR(103 downto  96);
  129.                                 RegsH(6) <= DIR(111 downto 104);
  130.  
  131.                                 RegsL(7) <= DIR(119 downto 112);
  132.                                 RegsH(7) <= DIR(127 downto 120);
  133.                         elsif CEN = '1' then
  134.                                 if WEH = '1' then
  135.                                         RegsH(to_integer(unsigned(AddrA))) <= DIH;
  136.                                 end if;
  137.                                 if WEL = '1' then
  138.                                         RegsL(to_integer(unsigned(AddrA))) <= DIL;
  139.                                 end if;
  140.                         end if;
  141.                 end if;
  142.         end process;
  143.  
  144.         DOAH <= RegsH(to_integer(unsigned(AddrA)));
  145.         DOAL <= RegsL(to_integer(unsigned(AddrA)));
  146.         DOBH <= RegsH(to_integer(unsigned(AddrB)));
  147.         DOBL <= RegsL(to_integer(unsigned(AddrB)));
  148.         DOCH <= RegsH(to_integer(unsigned(AddrC)));
  149.         DOCL <= RegsL(to_integer(unsigned(AddrC)));
  150.         DOR  <= RegsH(7) & RegsL(7) & RegsH(6) & RegsL(6) & RegsH(5) & RegsL(5) & RegsH(4) & RegsL(4) & RegsH(3) & RegsL(3) & RegsH(2) & RegsL(2) & RegsH(1) & RegsL(1) & RegsH(0) & RegsL(0);
  151.  
  152. end;
  153.