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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [memory/] [dual_port_memory_wb.vhd] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5
--| File: dual_port_memory_wb.vhd
6
--| Version: 0.1
7
--| Tested in: Actel A3PE1500
8
--|-------------------------------------------------------------------------------------------------
9
--| Description:
10
--|   MEMORY - Dual Port Memory Wishbone Interface
11
--|   An interface designed for a dual port memory generated by Actel SmartGen tool. It may not work 
12
--|   with other than ProASIC3 Family FPGA.
13
--|   
14
--|-------------------------------------------------------------------------------------------------
15
--| File history:
16
--|   0.1   | jun-2009 | First testing
17 54 budinero
--|   0.11  | aug-2009 | Corrected error in ACK_O from port B
18 27 budinero
----------------------------------------------------------------------------------------------------
19 40 budinero
--| Copyright © 2009, Facundo Aguilera.
20 27 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
--| Wishbone Rev. B.3 compatible
25
----------------------------------------------------------------------------------------------------
26
 
27 40 budinero
-- La memoria solo puede accederse desde la dirección 0 hasta la 15360 (0011 11000 0000 0000). No 
28
-- están especificados los valores obtenidos fuera de ese rango. 
29 27 budinero
 
30
 
31
library ieee;
32
use ieee.std_logic_1164.all;
33
 
34
entity dual_port_memory_wb is
35
        port(
36
                -- Puerto A (Higer prioriry)
37
                RST_I_a: in std_logic;
38
                CLK_I_a: in std_logic;
39
                DAT_I_a: in std_logic_vector (15 downto 0);
40
                DAT_O_a: out std_logic_vector (15 downto 0);
41
                ADR_I_a: in std_logic_vector (13 downto 0);
42
                CYC_I_a: in std_logic;
43
                STB_I_a: in std_logic;
44
                ACK_O_a: out std_logic ;
45
                WE_I_a: in std_logic;
46
 
47
 
48
    -- Puerto B (Lower prioriry)
49
                RST_I_b: in std_logic;
50
                CLK_I_b: in std_logic;
51
                DAT_I_b: in std_logic_vector (15 downto 0);
52
                DAT_O_b: out std_logic_vector (15 downto 0);
53
                ADR_I_b: in std_logic_vector (13 downto 0);
54
                CYC_I_b: in std_logic;
55
                STB_I_b: in std_logic;
56
                ACK_O_b: out std_logic ;
57
                WE_I_b: in std_logic
58
        );
59
end entity dual_port_memory_wb;
60
 
61
 
62
 
63
architecture arch01  of dual_port_memory_wb is
64
        ---- Componentes ----
65
  component dual_port_memory is
66
    port(
67
      DINA:   in    std_logic_vector(15 downto 0);
68
      DOUTA:  out   std_logic_vector(15 downto 0);
69
      ADDRA:  in    std_logic_vector(13 downto 0);  -- Only available up to 15360 (11110000000000)
70
      RWA:    in    std_logic;                      -- '1' Read, '0' Write
71
      BLKA:   in    std_logic;                      -- '1' Block select
72
      CLKA:   in    std_logic;                      -- Rising edge
73
 
74
      DINB:   in    std_logic_vector(15 downto 0);
75
      DOUTB:  out   std_logic_vector(15 downto 0);
76
      ADDRB:  in    std_logic_vector(13 downto 0);
77
      RWB:    in    std_logic;
78
      BLKB:   in    std_logic;
79
      CLKB:   in    std_logic;
80
 
81
      RESET:  in    std_logic                       -- '1' Reset
82
    ) ;
83
 
84
        end component dual_port_memory;
85
 
86
  ---- Señales ----
87
        signal RST_I_common: std_logic;
88
  signal enable_BLK, to_BLKB, to_BLKA : std_logic;
89
  signal pre_ACK_O_a_read, pre_ACK_O_a_write: std_logic;
90
  signal pre_ACK_O_b_read, pre_ACK_O_b_write: std_logic;
91
  signal to_RWB, to_RWA: std_logic; -- para entradas negadas
92
 
93
 
94
begin
95
 
96
  RST_I_common <= RST_I_b or RST_I_a;
97
 
98
 
99
  -- Corrección de escritura en la misma dirección
100
  to_BLKB <= CYC_I_b and STB_I_b and enable_BLK;
101
  to_BLKA <= CYC_I_a and STB_I_a;
102
 
103 54 budinero
  enable_BLK <= '1' when ADR_I_a /= ADR_I_b or to_BLKA = '0' else
104 27 budinero
                '0';
105
 
106
 
107
  -- Solución de ACK en puerto A
108
  ACK_O_a <= pre_ACK_O_a_write or pre_ACK_O_a_read;
109
  pre_ACK_O_a_write <= STB_I_a and CYC_I_a and WE_I_a;
110
    -- la primera respuesta para el ciclo de lectura debe retrasarse un ciclo
111
  P_ACK_a_resolution: process (STB_I_a, CYC_I_a, RST_I_a, CLK_I_a, WE_I_a)
112
  begin
113
    if STB_I_a = '0' or CYC_I_a = '0' then
114
      pre_ACK_O_a_read <= '0';
115
    elsif CLK_I_a'event and CLK_I_a = '1' then
116
      if RST_I_a = '1' then
117
        pre_ACK_O_a_read <= '0';
118
      elsif STB_I_a = '1' and CYC_I_a = '1' and WE_I_a = '0' then
119
        pre_ACK_O_a_read <= '1';
120
      end if;
121
    end if;
122
  end process;
123
 
124
   -- Solución de ACK en puerto B
125
  ACK_O_b <= (pre_ACK_O_b_write or pre_ACK_O_b_read) and enable_BLK;
126
  pre_ACK_O_b_write <= STB_I_b and CYC_I_b and WE_I_b;
127
    -- la primera respuesta para el ciclo de lectura debe retrasarse un ciclo
128
  P_ACK_b_resolution: process (STB_I_b, CYC_I_b, RST_I_b, CLK_I_b)
129
  begin
130
    if STB_I_b = '0' or CYC_I_b = '0' then
131
      pre_ACK_O_b_read <= '0';
132
    elsif CLK_I_b'event and CLK_I_b = '1' then
133
      if RST_I_b = '1' then
134
        pre_ACK_O_b_read <= '0';
135
      elsif STB_I_b = '1' and CYC_I_b = '1' and WE_I_b = '0'  then
136
        pre_ACK_O_b_read <= '1';
137
      end if;
138
    end if;
139
  end process;
140
 
141
 
142
  -- Instancia
143
  to_RWA <= not(WE_I_a);
144
  to_RWB <= not(WE_I_b);
145
        MEM: dual_port_memory port map (
146
                        DINA => DAT_I_a,
147
                        DOUTA => DAT_O_a,
148
                        ADDRA => ADR_I_a,
149
                        RWA => to_RWA,
150
                        BLKA => to_BLKA,
151
                        CLKA => CLK_I_a,
152
 
153
                        DINB => DAT_I_b,
154
                        DOUTB => DAT_O_b,
155
                        ADDRB => ADR_I_b,
156
                        RWB => to_RWB,
157
                        BLKB => to_BLKB,
158
                        CLKB => CLK_I_b,
159
 
160
                        RESET => RST_I_common
161
        );
162
 
163
 
164
end architecture;

powered by: WebSVN 2.1.0

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