]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - hw/lx-fncapprox/lx_fncapprox.vhd
Include initial stub of function generator to LX HW design.
[fpga/lx-cpu1/lx-rocon.git] / hw / lx-fncapprox / lx_fncapprox.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_unsigned.all;
4 use ieee.numeric_std.all;
5 use work.mbl_pkg.all;
6 use work.lx_rocon_pkg.all;
7
8 -- IRC bus interconnect
9 entity lx_fncapprox is
10         port
11         (
12                 clk_i        : in std_logic;
13                 reset_i      : in std_logic;
14                 -- Data bus
15                 address_i    : in std_logic_vector(4 downto 0);
16                 next_ce_i    : in std_logic;
17                 data_i       : in std_logic_vector(31 downto 0);
18                 data_o       : out std_logic_vector(31 downto 0);
19                 --
20                 bls_i        : in std_logic_vector(3 downto 0)
21         );
22 end lx_fncapprox;
23
24 architecture Behavioral of lx_fncapprox is
25
26         component rom_table
27         generic
28         (
29                 data_width : integer;
30                 addr_width : integer;
31                 init_file  : string
32         );
33         port
34         (
35                 ack_o  : out std_logic;
36                 addr_i : in  std_logic_vector (addr_width-1 downto 0);
37                 clk_i  : in  std_logic;
38                 data_o : out std_logic_vector (data_width-1 downto 0);
39                 stb_i  : in  std_logic
40         );
41         end component;
42
43         signal ce_s                 : std_logic;
44
45         signal reci_tab_idx_s       : std_logic_vector(7 downto 0);
46         signal reci_tab_idx_r       : std_logic_vector(7 downto 0);
47         signal reci_tab_a_data_s    : std_logic_vector(35 downto 0);
48         signal reci_tab_a_data_r    : std_logic_vector(35 downto 0);
49
50         signal reci_tab_a_ack_s     : std_logic;
51         signal reci_tab_a_stb_s     : std_logic;
52 begin
53
54 reci_tab_a : rom_table
55         generic map (
56                 data_width => 36,
57                 addr_width => 8,
58                 init_file  => "reci_tab_a.lut"
59         )
60         port map
61         (
62                 clk_i  => clk_i,
63                 stb_i  => reci_tab_a_stb_s,
64                 addr_i => reci_tab_idx_s,
65                 data_o => reci_tab_a_data_s,
66                 ack_o  => reci_tab_a_ack_s
67         );
68
69
70 wire_in:
71         process(next_ce_i, ce_s, bls_i, address_i, data_i, reci_tab_idx_r)
72         begin
73                 -- init values
74                 reci_tab_a_stb_s     <= '0';
75                 reci_tab_idx_s <= reci_tab_idx_r;
76
77                 -- Incoming bus request
78                 if next_ce_i = '1' then
79                         if bls_i(0) = '1' then
80                                 reci_tab_a_stb_s <= '1';
81                                 reci_tab_idx_s <= data_i(7 downto 0);
82                         end if;
83                 end if;
84         end process;
85
86 wire_out:
87         process(ce_s, reci_tab_a_data_r)
88         begin
89
90                 data_o <= (others => '0');
91
92                 if ce_s = '1' then
93                         data_o <= reci_tab_a_data_r(35 downto 4);
94                 end if;
95         end process;
96
97 update:
98         process
99         begin
100                 wait until clk_i'event and clk_i= '1';
101                 ce_s      <= next_ce_i;
102                 if reci_tab_a_ack_s = '1' then
103                         reci_tab_a_data_r <= reci_tab_a_data_s;
104                 end if;
105
106                 reci_tab_idx_r <= reci_tab_idx_s;
107         end process;
108
109 end Behavioral;
110