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] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 JonasDC
----------------------------------------------------------------------  
2
----  fifo_primitive                                              ---- 
3
----                                                              ---- 
4
----  This file is part of the                                    ----
5
----    Modular Simultaneous Exponentiation Core project          ---- 
6
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
7
----                                                              ---- 
8
----  Description                                                 ---- 
9
----    512 x 32 bit fifo                                         ----
10
----                                                              ---- 
11
----  Dependencies:                                               ----
12
----    - FIFO18E1 (xilinx primitive)                             ----
13
----                                                              ----
14
----  Authors:                                                    ----
15
----      - Geoffrey Ottoy, DraMCo research group                 ----
16
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
17
----                                                              ---- 
18
---------------------------------------------------------------------- 
19
----                                                              ---- 
20
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
21
----                                                              ---- 
22
---- This source file may be used and distributed without         ---- 
23
---- restriction provided that this copyright statement is not    ---- 
24
---- removed from the file and that any derivative work contains  ---- 
25
---- the original copyright notice and the associated disclaimer. ---- 
26
----                                                              ---- 
27
---- This source file is free software; you can redistribute it   ---- 
28
---- and/or modify it under the terms of the GNU Lesser General   ---- 
29
---- Public License as published by the Free Software Foundation; ---- 
30
---- either version 2.1 of the License, or (at your option) any   ---- 
31
---- later version.                                               ---- 
32
----                                                              ---- 
33
---- This source is distributed in the hope that it will be       ---- 
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
36
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
37
---- details.                                                     ---- 
38
----                                                              ---- 
39
---- You should have received a copy of the GNU Lesser General    ---- 
40
---- Public License along with this source; if not, download it   ---- 
41
---- from http://www.opencores.org/lgpl.shtml                     ---- 
42
----                                                              ---- 
43
----------------------------------------------------------------------
44 2 JonasDC
 
45 3 JonasDC
library ieee;
46
use ieee.std_logic_1164.all;
47
use ieee.std_logic_arith.all;
48
use ieee.std_logic_unsigned.all;
49
 
50
-- Xilinx primitives used in this code.
51 2 JonasDC
library UNISIM;
52
use UNISIM.VComponents.all;
53
 
54 3 JonasDC
 
55 2 JonasDC
entity fifo_primitive is
56 3 JonasDC
  port (
57
    clk    : in  std_logic;
58
    din    : in  std_logic_vector (31 downto 0);
59
    dout   : out  std_logic_vector (31 downto 0);
60
    empty  : out  std_logic;
61
    full   : out  std_logic;
62
    push   : in  std_logic;
63
    pop    : in  std_logic;
64
    reset  : in std_logic;
65
    nopop  : out std_logic;
66
    nopush : out std_logic
67
  );
68 2 JonasDC
end fifo_primitive;
69
 
70 3 JonasDC
 
71 2 JonasDC
architecture Behavioral of fifo_primitive is
72
        signal rdcount : std_logic_vector(11 downto 0); -- debugging
73
        signal wrcount : std_logic_vector(11 downto 0); -- debugging
74
 
75
        signal reset_i, pop_i, push_i, empty_i, full_i, wrerr_i, rderr_i : std_logic;
76
begin
77
 
78
        empty <= empty_i;
79
        full <= full_i;
80
 
81
        -- these logical equations need to be extended where necessary
82
        nopop <= rderr_i or (pop and reset_i);
83
        nopush <= wrerr_i or (push and reset_i);
84
 
85
        pop_i <= pop and (not reset_i);
86
        push_i <= push and (not reset_i);
87
 
88
        -- makes the reset at least three clk_cycles long
89
        RESET_PROC: process (reset, clk)
90
                variable clk_counter : integer range 0 to 3 := 3;
91
        begin
92
                if reset = '1' then
93
                        reset_i <= '1';
94
                        clk_counter := 3;
95
                elsif rising_edge(clk) then
96
                        if clk_counter = 0 then
97
                                clk_counter := 0;
98
                                reset_i <= '0';
99
                        else
100
                                clk_counter := clk_counter - 1;
101
                                reset_i <= '1';
102
                        end if;
103
                end if;
104
        end process;
105
 
106
   FIFO18E1_inst : FIFO18E1
107
   generic map (
108
      ALMOST_EMPTY_OFFSET => X"00080",  -- Sets the almost empty threshold
109
      ALMOST_FULL_OFFSET => X"00080",   -- Sets almost full threshold
110
      DATA_WIDTH => 36,                 -- Sets data width to 4, 9, 18, or 36
111
      DO_REG => 1,                      -- Enable output register (0 or 1) Must be 1 if EN_SYN = "FALSE" 
112
      EN_SYN => TRUE,                   -- Specifies FIFO as dual-clock ("FALSE") or Synchronous ("TRUE")
113 3 JonasDC
      FIFO_MODE => "FIFO18_36",         -- Sets mode to FIFO18 or FIFO18_36
114 2 JonasDC
      FIRST_WORD_FALL_THROUGH => FALSE, -- Sets the FIFO FWFT to "TRUE" or "FALSE" 
115
      INIT => X"000000000",             -- Initial values on output port
116
      SRVAL => X"000000000"             -- Set/Reset value for output port
117
   )
118
   port map (
119
     -- ALMOSTEMPTY => ALMOSTEMPTY, -- 1-bit almost empty output flag
120
     -- ALMOSTFULL => ALMOSTFULL,   -- 1-bit almost full output flag
121
      DO => dout,                   -- 32-bit data output
122
     -- DOP => DOP,                 -- 4-bit parity data output
123
      EMPTY => empty_i,             -- 1-bit empty output flag
124
      FULL => full_i,               -- 1-bit full output flag
125
      -- WRCOUNT, RDCOUNT: 12-bit (each) FIFO pointers
126 3 JonasDC
      RDCOUNT => RDCOUNT,           -- 12-bit read count output
127
      WRCOUNT => WRCOUNT,           -- 12-bit write count output
128 2 JonasDC
      -- WRERR, RDERR: 1-bit (each) FIFO full or empty error
129
      RDERR => rderr_i,             -- 1-bit read error output
130
      WRERR => wrerr_i,             -- 1-bit write error
131 3 JonasDC
      DI => din,                    -- 32-bit data input
132
      DIP => "0000",                -- 4-bit parity input
133
      RDEN => pop_i,                -- 1-bit read enable input
134
      REGCE => '1',                 -- 1-bit clock enable input
135
      RST => reset_i,               -- 1-bit reset input
136
      RSTREG => reset_i,            -- 1-bit output register set/reset
137 2 JonasDC
      -- WRCLK, RDCLK: 1-bit (each) Clocks
138 3 JonasDC
      RDCLK => clk,                 -- 1-bit read clock input
139
      WRCLK => clk,                 -- 1-bit write clock input
140 2 JonasDC
      WREN => push_i                -- 1-bit write enable input
141
   );
142
 
143
end Behavioral;

powered by: WebSVN 2.1.0

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