]> rtime.felk.cvut.cz Git - fpga/pwm.git/blob - pwm_dump.vhd
Wave_table initialization data format modified.
[fpga/pwm.git] / pwm_dump.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
6 --------------------------------------------------------------------------------
7
8 entity pwm_dump is
9   generic (
10     IRF_ADR_W : integer := 5;
11     P_BASE    : integer := 16;
12     PWM_OFF   : integer := 1;
13     PWM_W     : integer := 10);
14   port (
15     -- Primary slave intefrace
16     ACK_O     : out std_logic;
17     CLK_I     : in  std_logic;
18     RST_I     : in  std_logic;
19     STB_I     : in  std_logic;
20     -- PWM interface
21     PWM_DAT_O : out std_logic_vector (PWM_W-1 downto 0);
22     PWM_STB_O : out std_logic := '0';
23     -- Shared dual-port memory
24     IRF_ACK_I : in  std_logic;
25     IRF_ADR_O : out std_logic_vector (IRF_ADR_W-1 downto 0);
26     IRF_DAT_I : in  std_logic_vector (15 downto 0);
27     IRF_STB_O : out std_logic);
28 end entity pwm_dump;
29
30 --------------------------------------------------------------------------------
31
32 architecture behavioral of pwm_dump is
33
34   type state_t is (ready, done);
35   subtype irf_adr_t is std_logic_vector (IRF_ADR_W-1 downto 0);
36
37   constant PWM_ADR : irf_adr_t :=  conv_std_logic_vector(P_BASE + PWM_OFF, IRF_ADR_W);
38   
39   signal state : state_t := ready;
40
41   signal INNER_ACK : std_logic := '0';
42   
43 --------------------------------------------------------------------------------
44
45 begin
46
47   ACK_O <= STB_I and INNER_ACK;
48
49   PWM_DAT_O <= IRF_DAT_I (PWM_DAT_O'RANGE);
50   
51   IRF_ADR_O <= PWM_ADR;
52   IRF_STB_O <= STB_I;
53
54   
55   FSM : process (CLK_I, RST_I) is
56   begin
57     if rising_edge(CLK_I) then
58       if RST_I = '1' then
59         state     <= ready;
60         INNER_ACK <= '0';
61         PWM_STB_O <= '0';
62       
63       else  
64         case state is
65           when ready =>
66             if STB_I = '1' then
67               state     <= done;
68               INNER_ACK <= '1';
69               PWM_STB_O <= '1';
70             end if;
71
72           when done =>
73             PWM_STB_O <= '0';
74             if STB_I = '0' then
75               state     <= ready;
76               INNER_ACK <= '0';
77             end if;
78         end case;
79       end if;
80     end if;
81   end process;
82   
83 end architecture behavioral;
84