]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/blob - hw/lx_dad_pkg.vhd
Include testbed for simulation in GHDL.
[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         -- Dualported memory for example componenet
119         component lx_example_mem
120         port
121         (
122                 -- Memory wiring for internal state automata use
123                 clk_i  : in std_logic;
124                 ce_i   : in std_logic;
125                 adr_i  : in std_logic_vector(9 downto 0);
126                 bls_i  : in std_logic_vector(3 downto 0);
127                 dat_i  : in std_logic_vector(31 downto 0);
128                 dat_o  : out std_logic_vector(31 downto 0);
129                 -- Memory wiring for Master CPU
130                 clk_m  : in std_logic;
131                 en_m   : in std_logic;
132                 we_m   : in std_logic_vector(3 downto 0);
133                 addr_m : in std_logic_vector(9 downto 0);
134                 din_m  : in std_logic_vector(31 downto 0);
135                 dout_m : out std_logic_vector(31 downto 0)
136         );
137         end component;
138
139         -- Measurement interconnect
140         component bus_measurement
141         port
142         (
143                 -- Clock
144                 clk_i     : in std_logic;
145                 -- Reset
146                 reset_i   : in std_logic;
147                 -- Chip enable
148                 ce_i      : in std_logic;
149                 -- Address
150                 address_i : in std_logic_vector(1 downto 0);
151                 -- Data bus
152                 data_i    : in std_logic_vector(31 downto 0);
153                 data_o    : out std_logic_vector(31 downto 0);
154                 -- Bus signals
155                 bls_i     : in std_logic_vector(3 downto 0)
156         );
157         end component;
158
159         -- Register on the bus
160         component bus_register is
161         generic
162         (
163                 -- Reset value
164                 reset_value_g : std_logic_vector(31 downto 0) := (others => '0');
165                 -- Width
166                 b0_g          : natural := 8;
167                 b1_g          : natural := 8;
168                 b2_g          : natural := 8;
169                 b3_g          : natural := 8
170         );
171         port
172         (
173                 -- Clock
174                 clk_i         : in std_logic;
175                 -- Reset
176                 reset_i       : in std_logic;
177                 -- Chip enable
178                 ce_i          : in std_logic;
179                 -- Data bus
180                 data_i        : in std_logic_vector((b0_g+b1_g+b2_g+b3_g-1) downto 0);
181                 data_o        : out std_logic_vector((b0_g+b1_g+b2_g+b3_g-1) downto 0);
182                 -- Bus signals
183                 bls_i         : in std_logic_vector(3 downto 0)
184         );
185         end component;
186
187
188         --------------------------------------------------------------------------------
189         -- BRAM
190         --------------------------------------------------------------------------------
191         type BRAM_type is (READ_FIRST, WRITE_FIRST, NO_CHANGE);
192
193         component xilinx_dualport_bram
194         generic
195         (
196                 byte_width    : positive := 8;
197                 address_width : positive := 8;
198                 we_width      : positive := 4;
199                 port_a_type   : BRAM_type := READ_FIRST;
200                 port_b_type   : BRAM_type := READ_FIRST
201         );
202         port
203         (
204                 clka  : in std_logic;
205                 rsta  : in std_logic;
206                 ena   : in std_logic;
207                 wea   : in std_logic_vector((we_width-1) downto 0);
208                 addra : in std_logic_vector((address_width-1) downto 0);
209                 dina  : in std_logic_vector(((byte_width*we_width)-1) downto 0);
210                 douta : out std_logic_vector(((byte_width*we_width)-1) downto 0);
211                 clkb  : in std_logic;
212                 rstb  : in std_logic;
213                 enb   : in std_logic;
214                 web   : in std_logic_vector((we_width-1) downto 0);
215                 addrb : in std_logic_vector((address_width-1) downto 0);
216                 dinb  : in std_logic_vector(((byte_width*we_width)-1) downto 0);
217                 doutb : out std_logic_vector(((byte_width*we_width)-1) downto 0)
218         );
219         end component;
220
221 end lx_dad_pkg;
222
223 package body lx_dad_pkg is
224
225 end lx_dad_pkg;