1 |
18 |
kavi |
----==============================================================----
|
2 |
|
|
---- ----
|
3 |
|
|
---- Filename: prenc_loops5.vhd ----
|
4 |
|
|
---- Module description: Priority encoder unit. Obtains ----
|
5 |
|
|
---- increment and reset decisions for the loop indices. ----
|
6 |
|
|
---- ----
|
7 |
|
|
---- Author: Nikolaos Kavvadias ----
|
8 |
|
|
---- nkavv@physics.auth.gr ----
|
9 |
|
|
---- ----
|
10 |
|
|
---- ----
|
11 |
|
|
---- Part of the hwlu OPENCORES project generated automatically ----
|
12 |
|
|
---- with the use of the "gen_priority_encoder" tool ----
|
13 |
|
|
---- ----
|
14 |
|
|
---- To Do: ----
|
15 |
|
|
---- Considered stable for the time being ----
|
16 |
|
|
---- ----
|
17 |
|
|
---- Author: Nikolaos Kavvadias ----
|
18 |
|
|
---- nkavv@physics.auth.gr ----
|
19 |
|
|
---- ----
|
20 |
|
|
----==============================================================----
|
21 |
|
|
---- ----
|
22 |
|
|
---- Copyright (C) 2004-2010 Nikolaos Kavvadias ----
|
23 |
|
|
---- nkavv@uop.gr ----
|
24 |
|
|
---- nkavv@physics.auth.gr ----
|
25 |
|
|
---- nikolaos.kavvadias@gmail.com ----
|
26 |
|
|
---- ----
|
27 |
|
|
---- This source file may be used and distributed without ----
|
28 |
|
|
---- restriction provided that this copyright statement is not ----
|
29 |
|
|
---- removed from the file and that any derivative work contains ----
|
30 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
31 |
|
|
---- ----
|
32 |
|
|
---- This source file is free software; you can redistribute it ----
|
33 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
34 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
35 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
36 |
|
|
---- later version. ----
|
37 |
|
|
---- ----
|
38 |
|
|
---- This source is distributed in the hope that it will be ----
|
39 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
40 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
41 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
42 |
|
|
---- details. ----
|
43 |
|
|
---- ----
|
44 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
45 |
|
|
---- Public License along with this source; if not, download it ----
|
46 |
|
|
---- from <http://www.opencores.org/lgpl.shtml> ----
|
47 |
|
|
---- ----
|
48 |
|
|
----==============================================================----
|
49 |
|
|
--
|
50 |
|
|
-- CVS Revision History
|
51 |
|
|
--
|
52 |
|
|
|
53 |
|
|
library IEEE;
|
54 |
|
|
use IEEE.std_logic_1164.all;
|
55 |
|
|
use IEEE.std_logic_unsigned.all;
|
56 |
|
|
|
57 |
|
|
entity priority_encoder is
|
58 |
|
|
generic (
|
59 |
|
|
NLP : integer := 5
|
60 |
|
|
);
|
61 |
|
|
port (
|
62 |
|
|
flag : in std_logic_vector(NLP-1 downto 0);
|
63 |
|
|
task_loop5_end : in std_logic;
|
64 |
|
|
incl : out std_logic_vector(NLP-1 downto 0);
|
65 |
|
|
reset_vct : out std_logic_vector(NLP-1 downto 0);
|
66 |
|
|
loops_end : out std_logic
|
67 |
|
|
);
|
68 |
|
|
end priority_encoder;
|
69 |
|
|
|
70 |
|
|
architecture rtl of priority_encoder is
|
71 |
|
|
begin
|
72 |
|
|
|
73 |
|
|
-- Fully-nested loop structure with 5 loops
|
74 |
|
|
-- From outer to inner: 4-> 3-> 2-> 1-> 0
|
75 |
|
|
process (flag, task_loop5_end)
|
76 |
|
|
begin
|
77 |
|
|
--
|
78 |
|
|
-- if loop4 is terminating:
|
79 |
|
|
-- reset loops 4-0 to initial index
|
80 |
|
|
if (flag(4 downto 0) = "11111") then
|
81 |
|
|
incl <= "00000";
|
82 |
|
|
reset_vct <= "11111";
|
83 |
|
|
loops_end <= '1';
|
84 |
|
|
-- else if loop3 is terminating:
|
85 |
|
|
-- 1. increment loop4 index
|
86 |
|
|
-- 2. reset loop3 to initial index
|
87 |
|
|
elsif (flag(3 downto 0) = "1111") then
|
88 |
|
|
incl <= "10000";
|
89 |
|
|
reset_vct <= "01111";
|
90 |
|
|
loops_end <= '0';
|
91 |
|
|
-- else if loop2 is terminating:
|
92 |
|
|
-- 1. increment loop3 index
|
93 |
|
|
-- 2. reset loop2 to initial index
|
94 |
|
|
elsif (flag(2 downto 0) = "111") then
|
95 |
|
|
incl <= "01000";
|
96 |
|
|
reset_vct <= "00111";
|
97 |
|
|
loops_end <= '0';
|
98 |
|
|
-- else if loop1 is terminating:
|
99 |
|
|
-- 1. increment loop2 index
|
100 |
|
|
-- 2. reset loop1 to initial index
|
101 |
|
|
elsif (flag(1 downto 0) = "11") then
|
102 |
|
|
incl <= "00100";
|
103 |
|
|
reset_vct <= "00011";
|
104 |
|
|
loops_end <= '0';
|
105 |
|
|
-- else if loop0 is terminating:
|
106 |
|
|
-- 1. increment loop1 index
|
107 |
|
|
-- 2. reset loop0 to initial index
|
108 |
|
|
elsif (flag(0 downto 0) = "1") then
|
109 |
|
|
incl <= "00010";
|
110 |
|
|
reset_vct <= "00001";
|
111 |
|
|
loops_end <= '0';
|
112 |
|
|
-- else increment loop-1 index
|
113 |
|
|
else
|
114 |
|
|
reset_vct <= "00000";
|
115 |
|
|
loops_end <= '0';
|
116 |
|
|
if (task_loop5_end = '1') then
|
117 |
|
|
incl <= "00001";
|
118 |
|
|
else
|
119 |
|
|
incl <= "00000";
|
120 |
|
|
end if;
|
121 |
|
|
end if;
|
122 |
|
|
end process;
|
123 |
|
|
|
124 |
|
|
end rtl;
|