]> rtime.felk.cvut.cz Git - fpga/zynq/canbench-sw.git/blob - system/ip/spi_leds_and_enc_1.0/hdl/spi_leds_and_enc_v1_0_S00_AXI.vhd
6a55a3593501adc014d5519987fe77ac91c35efd
[fpga/zynq/canbench-sw.git] / system / ip / spi_leds_and_enc_1.0 / hdl / spi_leds_and_enc_v1_0_S00_AXI.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4
5 entity spi_leds_and_enc_v1_0_S00_AXI is
6         generic (
7                 -- Users to add parameters here
8
9                 -- User parameters ends
10                 -- Do not modify the parameters beyond this line
11
12                 -- Width of S_AXI data bus
13                 C_S_AXI_DATA_WIDTH      : integer       := 32;
14                 -- Width of S_AXI address bus
15                 C_S_AXI_ADDR_WIDTH      : integer       := 6
16         );
17         port (
18                 -- Users to add ports here
19
20                 -- User ports ends
21                 -- Do not modify the ports beyond this line
22
23                 -- Global Clock Signal
24                 S_AXI_ACLK      : in std_logic;
25                 -- Global Reset Signal. This Signal is Active LOW
26                 S_AXI_ARESETN   : in std_logic;
27                 -- Write address (issued by master, acceped by Slave)
28                 S_AXI_AWADDR    : in std_logic_vector(C_S_AXI_ADDR_WIDTH-1 downto 0);
29                 -- Write channel Protection type. This signal indicates the
30                 -- privilege and security level of the transaction, and whether
31                 -- the transaction is a data access or an instruction access.
32                 S_AXI_AWPROT    : in std_logic_vector(2 downto 0);
33                 -- Write address valid. This signal indicates that the master signaling
34                 -- valid write address and control information.
35                 S_AXI_AWVALID   : in std_logic;
36                 -- Write address ready. This signal indicates that the slave is ready
37                 -- to accept an address and associated control signals.
38                 S_AXI_AWREADY   : out std_logic;
39                 -- Write data (issued by master, acceped by Slave)
40                 S_AXI_WDATA     : in std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
41                 -- Write strobes. This signal indicates which byte lanes hold
42                 -- valid data. There is one write strobe bit for each eight
43                 -- bits of the write data bus.
44                 S_AXI_WSTRB     : in std_logic_vector((C_S_AXI_DATA_WIDTH/8)-1 downto 0);
45                 -- Write valid. This signal indicates that valid write
46                 -- data and strobes are available.
47                 S_AXI_WVALID    : in std_logic;
48                 -- Write ready. This signal indicates that the slave
49                 -- can accept the write data.
50                 S_AXI_WREADY    : out std_logic;
51                 -- Write response. This signal indicates the status
52                 -- of the write transaction.
53                 S_AXI_BRESP     : out std_logic_vector(1 downto 0);
54                 -- Write response valid. This signal indicates that the channel
55                 -- is signaling a valid write response.
56                 S_AXI_BVALID    : out std_logic;
57                 -- Response ready. This signal indicates that the master
58                 -- can accept a write response.
59                 S_AXI_BREADY    : in std_logic;
60                 -- Read address (issued by master, acceped by Slave)
61                 S_AXI_ARADDR    : in std_logic_vector(C_S_AXI_ADDR_WIDTH-1 downto 0);
62                 -- Protection type. This signal indicates the privilege
63                 -- and security level of the transaction, and whether the
64                 -- transaction is a data access or an instruction access.
65                 S_AXI_ARPROT    : in std_logic_vector(2 downto 0);
66                 -- Read address valid. This signal indicates that the channel
67                 -- is signaling valid read address and control information.
68                 S_AXI_ARVALID   : in std_logic;
69                 -- Read address ready. This signal indicates that the slave is
70                 -- ready to accept an address and associated control signals.
71                 S_AXI_ARREADY   : out std_logic;
72                 -- Read data (issued by slave)
73                 S_AXI_RDATA     : out std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
74                 -- Read response. This signal indicates the status of the
75                 -- read transfer.
76                 S_AXI_RRESP     : out std_logic_vector(1 downto 0);
77                 -- Read valid. This signal indicates that the channel is
78                 -- signaling the required read data.
79                 S_AXI_RVALID    : out std_logic;
80                 -- Read ready. This signal indicates that the master can
81                 -- accept the read data and response information.
82                 S_AXI_RREADY    : in std_logic
83         );
84 end spi_leds_and_enc_v1_0_S00_AXI;
85
86 architecture arch_imp of spi_leds_and_enc_v1_0_S00_AXI is
87
88         -- AXI4LITE signals
89         signal axi_awaddr       : std_logic_vector(C_S_AXI_ADDR_WIDTH-1 downto 0);
90         signal axi_awready      : std_logic;
91         signal axi_wready       : std_logic;
92         signal axi_bresp        : std_logic_vector(1 downto 0);
93         signal axi_bvalid       : std_logic;
94         signal axi_araddr       : std_logic_vector(C_S_AXI_ADDR_WIDTH-1 downto 0);
95         signal axi_arready      : std_logic;
96         signal axi_rdata        : std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
97         signal axi_rresp        : std_logic_vector(1 downto 0);
98         signal axi_rvalid       : std_logic;
99
100         -- Example-specific design signals
101         -- local parameter for addressing 32 bit / 64 bit C_S_AXI_DATA_WIDTH
102         -- ADDR_LSB is used for addressing 32/64 bit registers/memories
103         -- ADDR_LSB = 2 for 32 bits (n downto 2)
104         -- ADDR_LSB = 3 for 64 bits (n downto 3)
105         constant ADDR_LSB  : integer := (C_S_AXI_DATA_WIDTH/32)+ 1;
106         constant OPT_MEM_ADDR_BITS : integer := 3;
107         ------------------------------------------------
108         ---- Signals for user logic register space example
109         --------------------------------------------------
110         ---- Number of Slave Registers 16
111         signal slv_reg0 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
112         signal slv_reg1 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
113         signal slv_reg2 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
114         signal slv_reg3 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
115         signal slv_reg4 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
116         signal slv_reg5 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
117         signal slv_reg6 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
118         signal slv_reg7 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
119         signal slv_reg8 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
120         signal slv_reg9 :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
121         signal slv_reg10        :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
122         signal slv_reg11        :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
123         signal slv_reg12        :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
124         signal slv_reg13        :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
125         signal slv_reg14        :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
126         signal slv_reg15        :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
127         signal slv_reg_rden     : std_logic;
128         signal slv_reg_wren     : std_logic;
129         signal reg_data_out     :std_logic_vector(C_S_AXI_DATA_WIDTH-1 downto 0);
130         signal byte_index       : integer;
131
132 begin
133         -- I/O Connections assignments
134
135         S_AXI_AWREADY   <= axi_awready;
136         S_AXI_WREADY    <= axi_wready;
137         S_AXI_BRESP     <= axi_bresp;
138         S_AXI_BVALID    <= axi_bvalid;
139         S_AXI_ARREADY   <= axi_arready;
140         S_AXI_RDATA     <= axi_rdata;
141         S_AXI_RRESP     <= axi_rresp;
142         S_AXI_RVALID    <= axi_rvalid;
143         -- Implement axi_awready generation
144         -- axi_awready is asserted for one S_AXI_ACLK clock cycle when both
145         -- S_AXI_AWVALID and S_AXI_WVALID are asserted. axi_awready is
146         -- de-asserted when reset is low.
147
148         process (S_AXI_ACLK)
149         begin
150           if rising_edge(S_AXI_ACLK) then
151             if S_AXI_ARESETN = '0' then
152               axi_awready <= '0';
153             else
154               if (axi_awready = '0' and S_AXI_AWVALID = '1' and S_AXI_WVALID = '1') then
155                 -- slave is ready to accept write address when
156                 -- there is a valid write address and write data
157                 -- on the write address and data bus. This design
158                 -- expects no outstanding transactions.
159                 axi_awready <= '1';
160               else
161                 axi_awready <= '0';
162               end if;
163             end if;
164           end if;
165         end process;
166
167         -- Implement axi_awaddr latching
168         -- This process is used to latch the address when both
169         -- S_AXI_AWVALID and S_AXI_WVALID are valid.
170
171         process (S_AXI_ACLK)
172         begin
173           if rising_edge(S_AXI_ACLK) then
174             if S_AXI_ARESETN = '0' then
175               axi_awaddr <= (others => '0');
176             else
177               if (axi_awready = '0' and S_AXI_AWVALID = '1' and S_AXI_WVALID = '1') then
178                 -- Write Address latching
179                 axi_awaddr <= S_AXI_AWADDR;
180               end if;
181             end if;
182           end if;
183         end process;
184
185         -- Implement axi_wready generation
186         -- axi_wready is asserted for one S_AXI_ACLK clock cycle when both
187         -- S_AXI_AWVALID and S_AXI_WVALID are asserted. axi_wready is
188         -- de-asserted when reset is low.
189
190         process (S_AXI_ACLK)
191         begin
192           if rising_edge(S_AXI_ACLK) then
193             if S_AXI_ARESETN = '0' then
194               axi_wready <= '0';
195             else
196               if (axi_wready = '0' and S_AXI_WVALID = '1' and S_AXI_AWVALID = '1') then
197                   -- slave is ready to accept write data when
198                   -- there is a valid write address and write data
199                   -- on the write address and data bus. This design
200                   -- expects no outstanding transactions.
201                   axi_wready <= '1';
202               else
203                 axi_wready <= '0';
204               end if;
205             end if;
206           end if;
207         end process;
208
209         -- Implement memory mapped register select and write logic generation
210         -- The write data is accepted and written to memory mapped registers when
211         -- axi_awready, S_AXI_WVALID, axi_wready and S_AXI_WVALID are asserted. Write strobes are used to
212         -- select byte enables of slave registers while writing.
213         -- These registers are cleared when reset (active low) is applied.
214         -- Slave register write enable is asserted when valid address and data are available
215         -- and the slave is ready to accept the write address and write data.
216         slv_reg_wren <= axi_wready and S_AXI_WVALID and axi_awready and S_AXI_AWVALID ;
217
218         process (S_AXI_ACLK)
219         variable loc_addr :std_logic_vector(OPT_MEM_ADDR_BITS downto 0);
220         begin
221           if rising_edge(S_AXI_ACLK) then
222             if S_AXI_ARESETN = '0' then
223               slv_reg0 <= (others => '0');
224               slv_reg1 <= (others => '0');
225               slv_reg2 <= (others => '0');
226               slv_reg3 <= (others => '0');
227               slv_reg4 <= (others => '0');
228               slv_reg5 <= (others => '0');
229               slv_reg6 <= (others => '0');
230               slv_reg7 <= (others => '0');
231               slv_reg8 <= (others => '0');
232               slv_reg9 <= (others => '0');
233               slv_reg10 <= (others => '0');
234               slv_reg11 <= (others => '0');
235               slv_reg12 <= (others => '0');
236               slv_reg13 <= (others => '0');
237               slv_reg14 <= (others => '0');
238               slv_reg15 <= (others => '0');
239             else
240               loc_addr := axi_awaddr(ADDR_LSB + OPT_MEM_ADDR_BITS downto ADDR_LSB);
241               if (slv_reg_wren = '1') then
242                 case loc_addr is
243                   when b"0000" =>
244                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
245                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
246                         -- Respective byte enables are asserted as per write strobes
247                         -- slave registor 0
248                         slv_reg0(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
249                       end if;
250                     end loop;
251                   when b"0001" =>
252                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
253                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
254                         -- Respective byte enables are asserted as per write strobes
255                         -- slave registor 1
256                         slv_reg1(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
257                       end if;
258                     end loop;
259                   when b"0010" =>
260                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
261                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
262                         -- Respective byte enables are asserted as per write strobes
263                         -- slave registor 2
264                         slv_reg2(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
265                       end if;
266                     end loop;
267                   when b"0011" =>
268                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
269                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
270                         -- Respective byte enables are asserted as per write strobes
271                         -- slave registor 3
272                         slv_reg3(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
273                       end if;
274                     end loop;
275                   when b"0100" =>
276                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
277                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
278                         -- Respective byte enables are asserted as per write strobes
279                         -- slave registor 4
280                         slv_reg4(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
281                       end if;
282                     end loop;
283                   when b"0101" =>
284                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
285                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
286                         -- Respective byte enables are asserted as per write strobes
287                         -- slave registor 5
288                         slv_reg5(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
289                       end if;
290                     end loop;
291                   when b"0110" =>
292                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
293                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
294                         -- Respective byte enables are asserted as per write strobes
295                         -- slave registor 6
296                         slv_reg6(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
297                       end if;
298                     end loop;
299                   when b"0111" =>
300                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
301                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
302                         -- Respective byte enables are asserted as per write strobes
303                         -- slave registor 7
304                         slv_reg7(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
305                       end if;
306                     end loop;
307                   when b"1000" =>
308                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
309                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
310                         -- Respective byte enables are asserted as per write strobes
311                         -- slave registor 8
312                         slv_reg8(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
313                       end if;
314                     end loop;
315                   when b"1001" =>
316                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
317                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
318                         -- Respective byte enables are asserted as per write strobes
319                         -- slave registor 9
320                         slv_reg9(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
321                       end if;
322                     end loop;
323                   when b"1010" =>
324                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
325                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
326                         -- Respective byte enables are asserted as per write strobes
327                         -- slave registor 10
328                         slv_reg10(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
329                       end if;
330                     end loop;
331                   when b"1011" =>
332                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
333                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
334                         -- Respective byte enables are asserted as per write strobes
335                         -- slave registor 11
336                         slv_reg11(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
337                       end if;
338                     end loop;
339                   when b"1100" =>
340                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
341                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
342                         -- Respective byte enables are asserted as per write strobes
343                         -- slave registor 12
344                         slv_reg12(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
345                       end if;
346                     end loop;
347                   when b"1101" =>
348                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
349                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
350                         -- Respective byte enables are asserted as per write strobes
351                         -- slave registor 13
352                         slv_reg13(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
353                       end if;
354                     end loop;
355                   when b"1110" =>
356                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
357                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
358                         -- Respective byte enables are asserted as per write strobes
359                         -- slave registor 14
360                         slv_reg14(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
361                       end if;
362                     end loop;
363                   when b"1111" =>
364                     for byte_index in 0 to (C_S_AXI_DATA_WIDTH/8-1) loop
365                       if ( S_AXI_WSTRB(byte_index) = '1' ) then
366                         -- Respective byte enables are asserted as per write strobes
367                         -- slave registor 15
368                         slv_reg15(byte_index*8+7 downto byte_index*8) <= S_AXI_WDATA(byte_index*8+7 downto byte_index*8);
369                       end if;
370                     end loop;
371                   when others =>
372                     slv_reg0 <= slv_reg0;
373                     slv_reg1 <= slv_reg1;
374                     slv_reg2 <= slv_reg2;
375                     slv_reg3 <= slv_reg3;
376                     slv_reg4 <= slv_reg4;
377                     slv_reg5 <= slv_reg5;
378                     slv_reg6 <= slv_reg6;
379                     slv_reg7 <= slv_reg7;
380                     slv_reg8 <= slv_reg8;
381                     slv_reg9 <= slv_reg9;
382                     slv_reg10 <= slv_reg10;
383                     slv_reg11 <= slv_reg11;
384                     slv_reg12 <= slv_reg12;
385                     slv_reg13 <= slv_reg13;
386                     slv_reg14 <= slv_reg14;
387                     slv_reg15 <= slv_reg15;
388                 end case;
389               end if;
390             end if;
391           end if;
392         end process;
393
394         -- Implement write response logic generation
395         -- The write response and response valid signals are asserted by the slave
396         -- when axi_wready, S_AXI_WVALID, axi_wready and S_AXI_WVALID are asserted.
397         -- This marks the acceptance of address and indicates the status of
398         -- write transaction.
399
400         process (S_AXI_ACLK)
401         begin
402           if rising_edge(S_AXI_ACLK) then
403             if S_AXI_ARESETN = '0' then
404               axi_bvalid  <= '0';
405               axi_bresp   <= "00"; --need to work more on the responses
406             else
407               if (axi_awready = '1' and S_AXI_AWVALID = '1' and axi_wready = '1' and S_AXI_WVALID = '1' and axi_bvalid = '0'  ) then
408                 axi_bvalid <= '1';
409                 axi_bresp  <= "00";
410               elsif (S_AXI_BREADY = '1' and axi_bvalid = '1') then   --check if bready is asserted while bvalid is high)
411                 axi_bvalid <= '0';                                 -- (there is a possibility that bready is always asserted high)
412               end if;
413             end if;
414           end if;
415         end process;
416
417         -- Implement axi_arready generation
418         -- axi_arready is asserted for one S_AXI_ACLK clock cycle when
419         -- S_AXI_ARVALID is asserted. axi_awready is
420         -- de-asserted when reset (active low) is asserted.
421         -- The read address is also latched when S_AXI_ARVALID is
422         -- asserted. axi_araddr is reset to zero on reset assertion.
423
424         process (S_AXI_ACLK)
425         begin
426           if rising_edge(S_AXI_ACLK) then
427             if S_AXI_ARESETN = '0' then
428               axi_arready <= '0';
429               axi_araddr  <= (others => '1');
430             else
431               if (axi_arready = '0' and S_AXI_ARVALID = '1') then
432                 -- indicates that the slave has acceped the valid read address
433                 axi_arready <= '1';
434                 -- Read Address latching
435                 axi_araddr  <= S_AXI_ARADDR;
436               else
437                 axi_arready <= '0';
438               end if;
439             end if;
440           end if;
441         end process;
442
443         -- Implement axi_arvalid generation
444         -- axi_rvalid is asserted for one S_AXI_ACLK clock cycle when both
445         -- S_AXI_ARVALID and axi_arready are asserted. The slave registers
446         -- data are available on the axi_rdata bus at this instance. The
447         -- assertion of axi_rvalid marks the validity of read data on the
448         -- bus and axi_rresp indicates the status of read transaction.axi_rvalid
449         -- is deasserted on reset (active low). axi_rresp and axi_rdata are
450         -- cleared to zero on reset (active low).
451         process (S_AXI_ACLK)
452         begin
453           if rising_edge(S_AXI_ACLK) then
454             if S_AXI_ARESETN = '0' then
455               axi_rvalid <= '0';
456               axi_rresp  <= "00";
457             else
458               if (axi_arready = '1' and S_AXI_ARVALID = '1' and axi_rvalid = '0') then
459                 -- Valid read data is available at the read data bus
460                 axi_rvalid <= '1';
461                 axi_rresp  <= "00"; -- 'OKAY' response
462               elsif (axi_rvalid = '1' and S_AXI_RREADY = '1') then
463                 -- Read data is accepted by the master
464                 axi_rvalid <= '0';
465               end if;
466             end if;
467           end if;
468         end process;
469
470         -- Implement memory mapped register select and read logic generation
471         -- Slave register read enable is asserted when valid address is available
472         -- and the slave is ready to accept the read address.
473         slv_reg_rden <= axi_arready and S_AXI_ARVALID and (not axi_rvalid) ;
474
475         process (slv_reg0, slv_reg1, slv_reg2, slv_reg3, slv_reg4, slv_reg5, slv_reg6, slv_reg7, slv_reg8, slv_reg9, slv_reg10, slv_reg11, slv_reg12, slv_reg13, slv_reg14, slv_reg15, axi_araddr, S_AXI_ARESETN, slv_reg_rden)
476         variable loc_addr :std_logic_vector(OPT_MEM_ADDR_BITS downto 0);
477         begin
478             -- Address decoding for reading registers
479             loc_addr := axi_araddr(ADDR_LSB + OPT_MEM_ADDR_BITS downto ADDR_LSB);
480             case loc_addr is
481               when b"0000" =>
482                 reg_data_out <= slv_reg0;
483               when b"0001" =>
484                 reg_data_out <= slv_reg1;
485               when b"0010" =>
486                 reg_data_out <= slv_reg2;
487               when b"0011" =>
488                 reg_data_out <= slv_reg3;
489               when b"0100" =>
490                 reg_data_out <= slv_reg4;
491               when b"0101" =>
492                 reg_data_out <= slv_reg5;
493               when b"0110" =>
494                 reg_data_out <= slv_reg6;
495               when b"0111" =>
496                 reg_data_out <= slv_reg7;
497               when b"1000" =>
498                 reg_data_out <= slv_reg8;
499               when b"1001" =>
500                 reg_data_out <= slv_reg9;
501               when b"1010" =>
502                 reg_data_out <= slv_reg10;
503               when b"1011" =>
504                 reg_data_out <= slv_reg11;
505               when b"1100" =>
506                 reg_data_out <= slv_reg12;
507               when b"1101" =>
508                 reg_data_out <= slv_reg13;
509               when b"1110" =>
510                 reg_data_out <= slv_reg14;
511               when b"1111" =>
512                 reg_data_out <= slv_reg15;
513               when others =>
514                 reg_data_out  <= (others => '0');
515             end case;
516         end process;
517
518         -- Output register or memory read data
519         process( S_AXI_ACLK ) is
520         begin
521           if (rising_edge (S_AXI_ACLK)) then
522             if ( S_AXI_ARESETN = '0' ) then
523               axi_rdata  <= (others => '0');
524             else
525               if (slv_reg_rden = '1') then
526                 -- When there is a valid read address (S_AXI_ARVALID) with
527                 -- acceptance of read address by the slave (axi_arready),
528                 -- output the read dada
529                 -- Read address mux
530                   axi_rdata <= reg_data_out;     -- register read data
531               end if;
532             end if;
533           end if;
534         end process;
535
536
537         -- Add user logic here
538
539         -- User logic ends
540
541 end arch_imp;