1 |
2 |
eejlny |
----------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the LM VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2009 Jose Nunez-Yanez
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- See the file COPYING for the full details of the license.
|
11 |
|
|
--
|
12 |
|
|
-- The license allows free and unlimited use of the library and tools for research and education purposes.
|
13 |
|
|
-- The full LM core supports many more advanced motion estimation features and it is available under a
|
14 |
|
|
-- low-cost commercial license. See the readme file to learn more or contact us at
|
15 |
|
|
-- eejlny@byacom.co.uk or www.byacom.co.uk
|
16 |
|
|
--------------------------------------
|
17 |
|
|
-- entity = reference_memory64_remap
|
18 |
|
|
-- version = 1.0
|
19 |
|
|
-- last update = 08/10/06
|
20 |
|
|
-- author = Jose Nunez
|
21 |
|
|
--------------------------------------
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
-- wrapper for reference memory remaps addresses
|
25 |
|
|
|
26 |
|
|
LIBRARY ieee;
|
27 |
|
|
USE ieee.std_logic_1164.ALL;
|
28 |
|
|
use IEEE.Numeric_STD.all;
|
29 |
|
|
use IEEE.std_logic_unsigned."+";
|
30 |
|
|
use IEEE.std_logic_unsigned."-";
|
31 |
|
|
use IEEE.std_logic_unsigned."=";
|
32 |
|
|
|
33 |
|
|
entity reference_memory64_remap is -- This memory stores the 5x7 reference data (1120 words of 64 bit)
|
34 |
|
|
port ( -- It also remaps the addresses
|
35 |
|
|
addr_r: in std_logic_vector(10 downto 0);
|
36 |
|
|
addr_w: in std_logic_vector(10 downto 0);
|
37 |
|
|
enable_hp_inter : in std_logic; -- working in interpolation mode
|
38 |
|
|
clk: in std_logic;
|
39 |
|
|
start : in std_logic;
|
40 |
|
|
next_configuration : in std_logic; -- move to the next configuration
|
41 |
|
|
start_row : in std_logic;
|
42 |
|
|
reset : in std_logic;
|
43 |
|
|
clear : in std_logic;
|
44 |
|
|
din: in std_logic_vector(63 downto 0);
|
45 |
|
|
dout: out std_logic_vector(63 downto 0);
|
46 |
|
|
dout2 : out std_logic_vector(63 downto 0); -- from the second read port
|
47 |
|
|
we: in std_logic);
|
48 |
|
|
end reference_memory64_remap;
|
49 |
|
|
|
50 |
|
|
architecture struct of reference_memory64_remap is
|
51 |
|
|
|
52 |
|
|
component reference_memory64_dp_large
|
53 |
|
|
port (
|
54 |
|
|
we : in std_logic;
|
55 |
|
|
addra: in std_logic_VECTOR(6 downto 0);
|
56 |
|
|
addrb: in std_logic_VECTOR(6 downto 0);
|
57 |
|
|
addrw : in std_logic_vector(6 downto 0);
|
58 |
|
|
clk: in std_logic;
|
59 |
|
|
clear : in std_logic;
|
60 |
|
|
reset : in std_logic;
|
61 |
|
|
dina: in std_logic_VECTOR(63 downto 0);
|
62 |
|
|
douta: out std_logic_VECTOR(63 downto 0);
|
63 |
|
|
doutb: out std_logic_VECTOR(63 downto 0);
|
64 |
|
|
wea: in std_logic_vector(3 downto 0);
|
65 |
|
|
rea : in std_logic_vector(3 downto 0);
|
66 |
|
|
reb : in std_logic_vector(3 downto 0));
|
67 |
|
|
end component;
|
68 |
|
|
|
69 |
|
|
type memory_map_type is (idle,zero,one,two,three,four,five,six,seven); -- 8 different memory configurations
|
70 |
|
|
|
71 |
|
|
type state_type is record
|
72 |
|
|
memory_map : memory_map_type;
|
73 |
|
|
end record;
|
74 |
|
|
|
75 |
|
|
signal r, r_in: state_type;
|
76 |
|
|
signal real_addr,real_addr2,real_addr_w: std_logic_vector(6 downto 0);
|
77 |
|
|
signal rea,reb,wea : std_logic_vector(3 downto 0);
|
78 |
|
|
|
79 |
|
|
begin
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
control: process(r,addr_r,addr_w,next_configuration,start)
|
83 |
|
|
|
84 |
|
|
variable v : state_type;
|
85 |
|
|
variable vreal_addr_r,vreal_addr_w: std_logic_vector(10 downto 0);
|
86 |
|
|
variable vrea,vreb,vwea : std_logic_vector(3 downto 0);
|
87 |
|
|
|
88 |
|
|
begin
|
89 |
|
|
|
90 |
|
|
v.memory_map := r.memory_map;
|
91 |
|
|
vrea := (others => '0');
|
92 |
|
|
vreb := (others => '0');
|
93 |
|
|
vreal_addr_r := addr_r;
|
94 |
|
|
vreal_addr_w := addr_w;
|
95 |
|
|
|
96 |
|
|
case v.memory_map is
|
97 |
|
|
|
98 |
|
|
when idle =>
|
99 |
|
|
if (start = '1') then
|
100 |
|
|
v.memory_map := zero;
|
101 |
|
|
end if;
|
102 |
|
|
when zero =>
|
103 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "1110";
|
104 |
|
|
if (next_configuration = '1') then
|
105 |
|
|
v.memory_map := one;
|
106 |
|
|
end if;
|
107 |
|
|
when one =>
|
108 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "0010"; -- a full macroblock (two addresses) to the right
|
109 |
|
|
vreal_addr_w := addr_w;
|
110 |
|
|
if (next_configuration = '1') then
|
111 |
|
|
v.memory_map := two;
|
112 |
|
|
end if;
|
113 |
|
|
when two =>
|
114 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "0100"; -- and so on
|
115 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "0010";
|
116 |
|
|
if (next_configuration = '1') then
|
117 |
|
|
v.memory_map := three;
|
118 |
|
|
end if;
|
119 |
|
|
when three =>
|
120 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "0110";
|
121 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "0100";
|
122 |
|
|
if (next_configuration = '1') then
|
123 |
|
|
v.memory_map := four;
|
124 |
|
|
end if;
|
125 |
|
|
when four =>
|
126 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "1000";
|
127 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "0110";
|
128 |
|
|
if (next_configuration = '1') then
|
129 |
|
|
v.memory_map := five;
|
130 |
|
|
end if;
|
131 |
|
|
when five =>
|
132 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "1010";
|
133 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "1000";
|
134 |
|
|
if (next_configuration = '1') then
|
135 |
|
|
v.memory_map := six;
|
136 |
|
|
end if;
|
137 |
|
|
when six =>
|
138 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "1100";
|
139 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "1010";
|
140 |
|
|
if (next_configuration = '1') then
|
141 |
|
|
v.memory_map := seven;
|
142 |
|
|
end if;
|
143 |
|
|
when seven =>
|
144 |
|
|
vreal_addr_r(3 downto 0) := addr_r(3 downto 0) + "1110";
|
145 |
|
|
vreal_addr_w(3 downto 0) := addr_w(3 downto 0) + "1100";
|
146 |
|
|
if (next_configuration = '1') then
|
147 |
|
|
v.memory_map := zero;
|
148 |
|
|
end if;
|
149 |
|
|
when others => null;
|
150 |
|
|
|
151 |
|
|
end case;
|
152 |
|
|
|
153 |
|
|
r_in.memory_map <= v.memory_map;
|
154 |
|
|
vrea := vreal_addr_r(3 downto 0);
|
155 |
|
|
vreb := vreal_addr_r(3 downto 0);
|
156 |
|
|
if (enable_hp_inter = '1') then
|
157 |
|
|
vreb := vreb - "0001";
|
158 |
|
|
else
|
159 |
|
|
vreb := vreb + "0001";
|
160 |
|
|
end if;
|
161 |
|
|
vwea := vreal_addr_w(3 downto 0);
|
162 |
|
|
|
163 |
|
|
real_addr <= vreal_addr_r(10 downto 4);
|
164 |
|
|
real_addr2 <= vreal_addr_r(10 downto 4);
|
165 |
|
|
real_addr_w <= vreal_addr_w(10 downto 4);
|
166 |
|
|
rea <= vrea;
|
167 |
|
|
reb <= vreb;
|
168 |
|
|
wea <= vwea;
|
169 |
|
|
|
170 |
|
|
end process control;
|
171 |
|
|
|
172 |
|
|
reference_memory64_1 : reference_memory64_dp_large
|
173 |
|
|
port map (
|
174 |
|
|
we => we,
|
175 |
|
|
addra =>real_addr,
|
176 |
|
|
addrb =>real_addr2,
|
177 |
|
|
addrw =>real_addr_w,
|
178 |
|
|
clk =>clk,
|
179 |
|
|
clear => clear,
|
180 |
|
|
reset => reset,
|
181 |
|
|
dina =>din,
|
182 |
|
|
douta =>dout,
|
183 |
|
|
doutb =>dout2,
|
184 |
|
|
wea =>wea,
|
185 |
|
|
rea =>rea,
|
186 |
|
|
reb =>reb);
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
regs: process (clk,clear)
|
190 |
|
|
|
191 |
|
|
begin
|
192 |
|
|
|
193 |
|
|
if (clear = '1') then
|
194 |
|
|
r.memory_map <= idle;
|
195 |
|
|
elsif rising_edge(clk) then
|
196 |
|
|
if (reset = '1' or start_row ='1') then
|
197 |
|
|
r.memory_map <= idle;
|
198 |
|
|
else
|
199 |
|
|
r <= r_in;
|
200 |
|
|
end if;
|
201 |
|
|
end if;
|
202 |
|
|
|
203 |
|
|
end process regs;
|
204 |
|
|
|
205 |
|
|
end;
|