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