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 10

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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