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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [eppwbn_width_extension.vhd] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 57 budinero
-------------------------------------------------------------------------------------------------100
2 19 budinero
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| Version: 0.01
6
--| Tested in: Actel APA300
7 57 budinero
--| Tested in: Actel A3PE1500
8
--|   Board: RVI Prototype Board + LP Data Conversion Daughter Board
9 19 budinero
--|-------------------------------------------------------------------------------------------------
10
--| Description:
11
--|     EPP - Wishbone bridge. 
12
--|       Convert 8 to 16 bits width data bus
13
--|-------------------------------------------------------------------------------------------------
14
--| File history:
15
--|   0.01  | mar-2009 | First release
16
----------------------------------------------------------------------------------------------------
17 57 budinero
--| Copyright © 2008, Facundo Aguilera.
18 19 budinero
--|
19
--| This VHDL design file is an open design; you can redistribute it and/or
20
--| modify it and/or implement it after contacting the author.
21
 
22
--| Wishbone Rev. B.3 compatible
23
----------------------------------------------------------------------------------------------------
24
 
25
 
26 57 budinero
 
27
 
28 19 budinero
-- COMO USAR:
29
-- Puente entre un bus de datos de 8 bit (esclavo) y otro de 16 bit (maestro). cada dos acciones del
30
-- lado de 8 bit realiza una en en lado de 16. Posee un timer configurable con el que vuelve al 
31
-- estado inicial luego de sierto tiempo (ningun byte leido). También vuelve al estado inicial al 
32
-- hacer un cambio de dirección, por lo que puede realizarse una sincronización inicial haciendo un
33
-- cambio de dirección de escritura.
34
 
35
 
36
library IEEE;
37
use IEEE.STD_LOGIC_1164.all;
38
use IEEE.STD_LOGIC_ARITH.all;
39
use ieee.std_logic_unsigned.all;
40
use IEEE.numeric_std.all;
41 22 budinero
use work.eppwbn_pkg.all;
42 19 budinero
 
43
entity eppwbn_width_extension is
44
  generic (
45 57 budinero
    TIME_OUT_VALUE: integer  := 512;
46
    TIME_OUT_WIDTH: integer  := 9
47 19 budinero
  );
48
  port(
49
    -- Slave signals
50
    DAT_I_sl: in  std_logic_vector (7 downto 0);
51
    DAT_O_sl: out std_logic_vector (7 downto 0);
52
    ADR_I_sl: in  std_logic_vector (7 downto 0);
53
    CYC_I_sl: in  std_logic;
54
    STB_I_sl: in  std_logic;
55
    ACK_O_sl: out std_logic ;
56
    WE_I_sl:  in  std_logic;
57
 
58
 
59
    --  Master signals
60
    DAT_I_ma: in  std_logic_vector (15 downto 0);
61
    DAT_O_ma: out std_logic_vector (15 downto 0);
62
    ADR_O_ma: out std_logic_vector (7 downto 0);
63
    CYC_O_ma: out std_logic;
64
    STB_O_ma: out std_logic;
65
    ACK_I_ma: in  std_logic ;
66
    WE_O_ma:  out std_logic;
67
 
68
    -- Common signals
69
    RST_I: in std_logic;
70
    CLK_I: in std_logic
71
  );
72
end entity eppwbn_width_extension;
73
 
74
 
75
architecture arch_0 of eppwbn_width_extension is
76
  type StateType is (
77
          st_low,
78
          st_high
79
          );
80
        signal next_state, present_state: StateType;
81
 
82
  signal dat_reg, adr_reg: std_logic_vector (7 downto 0);  -- Almacena temporalmente las entradas
83
  signal timer, time_out_ref: std_logic_vector (TIME_OUT_WIDTH - 1 downto 0);
84
 
85
begin
86
 
87
  ADR_O_ma <= ADR_I_sl;
88
  time_out_ref <= conv_std_logic_vector(TIME_OUT_VALUE, TIME_OUT_WIDTH);
89
 
90
  P_state_comb: process(DAT_I_sl,CYC_I_sl,STB_I_sl,WE_I_sl,ACK_I_ma,present_state,ADR_I_sl,
91
                        DAT_I_ma,dat_reg,adr_reg,timer,time_out_ref)
92
  begin
93
 
94
    case present_state is
95
 
96
      -- Escritura: Señales de hadshake provistas por el módulo. Se guarda byte bajo.
97
      -- Lectura: Señales de hadshake provistas por fuente. Se guarda byte alto.
98
      when st_low =>
99
        WE_O_ma <= '0';
100
        DAT_O_ma <= (others => '0');
101
        DAT_O_sl <= DAT_I_ma(7 downto 0);
102
        if WE_I_sl = '1' then
103
          CYC_O_ma <= '0'; -- Esperar hasta recibir el proximo byte
104
          STB_O_ma <= '0';
105
          ACK_O_sl <= CYC_I_sl and STB_I_sl; -- Genera autorespuesta
106
        else
107
          CYC_O_ma <= CYC_I_sl;
108
          STB_O_ma <= STB_I_sl;
109
          ACK_O_sl <= ACK_I_ma;
110
        end if;
111
 
112
 
113
 
114
        if (CYC_I_sl = '1' and STB_I_sl = '1') and (WE_I_sl = '1' or ACK_I_ma = '1') then
115
          next_state <= st_high;
116
        else
117
          next_state <= st_low;
118
        end if;
119
 
120
      -- Escritura: Señales de hadshake provistas por fuentepor el módulo. 
121
      -- Lectura: Señales de hadshake provistas por el módulo. 
122
      when others =>
123
        WE_O_ma <= WE_I_sl;
124
        DAT_O_ma <= DAT_I_sl & dat_reg;
125
        DAT_O_sl <= dat_reg;
126
        if adr_reg = ADR_I_sl then
127
          if WE_I_sl = '1' then
128
            CYC_O_ma <= CYC_I_sl; -- Usa señales de la fuente
129
            STB_O_ma <= STB_I_sl;
130
            ACK_O_sl <= ACK_I_ma;
131
          else
132
            CYC_O_ma <= '0';
133
            STB_O_ma <= '0';
134
            ACK_O_sl <= CYC_I_sl and STB_I_sl; -- Genera autorespuesta
135
          end if;
136
        else
137
          CYC_O_ma <= '0';
138
          STB_O_ma <= '0';
139
          ACK_O_sl <= '0';
140
        end if;
141
 
142 57 budinero
        if  ( (CYC_I_sl = '1' and STB_I_sl = '1' ) and (WE_I_sl /= '1' or ACK_I_ma = '1' ) )
143
        or ( (CYC_I_sl = '1' and STB_I_sl = '1' ) and (ADR_I_sl /= adr_reg) )
144 19 budinero
        or (timer >= time_out_ref) then
145
          next_state <= st_low;
146
        else
147
          next_state <= st_high;
148
        end if;
149
    end case;
150
 
151
  end process;
152
 
153
 
154
  P_state_clocked: process(RST_I,CLK_I,next_state,timer)
155
  begin
156
    if RST_I = '1' then
157
      present_state <= st_low;
158
 
159
      timer <= (others => '0');
160
      dat_reg <= (others => '0');
161
      adr_reg <= (others => '0');
162
    elsif CLK_I'event and CLK_I = '1' then
163
      -- Resgistrar los valores si va a cambir al estado st_high
164
      if next_state = st_high and present_state = st_low then
165
        adr_reg <= ADR_I_sl;
166
        if WE_I_sl = '1' then
167
          dat_reg <= DAT_I_sl; -- Guarda byte bajo
168
        else
169
          dat_reg <= DAT_I_ma(15 downto 8);
170
        end if;
171
      end if;
172
 
173
      -- Configuración del timer
174
      if present_state = st_high then
175
        timer <= timer + 1;
176
      else
177
        timer <= (others => '0');
178
      end if;
179
 
180
      -- Cambio de estado
181
      present_state <= next_state;
182
    end if;
183
  end process;
184
 
185
end architecture arch_0;

powered by: WebSVN 2.1.0

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