Ignore:
Timestamp:
05/31/11 17:00:37 (13 years ago)
Author:
neise
Message:
- not yet tested; not yet simulated - 
w5300_modul2.vhd implements the new w5300_interface entity.

it is not really getting simpler, but maybe we are on a good way anyway.
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  
    182182
    183183
     184constant TIME_UNTIL_READ_READY : integer := 4;
     185constant 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
    184194end 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  
    33use IEEE.NUMERIC_STD.all;
    44
    5 ENTITY w5300_modul IS
    6   generic(
    7     TIME_UNTIL_READ_READY : integer := 4;
    8         TIME_UNTIL_READ_READY : integer := 4;
    9   );
     5library FACT_FAD_lib;
     6use FACT_FAD_lib.fad_definitions.ALL;
     7
     8ENTITY w5300_interface IS
    109PORT(
    1110        clk                                                     : IN    std_logic;                                              -- expecting 50MHz
     
    2423        data_o                                          : OUT   std_logic_vector (15 DOWNTO 0)  := (others => '0');
    2524        data_i                                          : IN    std_logic_vector (15 DOWNTO 0);
    26        
     25        ready_o                                         : OUT   std_logic := '0';
     26        reset_i                                         : IN    std_logic
    2727);
    28 END w5300_modul ;
     28END w5300_interface ;
    2929
    30 architecture Behavioral of w5300_modul is
    31         signal read_not_write_signal : std_logic := '1';
     30architecture 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
    3244        signal data_signal : std_logic_vector (15 DOWNTO 0) := (others => 'Z');
    3345        signal addr_signal : std_logic_vector (9 DOWNTO 0) := (others => '0');
    3446
     47    signal read_sr : std_logic_vector (1 DOWNTO 0) := (others => '0');
     48    signal write_sr : std_logic_vector (1 DOWNTO 0) := (others => '0');
    3549       
    3650        -- this counter counts the time, the cs signal is low in units of 1/clk_period
    3751        -- since it is increased already in IDLE state, it really
    3852        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';
     57begin
    3958       
     59main_process : process(clk)
     60        begin
    4061       
    41 main_process: process(clk)
    42         begin
    43         if rising__edge(clk) then
     62        ready_o <= ready and not write_i and not read_i;
     63       
     64        if rising_edge(clk) then
    4465                -- synch in read & write commands
    4566                read_sr         <= read_sr(0)   & read_i;
    4667                write_sr        <= write_sr(0)  & write_i;
     68
     69                --synthesis translate_off
     70                RST_TIME <= 288;
     71                --synthesis translate_on
     72
    4773
    4874                case state is
     
    5278                        -- this is ensured by the IDLE state and a certain 'wait'-state and the end of each transmission.
    5379                        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;
    64110                                end if;
    65111                       
    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--
    84130                        -- actually WRITE ACCESS needs less time than READ access.
    85131                        -- but in order to make an easy timed interface to this entity possible
     
    88134                       
    89135                        when READ_WAIT =>
     136                                wait_ctr <= wait_ctr + 1;
    90137                                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;
    94147                                end if;
     148                               
     149                               
     150                        when WRITE_WAIT =>
    95151                                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;
    96163                               
    97                         when WRITE_WAIT
    98                                 if (wait_ctr = TIME_UNTIL_WRITE_READY - 1) then
    99                                         wait_ctr = 0;
    100                                         state <= CLEANUP;
    101                                 end if;
    102                                 wait_ctr <= wait_ctr + 1;
    103164                       
    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';
    105177                                cs <= '1';
    106178                                wr <= '1';
    107179                                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;                         
    112191                               
    113192                        end case;
     
    116195                                               
    117196end process main_process;
     197
     198end Behavioral;
Note: See TracChangeset for help on using the changeset viewer.