1
|
library ieee;
|
2
|
use ieee.std_logic_1164.all;
|
3
|
|
4
|
|
5
|
library ieee;
|
6
|
use ieee.numeric_std.all;
|
7
|
|
8
|
entity idctbuff is
|
9
|
port (
|
10
|
wa0_data : in std_logic_vector(31 downto 0);
|
11
|
wa0_addr : in std_logic_vector(8 downto 0);
|
12
|
clk : in std_logic;
|
13
|
ra2_data : out std_logic_vector(31 downto 0);
|
14
|
ra2_addr : in std_logic_vector(8 downto 0);
|
15
|
ra1_data : out std_logic_vector(31 downto 0);
|
16
|
ra1_addr : in std_logic_vector(8 downto 0);
|
17
|
ra0_addr : in std_logic_vector(8 downto 0);
|
18
|
ra0_data : out std_logic_vector(31 downto 0);
|
19
|
wa0_en : in std_logic
|
20
|
);
|
21
|
end idctbuff;
|
22
|
architecture augh of idctbuff is
|
23
|
|
24
|
-- Embedded RAM
|
25
|
|
26
|
type ram_type is array (0 to 383) of std_logic_vector(31 downto 0);
|
27
|
signal ram : ram_type := (others => (others => '0'));
|
28
|
|
29
|
|
30
|
-- Little utility functions to make VHDL syntactically correct
|
31
|
-- with the syntax to_integer(unsigned(vector)) when 'vector' is a std_logic.
|
32
|
-- This happens when accessing arrays with <= 2 cells, for example.
|
33
|
|
34
|
function to_integer(B: std_logic) return integer is
|
35
|
variable V: std_logic_vector(0 to 0);
|
36
|
begin
|
37
|
V(0) := B;
|
38
|
return to_integer(unsigned(V));
|
39
|
end;
|
40
|
|
41
|
function to_integer(V: std_logic_vector) return integer is
|
42
|
begin
|
43
|
return to_integer(unsigned(V));
|
44
|
end;
|
45
|
|
46
|
begin
|
47
|
|
48
|
-- Sequential process
|
49
|
-- It handles the Writes
|
50
|
|
51
|
process (clk)
|
52
|
begin
|
53
|
if rising_edge(clk) then
|
54
|
|
55
|
-- Write to the RAM
|
56
|
-- Note: there should be only one port.
|
57
|
|
58
|
if wa0_en = '1' then
|
59
|
ram( to_integer(wa0_addr) ) <= wa0_data;
|
60
|
end if;
|
61
|
|
62
|
end if;
|
63
|
end process;
|
64
|
|
65
|
-- The Read side (the outputs)
|
66
|
|
67
|
ra1_data <= ram( to_integer(ra1_addr) ) when to_integer(ra1_addr) < 384 else (others => '-');
|
68
|
ra0_data <= ram( to_integer(ra0_addr) ) when to_integer(ra0_addr) < 384 else (others => '-');
|
69
|
ra2_data <= ram( to_integer(ra2_addr) ) when to_integer(ra2_addr) < 384 else (others => '-');
|
70
|
|
71
|
end architecture;
|