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

Subversion Repositories motion_estimation_processor

[/] [motion_estimation_processor/] [trunk/] [src_me/] [forward_engine.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       = forward_engine        --
18
--  version      = 1.0                   --
19
--  last update  = 1/10/07               --
20
--  author       = Jose Nunez            --
21
-------------------------------------------
22
 
23
 
24
-- FUNCTION
25
-- forward data into distance engine memories for fp data
26
 
27
library ieee;
28
use ieee.std_logic_1164.all;
29
use IEEE.std_logic_unsigned."+";
30
use work.config.all;
31
 
32
entity forward_engine is
33
port(
34
    clk : in std_logic;
35
    clear : in std_logic;
36
    reset : in std_logic;
37
    enable_hp_inter : in std_logic; -- when hp interpolation is being performed in the background
38
    write_register : in std_logic;
39
    mode_in : in mode_type;
40
    in_pixels : in std_logic_vector(63 downto 0);
41
    partition_count_in : in std_logic_vector(3 downto 0);
42
    write_block1 : out std_logic;  -- control which of the two blocks is being read and written (interpolate and dist engine)
43
    rma_address : out std_logic_vector(4 downto 0); -- extracted reference pixels use this address
44
    rma_we : out std_logic;
45
    out_pixels : out std_logic_vector(63 downto 0)
46
    );
47
end forward_engine;
48
 
49
architecture behav of forward_engine is
50
 
51
type state_type is (idle,write_line_m8x8,write_line_m8x16,write_line_m16x8,write_line,wait_for_distance_engine,wait_for_distance_engine2); -- me control unit states
52
 
53
type state_register_type is record
54
   state : state_type;
55
   rma_address : std_logic_vector(5 downto 0); -- address for the reference macroblock memory
56
   write_block1 : std_logic; -- flag
57
   pixel_registers : std_logic_vector(63 downto 0);
58
end record;
59
 
60
 
61
signal r,r_in : state_register_type;
62
signal pixels : std_logic_vector(127 downto 0);
63
 
64
begin
65
 
66
 
67
shift : process(r,in_pixels,write_register,enable_hp_inter)
68
 
69
variable v : state_register_type;
70
 
71
begin
72
 
73
    v.pixel_registers := r.pixel_registers;
74
    if (write_register = '1' and enable_hp_inter = '0') then -- in enable hp inter then this unit should wait
75
        v.pixel_registers := in_pixels;
76
    end if;
77
    r_in.pixel_registers <= v.pixel_registers;
78
 
79
end process shift;
80
 
81
 
82
control :process(r,write_register,pixels,mode_in,enable_hp_inter,partition_count_in)
83
variable vrma_we : std_logic;
84
variable v : state_register_type;
85
begin
86
 
87
   v.state := r.state;
88
   v.rma_address := r.rma_address;
89
   v.write_block1 := r.write_block1;
90
   vrma_we := '0';
91
 
92
 
93
   case v.state is
94
 
95
     when idle =>
96
                 v.rma_address := "000000";
97
             if (write_register = '1' and enable_hp_inter = '0') then
98
                        v.rma_address := v.rma_address + "000001";
99
                                v.state := write_line;
100
                 end if;
101
     when write_line =>
102
              vrma_we := '1';
103
              v.rma_address := v.rma_address + "00001";
104
              if (r.rma_address = "100000")then -- 16 lines in 32 locations 
105
                     v.state := idle;
106
                     v.rma_address := (others => '0');
107
                     v.write_block1 := not(v.write_block1);
108
              elsif (write_register = '0') then
109
                     v.state := idle;
110
              end if;
111
        when others => null;
112
        end case;
113
 
114
         rma_we <= vrma_we;
115
         rma_we <= vrma_we;
116
         r_in.rma_address <= v.rma_address;
117
         r_in.state <= v.state;
118
         r_in.write_block1 <= v.write_block1;
119
 
120
end process control;
121
 
122
out_pixels <= r.pixel_registers;
123
rma_address <= r.rma_address(4 downto 0);
124
write_block1 <= r.write_block1;
125
 
126
regs : process(clk,clear)
127
 
128
begin
129
 
130
 if (clear = '1') then
131
   r.state <= idle;
132
   r.write_block1 <= '1';
133
   r.rma_address <= (others => '0');
134
        r.pixel_registers <= (others => '0');
135
 elsif rising_edge(clk) then
136
                if (reset = '1') then -- general enable
137
               r.state <= idle;
138
               r.write_block1 <= '1';
139
               r.rma_address <= (others => '0');
140
                   r.pixel_registers <= (others => '0');
141
                else
142
                   r <= r_in;
143
                end if;
144
 end if;
145
 
146
end process regs;
147
 
148
 
149
end behav; -- end of architecture
150
 
151
 
152
 
153
 
154
 

powered by: WebSVN 2.1.0

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