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 21

Go to most recent revision | 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
--| Copyright ® 2008, Facundo Aguilera.
20
--|
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
        -- i indica misma señal de salida al puerto, aunque interna en el core y controlada por el bloque de control
48
 
49
        -- 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
        type StateType is (
66
          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
                                        -- otros modos
73
          );
74
        signal next_state, present_state: StateType;
75
        signal ext_req_val: std_logic_vector (7 downto 0);
76
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
    elsif (present_state = st_negotiation2 and nStrobe = '0') then
91
      ext_req_val <= Data;
92
    end if;
93
  end process P_data_store;
94
 
95
  ----------------------------------------------------------------------------------------
96
  -- estado siguiente
97
  P_state_comb: process(present_state, next_state, RST_I, nSelectIn, nAutoFd, ext_req_val, nInit, nStrobe) begin
98
 
99
    if RST_I = '1' then
100
      PError <= '0';
101
          nFault <= '1';
102
          Sel <= '1';
103
          nAck <= '1';
104
 
105
          epp_mode <= "00";
106
 
107
      next_state <= st_compatibility_idle;
108
    else
109
      case present_state is
110
 
111
        when st_compatibility_idle =>
112
          PError <= '0';
113
          nFault <= '1';
114
          Sel <= '1';
115
          nAck <= '1';
116
 
117
          epp_mode <= "00";
118
 
119
          -- verificación de compatibilidad con 1284
120
          if (nAutoFd = '0' and  nSelectIn = '1') then
121
            next_state <= st_negotiation2;
122
          else
123
            next_state <= st_compatibility_idle;
124
          end if;
125
 
126
        when st_negotiation2 =>
127
          PError <= '1';
128
          nFault <= '1';
129
          Sel <= '1';
130
          nAck <= '0';
131
 
132
          epp_mode <= "00";
133
 
134
          -- Respuesta según modo solicitado
135
          if (nStrobe = '1' and
136
              nAutoFd = '1') then
137
            if (ext_req_val = "01000000") then
138
              next_state <= st_initial_epp;
139
 
140
            -- Otros modos
141
 
142
            else
143
              next_state <= st_compatibility_idle;
144
            end if;
145
          else
146
            next_state <= st_negotiation2;
147
          end if;
148
 
149
        when st_initial_epp =>
150
          Sel <= '1';
151
          PError <= '1';
152
          nFault <= '1';
153
          nAck <= '1';
154
 
155
          epp_mode <= "01";
156
 
157
 
158
          -- Finalizacón del modo EPP o cambio a EPP idle
159
          if nInit = '0' then
160
            next_state <= st_compatibility_idle;
161
          elsif (nSelectIn = '0' or nAutoFd = '0') then
162
            next_state <= st_epp_mode;
163
          else
164
            next_state <= st_initial_epp;
165
          end if;
166
 
167
        when st_epp_mode =>
168
          Sel <= '0';     -- El bus debe asegurar que se puedan usar
169
          PError <= '0';  --  las señales definidas por el usuario en el módulo 
170
          nFault <= '0';  --  EPP.
171
          nAck <= '0';
172
 
173
          epp_mode <= "11";
174
 
175
          -- Finalización del modo EPP
176
          if nInit = '0' then
177
            next_state <= st_compatibility_idle;
178
          else
179
            next_state <= st_epp_mode;
180
          end if;
181
                  -- Se sale de este estado en forma asíncrona ya que esta acción
182
      end case;   --  no tiene handshake.
183
    end if;
184
 
185
  end process P_state_comb;
186
 
187
 
188
 
189
  ----------------------------------------------------------------------------------------
190
  -- estado actual
191
  P_state_clocked: process(CLK_I, nInit, nSelectIn,RST_I) begin
192
    -- if (nInit = '0' and nSelectIn = '0') or RST_I = '1' then
193
      -- present_state <= st_compatibility_idle;
194
    -- elsif present_state = st_epp_mode and nInit = '0' then
195
      -- present_state <= st_compatibility_idle;
196
    -- elsif (CLK_I'event and CLK_I='1') then
197
      -- present_state <= next_state;
198
    -- end if;  
199
 
200
 
201
    if (nInit = '0' and nSelectIn = '0') or RST_I = '1' then
202
      present_state <= st_compatibility_idle;
203
    elsif (CLK_I'event and CLK_I='1') then
204
      present_state <= next_state;
205
    end if;
206
  end process P_state_clocked;
207
 
208 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.