专栏中心

EEPW首页 > 专栏 > 8*8位的fifo的vhdl源程序

8*8位的fifo的vhdl源程序

发布人:0750long 时间:2009-07-23 来源:工程师 发布文章
8*8位的fifo的vhdl源程序

 

library ieee;
      use ieee.std_logic_1164.all;
      entity fifo is
       generic( w: integer :=8;  k: integer :=8 );
       port (clk,reset,wr,rd :in std_logic;
              din :in std_logic_vector( k-1 downto 0);
             dout :out std_logic_vector( k-1 downto 0);
             full,empty :out std_logic);
      end fifo;
      architecture fifo_arch of fifo is
        type memory is array (0 to w-1) of std_logic_vector( k-1 downto 0);
        signal ram:memory;
        signal wp,rp: integer range 0 to w-1;
        signal in_full,in_empty:std_logic;
      begin
      process(clk)
        begin
        if rising_edge(clk) then
           if (wr=''0'' and in_full=''0'') then
               ram(wp)<=din;
           end if;
        end if;
      end process;
      process(clk,reset)
        begin
        if (reset=''1'') then
           wp<=0;
        elsif rising_edge(clk) then
           if (wr=''0'' and in_full=''0'') then
               if(wp=w-1) then
                  wp<=0;
                 else wp<=wp+1;
                end if;
           end if;
         end if;
      end process;
      process(clk,reset)
        begin
        if (reset=''1'') then
           rp<=w-1;
        elsif rising_edge(clk) then
           if (rd=''0'' and in_empty=''0'') then
               if(rp=w-1) then

rp<=0;
                 else rp<=rp+1;
                end if;
           end if;
         end if;
      end process;
      process(clk,reset)
        begin
        if (reset=''1'') then
           in_empty<=''1'';
          elsif rising_edge(clk) then
           if ((rp=wp-2 or (rp=w-1 and wp="1") or (rp=w-2 and wp="0")) and (rd=''0''
      and wr=''1''))then
                 in_empty<=''1'';
             elsif (in_empty=''1'' and wr=''0'') then
                 in_empty<=''0'';
           end if;
         end if;
      end process;
      process(clk,reset)
        begin
         if (reset=''1'') then
            in_full<=''0'';
          elsif  rising_edge(clk) then
            if (rp=wp and wr=''0'' and rd=''1'') then
               in_full<=''1'';
             elsif (in_full=''1'' and rd=''0'') then
               in_full<=''0'';
             end if;
          end if;
      end process;
      full<=in_full;
      empty<=in_empty;
      dout<=ram(rp) when rd=''0'' ;
      end fifo_arch;

专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词:

相关推荐

X-fest 2012 ADI公司技术展示预览

视频 2012-06-18

HDMI信号间隔地线间隔,多少距离打地孔?

EDA/PCB 2025-02-27

三星下一代手机OLED面板来了:同功耗亮度提升1.5倍

在您的下一个设计中使用实验室电路

视频 2012-06-18

全步、半步和微步 步进电机这三种控制模式哪种好?

示波器探头的作用及工作原理

ADI在线研讨会:您不知道的关于DAC的五件事

视频 2012-06-18

恒压和恒流 LED驱动器是怎么切换的?

MWC25先睹|5分钟速览:MWC2025参展厂商“关键”信息与亮点

手机与无线通信 2025-02-27

ATA-304C功率放大器在半波整流电化学方法去除低浓度含铅废水中铅离子中的应用

硬件工程师必看,一大波电子产品高清结构爆炸图~太漂亮了!

无线通信是怎样传递信息的?技术原理及常用类型科普

传V社开发高阶VR头显

消费电子 2025-02-27

ADI在线研讨会:差分驱动ADC的最新发展:第一部分

视频 2012-06-18

为何不马上使用MEMS麦克风呢?

视频 2012-06-18
更多 培训课堂
更多 焦点
更多 视频

技术专区