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 15

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

powered by: WebSVN 2.1.0

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