1 |
145 |
lanttu |
-------------------------------------------------------------------------------
|
2 |
|
|
-- File : double_fifo_demuxed_write.vhdl
|
3 |
|
|
-- Description : Double_Fifo_Demuxed_Write buffer for hibi v.2 interface
|
4 |
|
|
-- Includes two fifos and a special demultiplexer
|
5 |
|
|
-- so that the writer sees only one fifo. Demultiplexer
|
6 |
|
|
-- directs addr+data to correct fifo (0 = for messages)
|
7 |
|
|
-- Author : Vesa Lahtinen
|
8 |
|
|
-- Date : 08.04.2003
|
9 |
|
|
-- Modified :
|
10 |
|
|
--
|
11 |
|
|
-------------------------------------------------------------------------------
|
12 |
|
|
library ieee;
|
13 |
|
|
use ieee.std_logic_1164.all;
|
14 |
|
|
use ieee.std_logic_arith.all;
|
15 |
|
|
use ieee.std_logic_unsigned.all;
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
entity double_fifo_demuxed_write is
|
20 |
|
|
|
21 |
|
|
generic (
|
22 |
|
|
Data_Width : integer := 0;
|
23 |
|
|
Depth_0 : integer := 0;
|
24 |
|
|
Depth_1 : integer := 0;
|
25 |
|
|
Comm_Width : integer := 0
|
26 |
|
|
);
|
27 |
|
|
port (
|
28 |
|
|
Clk : in std_logic;
|
29 |
|
|
Rst_n : in std_logic;
|
30 |
|
|
|
31 |
|
|
Data_In : in std_logic_vector ( Data_Width-1 downto 0);
|
32 |
|
|
Comm_In : in std_logic_vector ( Comm_Width-1 downto 0);
|
33 |
|
|
Addr_Valid_In : in std_logic;
|
34 |
|
|
Write_Enable_In : in std_logic;
|
35 |
|
|
One_Place_Left_Out : out std_logic;
|
36 |
|
|
Full_Out : out std_logic;
|
37 |
|
|
|
38 |
|
|
Read_Enable_In_0 : in std_logic;
|
39 |
|
|
Data_Out_0 : out std_logic_vector ( Data_Width-1 downto 0);
|
40 |
|
|
Comm_Out_0 : out std_logic_vector ( Comm_Width-1 downto 0);
|
41 |
|
|
Addr_Valid_Out_0 : out std_logic;
|
42 |
|
|
Empty_Out_0 : out std_logic;
|
43 |
|
|
One_Data_Left_Out_0 : out std_logic;
|
44 |
|
|
|
45 |
|
|
Read_Enable_In_1 : in std_logic;
|
46 |
|
|
Data_Out_1 : out std_logic_vector ( Data_Width-1 downto 0);
|
47 |
|
|
Comm_Out_1 : out std_logic_vector ( Comm_Width-1 downto 0);
|
48 |
|
|
Addr_Valid_Out_1 : out std_logic;
|
49 |
|
|
Empty_Out_1 : out std_logic;
|
50 |
|
|
One_Data_Left_Out_1 : out std_logic
|
51 |
|
|
);
|
52 |
|
|
end double_fifo_demuxed_write;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
architecture structural of double_fifo_demuxed_write is
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
component fifo
|
62 |
|
|
generic (
|
63 |
|
|
width : integer := 0;
|
64 |
|
|
depth : integer := 0);
|
65 |
|
|
|
66 |
|
|
port (
|
67 |
|
|
Clk : in std_logic;
|
68 |
|
|
Rst_n : in std_logic;
|
69 |
|
|
Data_In : in std_logic_vector (width-1 downto 0);
|
70 |
|
|
Write_Enable : in std_logic;
|
71 |
|
|
One_Place_Left : out std_logic;
|
72 |
|
|
Full : out std_logic;
|
73 |
|
|
|
74 |
|
|
Read_Enable : in std_logic;
|
75 |
|
|
Data_Out : out std_logic_vector (width-1 downto 0);
|
76 |
|
|
Empty : out std_logic;
|
77 |
|
|
One_Data_Left : out std_logic
|
78 |
|
|
);
|
79 |
|
|
end component; --fifo;
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
component fifo_demux_write
|
83 |
|
|
generic (
|
84 |
|
|
Data_Width : integer := 0;
|
85 |
|
|
Comm_Width : integer := 0);
|
86 |
|
|
|
87 |
|
|
port (
|
88 |
|
|
-- 13.04 Clk : in std_logic;
|
89 |
|
|
-- 13.04 Rst_n : in std_logic;
|
90 |
|
|
Data_In : in std_logic_vector (Data_Width-1 downto 0);
|
91 |
|
|
Addr_Valid_In : in std_logic;
|
92 |
|
|
Comm_In : in std_logic_vector (Comm_Width-1 downto 0);
|
93 |
|
|
WE_In : in std_logic;
|
94 |
|
|
One_Place_Left_Out : out std_logic;
|
95 |
|
|
Full_Out : out std_logic;
|
96 |
|
|
|
97 |
|
|
-- Data/Comm/AV conencted to both fifos
|
98 |
|
|
-- Distinction made with WE!
|
99 |
|
|
Data_Out : out std_logic_vector (Data_Width-1 downto 0);
|
100 |
|
|
Comm_Out : out std_logic_vector (Comm_Width-1 downto 0);
|
101 |
|
|
Addr_Valid_Out : out std_logic;
|
102 |
|
|
WE_0_Out : out std_logic;
|
103 |
|
|
WE_1_Out : out std_logic;
|
104 |
|
|
Full_0_In : in std_logic;
|
105 |
|
|
Full_1_In : in std_logic;
|
106 |
|
|
One_Place_Left_0_In : in std_logic;
|
107 |
|
|
One_Place_Left_1_In : in std_logic
|
108 |
|
|
);
|
109 |
|
|
end component;
|
110 |
|
|
|
111 |
|
|
signal Data_AV_Comm_Out_0 : std_logic_vector ( 1 + Comm_Width + Data_Width-1 downto 0);
|
112 |
|
|
signal Data_AV_Comm_Out_1 : std_logic_vector ( 1 + Comm_Width + Data_Width-1 downto 0);
|
113 |
|
|
|
114 |
|
|
signal Data_AV_Comm_From_Demux : std_logic_vector ( 1 + Comm_Width + Data_Width-1 downto 0);
|
115 |
|
|
|
116 |
|
|
signal Data_Demux_To_fifo : std_logic_vector(Data_Width-1 downto 0);
|
117 |
|
|
signal Comm_Demux_To_fifo : std_logic_vector(Comm_Width-1 downto 0);
|
118 |
|
|
signal Addr_Valid_Demux_To_fifo : std_logic;
|
119 |
|
|
|
120 |
|
|
signal Write_Enable_0 : std_logic;
|
121 |
|
|
signal Full_0 : std_logic;
|
122 |
|
|
signal One_Place_Left_0 : std_logic;
|
123 |
|
|
|
124 |
|
|
signal Write_Enable_1 : std_logic;
|
125 |
|
|
signal Full_1 : std_logic;
|
126 |
|
|
signal One_Place_Left_1 : std_logic;
|
127 |
|
|
|
128 |
|
|
signal Tie_High : std_logic;
|
129 |
|
|
signal Tie_Low : std_logic;
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
begin -- structural
|
133 |
|
|
-- Check generics
|
134 |
|
|
assert (Depth_0 + Depth_1 > 0) report "Both fifo depths zero!" severity warning;
|
135 |
|
|
|
136 |
|
|
-- Concurrent assignments
|
137 |
|
|
Tie_High <= '1';
|
138 |
|
|
Tie_Low <= '0';
|
139 |
|
|
-- Combine fifo inputs
|
140 |
|
|
-- Data_AV_Comm_From_Demux <= Addr_Valid_Demux_To_fifo & Comm_Demux_To_fifo & Data_Demux_To_fifo;
|
141 |
|
|
|
142 |
|
|
-- Splitting the data
|
143 |
|
|
Addr_Valid_Out_0 <= Data_AV_Comm_Out_0(Comm_Width+Data_Width);
|
144 |
|
|
Comm_Out_0 <= Data_AV_Comm_Out_0(Comm_Width+Data_Width-1 downto Data_Width);
|
145 |
|
|
Data_Out_0 <= Data_AV_Comm_Out_0(Data_Width-1 downto 0);
|
146 |
|
|
Addr_Valid_Out_1 <= Data_AV_Comm_Out_1(Comm_Width+Data_Width);
|
147 |
|
|
Comm_Out_1 <= Data_AV_Comm_Out_1(Comm_Width+Data_Width-1 downto Data_Width);
|
148 |
|
|
Data_Out_1 <= Data_AV_Comm_Out_1(Data_Width-1 downto 0);
|
149 |
|
|
|
150 |
|
|
Map_Fifo_0 : if Depth_0 > 0 generate
|
151 |
|
|
Fifo_0 : fifo
|
152 |
|
|
generic map(
|
153 |
|
|
width => 1 + Comm_Width + Data_Width,
|
154 |
|
|
depth => Depth_0
|
155 |
|
|
)
|
156 |
|
|
port map(
|
157 |
|
|
Clk => Clk,
|
158 |
|
|
Rst_n => Rst_n,
|
159 |
|
|
|
160 |
|
|
Data_In => Data_AV_Comm_From_Demux,
|
161 |
|
|
Write_Enable => Write_Enable_0,
|
162 |
|
|
One_Place_Left => One_Place_Left_0,
|
163 |
|
|
Full => Full_0,
|
164 |
|
|
|
165 |
|
|
Read_Enable => Read_Enable_In_0,
|
166 |
|
|
Data_Out => Data_AV_Comm_Out_0,
|
167 |
|
|
Empty => Empty_Out_0,
|
168 |
|
|
One_Data_Left => One_Data_Left_Out_0
|
169 |
|
|
);
|
170 |
|
|
end generate Map_Fifo_0;
|
171 |
|
|
|
172 |
|
|
Not_Map_Fifo_0 : if Depth_0 = 0 generate
|
173 |
|
|
-- Fifo #0 and demux does not exist!
|
174 |
|
|
Data_AV_Comm_Out_0 <= (others => '0');
|
175 |
|
|
Empty_Out_0 <= Tie_High;
|
176 |
|
|
One_Data_Left_Out_0 <= Tie_Low;
|
177 |
|
|
Full_0 <= Tie_High;
|
178 |
|
|
One_Place_Left_0 <= Tie_Low;
|
179 |
|
|
Write_Enable_0 <= Tie_Low;
|
180 |
|
|
|
181 |
|
|
-- Connect the other fifo (#1) straight to the outputs (FSM)
|
182 |
|
|
Write_Enable_1 <= Write_Enable_In;
|
183 |
|
|
One_Place_Left_Out <= One_Place_Left_1;
|
184 |
|
|
Full_Out <= Full_1;
|
185 |
|
|
Data_AV_Comm_From_Demux(Data_Width-1 downto 0) <= Data_In;
|
186 |
|
|
Data_AV_Comm_From_Demux(Comm_Width+Data_Width-1 downto Data_Width) <= Comm_In;
|
187 |
|
|
Data_AV_Comm_From_Demux(Comm_Width+Data_Width) <= Addr_Valid_In;
|
188 |
|
|
|
189 |
|
|
end generate Not_Map_Fifo_0;
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
Map_Fifo_1 : if Depth_1 > 0 generate
|
195 |
|
|
Fifo_1 : fifo
|
196 |
|
|
generic map(
|
197 |
|
|
width => 1 + Comm_Width + Data_Width,
|
198 |
|
|
depth => Depth_1
|
199 |
|
|
)
|
200 |
|
|
port map(
|
201 |
|
|
Clk => Clk,
|
202 |
|
|
Rst_n => Rst_n,
|
203 |
|
|
|
204 |
|
|
Data_In => Data_AV_Comm_From_Demux,
|
205 |
|
|
Write_Enable => Write_Enable_1,
|
206 |
|
|
One_Place_Left => One_Place_Left_1,
|
207 |
|
|
Full => Full_1,
|
208 |
|
|
|
209 |
|
|
Read_Enable => Read_Enable_In_1,
|
210 |
|
|
Data_Out => Data_AV_Comm_Out_1,
|
211 |
|
|
Empty => Empty_Out_1,
|
212 |
|
|
One_Data_Left => One_Data_Left_Out_1
|
213 |
|
|
);
|
214 |
|
|
end generate Map_Fifo_1;
|
215 |
|
|
|
216 |
|
|
Not_Map_Fifo_1 : if Depth_1 = 0 generate
|
217 |
|
|
-- Fifo #1 and demux does not exist!
|
218 |
|
|
Data_AV_Comm_Out_1 <= (others => '0');
|
219 |
|
|
Empty_Out_1 <= Tie_High;
|
220 |
|
|
One_Data_Left_Out_1 <= Tie_Low;
|
221 |
|
|
Full_1 <= Tie_High;
|
222 |
|
|
One_Place_Left_1 <= Tie_Low;
|
223 |
|
|
Write_Enable_1 <= Tie_Low;
|
224 |
|
|
|
225 |
|
|
-- Connect the other fifo (#0) straight to the outputs (FSM)
|
226 |
|
|
Write_Enable_0 <= Write_Enable_In;
|
227 |
|
|
One_Place_Left_Out <= One_Place_Left_0;
|
228 |
|
|
Full_Out <= Full_0;
|
229 |
|
|
Data_AV_Comm_From_Demux(Data_Width-1 downto 0) <= Data_In;
|
230 |
|
|
Data_AV_Comm_From_Demux(Comm_Width+Data_Width-1 downto Data_Width) <= Comm_In;
|
231 |
|
|
Data_AV_Comm_From_Demux(Comm_Width+Data_Width) <= Addr_Valid_In;
|
232 |
|
|
|
233 |
|
|
end generate Not_Map_Fifo_1;
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
Map_Demux : if Depth_0 > 0 and Depth_1 > 0 generate
|
237 |
|
|
-- Demultiplexer is needed only if two fifos are used
|
238 |
|
|
DEMUX_01 : fifo_demux_write
|
239 |
|
|
generic map(
|
240 |
|
|
Data_Width => Data_Width,
|
241 |
|
|
Comm_Width => Comm_Width
|
242 |
|
|
)
|
243 |
|
|
port map(
|
244 |
|
|
-- 13.04
|
245 |
|
|
-- Clk => Clk,
|
246 |
|
|
-- Rst_n => Rst_n,
|
247 |
|
|
Data_In => Data_In,
|
248 |
|
|
Comm_In => Comm_In,
|
249 |
|
|
Addr_Valid_In => Addr_Valid_In,
|
250 |
|
|
WE_In => Write_Enable_In,
|
251 |
|
|
|
252 |
|
|
One_Place_Left_Out => One_Place_Left_Out,
|
253 |
|
|
Full_Out => Full_Out,
|
254 |
|
|
Data_Out => Data_AV_Comm_From_Demux(Data_Width-1 downto 0),
|
255 |
|
|
Comm_Out => Data_AV_Comm_From_Demux(Comm_Width+Data_Width-1 downto Data_Width),
|
256 |
|
|
Addr_Valid_Out => Data_AV_Comm_From_Demux(Comm_Width+Data_Width),
|
257 |
|
|
WE_0_Out => Write_Enable_0,
|
258 |
|
|
WE_1_Out => Write_Enable_1,
|
259 |
|
|
|
260 |
|
|
Full_0_In => Full_0,
|
261 |
|
|
Full_1_In => Full_1,
|
262 |
|
|
One_Place_Left_0_In => One_Place_Left_0,
|
263 |
|
|
One_Place_Left_1_In => One_Place_Left_1
|
264 |
|
|
);
|
265 |
|
|
end generate Map_Demux;
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
end structural;
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
|