]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/blob - hw/lx_dad_pkg.vhd
extended memotry for 2 samples of sensor data
[fpga/lx-cpu1/lx-dad.git] / hw / lx_dad_pkg.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4 use work.util_pkg.all;
5
6 -- Entities within lx_dad
7
8 package lx_dad_pkg is
9
10         -- D sampler (filtered, 2 cycles)
11         component dff2
12         port
13         (
14                 clk_i   : in std_logic;
15                 d_i     : in std_logic;
16                 q_o     : out std_logic
17         );
18         end component;
19
20         -- D sampler (filtered, 3 cycles)
21         component dff3
22         port
23         (
24                 clk_i   : in std_logic;
25                 d_i     : in std_logic;
26                 q_o     : out std_logic
27         );
28         end component;
29
30         -- Counter - divider
31         component cnt_div
32         generic (
33                 cnt_width_g : natural := 8
34         );
35         port
36         (
37                 clk_i     : in std_logic;
38                 en_i      : in std_logic;
39                 reset_i   : in std_logic;
40                 ratio_i   : in std_logic_vector(cnt_width_g-1 downto 0);
41                 q_out_o   : out std_logic
42         );
43         end component;
44
45         -- Clock Cross Domain Synchronization Elastic Buffer/FIFO
46         component lx_crosdom_ser_fifo
47         generic
48         (
49                 fifo_len_g   : positive := 8;
50                 sync_adj_g   : integer := 0
51         );
52         port
53         (
54                 -- Asynchronous clock domain interface
55                 acd_clock_i  : in std_logic;
56                 acd_miso_i   : in std_logic;
57                 acd_sync_i   : in std_logic;
58                 -- Clock
59                 clk_i        : in std_logic;
60                 reset_i      : in std_logic;
61                 -- Output synchronous with clk_i
62                 miso_o       : out std_logic;
63                 sync_o       : out std_logic;
64                 data_ready_o : out std_logic
65         );
66         end component;
67
68         --------------------------------------------------------------------------------
69         -- MEMORY BUS
70         --------------------------------------------------------------------------------
71
72         -- Measurement register
73         component measurement_register
74         generic
75         (
76                 id_g   : std_logic_vector(31 downto 0) := (others => '0')
77         );
78         port
79         (
80                 -- Clock
81                 clk_i    : in std_logic;
82                 -- Reset
83                 reset_i  : in std_logic;
84                 -- Chip enable
85                 ce_i     : in std_logic;
86                 -- Switch
87                 switch_i : in std_logic;
88                 -- Data bus
89                 data_i   : in std_logic_vector(31 downto 0);
90                 data_o   : out std_logic_vector(31 downto 0);
91                 -- Bus signals
92                 bls_i    : in std_logic_vector(3 downto 0)
93         );
94         end component;
95
96         -- Example component interconnect
97         component bus_example
98         port
99         (
100                 clk_i        : in std_logic;
101                 reset_i      : in std_logic;
102                 -- Master CPU peripheral bus
103                 address_i    : in std_logic_vector(11 downto 0);
104                 ce_i         : in std_logic;
105                 data_i       : in std_logic_vector(31 downto 0);
106                 data_o       : out std_logic_vector(31 downto 0);
107                 --
108                 bls_i        : in std_logic_vector(3 downto 0)
109
110                 -- Non bus signals
111                 --
112                 -- Add there externaly visible signals
113         );
114         end component;
115
116         -- Dualported memory for example componenet
117         component lx_example_mem
118         port
119         (
120                 -- Memory wiring for internal state automata use
121                 clk_i  : in std_logic;
122                 ce_i   : in std_logic;
123                 adr_i  : in std_logic_vector(9 downto 0);
124                 bls_i  : in std_logic_vector(3 downto 0);
125                 dat_i  : in std_logic_vector(31 downto 0);
126                 dat_o  : out std_logic_vector(31 downto 0);
127                 -- Memory wiring for Master CPU
128                 clk_m  : in std_logic;
129                 en_m   : in std_logic;
130                 we_m   : in std_logic_vector(3 downto 0);
131                 addr_m : in std_logic_vector(9 downto 0);
132                 din_m  : in std_logic_vector(31 downto 0);
133                 dout_m : out std_logic_vector(31 downto 0)
134         );
135         end component;
136
137         -- Measurement interconnect
138         component bus_measurement
139         port
140         (
141                 -- Clock
142                 clk_i     : in std_logic;
143                 -- Reset
144                 reset_i   : in std_logic;
145                 -- Chip enable
146                 ce_i      : in std_logic;
147                 -- Address
148                 address_i : in std_logic_vector(1 downto 0);
149                 -- Data bus
150                 data_i    : in std_logic_vector(31 downto 0);
151                 data_o    : out std_logic_vector(31 downto 0);
152                 -- Bus signals
153                 bls_i     : in std_logic_vector(3 downto 0)
154         );
155         end component;
156
157         -- Register on the bus
158         component bus_register is
159         generic
160         (
161                 -- Reset value
162                 reset_value_g : std_logic_vector(31 downto 0) := (others => '0');
163                 -- Width
164                 b0_g          : natural := 8;
165                 b1_g          : natural := 8;
166                 b2_g          : natural := 8;
167                 b3_g          : natural := 8
168         );
169         port
170         (
171                 -- Clock
172                 clk_i         : in std_logic;
173                 -- Reset
174                 reset_i       : in std_logic;
175                 -- Chip enable
176                 ce_i          : in std_logic;
177                 -- Data bus
178                 data_i        : in std_logic_vector((b0_g+b1_g+b2_g+b3_g-1) downto 0);
179                 data_o        : out std_logic_vector((b0_g+b1_g+b2_g+b3_g-1) downto 0);
180                 -- Bus signals
181                 bls_i         : in std_logic_vector(3 downto 0)
182         );
183         end component;
184
185
186         --------------------------------------------------------------------------------
187         -- BRAM
188         --------------------------------------------------------------------------------
189         type BRAM_type is (READ_FIRST, WRITE_FIRST, NO_CHANGE);
190
191         component xilinx_dualport_bram
192         generic
193         (
194                 byte_width    : positive := 8;
195                 address_width : positive := 8;
196                 we_width      : positive := 4;
197                 port_a_type   : BRAM_type := READ_FIRST;
198                 port_b_type   : BRAM_type := READ_FIRST
199         );
200         port
201         (
202                 clka  : in std_logic;
203                 rsta  : in std_logic;
204                 ena   : in std_logic;
205                 wea   : in std_logic_vector((we_width-1) downto 0);
206                 addra : in std_logic_vector((address_width-1) downto 0);
207                 dina  : in std_logic_vector(((byte_width*we_width)-1) downto 0);
208                 douta : out std_logic_vector(((byte_width*we_width)-1) downto 0);
209                 clkb  : in std_logic;
210                 rstb  : in std_logic;
211                 enb   : in std_logic;
212                 web   : in std_logic_vector((we_width-1) downto 0);
213                 addrb : in std_logic_vector((address_width-1) downto 0);
214                 dinb  : in std_logic_vector(((byte_width*we_width)-1) downto 0);
215                 doutb : out std_logic_vector(((byte_width*we_width)-1) downto 0)
216         );
217         end component;
218
219 end lx_dad_pkg;
220
221 package body lx_dad_pkg is
222
223 end lx_dad_pkg;