1 |
19 |
budinero |
----------------------------------------------------------------------------------------------------
|
2 |
|
|
--| Modular Oscilloscope
|
3 |
|
|
--| UNSL - Argentine
|
4 |
|
|
--|
|
5 |
|
|
--| File: eppwbn_wbn_side.vhd
|
6 |
|
|
--| Version: 0.2
|
7 |
|
|
--| Tested in: Actel APA300
|
8 |
|
|
--|-------------------------------------------------------------------------------------------------
|
9 |
|
|
--| Description:
|
10 |
|
|
--| EPP - Wishbone bridge.
|
11 |
|
|
--| This module is in the wishbone side (IEEE Std. 1284-2000).
|
12 |
|
|
--|-------------------------------------------------------------------------------------------------
|
13 |
|
|
--| File history:
|
14 |
|
|
--| 0.01 | nov-2008 | First release
|
15 |
|
|
--| 0.1 | jan-2009 | Sinc reset
|
16 |
|
|
--| 0.2 | feb-2009 | Some improvements
|
17 |
|
|
----------------------------------------------------------------------------------------------------
|
18 |
|
|
--| Copyright ® 2008, 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 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
library IEEE;
|
27 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
28 |
|
|
--use IEEE.STD_LOGIC_ARITH.ALL;
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
entity eppwbn_wbn_side is
|
32 |
|
|
port(
|
33 |
|
|
|
34 |
|
|
-- al puerto epp
|
35 |
|
|
-- Nomenclatura IEEE Std. 1284-2000
|
36 |
|
|
-- Negotiation/ECP/EPP (Compatibiliy)
|
37 |
|
|
inStrobe: in std_logic; -- HostClk/nWrite
|
38 |
|
|
iData: inout std_logic_vector (7 downto 0); -- AD8..1/AD8..1 (Data1..Data8)
|
39 |
|
|
-- inAck: out std_logic; -- PtrClk/PeriphClk/Intr
|
40 |
|
|
iBusy: out std_logic; -- PtrBusy/PeriphAck/nWait
|
41 |
|
|
-- iPError: out std_logic; -- AckData/nAckReverse
|
42 |
|
|
-- iSel: out std_logic; -- XFlag (Select)
|
43 |
|
|
inAutoFd: in std_logic; -- HostBusy/HostAck/nDStrb
|
44 |
|
|
-- iPeriphLogicH: out std_logic; -- (Periph Logic High)
|
45 |
|
|
-- inInit: in std_logic; -- nReverseRequest
|
46 |
|
|
-- inFault: out std_logic; -- nDataAvail/nPeriphRequest
|
47 |
|
|
inSelectIn: in std_logic; -- 1284 Active/nAStrb
|
48 |
|
|
-- iHostLogicH: in std_logic; -- (Host Logic High)
|
49 |
|
|
-- i indica interna en el core y controlada por el bloque de control
|
50 |
|
|
|
51 |
|
|
-- a la interface wishbone
|
52 |
|
|
RST_I: in std_logic;
|
53 |
|
|
CLK_I: in std_logic;
|
54 |
|
|
DAT_I: in std_logic_vector (7 downto 0);
|
55 |
|
|
DAT_O: out std_logic_vector (7 downto 0);
|
56 |
|
|
ADR_O: out std_logic_vector (7 downto 0);
|
57 |
|
|
CYC_O: out std_logic;
|
58 |
|
|
STB_O: out std_logic;
|
59 |
|
|
ACK_I: in std_logic ;
|
60 |
|
|
WE_O: out std_logic;
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
rst_pp: in std_logic -- reset desde la interfaz del puerto paralelo
|
64 |
|
|
);
|
65 |
|
|
|
66 |
|
|
end eppwbn_wbn_side;
|
67 |
|
|
|
68 |
|
|
architecture con_registro of eppwbn_wbn_side is
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
signal adr_ack,data_ack: std_logic;
|
72 |
|
|
signal adr_reg,data_reg: std_logic_vector (7 downto 0); -- registros internos temporales
|
73 |
|
|
signal pre_STB_O: std_logic; -- registro que maneja a STB_O
|
74 |
|
|
|
75 |
|
|
begin
|
76 |
|
|
|
77 |
|
|
iBusy <= adr_ack or data_ack; -- nWait. Se utiliza para confirmación de lectura/escritura de datos/direcciones
|
78 |
|
|
WE_O <= not(inStrobe); -- Ambas señales tienen la misma utilidad, habilitan escritura
|
79 |
|
|
STB_O <= pre_STB_O ;
|
80 |
|
|
CYC_O <= pre_STB_O;
|
81 |
|
|
DAT_O <= data_reg; -- se utiliza el mismo registro para salida de datos
|
82 |
|
|
-- a wishbone, lectura y escritura de datos desde epp
|
83 |
|
|
|
84 |
|
|
-- Data R/W
|
85 |
|
|
data_strobing: process (inAutoFd, ACK_I, CLK_I, pre_STB_O, RST_I, rst_pp, data_ack,inStrobe,iData)
|
86 |
|
|
begin
|
87 |
|
|
|
88 |
|
|
if (rst_pp = '1') then -- Reset de desde interfaz EPP asíncrono
|
89 |
|
|
data_reg <= (others => '0');
|
90 |
|
|
pre_STB_O <= '0';
|
91 |
|
|
data_ack <= '0';
|
92 |
|
|
|
93 |
|
|
elsif inAutoFd = '0' and data_ack = '0' and pre_STB_O = '0' then -- Data strobe
|
94 |
|
|
if (inStrobe = '0') then -- Escritura EPP
|
95 |
|
|
data_reg <= iData;
|
96 |
|
|
end if;
|
97 |
|
|
pre_STB_O <= '1';
|
98 |
|
|
elsif inAutoFd = '1' and data_ack = '1' then -- iBusy solo se pondrá a cero
|
99 |
|
|
data_ack <= '0';
|
100 |
|
|
-- Se indica el la comprobación de data_ack = '1' para forzar a la herramienta
|
101 |
|
|
-- de síntesis a crear un registro.
|
102 |
|
|
|
103 |
|
|
elsif (CLK_I'event and CLK_I = '1') then
|
104 |
|
|
if RST_I = '1' then
|
105 |
|
|
data_reg <= (others => '0');
|
106 |
|
|
pre_STB_O <= '0';
|
107 |
|
|
data_ack <= '0';
|
108 |
|
|
else
|
109 |
|
|
if (ACK_I = '1' and pre_STB_O = '1') then -- Dato escrito o leído
|
110 |
|
|
pre_STB_O <= '0';
|
111 |
|
|
data_ack <= '1';
|
112 |
|
|
if (inStrobe = '1') then -- Lectura EPP
|
113 |
|
|
data_reg <= DAT_I;
|
114 |
|
|
end if;
|
115 |
|
|
end if;
|
116 |
|
|
end if;
|
117 |
|
|
end if;
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
end process;
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
-- Adr R/W
|
126 |
|
|
adr_ack <= not(inSelectIn); -- Autoconfirmación de estado.
|
127 |
|
|
adr_strobing: process (inSelectIn, RST_I, rst_pp,inStrobe,iData)
|
128 |
|
|
begin
|
129 |
|
|
if (RST_I = '1' or rst_pp = '1') then
|
130 |
|
|
adr_reg <= (others => '0');
|
131 |
|
|
elsif (inSelectIn'event and inSelectIn = '1') then -- Adr strobe
|
132 |
|
|
if inStrobe = '0' then
|
133 |
|
|
adr_reg <= iData;
|
134 |
|
|
end if;
|
135 |
|
|
end if;
|
136 |
|
|
end process;
|
137 |
|
|
ADR_O <= adr_reg;
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
-- Puerto bidireccional
|
141 |
|
|
iData <= data_reg when (inStrobe = '1' and data_ack = '1') else
|
142 |
|
|
adr_reg when (inStrobe = '1' and adr_ack = '1') else
|
143 |
|
|
(others => 'Z');
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
8 |
budinero |
end con_registro;
|