OpenCores
URL https://opencores.org/ocsvn/motion_estimation_processor/motion_estimation_processor/trunk

Subversion Repositories motion_estimation_processor

[/] [motion_estimation_processor/] [trunk/] [src_me/] [phy_address.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
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:      phy_address.vhd
18
-- Author:      Jose Luis Nunez 
19
-- Description: conversion to move from mvx and mvy to phy address in a 5x5 macroblocks reference data 
20
------------------------------------------------------------------------------
21
 
22
 
23
library IEEE;
24
use IEEE.std_logic_1164.all;
25
use IEEE.Numeric_STD.all;
26
use IEEE.std_logic_unsigned."+";
27
use IEEE.std_logic_unsigned."=";
28
 
29
 
30
entity phy_address is
31
    port(
32
      clk : in std_logic;
33
           clear : in std_logic;
34
           reset : in std_logic;
35
      partition_count : in std_logic_vector(3 downto 0); --identify the subpartition active
36
      line_offset : in std_logic_vector(5 downto 0); -- read multiple lines
37
      mvx : in std_logic_vector(7 downto 0); --two lsb are fractional only for fractional me 
38
      mvy : in std_logic_vector (7 downto 0);
39
      phy_address : out std_logic_vector (13 downto 0)
40
      );
41
end;
42
 
43
 
44
architecture rtl of phy_address is
45
 
46
signal component_x,component_y : std_logic_vector(13 downto 0);
47
subtype word is integer range -4096 to 5888;
48
type mem is array (0 to 127) of word;
49
 
50
type type_register_file is record
51
        mvy,mvx : std_logic_vector(7 downto 0);
52
end record;
53
 
54
signal r,r_in : type_register_file;
55
 
56
 
57
signal memory : mem := (
58
0,128,256,384,512,
59
640,768,896,1024,
60
1152,1280,1408,1536,
61
1664,1792,1920,2048,
62
2176,2304,2432,2560,
63
2688,2816,2944,3072,
64
3200,3328,3456,3584,
65
3712,3840,3968,4096,
66
4224,4352,4480,4608,
67
4736,4864,4992,5120,
68
5248,5376,5504,5632,
69
5760,5888,0,0,0,0,0,0,0,0,
70
0,0,0,0,0,0,0,0,0,0,0,0,0,
71
0,0,0,0,0,0,0,0,0,0,0,0,0,
72
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
73
-4096,-3968,-3840,-3712,
74
-3584,-3456,-3328,-3200,
75
-3072,-2944,-2816,-2688,
76
-2560,-2432,-2304,-2176,
77
-2048,-1920,-1792,-1664,
78
-1536,-1408,-1280,-1152,
79
-1024,-896,-768,-640,-512,
80
-384,-256,-128);
81
 
82
 
83
--attribute syn_romstyle : string;
84
--attribute syn_romstyle of memory : signal is "logic";
85
 
86
begin
87
 
88
  adjust_address : process(mvy,line_offset)
89
 
90
  variable vmvy : std_logic_vector(7 downto 0);
91
 
92
  begin
93
 
94
      vmvy := mvy;
95
 
96
           r_in.mvy <= vmvy + line_offset;
97
 
98
end process adjust_address;
99
 
100
 
101
r_in.mvx <= mvx;
102
 
103
 
104
  px : process(r.mvx)
105
 
106
  variable vmvx : std_logic_vector(7 downto 0);
107
  variable vmvx_long : std_logic_vector(13 downto 0);
108
  begin
109
    vmvx := r.mvx;
110
    if(vmvx(7) = '1') then -- negative number
111
          vmvx_long := ("111111"&vmvx);
112
    else
113
          vmvx_long := ("000000"&vmvx);
114
     end if;
115
 
116
   component_x <= vmvx_long;
117
  end process;
118
 
119
 
120
  py : process(r.mvy)
121
  variable vaddr : integer range 0 to 127;
122
  variable vmvy,vmvy_ref : std_logic_vector(7 downto 0);
123
  variable vrom_data : std_logic_vector(13 downto 0);
124
 
125
        begin
126
              vmvy := r.mvy;
127
--            vmvy_ref := r.mvy;
128
--            if (vmvy(5) = '1') then -- negative number
129
--                  for i in 5 downto 0 loop
130
--                     vmvy(i) := not(vmvy(i));
131
--                  end loop;
132
--                  vmvy := vmvy + "000001"; -- now is positive
133
--            end if;
134
 
135
 
136
                        vaddr := To_integer(unsigned(vmvy(6 downto 0)));
137
                        vrom_data := (std_logic_vector(to_signed(memory(vaddr),14)));
138
 
139
 
140
--                 if (vmvy_ref(5)='1') then-- negative number : we need to substract to departure address
141
--                        for i in 12 downto 0 loop
142
--                                vrom_data(i) := not(vrom_data(i));        
143
--                        end loop;
144
--                        vrom_data := vrom_data + "0000000000001"; -- now is negative
145
--                 end if;
146
 
147
                   component_y <= vrom_data;
148
 
149
         end process;
150
 
151
 
152
   -- 4144 is reference position of current macroblock at 0,0
153
  address_reference : process(component_x,component_y,partition_count)
154
  begin
155
        case partition_count is
156
                when "0000" => phy_address <= std_logic_vector(to_unsigned(4144,14)) + component_x + component_y ;
157
                when "0010" => phy_address <= std_logic_vector(to_unsigned(4152,14)) + component_x + component_y ;
158
                when "1000" => phy_address <= std_logic_vector(to_unsigned(5168,14)) + component_x + component_y ;
159
                when "1010" => phy_address <= std_logic_vector(to_unsigned(5176,14)) + component_x + component_y ;
160
                when others => null;
161
        end case;
162
 
163
  end process;
164
 
165
-- pipeline for performance reasons
166
 
167
regs : process(clk,clear)
168
 
169
begin
170
 
171
 if (clear = '1') then
172
                r.mvy <= (others => '0');
173
                r.mvx <= (others => '0');
174
 elsif rising_edge(clk) then
175
                if (reset = '1') then -- general enable
176
                                r.mvy <= (others => '0');
177
                                r.mvx <= (others => '0');
178
                else
179
                                  r <= r_in;
180
                end if;
181
 end if;
182
 
183
end process regs;
184
 
185
 
186
end rtl;

powered by: WebSVN 2.1.0

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