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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [eppwbm_width_extension.vhd] - Blame information for rev 52

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

powered by: WebSVN 2.1.0

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