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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [eppwbn_wbn_side.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 57 budinero
--| Version: 0.5
7 19 budinero
--| Tested in: Actel APA300
8 57 budinero
--| Tested in: Actel A3PE1500
9
--|   Board: RVI Prototype Board + LP Data Conversion Daughter Board
10 19 budinero
--|-------------------------------------------------------------------------------------------------
11
--| Description:
12 57 budinero
--|   EPP - Wishbone bridge. 
13
--|   This module is in the wishbone side (IEEE Std. 1284-2000).
14 19 budinero
--|-------------------------------------------------------------------------------------------------
15
--| File history:
16 57 budinero
--|   0.01  | nov-2008 | First release
17 19 budinero
--|   0.1   | jan-2009 | Sinc reset
18
--|   0.2   | feb-2009 | Some improvements
19 57 budinero
--|   0.5   | sep-2009 | New design, full sincronous
20 19 budinero
----------------------------------------------------------------------------------------------------
21 57 budinero
--| Copyright © 2008, Facundo Aguilera.
22 19 budinero
--|
23
--| This VHDL design file is an open design; you can redistribute it and/or
24
--| modify it and/or implement it after contacting the author.
25
----------------------------------------------------------------------------------------------------
26
 
27
 
28
 
29
library IEEE;
30
use IEEE.STD_LOGIC_1164.ALL;
31
 
32
 
33
entity eppwbn_wbn_side is
34 57 budinero
--   generic(
35
--     WAIT_DELAY : integer := 4  -- min value: 3
36
--   ); 
37
  port(
38
    inStrobe: in std_logic;                     --  HostClk/nWrite 
39
    iData: inout std_logic_vector (7 downto 0); --  AD8..1/AD8..1 (Data1..Data8)
40
    iBusy: out std_logic;                       --  PtrBusy/PeriphAck/nWait
41
    inAutoFd: in std_logic;                     --  HostBusy/HostAck/nDStrb
42
    inSelectIn: in std_logic;                   --  1284 Active/nAStrb
43
    RST_I: in std_logic;
44
    CLK_I: in std_logic;
45
    DAT_I: in std_logic_vector (7 downto 0);
46
    DAT_O: out std_logic_vector (7 downto 0);
47
    ADR_O: out std_logic_vector (7 downto 0);
48
    CYC_O: out std_logic;
49
    STB_O: out std_logic;
50
    ACK_I: in std_logic ;
51
    WE_O: out std_logic;
52 19 budinero
 
53 57 budinero
    rst_pp: in std_logic  -- reset from pp
54
  );
55 19 budinero
end eppwbn_wbn_side;
56
 
57 57 budinero
architecture bridge2 of eppwbn_wbn_side is
58 19 budinero
 
59 57 budinero
  type StateType is (
60
      ST_IDLE,
61
      ST_ADDR,
62
      ST_WRITING_D1,
63
      ST_WRITING_D2,
64
      ST_READING_D1,
65
      ST_READING_D2
66
      );
67
  signal next_state, present_state: StateType;
68 19 budinero
 
69 57 budinero
  signal nWrite: std_logic;
70
  signal nWait:  std_logic;
71
  signal nDStrb: std_logic;
72
  signal nAStrb: std_logic;
73
  signal strb_hist: std_logic_vector(4 downto 0);
74
  signal strb_ris: std_logic;
75
  signal strb_fall: std_logic;
76
  signal strb_wb: std_logic;
77
  signal ack_pp: std_logic;
78
 
79
  signal adr_reg, data_reg: std_logic_vector (7 downto 0); -- registros internos temporales
80
  --signal waiting: std_logic_vector(WAIT_DELAY-1 downto 0);
81
 
82 19 budinero
begin
83 57 budinero
 
84
  -- Equal
85
  nWrite <= inStrobe;
86
  nAStrb <= inSelectIn;
87
  nDStrb <= inAutoFd;
88
  iBusy  <= nWait;
89
 
90
  STB_O <= strb_wb;
91
  CYC_O <= strb_wb;
92
  ADR_O <= adr_reg;
93
  DAT_O <= data_reg;
94
 
95
  -- Thanks fpga4fun
96
  P_strobes: process(nAStrb, nDStrb, CLK_I, strb_hist, RST_I, rst_pp)
97
  begin
98
    if CLK_I 'event and CLK_I = '1' then
99
      if RST_I = '1' or rst_pp = '1' then
100
        strb_hist <= (others => '1' );
101
      else
102
        strb_hist <= strb_hist(3 downto 0) & (nAStrb and nDStrb); -- only one is zero at a time
103 19 budinero
      end if;
104 57 budinero
    end if;
105
  end process;
106
  strb_ris  <= '1' when strb_hist(4 downto 1) = "0111" else '0';
107
  strb_fall <= '1' when strb_hist(4 downto 1) = "0000" else '0';
108
 
109
 
110
  P_next_st: process(strb_ris, strb_fall, ACK_I, nAStrb, nDStrb, nWrite, present_state)
111
  begin
112
 
113
      case present_state is
114
        when ST_ADDR =>
115
          strb_wb <= '0';
116
          ack_pp <= '1';
117
          WE_O <= '0';
118
          -- >>> --
119
        if strb_ris = '1' then
120
          next_state <= ST_IDLE;
121
        else
122
          next_state <= present_state;
123
        end if;
124
 
125
      when ST_WRITING_D1 =>
126
        strb_wb <= '0';
127
        ack_pp <= '1';
128
        WE_O <= '0';
129
        -- >>> --
130
        if strb_ris = '1' then
131
          next_state <= ST_WRITING_D2;
132
        else
133
          next_state <= present_state;
134
        end if;
135
 
136
      when ST_WRITING_D2 =>
137
        strb_wb <= '1';
138
        ack_pp <= '0';
139
        WE_O <= '1';
140
        -- >>> --
141
        if ACK_I = '1' then
142
          next_state <= ST_IDLE;
143
        else
144
          next_state <= present_state;
145
        end if;
146
 
147
      when ST_READING_D1 =>
148
        strb_wb <= '1';
149
        ack_pp <= '0';
150
        WE_O <= '0';
151
        -- >>> --
152
        if strb_ris = '1' then
153
          next_state <= ST_IDLE;
154
        elsif ACK_I = '1' then
155
          next_state <= ST_READING_D2;
156
        else
157
          next_state <= present_state;
158
        end if;
159
 
160
      when ST_READING_D2 =>
161
        strb_wb <= '0';
162
        ack_pp <= '1';
163
        WE_O <= '0';
164
        -- >>> --
165
        if strb_ris = '1' then
166
          next_state <= ST_IDLE;
167
        else
168
          next_state <= present_state;
169
        end if;
170
 
171
      when others =>  -- ST_IDLE
172
        strb_wb <= '0';
173
        ack_pp <= '0';
174
        WE_O <= '0';
175
        -- >>> --
176
        if strb_fall = '1' then
177
          if    nWrite = '0' and nDStrb = '0' then
178
            next_state <= ST_WRITING_D1;
179
          elsif nWrite = '1' and nDStrb = '0' then
180
            next_state <= ST_READING_D1;
181
          elsif nAStrb = '0' then
182
            next_state <= ST_ADDR;
183
          else
184
            next_state <= present_state;
185
          end if;
186
        else
187
          next_state <= present_state;
188
        end if;
189
    end case;
190
  end process;
191
 
192
  P_act_st: process(CLK_I, RST_I, rst_pp, next_state, iData, DAT_I, present_state, nWrite)
193
  begin
194
    if (CLK_I'event and CLK_I='1') then
195
      if RST_I = '1' or rst_pp = '1' then
196
        present_state <= ST_IDLE;
197 19 budinero
        data_reg <= (others => '0');
198 57 budinero
        adr_reg <= (others => '0');
199 19 budinero
      else
200 57 budinero
        present_state <= next_state;
201
        case present_state is
202
          when ST_ADDR =>
203
            --if next_state = ST_IDLE and nWrite = '0' then
204
            if strb_hist(0) = '0' and nWrite = '0' then
205
              adr_reg <= iData;
206
            end if;
207
          when ST_WRITING_D1 =>
208
            --if next_state = ST_WRITING_D2 then
209
            if strb_hist(0) = '0' then
210
              data_reg <= iData;
211
            end if;
212
          when ST_READING_D1 =>
213
            if next_state = ST_READING_D2 then
214
              data_reg <= DAT_I;
215
            end if;
216
          when others =>
217
        end case;
218 19 budinero
      end if;
219 57 budinero
    end if;
220
  end process;
221
 
222
  nWait <= ack_pp;
223
 
224
  iData <= data_reg when (nWrite = '1' and nDStrb = '0' ) else
225
           adr_reg  when (nWrite = '1' and nAStrb = '0' ) else
226
           (others => 'Z');
227
 
228
--   P_delay: process(ack_pp, CLK_I, rst_pp, RST_I, waiting)
229
--   begin
230
--     if CLK_I'event and CLK_I = '1' then
231
--       if rst_pp = '1' or RST_I = '1' then
232
--         waiting <= (others => '0');
233
--       else 
234
--         waiting <= waiting(WAIT_DELAY-2 downto 0) & ack_pp;
235
--       end if;
236
--     end if;
237
--   end process;
238
 
239
 
240
end architecture bridge2;

powered by: WebSVN 2.1.0

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