Changeset 10888
- Timestamp:
- 05/31/11 17:00:37 (14 years ago)
- Location:
- firmware/FAD/FACT_FAD_20MHz_VAR_PS/FACT_FAD_lib/hdl
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/FAD/FACT_FAD_20MHz_VAR_PS/FACT_FAD_lib/hdl/fad_definitions.vhd
r10883 r10888 182 182 183 183 184 constant TIME_UNTIL_READ_READY : integer := 4; 185 constant TIME_UNTIL_WRITE_READY : integer := 4; 186 187 188 -- FUNCTION wait_if_started ( 189 -- signal sr : std_logic_vector(2 downto 0) 190 -- ) RETURN std_logic; 191 -- 192 193 184 194 end fad_definitions; 195 196 --PACKAGE BODY fad_definitions is 197 -- 198 -- FUNCTION wait_if_started ( 199 -- signal sr : std_logic_vector(2 downto 0) 200 -- ) RETURN std_logic IS 201 -- 202 -- BEGIN 203 -- 204 -- 205 -- 206 -- END FUNCTION wait_if_started; 207 -- 208 -- 209 --END fad_definitions; -
firmware/FAD/FACT_FAD_20MHz_VAR_PS/FACT_FAD_lib/hdl/w5300_interface.vhd
r10886 r10888 3 3 use IEEE.NUMERIC_STD.all; 4 4 5 ENTITY w5300_modul IS 6 generic( 7 TIME_UNTIL_READ_READY : integer := 4; 8 TIME_UNTIL_READ_READY : integer := 4; 9 ); 5 library FACT_FAD_lib; 6 use FACT_FAD_lib.fad_definitions.ALL; 7 8 ENTITY w5300_interface IS 10 9 PORT( 11 10 clk : IN std_logic; -- expecting 50MHz … … 24 23 data_o : OUT std_logic_vector (15 DOWNTO 0) := (others => '0'); 25 24 data_i : IN std_logic_vector (15 DOWNTO 0); 26 25 ready_o : OUT std_logic := '0'; 26 reset_i : IN std_logic 27 27 ); 28 END w5300_ modul;28 END w5300_interface ; 29 29 30 architecture Behavioral of w5300_modul is 31 signal read_not_write_signal : std_logic := '1'; 30 architecture Behavioral of w5300_interface is 31 32 type state_type is ( 33 RESET_WIZ, 34 IDLE, 35 --READ_STATE, 36 READ_WAIT, 37 --WRITE_STATE, 38 WRITE_WAIT 39 -- ,CLEANUP 40 41 ); 42 signal state : state_type; 43 32 44 signal data_signal : std_logic_vector (15 DOWNTO 0) := (others => 'Z'); 33 45 signal addr_signal : std_logic_vector (9 DOWNTO 0) := (others => '0'); 34 46 47 signal read_sr : std_logic_vector (1 DOWNTO 0) := (others => '0'); 48 signal write_sr : std_logic_vector (1 DOWNTO 0) := (others => '0'); 35 49 36 50 -- this counter counts the time, the cs signal is low in units of 1/clk_period 37 51 -- since it is increased already in IDLE state, it really 38 52 signal wait_ctr : integer range 0 to 15 := 0; 53 signal RST_TIME : integer range 0 to 500000 := 500000; 54 55 signal reset_counter : integer range 0 to RST_TIME := 0; 56 signal ready : std_logic := '0'; 57 begin 39 58 59 main_process : process(clk) 60 begin 40 61 41 main_process: process(clk) 42 begin43 if rising_ _edge(clk) then62 ready_o <= ready and not write_i and not read_i; 63 64 if rising_edge(clk) then 44 65 -- synch in read & write commands 45 66 read_sr <= read_sr(0) & read_i; 46 67 write_sr <= write_sr(0) & write_i; 68 69 --synthesis translate_off 70 RST_TIME <= 288; 71 --synthesis translate_on 72 47 73 48 74 case state is … … 52 78 -- this is ensured by the IDLE state and a certain 'wait'-state and the end of each transmission. 53 79 when IDLE => 54 if (read_sr = "01" ) then 55 data_signal <= (others => 'Z'); 56 addr_sig <= addr_i; 57 wait_ctr <= wait_ctr + 1; 58 state <= READ_STATE; 59 elsif (write_sr = "01" ) then 60 data_signal <= data_i; 61 addr_sig <= addr_i; 62 wait_ctr <= wait_ctr + 1; 63 state <= WRITE_STATE; 80 cs <= '1'; 81 wr <= '1'; 82 rd <= '1'; 83 ready <= '1'; 84 85 86 if (read_i = '1' ) then 87 cs <= '0'; 88 wr <= '1'; 89 rd <= '0'; 90 ready <= '0'; 91 92 wiz_addr <= addr_i; 93 wiz_data <= (others => 'Z'); 94 state <= READ_WAIT; 95 96 elsif (write_i = '1' ) then 97 cs <= '0'; 98 wr <= '0'; 99 rd <= '1'; 100 ready <= '0'; 101 102 wiz_addr <= addr_i; 103 wiz_data <= data_i; 104 105 state <= WRITE_WAIT; 106 end if; 107 108 if (reset_i = '1') then 109 state <= RESET_WIZ; 64 110 end if; 65 111 66 when READ_STATE =>67 cs <= '0';68 wr <= '1';69 rd <= '0';70 wiz_addr <= addr_sig;71 wiz_data <= data_signal;72 wait_ctr <= wait_ctr + 1;73 state <= READ_WAIT;74 75 when WRITE_STATE =>76 cs <= '0';77 wr <= '0';78 rd <= '1';79 wiz_addr <= addr_sig;80 wiz_data <= data_signal;81 wait_ctr <= wait_ctr + 1;82 state <= WRITE_WAIT;83 112 -- when READ_STATE => 113 -- cs <= '0'; 114 -- wr <= '1'; 115 -- rd <= '0'; 116 -- wiz_addr <= addr_signal; 117 -- wiz_data <= data_signal; 118 -- wait_ctr <= wait_ctr + 1; 119 -- state <= READ_WAIT; 120 -- 121 -- when WRITE_STATE => 122 -- cs <= '0'; 123 -- wr <= '0'; 124 -- rd <= '1'; 125 -- wiz_addr <= addr_signal; 126 -- wiz_data <= data_signal; 127 -- wait_ctr <= wait_ctr + 1; 128 -- state <= WRITE_WAIT; 129 -- 84 130 -- actually WRITE ACCESS needs less time than READ access. 85 131 -- but in order to make an easy timed interface to this entity possible … … 88 134 89 135 when READ_WAIT => 136 wait_ctr <= wait_ctr + 1; 90 137 if (wait_ctr = TIME_UNTIL_READ_READY - 1) then 91 wait_ctr = 0; 92 data_signal <= wiz_data; 93 state <= CLEANUP; 138 cs <= '1'; 139 wr <= '1'; 140 rd <= '1'; 141 ready <= '1'; 142 143 wait_ctr <= 0; 144 data_o <= wiz_data; 145 146 state <= IDLE; 94 147 end if; 148 149 150 when WRITE_WAIT => 95 151 wait_ctr <= wait_ctr + 1; 152 if (wait_ctr = TIME_UNTIL_WRITE_READY - 1) then 153 cs <= '1'; 154 wr <= '1'; 155 rd <= '1'; 156 ready <= '1'; 157 158 wait_ctr <= 0; 159 data_o <= (others => 'Z'); 160 161 state <= IDLE; 162 end if; 96 163 97 when WRITE_WAIT98 if (wait_ctr = TIME_UNTIL_WRITE_READY - 1) then99 wait_ctr = 0;100 state <= CLEANUP;101 end if;102 wait_ctr <= wait_ctr + 1;103 164 104 when CLEANUP => 165 -- when CLEANUP => 166 -- ready <= '1'; 167 -- cs <= '1'; 168 -- wr <= '1'; 169 -- rd <= '1'; 170 -- data_o <= data_signal; 171 -- wiz_addr <= (others => 'Z'); 172 -- wiz_data <= (others => 'Z'); 173 -- state <= IDLE; 174 175 when RESET_WIZ => 176 ready <= '0'; 105 177 cs <= '1'; 106 178 wr <= '1'; 107 179 rd <= '1'; 108 data_o <= data_sigal; 109 wiz_addr <= (others => 'Z'); 110 wiz_data <= (others => 'Z'); 111 state <= IDLE; 180 181 reset_counter <= reset_counter + 1; 182 wiz_reset <= '0'; 183 if (reset_counter >= 100) then -- wait 2µs 184 wiz_reset <= '1'; 185 end if; 186 if (reset_counter >= RST_TIME -1) then -- wait 10ms 187 reset_counter <= 0; 188 189 state <= IDLE; 190 end if; 112 191 113 192 end case; … … 116 195 117 196 end process main_process; 197 198 end Behavioral;
Note:
See TracChangeset
for help on using the changeset viewer.