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