⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ram.vhd

📁 此程序为dsp原码程序
💻 VHD
字号:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
ENTITY ram IS
PORT(clk,wr,rd,rst:in std_logic;
     a:IN STD_LOGIC_VECTOR(1 DOWNTO 0);
     d:IN STD_LOGIC_VECTOR(3 DOWNTO 0);
     q: OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
END;
ARCHITECTURE BEHAV OF ram IS
signal data0,data1,data2,data3:STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
process(clk,rst)
begin
  if rst='1' then 
      data0<=(others=>'0');
      data1<=(others=>'0');
      data2<=(others=>'0');
      data3<=(others=>'0');
   elsif (clk'event and clk='1') then
       if ((wr='1') and (rd='0'))  then
          case a is 
            when "00"=>data0<=d;
            when "01"=>data1<=d;
            when "10"=>data2<=d;
            when "11"=>data3<=d;
            when others=>null; 
          end case;                  
       elsif((wr='0') and (rd='1'))  then
          case a is 
            when "00"=>q<=data0;
            when "01"=>q<=data1;
            when "10"=>q<=data2;
            when "11"=>q<=data3;
            when others=>null; 
          end case;
       end if;
   end if;    
end process;   
END;

⌨️ 快捷键说明

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