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 22

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

powered by: WebSVN 2.1.0

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