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 42

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