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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [core/] [fifo_primitive.vhd] - Diff between revs 2 and 3

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 2 Rev 3
------------------------------------------------------------------------------------ 
----------------------------------------------------------------------  
--                      
----  fifo_primitive                                              ---- 
-- Geoffrey Ottoy - DraMCo research group
----                                                              ---- 
--
----  This file is part of the                                    ----
-- Module Name: adder_n.vhd / entity adder_n
----    Modular Simultaneous Exponentiation Core project          ---- 
-- 
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
-- Last Modified:       04/04/2012 
----                                                              ---- 
-- 
----  Description                                                 ---- 
-- Description:         512x32-bit fifo
----    512 x 32 bit fifo                                         ----
--
----                                                              ---- 
--
----  Dependencies:                                               ----
-- Dependencies:        FIFO18E1 primitive
----    - FIFO18E1 (xilinx primitive)                             ----
--
----                                                              ----
-- Revision:
----  Authors:                                                    ----
--      Revision 1.00 - Architecture
----      - Geoffrey Ottoy, DraMCo research group                 ----
--      Revision 0.01 - File Created
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
--
----                                                              ---- 
--
---------------------------------------------------------------------- 
------------------------------------------------------------------------------------
----                                                              ---- 
--
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
-- NOTICE:
----                                                              ---- 
--
---- This source file may be used and distributed without         ---- 
-- Copyright DraMCo research group. 2011. This code may be contain portions patented
---- restriction provided that this copyright statement is not    ---- 
-- by other third parties!
---- removed from the file and that any derivative work contains  ---- 
--
---- the original copyright notice and the associated disclaimer. ---- 
------------------------------------------------------------------------------------
----                                                              ---- 
library IEEE;
---- This source file is free software; you can redistribute it   ---- 
use IEEE.STD_LOGIC_1164.ALL;
---- and/or modify it under the terms of the GNU Lesser General   ---- 
use IEEE.STD_LOGIC_ARITH.ALL;
---- Public License as published by the Free Software Foundation; ---- 
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- either version 2.1 of the License, or (at your option) any   ---- 
 
---- later version.                                               ---- 
 
----                                                              ---- 
 
---- This source is distributed in the hope that it will be       ---- 
 
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
 
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
 
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
 
---- details.                                                     ---- 
 
----                                                              ---- 
 
---- You should have received a copy of the GNU Lesser General    ---- 
 
---- Public License along with this source; if not, download it   ---- 
 
---- from http://www.opencores.org/lgpl.shtml                     ---- 
 
----                                                              ---- 
 
----------------------------------------------------------------------
 
 
 
library ieee;
 
use ieee.std_logic_1164.all;
 
use ieee.std_logic_arith.all;
 
use ieee.std_logic_unsigned.all;
 
 
---- Uncomment the following library declaration if instantiating
-- Xilinx primitives used in this code.
---- any Xilinx primitives in this code.
 
library UNISIM;
library UNISIM;
use UNISIM.VComponents.all;
use UNISIM.VComponents.all;
 
 
 
 
entity fifo_primitive is
entity fifo_primitive is
    Port ( clk : in  STD_LOGIC;
  port (
           din : in  STD_LOGIC_VECTOR (31 downto 0);
    clk    : in  std_logic;
           dout : out  STD_LOGIC_VECTOR (31 downto 0);
    din    : in  std_logic_vector (31 downto 0);
           empty : out  STD_LOGIC;
    dout   : out  std_logic_vector (31 downto 0);
           full : out  STD_LOGIC;
    empty  : out  std_logic;
           push : in  STD_LOGIC;
    full   : out  std_logic;
           pop : in  STD_LOGIC;
    push   : in  std_logic;
                          reset : in STD_LOGIC;
    pop    : in  std_logic;
                          nopop : out STD_LOGIC;
    reset  : in std_logic;
                          nopush : out STD_LOGIC
    nopop  : out std_logic;
 
    nopush : out std_logic
                          );
                          );
end fifo_primitive;
end fifo_primitive;
 
 
 
 
architecture Behavioral of fifo_primitive is
architecture Behavioral of fifo_primitive is
        signal rdcount : std_logic_vector(11 downto 0); -- debugging
        signal rdcount : std_logic_vector(11 downto 0); -- debugging
        signal wrcount : std_logic_vector(11 downto 0); -- debugging
        signal wrcount : std_logic_vector(11 downto 0); -- debugging
 
 
        signal reset_i, pop_i, push_i, empty_i, full_i, wrerr_i, rderr_i : std_logic;
        signal reset_i, pop_i, push_i, empty_i, full_i, wrerr_i, rderr_i : std_logic;
begin
begin
 
 
        empty <= empty_i;
        empty <= empty_i;
        full <= full_i;
        full <= full_i;
 
 
        -- these logical equations need to be extended where necessary
        -- these logical equations need to be extended where necessary
        nopop <= rderr_i or (pop and reset_i);
        nopop <= rderr_i or (pop and reset_i);
        nopush <= wrerr_i or (push and reset_i);
        nopush <= wrerr_i or (push and reset_i);
 
 
        pop_i <= pop and (not reset_i);
        pop_i <= pop and (not reset_i);
        push_i <= push and (not reset_i);
        push_i <= push and (not reset_i);
 
 
        -- makes the reset at least three clk_cycles long
        -- makes the reset at least three clk_cycles long
        RESET_PROC: process (reset, clk)
        RESET_PROC: process (reset, clk)
                variable clk_counter : integer range 0 to 3 := 3;
                variable clk_counter : integer range 0 to 3 := 3;
        begin
        begin
                if reset = '1' then
                if reset = '1' then
                        reset_i <= '1';
                        reset_i <= '1';
                        clk_counter := 3;
                        clk_counter := 3;
                elsif rising_edge(clk) then
                elsif rising_edge(clk) then
                        if clk_counter = 0 then
                        if clk_counter = 0 then
                                clk_counter := 0;
                                clk_counter := 0;
                                reset_i <= '0';
                                reset_i <= '0';
                        else
                        else
                                clk_counter := clk_counter - 1;
                                clk_counter := clk_counter - 1;
                                reset_i <= '1';
                                reset_i <= '1';
                        end if;
                        end if;
                end if;
                end if;
        end process;
        end process;
 
 
   FIFO18E1_inst : FIFO18E1
   FIFO18E1_inst : FIFO18E1
   generic map (
   generic map (
      ALMOST_EMPTY_OFFSET => X"00080",  -- Sets the almost empty threshold
      ALMOST_EMPTY_OFFSET => X"00080",  -- Sets the almost empty threshold
      ALMOST_FULL_OFFSET => X"00080",   -- Sets almost full threshold
      ALMOST_FULL_OFFSET => X"00080",   -- Sets almost full threshold
      DATA_WIDTH => 36,                 -- Sets data width to 4, 9, 18, or 36
      DATA_WIDTH => 36,                 -- Sets data width to 4, 9, 18, or 36
      DO_REG => 1,                      -- Enable output register (0 or 1) Must be 1 if EN_SYN = "FALSE" 
      DO_REG => 1,                      -- Enable output register (0 or 1) Must be 1 if EN_SYN = "FALSE" 
      EN_SYN => TRUE,                   -- Specifies FIFO as dual-clock ("FALSE") or Synchronous ("TRUE")
      EN_SYN => TRUE,                   -- Specifies FIFO as dual-clock ("FALSE") or Synchronous ("TRUE")
      FIFO_MODE => "FIFO18_36",            -- Sets mode to FIFO18 or FIFO18_36
      FIFO_MODE => "FIFO18_36",         -- Sets mode to FIFO18 or FIFO18_36
      FIRST_WORD_FALL_THROUGH => FALSE, -- Sets the FIFO FWFT to "TRUE" or "FALSE" 
      FIRST_WORD_FALL_THROUGH => FALSE, -- Sets the FIFO FWFT to "TRUE" or "FALSE" 
      INIT => X"000000000",             -- Initial values on output port
      INIT => X"000000000",             -- Initial values on output port
      SRVAL => X"000000000"             -- Set/Reset value for output port
      SRVAL => X"000000000"             -- Set/Reset value for output port
   )
   )
   port map (
   port map (
     -- ALMOSTEMPTY => ALMOSTEMPTY, -- 1-bit almost empty output flag
     -- ALMOSTEMPTY => ALMOSTEMPTY, -- 1-bit almost empty output flag
     -- ALMOSTFULL => ALMOSTFULL,   -- 1-bit almost full output flag
     -- ALMOSTFULL => ALMOSTFULL,   -- 1-bit almost full output flag
      DO => dout,                   -- 32-bit data output
      DO => dout,                   -- 32-bit data output
     -- DOP => DOP,                 -- 4-bit parity data output
     -- DOP => DOP,                 -- 4-bit parity data output
      EMPTY => empty_i,             -- 1-bit empty output flag
      EMPTY => empty_i,             -- 1-bit empty output flag
      FULL => full_i,               -- 1-bit full output flag
      FULL => full_i,               -- 1-bit full output flag
      -- WRCOUNT, RDCOUNT: 12-bit (each) FIFO pointers
      -- WRCOUNT, RDCOUNT: 12-bit (each) FIFO pointers
      RDCOUNT => RDCOUNT,         -- 12-bit read count output
      RDCOUNT => RDCOUNT,           -- 12-bit read count output
      WRCOUNT => WRCOUNT,         -- 12-bit write count output
      WRCOUNT => WRCOUNT,           -- 12-bit write count output
      -- WRERR, RDERR: 1-bit (each) FIFO full or empty error
      -- WRERR, RDERR: 1-bit (each) FIFO full or empty error
      RDERR => rderr_i,             -- 1-bit read error output
      RDERR => rderr_i,             -- 1-bit read error output
      WRERR => wrerr_i,             -- 1-bit write error
      WRERR => wrerr_i,             -- 1-bit write error
      DI => din,                   -- 32-bit data input
      DI => din,                    -- 32-bit data input
      DIP => "0000",                 -- 4-bit parity input
      DIP => "0000",                -- 4-bit parity input
      RDEN => pop_i,               -- 1-bit read enable input
      RDEN => pop_i,                -- 1-bit read enable input
      REGCE => '1',             -- 1-bit clock enable input
      REGCE => '1',                 -- 1-bit clock enable input
      RST => reset_i,                 -- 1-bit reset input
      RST => reset_i,               -- 1-bit reset input
      RSTREG => reset_i,           -- 1-bit output register set/reset
      RSTREG => reset_i,            -- 1-bit output register set/reset
      -- WRCLK, RDCLK: 1-bit (each) Clocks
      -- WRCLK, RDCLK: 1-bit (each) Clocks
      RDCLK => clk,             -- 1-bit read clock input
      RDCLK => clk,                 -- 1-bit read clock input
      WRCLK => clk,             -- 1-bit write clock input
      WRCLK => clk,                 -- 1-bit write clock input
      WREN => push_i                -- 1-bit write enable input
      WREN => push_i                -- 1-bit write enable input
   );
   );
 
 
end Behavioral;
end Behavioral;
 
 
 
 
 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.