Advertisement
xerpi

SISA OS async_64Kx16.vhd

Jun 4th, 2016
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 22.16 KB | None | 0 0
  1.  
  2. --************************************************************************
  3. --**    MODEL   :       async_64Kx16.vhd                                 **
  4. --**    COMPANY :       Cypress Semiconductor                           **
  5. --**    REVISION:       1.0 Created new base model                          **
  6. --************************************************************************
  7.  
  8. Library IEEE,work;
  9. Use IEEE.Std_Logic_1164.All;
  10. use IEEE.Std_Logic_unsigned.All;
  11.  
  12. use ieee.std_logic_textio.all;
  13. use std.textio.all;
  14.  
  15. use work.package_timing.all;
  16. use work.package_utility.all;
  17.  
  18. ------------------------
  19. -- Entity Description
  20. ------------------------
  21.  
  22. Entity async_64Kx16 is
  23. generic
  24.     (ADDR_BITS          : integer := 16;
  25.     DATA_BITS            : integer := 16;
  26.     depth                : integer := 65536;
  27.  
  28.     TimingInfo          : BOOLEAN := TRUE;
  29.     TimingChecks    : std_logic := '1'
  30.     );
  31. Port (
  32.     CE_b   : IN Std_Logic;                                                  -- Chip Enable CE#
  33.     WE_b    : IN Std_Logic;                                                 -- Write Enable WE#
  34.     OE_b    : IN Std_Logic;                                                 -- Output Enable OE#
  35.     BHE_b       : IN std_logic;                                                 -- Byte Enable High BHE#
  36.     BLE_b  : IN std_logic;                                                 -- Byte Enable Low BLE#
  37.     A             : IN Std_Logic_Vector(addr_bits-1 downto 0);                    -- Address Inputs A
  38.     DQ            : INOUT Std_Logic_Vector(DATA_BITS-1 downto 0):=(others=>'Z');   -- Read/Write Data IO
  39.       boot         : in std_logic
  40.     );
  41. End async_64Kx16;
  42.  
  43. -----------------------------
  44. -- End Entity Description
  45. -----------------------------
  46. -----------------------------
  47. -- Architecture Description
  48. -----------------------------
  49.  
  50. Architecture behave_arch Of async_64Kx16 Is
  51.  
  52. Type mem_array_type Is array (depth-1 downto 0) of std_logic_vector(DATA_BITS-1 downto 0);
  53.  
  54. signal write_enable : std_logic;
  55. signal read_enable : std_logic;
  56. signal byte_enable : std_logic;
  57.  
  58. signal data_skew : Std_Logic_Vector(DATA_BITS-1 downto 0);
  59.  
  60. signal address_internal: Std_Logic_Vector(addr_bits-1 downto 0);
  61.  
  62. constant tSD_dataskew : time := tSD - 1 ns;
  63.  
  64. SIGNAL mem_array: mem_array_type;
  65.  
  66.     -- Instructions to read a text file into RAM --
  67.     procedure Load_FitxerDadesMemoria (signal data_word :inout mem_array_type) is
  68.         -- Open File in Read Mode
  69.         file romfile   :text open read_mode is "contingut.memoria.hexa16.rom";
  70.         variable lbuf  :line;
  71.         --variable i     :integer := 49152;  -- X"C000" ==> 49152 adreca inicial S.O.
  72.         variable i     :integer := 24576;  -- X"C000" ==> 49152 adreca inicial S.O., pero como la memoria se direcciona a nivel de word (dos bytes) ==>  X"6000" ==> 24576 es la direccion inicial del S.O.
  73.         variable fdata :std_logic_vector (15 downto 0);
  74.     begin
  75.         while not endfile(romfile) loop
  76.             -- read data from input file
  77.             readline(romfile, lbuf);
  78.             --read(lbuf, fdata);
  79.             hread(lbuf, fdata);
  80.             data_word(i) <= fdata;
  81.             i := i+1;
  82.         end loop;
  83.     end procedure;
  84.  
  85.     -- Kernel code at PA 0xC000
  86.     procedure Load_Kernel_Code(signal data_word: inout mem_array_type) is
  87.         file kernel_code: text open read_mode is "kernel.code.hex";
  88.         variable lbuf  :line;
  89.         variable i     :integer := 24576;  -- X"C000" ==> 49152 -> /2 = 24576
  90.         variable fdata :std_logic_vector (15 downto 0);
  91.     begin
  92.         while not endfile(kernel_code) loop
  93.             -- read data from input file
  94.             readline(kernel_code, lbuf);
  95.             --read(lbuf, fdata);
  96.             hread(lbuf, fdata);
  97.             data_word(i) <= fdata;
  98.             i := i+1;
  99.         end loop;
  100.     end procedure;
  101.  
  102.     -- Kernel data at PA 0x8000
  103.     procedure Load_Kernel_Data(signal data_word: inout mem_array_type) is
  104.         file kernel_data: text open read_mode is "kernel.data.hex";
  105.         variable lbuf  :line;
  106.         variable i     :integer := 16384;  -- X"8000" ==> 32768 -> /2 = 16384
  107.         variable fdata :std_logic_vector (15 downto 0);
  108.     begin
  109.         while not endfile(kernel_data) loop
  110.             -- read data from input file
  111.             readline(kernel_data, lbuf);
  112.             --read(lbuf, fdata);
  113.             hread(lbuf, fdata);
  114.             data_word(i) <= fdata;
  115.             i := i+1;
  116.         end loop;
  117.     end procedure;
  118.  
  119.     -- Userat PA 0x1000
  120.     procedure Load_User(signal data_word: inout mem_array_type) is
  121.         file user: text open read_mode is "kernel.user.hex";
  122.         variable lbuf  :line;
  123.         variable i     :integer := 2048;  -- X"1000" ==> 4096 -> /2 = 2048
  124.         variable fdata :std_logic_vector (15 downto 0);
  125.     begin
  126.         while not endfile(user) loop
  127.             -- read data from input file
  128.             readline(user, lbuf);
  129.             --read(lbuf, fdata);
  130.             hread(lbuf, fdata);
  131.             data_word(i) <= fdata;
  132.             i := i+1;
  133.         end loop;
  134.     end procedure;
  135.  
  136. begin
  137.  
  138. byte_enable <= not(BHE_b and BLE_b);
  139. write_enable <= not(CE_b) and not(WE_b) and byte_enable;
  140. read_enable <= not(CE_b) and (WE_b) and not(OE_b) and byte_enable;
  141.  
  142. data_skew <= DQ after 1 ns; -- changed on feb 15
  143.  
  144. process (OE_b)
  145. begin
  146.     if (OE_b'event and OE_b = '1' and write_enable /= '1') then
  147.         DQ <=(others=>'Z') after tHZOE;
  148.     end if;
  149. end process;
  150.  
  151. process (CE_b)
  152. begin
  153.     if (CE_b'event and CE_b = '1') then
  154.         DQ <=(others=>'Z') after tHZCE;
  155.     end if;
  156. end process;
  157.  
  158. process (write_enable'delayed(tHA))
  159. begin
  160.     if (write_enable'delayed(tHA) = '0' and TimingInfo) then
  161.     assert (A'last_event = 0 ns) or (A'last_event > tHA)
  162.     report "Address hold time tHA violated";
  163.     end if;
  164. end process;
  165.  
  166. process (write_enable'delayed(tHD))
  167. begin
  168.     if (write_enable'delayed(tHD) = '0' and TimingInfo) then
  169.     assert (DQ'last_event > tHD) or (DQ'last_event = 0 ns)
  170.     report "Data hold time tHD violated";
  171.     end if;
  172. end process;
  173.  
  174. -- main process
  175. process
  176.  
  177. --- Variables for timing checks
  178. VARIABLE tPWE_chk : TIME := -10 ns;
  179. VARIABLE tAW_chk : TIME := -10 ns;
  180. VARIABLE tSD_chk : TIME := -10 ns;
  181. VARIABLE tRC_chk : TIME := 0 ns;
  182. VARIABLE tBAW_chk : TIME := 0 ns;
  183. VARIABLE tBBW_chk : TIME := 0 ns;
  184. VARIABLE tBCW_chk : TIME := 0 ns;
  185. VARIABLE tBDW_chk : TIME := 0 ns;
  186.  
  187. VARIABLE write_flag : BOOLEAN := TRUE;
  188.  
  189. VARIABLE accesstime : TIME := 0 ns;
  190.  
  191. begin
  192.  
  193. if (boot'event and boot = '1') then
  194.     -- Procedural Call --
  195.     --Load_FitxerDadesMemoria(mem_array);
  196.  
  197.     Load_Kernel_Code(mem_array);
  198.     Load_Kernel_Data(mem_array);
  199.     Load_User(mem_array);
  200.  
  201.     --mem_array (65500) <= X"ABCD";
  202.  
  203. else
  204.  
  205.     -- start of write
  206.     if (write_enable = '1' and write_enable'event) then
  207.  
  208.        DQ(DATA_BITS-1 downto 0)<=(others=>'Z') after tHZWE;
  209.  
  210.        if (A'last_event >= tSA) then
  211.           address_internal <= A;
  212.           tPWE_chk := NOW;
  213.           tAW_chk := A'last_event;
  214.           write_flag := TRUE;
  215.  
  216.        else
  217.           if (TimingInfo) then
  218.                assert FALSE
  219.                report "Address setup violated";
  220.            end if;
  221.           write_flag := FALSE;
  222.  
  223.        end if;
  224.  
  225.     -- end of write (with CE high or WE high)
  226.     elsif (write_enable = '0' and write_enable'event) then
  227.  
  228.         --- check for pulse width
  229.         if (NOW - tPWE_chk >= tPWE or NOW - tPWE_chk <= 0.1 ns or NOW = 0 ns) then
  230.             --- pulse width OK, do nothing
  231.         else
  232.            if (TimingInfo) then
  233.             assert FALSE
  234.               report "Pulse Width violation";
  235.            end if;
  236.  
  237.          write_flag := FALSE;
  238.          end if;
  239.  
  240.         --- check for address setup with write end, i.e., tAW
  241.         if (NOW - tAW_chk >= tAW or NOW = 0 ns) then
  242.             --- tAW OK, do nothing
  243.         else
  244.            if (TimingInfo) then
  245.              assert FALSE
  246.               report "Address setup tAW violation";
  247.            end if;
  248.  
  249.           write_flag := FALSE;
  250.         end if;
  251.  
  252.         --- check for data setup with write end, i.e., tSD
  253.         if (NOW - tSD_chk >= tSD_dataskew or NOW - tSD_chk <= 0.1 ns or NOW = 0 ns) then
  254.             --- tSD OK, do nothing
  255.         else
  256.            if (TimingInfo) then
  257.               assert FALSE
  258.               report "Data setup tSD violation";
  259.            end if;
  260.           write_flag := FALSE;
  261.         end if;
  262.  
  263.         -- perform write operation if no violations
  264.         if (write_flag = TRUE) then
  265.  
  266.             if (BLE_b = '1' and BLE_b'last_event = write_enable'last_event and NOW /= 0 ns) then
  267.                 mem_array(conv_integer1(address_internal))(7 downto 0) <= data_skew(7 downto 0);
  268.             end if;
  269.  
  270.             if (BHE_b = '1' and BHE_b'last_event = write_enable'last_event and NOW /= 0 ns) then
  271.                 mem_array(conv_integer1(address_internal))(15 downto 8) <= data_skew(15 downto 8);
  272.             end if;
  273.  
  274.             if (BLE_b = '0' and NOW - tBAW_chk >= tBW) then
  275.                 mem_array(conv_integer1(address_internal))(7 downto 0) <= data_skew(7 downto 0);
  276.             elsif (NOW - tBAW_chk < tBW and NOW - tBAW_chk > 0.1 ns and NOW > 0 ns) then
  277.                 assert FALSE report "Insufficient pulse width for lower byte to be written";
  278.             end if;
  279.  
  280.             if (BHE_b = '0' and NOW - tBBW_chk >= tBW) then
  281.                 mem_array(conv_integer1(address_internal))(15 downto 8) <= data_skew(15 downto 8);
  282.             elsif (NOW - tBBW_chk < tBW and NOW - tBBW_chk > 0.1 ns and NOW > 0 ns) then
  283.                 assert FALSE report "Insufficient pulse width for higher byte to be written";
  284.             end if;
  285.  
  286.         end if;
  287.  
  288.     -- end of write (with BLE high)
  289.     elsif (BLE_b'event and not(BHE_b'event) and write_enable = '1') then
  290.  
  291.        if (BLE_b = '0') then
  292.  
  293.            --- Reset timing variables
  294.           tAW_chk := A'last_event;
  295.           tBAW_chk := NOW;
  296.           write_flag := TRUE;
  297.  
  298.        elsif (BLE_b = '1') then
  299.  
  300.           --- check for pulse width
  301.           if (NOW - tPWE_chk >= tPWE) then
  302.             --- tPWE OK, do nothing
  303.           else
  304.               if (TimingInfo) then
  305.                    assert FALSE
  306.                   report "Pulse Width violation";
  307.               end if;
  308.  
  309.               write_flag := FALSE;
  310.            end if;
  311.  
  312.            --- check for address setup with write end, i.e., tAW
  313.            if (NOW - tAW_chk >= tAW) then
  314.             --- tAW OK, do nothing
  315.            else
  316.                if (TimingInfo) then
  317.                   assert FALSE
  318.                    report "Address setup tAW violation for Lower Byte Write";
  319.                end if;
  320.  
  321.               write_flag := FALSE;
  322.            end if;
  323.  
  324.            --- check for byte write setup with write end, i.e., tBW
  325.            if (NOW - tBAW_chk >= tBW) then
  326.             --- tBW OK, do nothing
  327.            else
  328.                if (TimingInfo) then
  329.                  assert FALSE
  330.                    report "Lower Byte setup tBW violation";
  331.                end if;
  332.  
  333.               write_flag := FALSE;
  334.            end if;
  335.  
  336.             --- check for data setup with write end, i.e., tSD
  337.            if (NOW - tSD_chk >= tSD_dataskew or NOW - tSD_chk <= 0.1 ns or NOW = 0 ns) then
  338.             --- tSD OK, do nothing
  339.            else
  340.                if (TimingInfo) then
  341.                   assert FALSE
  342.                   report "Data setup tSD violation for Lower Byte Write";
  343.                end if;
  344.  
  345.               write_flag := FALSE;
  346.            end if;
  347.  
  348.             --- perform WRITE operation if no violations
  349.             if (write_flag = TRUE) then
  350.                mem_array(conv_integer1(address_internal))(7 downto 0) <= data_skew(7 downto 0);
  351.               if (BHE_b = '0') then
  352.                     mem_array(conv_integer1(address_internal))(15 downto 8) <= data_skew(15 downto 8);
  353.               end if;
  354.             end if;
  355.  
  356.            --- Reset timing variables
  357.            tAW_chk := A'last_event;
  358.            tBAW_chk := NOW;
  359.            write_flag := TRUE;
  360.  
  361.       end if;
  362.  
  363.     -- end of write (with BHE high)
  364.     elsif (BHE_b'event and not(BLE_b'event) and write_enable = '1') then
  365.  
  366.       if (BHE_b = '0') then
  367.  
  368.            --- Reset timing variables
  369.         tAW_chk := A'last_event;
  370.         tBBW_chk := NOW;
  371.         write_flag := TRUE;
  372.  
  373.       elsif (BHE_b = '1') then
  374.  
  375.         --- check for pulse width
  376.         if (NOW - tPWE_chk >= tPWE) then
  377.             --- tPWE OK, do nothing
  378.         else
  379.            if (TimingInfo) then
  380.             assert FALSE
  381.               report "Pulse Width violation";
  382.            end if;
  383.  
  384.          write_flag := FALSE;
  385.          end if;
  386.  
  387.         --- check for address setup with write end, i.e., tAW
  388.         if (NOW - tAW_chk >= tAW) then
  389.             --- tAW OK, do nothing
  390.         else
  391.            if (TimingInfo) then
  392.              assert FALSE
  393.               report "Address setup tAW violation for Upper Byte Write";
  394.            end if;
  395.           write_flag := FALSE;
  396.         end if;
  397.  
  398.         --- check for byte setup with write end, i.e., tBW
  399.         if (NOW - tBBW_chk >= tBW) then
  400.             --- tBW OK, do nothing
  401.         else
  402.            if (TimingInfo) then
  403.              assert FALSE
  404.               report "Upper Byte setup tBW violation";
  405.            end if;
  406.  
  407.         write_flag := FALSE;
  408.         end if;
  409.  
  410.         --- check for data setup with write end, i.e., tSD
  411.         if (NOW - tSD_chk >= tSD_dataskew or NOW - tSD_chk <= 0.1 ns or NOW = 0 ns) then
  412.             --- tSD OK, do nothing
  413.         else
  414.            if (TimingInfo) then
  415.               assert FALSE
  416.               report "Data setup tSD violation for Upper Byte Write";
  417.            end if;
  418.  
  419.           write_flag := FALSE;
  420.         end if;
  421.  
  422.          --- perform WRITE operation if no violations
  423.  
  424.          if (write_flag = TRUE) then
  425.            mem_array(conv_integer1(address_internal))(15 downto 8) <= data_skew(15 downto 8);
  426.           if (BLE_b = '0') then
  427.                 mem_array(conv_integer1(address_internal))(7 downto 0) <= data_skew(7 downto 0);
  428.           end if;
  429.  
  430.          end if;
  431.  
  432.          --- Reset timing variables
  433.          tAW_chk := A'last_event;
  434.         tBBW_chk := NOW;
  435.         write_flag := TRUE;
  436.  
  437.      end if;
  438.  
  439.   end if;
  440.   --- END OF WRITE
  441.  
  442.   if (data_skew'event and read_enable /= '1') then
  443.         tSD_chk := NOW;
  444.   end if;
  445.  
  446.   --- START of READ
  447.  
  448.   --- Tri-state the data bus if CE or OE disabled
  449.   if (read_enable = '0' and read_enable'event) then
  450.     if (OE_b'last_event >= CE_b'last_event) then
  451.         DQ <=(others=>'Z') after tHZCE;
  452.     elsif (CE_b'last_event > OE_b'last_event) then
  453.         DQ <=(others=>'Z') after tHZOE;
  454.     end if;
  455.   end if;
  456.  
  457.   --- Address-controlled READ operation
  458.   if (A'event) then
  459.     if (A'last_event = CE_b'last_event and CE_b = '1') then
  460.        DQ <=(others=>'Z') after tHZCE;
  461.     end if;
  462.  
  463.     if (NOW - tRC_chk >= tRC or NOW - tRC_chk <= 0.1 ns or tRC_chk = 0 ns) then
  464.       --- tRC OK, do nothing
  465.     else
  466.  
  467.        if (TimingInfo) then
  468.            assert FALSE
  469.            report "Read Cycle time tRC violation";
  470.         end if;
  471.  
  472.     end if;
  473.  
  474.     if (read_enable = '1') then
  475.  
  476.        if (BLE_b = '0') then
  477.            DQ (7 downto 0) <= mem_array (conv_integer1(A))(7 downto 0) after tAA;
  478.        end if;
  479.  
  480.        if (BHE_b = '0') then
  481.            DQ (15 downto 8) <= mem_array (conv_integer1(A))(15 downto 8) after tAA;
  482.        end if;
  483.  
  484.       tRC_chk := NOW;
  485.  
  486.     end if;
  487.  
  488.     if (write_enable = '1') then
  489.        --- do nothing
  490.     end if;
  491.  
  492.   end if;
  493.  
  494.   if (read_enable = '0' and read_enable'event) then
  495.      DQ <=(others=>'Z') after tHZCE;
  496.      if (NOW - tRC_chk >= tRC or tRC_chk = 0 ns or A'last_event = read_enable'last_event) then
  497.      --- tRC_chk needs to be reset when read ends
  498.         tRC_CHK := 0 ns;
  499.      else
  500.          if (TimingInfo) then
  501.             assert FALSE
  502.              report "Read Cycle time tRC violation";
  503.           end if;
  504.           tRC_CHK := 0 ns;
  505.      end if;
  506.  
  507.    end if;
  508.  
  509.    --- READ operation triggered by CE/OE/BHE/BLE
  510.    if (read_enable = '1' and read_enable'event) then
  511.  
  512.       tRC_chk := NOW;
  513.  
  514.        --- CE triggered READ
  515.        if (CE_b'last_event = read_enable'last_event ) then --  changed rev2
  516.  
  517.            if (BLE_b = '0') then
  518.                  DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after tACE;
  519.            end if;
  520.  
  521.            if (BHE_b = '0') then
  522.                  DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after tACE;
  523.            end if;
  524.  
  525.        end if;
  526.  
  527.  
  528.         --- OE triggered READ
  529.        if (OE_b'last_event = read_enable'last_event) then
  530.  
  531.            -- if address or CE changes before OE such that tAA/tACE > tDOE
  532.            if (CE_b'last_event < tACE - tDOE and A'last_event < tAA - tDOE) then
  533.  
  534.                if (A'last_event < CE_b'last_event) then
  535.  
  536.                   accesstime:=tAA-A'last_event;
  537.                   if (BLE_b = '0') then
  538.                        DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  539.                   end if;
  540.  
  541.                   if (BHE_b = '0') then
  542.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  543.                   end if;
  544.  
  545.                else
  546.                   accesstime:=tACE-CE_b'last_event;
  547.                   if (BLE_b = '0') then
  548.                        DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  549.                   end if;
  550.  
  551.                   if (BHE_b = '0') then
  552.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  553.                   end if;
  554.               end if;
  555.  
  556.            -- if address changes before OE such that tAA > tDOE
  557.            elsif (A'last_event < tAA - tDOE) then
  558.  
  559.                   accesstime:=tAA-A'last_event;
  560.                   if (BLE_b = '0') then
  561.                        DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  562.                   end if;
  563.  
  564.                   if (BHE_b = '0') then
  565.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  566.                   end if;
  567.  
  568.            -- if CE changes before OE such that tACE > tDOE
  569.            elsif (CE_b'last_event < tACE - tDOE) then
  570.  
  571.                   accesstime:=tACE-CE_b'last_event;
  572.                   if (BLE_b = '0') then
  573.                        DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  574.                   end if;
  575.  
  576.                   if (BHE_b = '0') then
  577.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  578.                   end if;
  579.  
  580.            -- if OE changes such that tDOE > tAA/tACE
  581.            else
  582.                    if (BLE_b = '0') then
  583.                        DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after tDOE;
  584.                    end if;
  585.  
  586.                    if (BHE_b = '0') then
  587.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after tDOE;
  588.                    end if;
  589.  
  590.            end if;
  591.  
  592.        end if;
  593.        --- END of OE triggered READ
  594.  
  595.         --- BLE/BHE triggered READ
  596.        if (BLE_b'last_event = read_enable'last_event or BHE_b'last_event = read_enable'last_event) then
  597.  
  598.            -- if address or CE changes before BHE/BLE such that tAA/tACE > tDBE
  599.            if (CE_b'last_event < tACE - tDBE and A'last_event < tAA - tDBE) then
  600.  
  601.                if (A'last_event < BLE_b'last_event) then
  602.                   accesstime:=tAA-A'last_event;
  603.  
  604.                   if (BLE_b = '0') then
  605.                      DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  606.                   end if;
  607.  
  608.                   if (BHE_b = '0') then
  609.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  610.                   end if;
  611.  
  612.                else
  613.                   accesstime:=tACE-CE_b'last_event;
  614.  
  615.                   if (BLE_b = '0') then
  616.                      DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  617.                   end if;
  618.  
  619.                   if (BHE_b = '0') then
  620.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  621.                   end if;
  622.               end if;
  623.  
  624.            -- if address changes before BHE/BLE such that tAA > tDBE
  625.            elsif (A'last_event < tAA - tDBE) then
  626.                   accesstime:=tAA-A'last_event;
  627.  
  628.                   if (BLE_b = '0') then
  629.                      DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  630.                   end if;
  631.  
  632.                   if (BHE_b = '0') then
  633.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  634.                   end if;
  635.  
  636.            -- if CE changes before BHE/BLE such that tACE > tDBE
  637.            elsif (CE_b'last_event < tACE - tDBE) then
  638.                   accesstime:=tACE-CE_b'last_event;
  639.  
  640.                   if (BLE_b = '0') then
  641.                      DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after accesstime;
  642.                   end if;
  643.  
  644.                   if (BHE_b = '0') then
  645.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after accesstime;
  646.                   end if;
  647.  
  648.            -- if BHE/BLE changes such that tDBE > tAA/tACE
  649.            else
  650.                    if (BLE_b = '0') then
  651.                        DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after tDBE;
  652.                    end if;
  653.  
  654.                    if (BHE_b = '0') then
  655.                        DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after tDBE;
  656.                    end if;
  657.  
  658.            end if;
  659.  
  660.        end if;
  661.        -- END of BHE/BLE controlled READ
  662.  
  663.        if (WE_b'last_event = read_enable'last_event) then
  664.  
  665.            if (BLE_b = '0') then
  666.               DQ (7 downto 0)<= mem_array (conv_integer1(A)) (7 downto 0) after tACE;
  667.            end if;
  668.  
  669.            if (BHE_b = '0') then
  670.               DQ (15 downto 8)<= mem_array (conv_integer1(A)) (15 downto 8) after tACE;
  671.            end if;
  672.  
  673.        end if;
  674.  
  675.      end if;
  676.      --- END OF CE/OE/BHE/BLE controlled READ
  677.  
  678.     --- If either BHE or BLE toggle during read mode
  679.     if (BLE_b'event and BLE_b = '0' and read_enable = '1' and not(read_enable'event)) then
  680.        DQ (7 downto 0) <= mem_array (conv_integer1(A)) (7 downto 0) after tDBE;
  681.     end if;
  682.  
  683.     if (BHE_b'event and BHE_b = '0' and read_enable = '1' and not(read_enable'event)) then
  684.        DQ (15 downto 8) <= mem_array (conv_integer1(A)) (15 downto 8) after tDBE;
  685.     end if;
  686.  
  687.     --- tri-state bus depending on BHE/BLE
  688.     if (BLE_b'event and BLE_b = '1') then
  689.         DQ (7 downto 0) <= (others=>'Z') after tHZBE;
  690.     end if;
  691.  
  692.     if (BHE_b'event and BHE_b = '1') then
  693.         DQ (15 downto 8) <=(others=>'Z') after tHZBE;
  694.     end if;
  695.  
  696. end if;
  697.  
  698.     wait on write_enable, A, read_enable, DQ, BLE_b, BHE_b, data_skew, boot;
  699.  
  700. end process;
  701. end behave_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement