-- Model Name : Reduced Activity - Parwan Memory -- Author : Zainalabedin Navabi -- Last Updated : 09 / 15 / 1996 -- This document is © copyrighted by the Author.
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
--
LIBRARY EXEMPLAR;
USE EXEMPLAR.exemplar_1164.ALL;
USE EXEMPLAR.exemplar.ALL;
--
LIBRARY WORK;
USE WORK.synthesis_parameters.ALL;
USE WORK.synthesis_utilities.ALL;
USE WORK.global_environment.ALL;
--
ENTITY parwan_memory IS
    PORT (cs, rwbar : IN std_logic);
END parwan_memory;
--
ARCHITECTURE behavioral OF parwan_memory IS
    TYPE byte_memory IS ARRAY ( INTEGER RANGE <> ) OF std_logic_vector ( 7 DOWNTO 0 );
-- SIGNAL da : std_logic_vector ( 7 DOWNTO 0 );
-- SIGNAL ad : std_logic_vector ( 11 DOWNTO 0 );
BEGIN
    mem : PROCESS
    VARIABLE memory : byte_memory ( 0 TO 63 ) :=
      ("00000000", "00011000", "10100000", "00011001", --00: lda 24, sta 25
      "00100000", "00011010", "01000000", "00011011", --04: and 26, add 27
      "11100010", "11101001", "01100000", "00011100", --08: cac, asr, sub 28
      "00010000", "00011101", "11000000", "00100100", --12: lda i 29, jsr 36
      "11101000", "11100000", "10000000", "00100000", --16: asl, nop, jmp 32
      "00000000", "00000000", "00000000", "00000000", --20:
      "01011100", "00000000", "01110000", "00010010", --24: (24, 25, 26, 27)
      "00001100", "00011111", "00000000", "01011010", --28: (28, 29, 30, 31)
      "10000000", "00010010", "00000000", "00000000", --32: jmp 18
      "00000000", "11100010", "10010000", "00100100", --36: , cma, jmp i 36
      "00000000", "00000000", "00000000", "00000000",
      "00000000", "00000000", "00000000", "00000000",
      "00000000", "00000000", "00000000", "00000000",
      "00000000", "00000000", "00000000", "00000000",
      "00000000", "00000000", "00000000", "00000000",
      "00000000", "00000000", "00000000", "00000000" );
    VARIABLE ia : INTEGER;
BEGIN
    IF cs = '1' THEN
      WAIT FOR 1 FS;
      ia := evec2int (adbus);
      IF rwbar = '1' THEN
        IF ia >= 64 THEN
          databus := "ZZZZZZZZ";
        ELSE
          databus := memory (ia);
        END IF;
      ELSIF rwbar = '0' THEN
        IF ia < 64 THEN
          memory (ia) := databus;
        END IF;
      END IF;
      -- da <= databus; ad <= adbus;
      WAIT ON cck;
      databus := "ZZZZZZZZ";
    END IF;
    WAIT ON cs;
END PROCESS mem; END behavioral;