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 |
94 |
JonasDC |
push_clk : in std_logic;
|
58 |
|
|
pop_clk : in std_logic;
|
59 |
|
|
din : in std_logic_vector (31 downto 0);
|
60 |
|
|
dout : out std_logic_vector (31 downto 0);
|
61 |
|
|
empty : out std_logic;
|
62 |
|
|
full : out std_logic;
|
63 |
|
|
push : in std_logic;
|
64 |
|
|
pop : in std_logic;
|
65 |
|
|
reset : in std_logic;
|
66 |
|
|
nopop : out std_logic;
|
67 |
|
|
nopush : out std_logic
|
68 |
3 |
JonasDC |
);
|
69 |
2 |
JonasDC |
end fifo_primitive;
|
70 |
|
|
|
71 |
3 |
JonasDC |
|
72 |
2 |
JonasDC |
architecture Behavioral of fifo_primitive is
|
73 |
|
|
signal rdcount : std_logic_vector(11 downto 0); -- debugging
|
74 |
|
|
signal wrcount : std_logic_vector(11 downto 0); -- debugging
|
75 |
|
|
|
76 |
|
|
signal reset_i, pop_i, push_i, empty_i, full_i, wrerr_i, rderr_i : std_logic;
|
77 |
|
|
begin
|
78 |
|
|
|
79 |
|
|
empty <= empty_i;
|
80 |
|
|
full <= full_i;
|
81 |
|
|
|
82 |
|
|
-- these logical equations need to be extended where necessary
|
83 |
|
|
nopop <= rderr_i or (pop and reset_i);
|
84 |
|
|
nopush <= wrerr_i or (push and reset_i);
|
85 |
|
|
|
86 |
|
|
pop_i <= pop and (not reset_i);
|
87 |
|
|
push_i <= push and (not reset_i);
|
88 |
|
|
|
89 |
|
|
-- makes the reset at least three clk_cycles long
|
90 |
94 |
JonasDC |
RESET_PROC: process (reset, push_clk)
|
91 |
2 |
JonasDC |
variable clk_counter : integer range 0 to 3 := 3;
|
92 |
|
|
begin
|
93 |
|
|
if reset = '1' then
|
94 |
|
|
reset_i <= '1';
|
95 |
|
|
clk_counter := 3;
|
96 |
94 |
JonasDC |
elsif rising_edge(push_clk) then
|
97 |
2 |
JonasDC |
if clk_counter = 0 then
|
98 |
|
|
clk_counter := 0;
|
99 |
|
|
reset_i <= '0';
|
100 |
|
|
else
|
101 |
|
|
clk_counter := clk_counter - 1;
|
102 |
|
|
reset_i <= '1';
|
103 |
|
|
end if;
|
104 |
|
|
end if;
|
105 |
|
|
end process;
|
106 |
|
|
|
107 |
|
|
FIFO18E1_inst : FIFO18E1
|
108 |
|
|
generic map (
|
109 |
|
|
ALMOST_EMPTY_OFFSET => X"00080", -- Sets the almost empty threshold
|
110 |
|
|
ALMOST_FULL_OFFSET => X"00080", -- Sets almost full threshold
|
111 |
|
|
DATA_WIDTH => 36, -- Sets data width to 4, 9, 18, or 36
|
112 |
|
|
DO_REG => 1, -- Enable output register (0 or 1) Must be 1 if EN_SYN = "FALSE"
|
113 |
94 |
JonasDC |
EN_SYN => FALSE, -- Specifies FIFO as dual-clock ("FALSE") or Synchronous ("TRUE")
|
114 |
3 |
JonasDC |
FIFO_MODE => "FIFO18_36", -- Sets mode to FIFO18 or FIFO18_36
|
115 |
2 |
JonasDC |
FIRST_WORD_FALL_THROUGH => FALSE, -- Sets the FIFO FWFT to "TRUE" or "FALSE"
|
116 |
|
|
INIT => X"000000000", -- Initial values on output port
|
117 |
|
|
SRVAL => X"000000000" -- Set/Reset value for output port
|
118 |
|
|
)
|
119 |
|
|
port map (
|
120 |
|
|
-- ALMOSTEMPTY => ALMOSTEMPTY, -- 1-bit almost empty output flag
|
121 |
|
|
-- ALMOSTFULL => ALMOSTFULL, -- 1-bit almost full output flag
|
122 |
|
|
DO => dout, -- 32-bit data output
|
123 |
|
|
-- DOP => DOP, -- 4-bit parity data output
|
124 |
|
|
EMPTY => empty_i, -- 1-bit empty output flag
|
125 |
|
|
FULL => full_i, -- 1-bit full output flag
|
126 |
|
|
-- WRCOUNT, RDCOUNT: 12-bit (each) FIFO pointers
|
127 |
3 |
JonasDC |
RDCOUNT => RDCOUNT, -- 12-bit read count output
|
128 |
|
|
WRCOUNT => WRCOUNT, -- 12-bit write count output
|
129 |
2 |
JonasDC |
-- WRERR, RDERR: 1-bit (each) FIFO full or empty error
|
130 |
|
|
RDERR => rderr_i, -- 1-bit read error output
|
131 |
|
|
WRERR => wrerr_i, -- 1-bit write error
|
132 |
3 |
JonasDC |
DI => din, -- 32-bit data input
|
133 |
|
|
DIP => "0000", -- 4-bit parity input
|
134 |
|
|
RDEN => pop_i, -- 1-bit read enable input
|
135 |
|
|
REGCE => '1', -- 1-bit clock enable input
|
136 |
|
|
RST => reset_i, -- 1-bit reset input
|
137 |
|
|
RSTREG => reset_i, -- 1-bit output register set/reset
|
138 |
2 |
JonasDC |
-- WRCLK, RDCLK: 1-bit (each) Clocks
|
139 |
94 |
JonasDC |
RDCLK => pop_clk, -- 1-bit read clock input
|
140 |
|
|
WRCLK => push_clk, -- 1-bit write clock input
|
141 |
2 |
JonasDC |
WREN => push_i -- 1-bit write enable input
|
142 |
|
|
);
|
143 |
|
|
|
144 |
|
|
end Behavioral;
|