OpenCores
URL https://opencores.org/ocsvn/modular_oscilloscope/modular_oscilloscope/trunk

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [eppwbn_ctrl.vhd] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 budinero
----------------------------------------------------------------------------------------------------
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: eppwbn_wbn_side.vhd
6
--| Version: 0.21
7
--| Tested in: Actel APA300
8
--|-------------------------------------------------------------------------------------------------
9
--| Description:
10
--|     EPP - Wishbone bridge. 
11
--|       This module controls the negotiation (IEEE Std. 1284-2000).
12
--|   This can be easily modified to control other modes besides the EPP.
13
--|-------------------------------------------------------------------------------------------------
14
--| File history:
15
--|     0.01    | nov-2008 | First testing release
16
--|   0.20  | dic-2008 | Custom signals without tri-state
17
--|   0.21  | jan-2009 | Sinc reset
18
----------------------------------------------------------------------------------------------------
19 41 budinero
--| Copyright © 2008, Facundo Aguilera.
20 19 budinero
--|
21
--| This VHDL design file is an open design; you can redistribute it and/or
22
--| modify it and/or implement it after contacting the author.
23
----------------------------------------------------------------------------------------------------
24
 
25
 
26
library IEEE;
27
use IEEE.STD_LOGIC_1164.ALL;
28
 
29
entity eppwbn_ctrl is
30
port(
31
 
32
        -- salida al puerto epp
33
  nStrobe: in std_logic;                  -- Nomenclatura IEEE Std. 1284-2000, 
34
                                          -- Negotiation/ECP/EPP (Compatibiliy) 
35
                                                                                                                  -- HostClk/nWrite 
36
        Data: in std_logic_vector (7 downto 0); -- AD8..1/AD8..1 (Data1..Data8)
37
        nAck: out std_logic;                    -- PtrClk/PeriphClk/Intr
38
        -- Busy: out std_logic;                 -- PtrBusy/PeriphAck/nWait
39
        PError: out std_logic;                  -- AckData/nAckReverse
40
        Sel: out std_logic;                     -- XFlag (Select). Select no puede usarse
41
        nAutoFd: in std_logic;                  -- HostBusy/HostAck/nDStrb
42
        PeriphLogicH: out std_logic;            -- (Periph Logic High)
43
        nInit: in std_logic;                    -- nReverseRequest
44
        nFault: out std_logic;                  -- nDataAvail/nPeriphRequest
45
        nSelectIn: in std_logic;                -- 1284 Active/nAStrb
46
        -- HostLogicH: in std_logic;            -- (Host Logic High)
47
 
48 41 budinero
 
49 19 budinero
        -- salida a la interface wishbone
50
        RST_I: in std_logic;
51
        CLK_I: in std_logic;
52
 
53
        -- señales internas
54
  rst_pp: out std_logic;  -- generador de reset desde la interfaz del puerto paralelo
55
        epp_mode: out std_logic_vector (1 downto 0) -- indicador de modo de comunicaci?n epp
56
      -- "00" deshabilitado
57
      -- "01" inicial (se?ales de usuario e interrupciones deshabilitadas)
58
      -- "10" sin definir
59
      -- "11" modo EPP normal
60
);
61
end entity eppwbn_ctrl;
62
 
63
 
64
architecture state_machines of eppwbn_ctrl is
65 41 budinero
  type StateType is (
66 19 budinero
          st_compatibility_idle,  -- Los estados corresponden a los especificados
67
          st_negotiation2,        --  por el est?ndar.
68
                                  -- Los n?meros de los estados negotiation corresponden 
69
                                  --  a las fases del est?ndar.
70
          st_initial_epp,
71
          st_epp_mode
72 41 budinero
          -- otros modos
73 19 budinero
          );
74 41 budinero
  signal next_state, present_state: StateType;
75
  signal ext_req_val: std_logic_vector (7 downto 0);
76 19 budinero
begin
77
 
78
  ----------------------------------------------------------------------------------------
79
  -- generación de señal de reset para otros módulos y señal de encendido hacia el host
80
  rst_pp <= not(nInit); -- (nInit = '0') and (nSelectIn = '0');
81
 
82
  PeriphLogicH <= '1';
83
 
84
  ----------------------------------------------------------------------------------------
85
  -- almacenamiento de Extensibility Request Value (asíncrono)
86
  P_data_store: process(nStrobe, present_state, Data, RST_I, nInit, nSelectIn)
87
  begin
88
    if (RST_I = '1' or (nInit = '0' and nSelectIn = '0')) then
89
      ext_req_val <= (others => '0');
90 57 budinero
    elsif nStrobe = '1' then
91
      if present_state = st_negotiation2 then
92
        ext_req_val <= Data;
93
      end if;
94
--     else
95
--       ext_req_val <= ext_req_val;
96 19 budinero
    end if;
97
  end process P_data_store;
98
 
99
  ----------------------------------------------------------------------------------------
100
  -- estado siguiente
101
  P_state_comb: process(present_state, next_state, RST_I, nSelectIn, nAutoFd, ext_req_val, nInit, nStrobe) begin
102
 
103
    if RST_I = '1' then
104
      PError <= '0';
105
          nFault <= '1';
106
          Sel <= '1';
107
          nAck <= '1';
108
 
109
          epp_mode <= "00";
110
 
111
      next_state <= st_compatibility_idle;
112
    else
113
      case present_state is
114
 
115
        when st_compatibility_idle =>
116
          PError <= '0';
117
          nFault <= '1';
118
          Sel <= '1';
119
          nAck <= '1';
120
 
121
          epp_mode <= "00";
122
 
123
          -- verificación de compatibilidad con 1284
124
          if (nAutoFd = '0' and  nSelectIn = '1') then
125
            next_state <= st_negotiation2;
126
          else
127
            next_state <= st_compatibility_idle;
128
          end if;
129
 
130
        when st_negotiation2 =>
131
          PError <= '1';
132
          nFault <= '1';
133
          Sel <= '1';
134
          nAck <= '0';
135
 
136
          epp_mode <= "00";
137
 
138
          -- Respuesta según modo solicitado
139
          if (nStrobe = '1' and
140
              nAutoFd = '1') then
141
            if (ext_req_val = "01000000") then
142
              next_state <= st_initial_epp;
143
 
144
            -- Otros modos
145
 
146
            else
147
              next_state <= st_compatibility_idle;
148
            end if;
149
          else
150
            next_state <= st_negotiation2;
151
          end if;
152
 
153
        when st_initial_epp =>
154
          Sel <= '1';
155
          PError <= '1';
156
          nFault <= '1';
157
          nAck <= '1';
158
 
159
          epp_mode <= "01";
160
 
161
 
162
          -- Finalizacón del modo EPP o cambio a EPP idle
163
          if nInit = '0' then
164
            next_state <= st_compatibility_idle;
165
          elsif (nSelectIn = '0' or nAutoFd = '0') then
166
            next_state <= st_epp_mode;
167
          else
168
            next_state <= st_initial_epp;
169
          end if;
170
 
171
        when st_epp_mode =>
172
          Sel <= '0';     -- El bus debe asegurar que se puedan usar
173
          PError <= '0';  --  las señales definidas por el usuario en el módulo 
174
          nFault <= '0';  --  EPP.
175
          nAck <= '0';
176
 
177
          epp_mode <= "11";
178
 
179
          -- Finalización del modo EPP
180
          if nInit = '0' then
181
            next_state <= st_compatibility_idle;
182
          else
183
            next_state <= st_epp_mode;
184
          end if;
185
                  -- Se sale de este estado en forma asíncrona ya que esta acción
186
      end case;   --  no tiene handshake.
187
    end if;
188
 
189
  end process P_state_comb;
190
 
191
 
192
 
193
  ----------------------------------------------------------------------------------------
194
  -- estado actual
195 22 budinero
  P_state_clocked: process(CLK_I, nInit, nSelectIn) begin
196 19 budinero
    -- if (nInit = '0' and nSelectIn = '0') or RST_I = '1' then
197
      -- present_state <= st_compatibility_idle;
198
    -- elsif present_state = st_epp_mode and nInit = '0' then
199
      -- present_state <= st_compatibility_idle;
200
    -- elsif (CLK_I'event and CLK_I='1') then
201
      -- present_state <= next_state;
202
    -- end if;  
203
 
204
 
205 22 budinero
    if (nInit = '0' and nSelectIn = '0') then
206 19 budinero
      present_state <= st_compatibility_idle;
207
    elsif (CLK_I'event and CLK_I='1') then
208
      present_state <= next_state;
209
    end if;
210
  end process P_state_clocked;
211
 
212 9 budinero
end architecture state_machines;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.