OpenCores
URL https://opencores.org/ocsvn/apbi2c/apbi2c/trunk

Subversion Repositories apbi2c

[/] [apbi2c/] [trunk/] [rtl/] [fifo.v] - Diff between revs 18 and 24

Show entire file | Details | Blame | View Log

Rev 18 Rev 24
Line 24... Line 24...
////
////
////
////
////
////
////
////
//// Author(s): - Felipe Fernandes Da Costa, fefe2560@gmail.com
//// Author(s): - Felipe Fernandes Da Costa, fefe2560@gmail.com
////              Ronal Dario Celaya ,rcelaya.dario@gmail.com
 
////
////
///////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////// 
////
////
////
////
//// Copyright (C) 2009 Authors and OPENCORES.ORG
//// Copyright (C) 2009 Authors and OPENCORES.ORG
Line 86... Line 85...
        output f_full, f_empty,
        output f_full, f_empty,
        output [DWIDTH-1:0] data_out
        output [DWIDTH-1:0] data_out
);
);
 
 
 
 
//      reg [DWIDTH-1:0] mem [0:2**AWIDTH-1];
        reg [DWIDTH-1:0] mem [0:2**AWIDTH-1];
        parameter integer DEPTH = 1 << AWIDTH;
        //parameter integer DEPTH = 1 << AWIDTH;
        wire [DWIDTH-1:0] data_ram_out;
        //wire [DWIDTH-1:0] data_ram_out;
        wire wr_en_ram;
        //wire wr_en_ram; 
        wire rd_en_ram;
        //wire rd_en_ram;       
 
 
        reg [AWIDTH-1:0] wr_ptr;
        reg [AWIDTH-1:0] wr_ptr;
        reg [AWIDTH-1:0] rd_ptr;
        reg [AWIDTH-1:0] rd_ptr;
        reg [AWIDTH:0] counter;
        reg [AWIDTH-1:0] counter;
 
 
 
 
 
        wire [AWIDTH-1:0] wr;
 
        wire [AWIDTH-1:0] rd;
 
        wire [AWIDTH-1:0] w_counter;
//Write pointer
//Write pointer
        always@(posedge clock)
        always@(posedge clock)
        begin
        begin
                if (reset)
                if (reset)
                begin
                begin
                        wr_ptr <= {(AWIDTH){1'b0}};
                        wr_ptr <= {(AWIDTH){1'b0}};
                end
                end
                else if (wr_en && !f_full)
                else if (wr_en && !f_full)
                begin
                begin
                        wr_ptr <= wr_ptr + 1'b1;
                        mem[wr_ptr]<=data_in;
 
                        wr_ptr <= wr;
                end
                end
        end
        end
 
 
//Read pointer
//Read pointer
        always@(posedge clock)
        always@(posedge clock)
Line 119... Line 121...
                begin
                begin
                        rd_ptr <= {(AWIDTH){1'b0}};
                        rd_ptr <= {(AWIDTH){1'b0}};
                end
                end
                else if (rd_en && !f_empty)
                else if (rd_en && !f_empty)
                begin
                begin
                        rd_ptr <= rd_ptr + 1'b1;
                        rd_ptr <= rd;
                end
                end
        end
        end
 
 
//Counter
//Counter
        always@(posedge clock)
        always@(posedge clock)
        begin
        begin
                if (reset)
                if (reset)
                begin
                begin
                        counter <= {(AWIDTH+1){1'b0}};
                        counter <= {(AWIDTH){1'b0}};
                end
                end
                else
                else
                begin
                begin
                        if (rd_en && !f_empty && !wr_en)
                        if (rd_en && !f_empty && !wr_en)
                        begin
                        begin
                                counter <= counter - 1'b1;
                                counter <= w_counter;
                        end
                        end
                        else if (wr_en && !f_full && !rd_en)
                        else if (wr_en && !f_full && !rd_en)
                        begin
                        begin
                                counter <= counter + 1'b1;
                                counter <= w_counter;
                        end
                        end
                end
                end
        end
        end
 
 
        assign f_full = (counter == DEPTH- 1) ;
        assign f_full = (counter == 4'd15)?1'b1:1'b0;//DEPTH- 1) ; 
        assign f_empty = (counter == {AWIDTH{1'b0}});
        assign f_empty = (counter == 4'd0)?1'b1:1'b0;//{AWIDTH{1'b0}});
        assign wr_en_ram = wr_en;
        assign wr = (wr_en && !f_full)?wr_ptr + 4'd1:wr_ptr + 4'd0;
        assign rd_en_ram = rd_en;
        assign rd = (rd_en && !f_empty)?rd_ptr+ 4'd1:rd_ptr+ 4'd0;
        assign data_out = data_ram_out;
        assign w_counter = (rd_en && !f_empty && !wr_en)? counter - 4'd1:
 
                           (wr_en && !f_full && !rd_en)? counter + 4'd1:
dp_ram #(DWIDTH, AWIDTH)
                            w_counter + 4'd0;
RAM_1   (
        //assign wr_en_ram = wr_en;
                .clock(clock),
        //assign rd_en_ram = rd_en;
                .reset(reset),
        assign data_out = mem[rd_ptr];//data_ram_out;
                .wr_en(wr_en_ram),
/*
                .rd_en(rd_en_ram),
dp_ram #(DWIDTH, AWIDTH)
                .data_in(data_in),
RAM_1   (
                .wr_addr(wr_ptr),
                .clock(clock),
                .data_out(data_ram_out),
                .reset(reset),
                .rd_addr(rd_ptr)
                .wr_en(wr_en_ram),
        );
                .rd_en(rd_en_ram),
 
                .data_in(data_in),
 
                .wr_addr(wr_ptr),
 
                .data_out(data_ram_out),
 
                .rd_addr(rd_ptr)
 
        );
 
*/
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.