在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2167|回复: 5

[求助] 关于FIFO的问题

[复制链接]
发表于 2011-5-17 15:58:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
我想用verilog构造一个fifo,由两个频率不同的独立时钟控分别制输入输出。可以实现吗?可以用两个状态机来控制FIFO吗?
发表于 2011-5-17 18:28:25 | 显示全部楼层
可以在google上搜一下,有很多介绍
 楼主| 发表于 2011-5-17 18:48:54 | 显示全部楼层
本帖最后由 yuwu131 于 2011-5-17 18:55 编辑

回复 2# bobzeng


我写了一个不知道有没有问题

module fifo_i (input [15:0]data_in,input clk_in,clk_o,rst,rd,wr,fifo_i,reset,
             output empty,full,output reg [4:0]fifo_cnt,output reg [15:0]data_out);
    reg [15:0] fifo_ram[0:15] ;
    reg [2:0]  rd_ptr,wr_ptr;                               //read and write point
    assign empty=(fifo_cnt==0);
    assign full= (fifo_cnt==15);
    always @( posedge clk_i ) begin:write
        if(fifo_i)begin
            if(wr &&!full)
                fifo_ram[wr_ptr] <= data_in;
                /*    else if(wr && rd)
                fifo_ram[wr_ptr] <= data_in;*/
            end
    end
    always @ (posedge clk_o )begin:read
        if(fifo_i)begin
            if (rd&&!empty)
                data_out <= fifo_ram[rd_ptr];
                    else if (wr&&rd)                          // always deal with the data read out fifo first
                data_out <= fifo_ram[rd_ptr];         
        end
    end
    always @ (posedge clk_i )begin:pointer1
        if (fifo_i)begin
            if (rst)begin
                wr_ptr<=0;
               
            end
            else begin
                wr_ptr<=((fifo_i&&(wr&&!full)/*||(wr&&rd)*/))?wr_ptr+1:wr_ptr;   
            end
        end
    end
   
        always @ (posedge clk_o )begin:pointer2
        if (fifo_i)begin
            if (rst)begin
                rd_ptr<=0;
            end
            else begin
                rd_ptr<=((fifo_i&&(rd&&!empty))||(fifo_i&&(wr&&rd)))?rd_ptr+1:rd_ptr;
            end
        end
    end
   
    always @ (posedge clk_i )begin:count1
        if (fifo_i)begin
            if (rst)
            fifo_cnt <=4'b0000;
            else begin
            case({wr,rd})
            2'b00:fifo_cnt<=fifo_cnt;
        /*    2'b01:fifo_cnt<=(fifo_cnt==0)?0:fifo_cnt-1;    */
            2'b10:fifo_cnt<=(fifo_cnt==15)?15:fifo_cnt+1;
        /*    2'b11:fifo_cnt<=fifo_cnt-1;                    */
            default:fifo_cnt<=fifo_cnt;
            endcase
            end
            end
          end
        always @ (posedge clk_o)begin:count2
        if (fifo_i)begin
            if (rst)
            fifo_cnt <=4'b0000;
            else begin
            case({wr,rd})
            2'b00:fifo_cnt<=fifo_cnt;
            2'b01:fifo_cnt<=(fifo_cnt==0)?0:fifo_cnt-1;
        /*    2'b01:fifo_cnt<=(fifo_cnt==15)?15:fifo_cnt+1;   */
            2'b11:fifo_cnt<=fifo_cnt-1;
            default:fifo_cnt<=fifo_cnt;
            endcase
            end
            end
        end
endmodule
发表于 2011-5-17 18:54:31 | 显示全部楼层
就是异步fifo,很多资料的
发表于 2011-5-17 21:49:09 | 显示全部楼层
当然可以 FIFO就是用在跨时钟域的地方
发表于 2011-5-17 23:45:58 | 显示全部楼层
一个异步FIFO的实现 怎么描述的怪怪的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-11 16:37 , Processed in 0.042217 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表