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

Subversion Repositories wb_fifo

[/] [wb_fifo/] [trunk/] [model/] [vhdl/] [fifo.vhdl] - Diff between revs 6 and 7

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 6 Rev 7
Line 77... Line 77...
                        when the FIFO is empty.
                        when the FIFO is empty.
        */
        */
        signal i_writeRequest,i_readRequest:i_transactor.t_bfm;
        signal i_writeRequest,i_readRequest:i_transactor.t_bfm;
        signal i_full,i_empty:boolean;
        signal i_full,i_empty:boolean;
        signal write,read:boolean;
        signal write,read:boolean;
 
 
 
        signal writeRequested, readRequested: boolean;
begin
begin
 
        /* Registers and pipelines. */
 
        /* TODO recheck pipelining. */
 
        process(clk) is begin
 
                if falling_edge(clk) then
 
                        /* TODO add buffers for pipelined request signals,
 
                                i.e., add a flip-flop and a buffer.
 
                        */
 
                        i_writeRequest <= fifoInterface.writeRequest after 1 ps;
 
                        i_readRequest <= fifoInterface.readRequest after 1 ps;
 
 
 
                        i_full <= fifoCtrl.full;
 
                        i_empty <= fifoCtrl.empty;
 
                end if;
 
        end process;
 
 
 
        /* Synchronous FIFO. */
        controller: process(reset,clk) is begin
        controller: process(reset,clk) is begin
                if reset then
                --if reset then
                        fifoInterface.readResponse.message<=(others=>'Z');
                --      fifoInterface.readResponse.message<=(others=>'Z');
                        fifoInterface.readResponse.trigger<=false;
                --      fifoInterface.readResponse.trigger<=false;
                elsif falling_edge(clk) then
                if falling_edge(clk) then
                        /* Default assignments. */
                        /* Default assignments. */
                        fifoInterface.readResponse.trigger<=false;
                        fifoInterface.readResponse.trigger<=false;
                        fifoInterface.writeResponse.trigger<=false;
                        fifoInterface.writeResponse.trigger<=false;
 
 
                        /* Write request.
                        /* Write request.
                                Safety control: allow writing only when FIFO is not full.
                                Safety control: allow writing only when FIFO is not full.
                        */
                        */
                        --if i_pctFilled<d"100" and (fifoInterface.writeRequest.trigger xor i_writeRequest.trigger) then
                        --if i_pctFilled<d"100" and (fifoInterface.writeRequest.trigger xor i_writeRequest.trigger) then
                        if not i_full and (fifoInterface.writeRequest.trigger xor i_writeRequest.trigger) then
                        --if not i_full and (fifoInterface.writeRequest.trigger xor i_writeRequest.trigger) then                -- TODO change to write
 
                        if not i_full and write then
                                fifoInterface.writeResponse.trigger<=true;
                                fifoInterface.writeResponse.trigger<=true;
                                memory(ptr)<=fifoInterface.writeRequest.message;
                                memory(ptr)<=fifoInterface.writeRequest.message;
                        end if;
                        end if;
 
 
                        /* Read request.
                        /* Read request.
                                Safety control: allow reading only when FIFO is not empty.
                                Safety control: allow reading only when FIFO is not empty.
                        */
                        */
                        if not i_empty and (fifoInterface.readRequest.trigger xor i_readRequest.trigger) then
                        --if not i_empty and (fifoInterface.readRequest.trigger xor i_readRequest.trigger) then         -- TODO change to read
 
                        if not i_empty and read then
                                fifoInterface.readResponse.trigger<=true;
                                fifoInterface.readResponse.trigger<=true;
                                fifoInterface.readResponse.message<=memory(ptr);
                                fifoInterface.readResponse.message<=memory(ptr);
                        end if;
                        end if;
 
 
 
                        /* Synchronous reset. */
 
                        if reset then
 
                                fifoInterface.readResponse.message<=(others=>'Z');
 
                                fifoInterface.readResponse.trigger<=false;
 
                        end if;
                end if;
                end if;
        end process controller;
        end process controller;
 
 
        write<=fifoInterface.writeRequest.trigger xor i_writeRequest.trigger;
        write<=fifoInterface.writeRequest.trigger xor i_writeRequest.trigger;
        read<=fifoInterface.readRequest.trigger xor i_readRequest.trigger;
        read<=fifoInterface.readRequest.trigger xor i_readRequest.trigger;
 
 
 
        /* Request indicator. Derived from fifoInterface.writeRequest.trigger
 
                and fifoInterface.readRequest.trigger.
 
                Asserts when there are incoming requests.
 
        */
 
        process(clk) is begin
 
                if falling_edge(clk) then
 
                        writeRequested <= fifoInterface.writeRequest.trigger xor i_writeRequest.trigger;
 
                        readRequested <= fifoInterface.readRequest.trigger xor i_readRequest.trigger;
 
                end if;
 
        end process;
 
 
        addrPointer: process(reset,clk) is begin
        addrPointer: process(reset,clk) is begin
                if reset then ptr<=0;
                if reset then ptr<=0;
                elsif falling_edge(clk) then
                elsif falling_edge(clk) then
                        /* Increment or decrement the address pointer only when write or read is HIGH;
                        /* Increment or decrement the address pointer only when write or read is HIGH;
                                do nothing when both are HIGH or when both are LOW.
                                do nothing when both are HIGH or when both are LOW.
Line 126... Line 163...
                                end if;
                                end if;
                        end if;
                        end if;
                end if;
                end if;
        end process addrPointer;
        end process addrPointer;
 
 
        /* Registers and pipelines. */
 
        /* TODO recheck pipelining. */
 
        process(clk) is begin
 
                if falling_edge(clk) then
 
                        i_writeRequest <= fifoInterface.writeRequest;
 
                        i_readRequest <= fifoInterface.readRequest;
 
                        i_full <= fifoCtrl.full;
 
                        i_empty <= fifoCtrl.empty;
 
                end if;
 
        end process;
 
 
 
        fifoCtrl.pctFilled<=to_unsigned(ptr*100/(memoryDepth-1), fifoCtrl.pctFilled'length);
        fifoCtrl.pctFilled<=to_unsigned(ptr*100/(memoryDepth-1), fifoCtrl.pctFilled'length);
 
 
        process(clk) is begin
        process(clk) is begin
                if rising_edge(clk) then
                if rising_edge(clk) then
                        fifoCtrl.nearFull<=true when fifoCtrl.pctFilled>=d"75" and fifoCtrl.pctFilled<d"100" else false;
                        fifoCtrl.nearFull<=true when fifoCtrl.pctFilled>=d"75" and fifoCtrl.pctFilled<d"100" else false;

powered by: WebSVN 2.1.0

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