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 |
|
|
----------------------------------------------------------------------------------------------------
|
18 |
|
|
--| Copyright ® 2009, Facundo Aguilera.
|
19 |
|
|
--|
|
20 |
|
|
--| This VHDL design file is an open design; you can redistribute it and/or
|
21 |
|
|
--| modify it and/or implement it after contacting the author.
|
22 |
|
|
|
23 |
|
|
--| Wishbone Rev. B.3 compatible
|
24 |
|
|
----------------------------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- La memoria solo puede accederse desde la dirección 0 hasta la 15360 (11110000000000). No están
|
27 |
|
|
-- especificados los valores obtenidos fuera de ese rango.
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
library ieee;
|
31 |
|
|
use ieee.std_logic_1164.all;
|
32 |
|
|
|
33 |
|
|
entity dual_port_memory_wb is
|
34 |
|
|
port(
|
35 |
|
|
-- Puerto A (Higer prioriry)
|
36 |
|
|
RST_I_a: in std_logic;
|
37 |
|
|
CLK_I_a: in std_logic;
|
38 |
|
|
DAT_I_a: in std_logic_vector (15 downto 0);
|
39 |
|
|
DAT_O_a: out std_logic_vector (15 downto 0);
|
40 |
|
|
ADR_I_a: in std_logic_vector (13 downto 0);
|
41 |
|
|
CYC_I_a: in std_logic;
|
42 |
|
|
STB_I_a: in std_logic;
|
43 |
|
|
ACK_O_a: out std_logic ;
|
44 |
|
|
WE_I_a: in std_logic;
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
-- Puerto B (Lower prioriry)
|
48 |
|
|
RST_I_b: in std_logic;
|
49 |
|
|
CLK_I_b: in std_logic;
|
50 |
|
|
DAT_I_b: in std_logic_vector (15 downto 0);
|
51 |
|
|
DAT_O_b: out std_logic_vector (15 downto 0);
|
52 |
|
|
ADR_I_b: in std_logic_vector (13 downto 0);
|
53 |
|
|
CYC_I_b: in std_logic;
|
54 |
|
|
STB_I_b: in std_logic;
|
55 |
|
|
ACK_O_b: out std_logic ;
|
56 |
|
|
WE_I_b: in std_logic
|
57 |
|
|
);
|
58 |
|
|
end entity dual_port_memory_wb;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
architecture arch01 of dual_port_memory_wb is
|
63 |
|
|
---- Componentes ----
|
64 |
|
|
component dual_port_memory is
|
65 |
|
|
port(
|
66 |
|
|
DINA: in std_logic_vector(15 downto 0);
|
67 |
|
|
DOUTA: out std_logic_vector(15 downto 0);
|
68 |
|
|
ADDRA: in std_logic_vector(13 downto 0); -- Only available up to 15360 (11110000000000)
|
69 |
|
|
RWA: in std_logic; -- '1' Read, '0' Write
|
70 |
|
|
BLKA: in std_logic; -- '1' Block select
|
71 |
|
|
CLKA: in std_logic; -- Rising edge
|
72 |
|
|
|
73 |
|
|
DINB: in std_logic_vector(15 downto 0);
|
74 |
|
|
DOUTB: out std_logic_vector(15 downto 0);
|
75 |
|
|
ADDRB: in std_logic_vector(13 downto 0);
|
76 |
|
|
RWB: in std_logic;
|
77 |
|
|
BLKB: in std_logic;
|
78 |
|
|
CLKB: in std_logic;
|
79 |
|
|
|
80 |
|
|
RESET: in std_logic -- '1' Reset
|
81 |
|
|
) ;
|
82 |
|
|
|
83 |
|
|
end component dual_port_memory;
|
84 |
|
|
|
85 |
|
|
---- Señales ----
|
86 |
|
|
signal RST_I_common: std_logic;
|
87 |
|
|
signal enable_BLK, to_BLKB, to_BLKA : std_logic;
|
88 |
|
|
signal pre_ACK_O_a_read, pre_ACK_O_a_write: std_logic;
|
89 |
|
|
signal pre_ACK_O_b_read, pre_ACK_O_b_write: std_logic;
|
90 |
|
|
signal to_RWB, to_RWA: std_logic; -- para entradas negadas
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
begin
|
94 |
|
|
|
95 |
|
|
RST_I_common <= RST_I_b or RST_I_a;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
-- Corrección de escritura en la misma dirección
|
99 |
|
|
to_BLKB <= CYC_I_b and STB_I_b and enable_BLK;
|
100 |
|
|
to_BLKA <= CYC_I_a and STB_I_a;
|
101 |
|
|
|
102 |
|
|
enable_BLK <= '1' when ADR_I_a /= ADR_I_b and to_BLKA = '0' else
|
103 |
|
|
'0';
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
-- Solución de ACK en puerto A
|
107 |
|
|
ACK_O_a <= pre_ACK_O_a_write or pre_ACK_O_a_read;
|
108 |
|
|
pre_ACK_O_a_write <= STB_I_a and CYC_I_a and WE_I_a;
|
109 |
|
|
-- la primera respuesta para el ciclo de lectura debe retrasarse un ciclo
|
110 |
|
|
P_ACK_a_resolution: process (STB_I_a, CYC_I_a, RST_I_a, CLK_I_a, WE_I_a)
|
111 |
|
|
begin
|
112 |
|
|
if STB_I_a = '0' or CYC_I_a = '0' then
|
113 |
|
|
pre_ACK_O_a_read <= '0';
|
114 |
|
|
elsif CLK_I_a'event and CLK_I_a = '1' then
|
115 |
|
|
if RST_I_a = '1' then
|
116 |
|
|
pre_ACK_O_a_read <= '0';
|
117 |
|
|
elsif STB_I_a = '1' and CYC_I_a = '1' and WE_I_a = '0' then
|
118 |
|
|
pre_ACK_O_a_read <= '1';
|
119 |
|
|
end if;
|
120 |
|
|
end if;
|
121 |
|
|
end process;
|
122 |
|
|
|
123 |
|
|
-- Solución de ACK en puerto B
|
124 |
|
|
ACK_O_b <= (pre_ACK_O_b_write or pre_ACK_O_b_read) and enable_BLK;
|
125 |
|
|
pre_ACK_O_b_write <= STB_I_b and CYC_I_b and WE_I_b;
|
126 |
|
|
-- la primera respuesta para el ciclo de lectura debe retrasarse un ciclo
|
127 |
|
|
P_ACK_b_resolution: process (STB_I_b, CYC_I_b, RST_I_b, CLK_I_b)
|
128 |
|
|
begin
|
129 |
|
|
if STB_I_b = '0' or CYC_I_b = '0' then
|
130 |
|
|
pre_ACK_O_b_read <= '0';
|
131 |
|
|
elsif CLK_I_b'event and CLK_I_b = '1' then
|
132 |
|
|
if RST_I_b = '1' then
|
133 |
|
|
pre_ACK_O_b_read <= '0';
|
134 |
|
|
elsif STB_I_b = '1' and CYC_I_b = '1' and WE_I_b = '0' then
|
135 |
|
|
pre_ACK_O_b_read <= '1';
|
136 |
|
|
end if;
|
137 |
|
|
end if;
|
138 |
|
|
end process;
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
-- Instancia
|
142 |
|
|
to_RWA <= not(WE_I_a);
|
143 |
|
|
to_RWB <= not(WE_I_b);
|
144 |
|
|
MEM: dual_port_memory port map (
|
145 |
|
|
DINA => DAT_I_a,
|
146 |
|
|
DOUTA => DAT_O_a,
|
147 |
|
|
ADDRA => ADR_I_a,
|
148 |
|
|
RWA => to_RWA,
|
149 |
|
|
BLKA => to_BLKA,
|
150 |
|
|
CLKA => CLK_I_a,
|
151 |
|
|
|
152 |
|
|
DINB => DAT_I_b,
|
153 |
|
|
DOUTB => DAT_O_b,
|
154 |
|
|
ADDRB => ADR_I_b,
|
155 |
|
|
RWB => to_RWB,
|
156 |
|
|
BLKB => to_BLKB,
|
157 |
|
|
CLKB => CLK_I_b,
|
158 |
|
|
|
159 |
|
|
RESET => RST_I_common
|
160 |
|
|
);
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
end architecture;
|