ram.txt

来自「设计一个存储容量为28×8的RAM」· 文本 代码 · 共 73 行

TXT
73
字号
CS为RAM的片选信号,WR为RAM的写信号,RD为RAM读信号,ADR:八位地址信号,Din:八位数据输入线,Dout为八位数据输出线。

library IEEE;

use IEEE.std_logic_1164.all;

use ieee.std_logic_unsigned.all;
entity RAM is

    port (WR: in STD_LOGIC;

                 RD: in STD_LOGIC;

                 ADR: in STD_LOGIC_VECTOR (7 downto 0);

                 CS: in STD_LOGIC;

                 Din: in STD_LOGIC_VECTOR (7 downto 0);

                 Dout: out STD_LOGIC_VECTOR (7 downto 0)

               );

end RAM;
	

图例6   RAM实体

architecture RAM_arch of RAM is

   subtype word is std_logic_vector(7 downto 0);

   type memory is array (0 to 15)of word;

   signal adr_in:integer range 0 to 15;

   signal sram:memory;

  begin

       adr_in<=conv_integer(ADR);

      process(wr)begin

         if(wr'event and wr='1')then

           if(cs='1'and wr='1')then

              sram(adr_in)<=din after 2 ns;

           end if;

         end if;

      end process;

      process(rd,cs)begin

         if(rd='0'and cs='1')then

           dout<=sram(adr_in)after 3 ns;

         else

           dout<="ZZZZZZZZ"after 4 ns;

         end if;

      end process;

end RAM_arch;

         

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?