1 |
311 |
arniml |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- T8042AH Microcontroller System
|
4 |
|
|
--
|
5 |
|
|
-- Copyright (c) 2004-2022, Arnim Laeuger (arniml@opencores.org)
|
6 |
|
|
--
|
7 |
|
|
-- All rights reserved
|
8 |
|
|
--
|
9 |
|
|
-- Redistribution and use in source and synthezised forms, with or without
|
10 |
|
|
-- modification, are permitted provided that the following conditions are met:
|
11 |
|
|
--
|
12 |
|
|
-- Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
-- this list of conditions and the following disclaimer.
|
14 |
|
|
--
|
15 |
|
|
-- Redistributions in synthesized form must reproduce the above copyright
|
16 |
|
|
-- notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
-- documentation and/or other materials provided with the distribution.
|
18 |
|
|
--
|
19 |
|
|
-- Neither the name of the author nor the names of other contributors may
|
20 |
|
|
-- be used to endorse or promote products derived from this software without
|
21 |
|
|
-- specific prior written permission.
|
22 |
|
|
--
|
23 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24 |
|
|
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
25 |
|
|
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
26 |
|
|
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
|
27 |
|
|
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
28 |
|
|
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
29 |
|
|
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30 |
|
|
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
31 |
|
|
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
32 |
|
|
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33 |
|
|
-- POSSIBILITY OF SUCH DAMAGE.
|
34 |
|
|
--
|
35 |
|
|
-- Please report bugs to the author, but before you do so, please
|
36 |
|
|
-- make sure that this is not a derivative work and that
|
37 |
|
|
-- you have the latest version of this file.
|
38 |
|
|
--
|
39 |
|
|
-- The latest version of this file can be found at:
|
40 |
|
|
-- http://www.opencores.org/cvsweb.shtml/t48/
|
41 |
|
|
--
|
42 |
|
|
-------------------------------------------------------------------------------
|
43 |
|
|
|
44 |
|
|
library ieee;
|
45 |
|
|
use ieee.std_logic_1164.all;
|
46 |
|
|
|
47 |
|
|
entity t8042ah is
|
48 |
|
|
|
49 |
|
|
port (
|
50 |
|
|
xtal_i : in std_logic;
|
51 |
|
|
reset_n_i : in std_logic;
|
52 |
|
|
t0_i : in std_logic;
|
53 |
|
|
cs_n_i : in std_logic;
|
54 |
|
|
rd_n_i : in std_logic;
|
55 |
|
|
a0_i : in std_logic;
|
56 |
|
|
wr_n_i : in std_logic;
|
57 |
|
|
sync_o : out std_logic;
|
58 |
|
|
db_b : inout std_logic_vector( 7 downto 0);
|
59 |
|
|
t1_i : in std_logic;
|
60 |
|
|
p2_b : inout std_logic_vector( 7 downto 0);
|
61 |
|
|
p1_b : inout std_logic_vector( 7 downto 0);
|
62 |
|
|
prog_n_o : out std_logic
|
63 |
|
|
);
|
64 |
|
|
|
65 |
|
|
end t8042ah;
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
library ieee;
|
69 |
|
|
use ieee.numeric_std.all;
|
70 |
|
|
|
71 |
|
|
use work.t48_system_comp_pack.t8042ah_notri;
|
72 |
|
|
|
73 |
|
|
architecture struct of t8042ah is
|
74 |
|
|
|
75 |
|
|
signal db_s : std_logic_vector( 7 downto 0);
|
76 |
|
|
signal db_dir_s : std_logic;
|
77 |
|
|
signal p2_s : std_logic_vector( 7 downto 0);
|
78 |
|
|
signal p2l_low_imp_s : std_logic;
|
79 |
|
|
signal p2h_low_imp_s : std_logic;
|
80 |
|
|
signal p1_s : std_logic_vector( 7 downto 0);
|
81 |
|
|
signal p1_low_imp_s : std_logic;
|
82 |
|
|
|
83 |
|
|
signal vdd_s : std_logic;
|
84 |
|
|
|
85 |
|
|
begin
|
86 |
|
|
|
87 |
|
|
vdd_s <= '1';
|
88 |
|
|
|
89 |
|
|
t8042ah_notri_b : t8042ah_notri
|
90 |
|
|
generic map (
|
91 |
|
|
-- we don't need explicit gating of input ports
|
92 |
|
|
-- this is done implicitely by the bidirectional pads
|
93 |
|
|
gate_port_input_g => 0
|
94 |
|
|
)
|
95 |
|
|
|
96 |
|
|
port map (
|
97 |
|
|
xtal_i => xtal_i,
|
98 |
|
|
xtal_en_i => vdd_s,
|
99 |
|
|
reset_n_i => reset_n_i,
|
100 |
|
|
t0_i => t0_i,
|
101 |
|
|
cs_n_i => cs_n_i,
|
102 |
|
|
rd_n_i => rd_n_i,
|
103 |
|
|
a0_i => a0_i,
|
104 |
|
|
wr_n_i => wr_n_i,
|
105 |
|
|
sync_o => sync_o,
|
106 |
|
|
db_i => db_b,
|
107 |
|
|
db_o => db_s,
|
108 |
|
|
db_dir_o => db_dir_s,
|
109 |
|
|
t1_i => t1_i,
|
110 |
|
|
p2_i => p2_b,
|
111 |
|
|
p2_o => p2_s,
|
112 |
|
|
p2l_low_imp_o => p2l_low_imp_s,
|
113 |
|
|
p2h_low_imp_o => p2h_low_imp_s,
|
114 |
|
|
p1_i => p1_b,
|
115 |
|
|
p1_o => p1_s,
|
116 |
|
|
p1_low_imp_o => p1_low_imp_s,
|
117 |
|
|
prog_n_o => prog_n_o
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
-----------------------------------------------------------------------------
|
121 |
|
|
-- Process bidirs
|
122 |
|
|
--
|
123 |
|
|
-- Purpose:
|
124 |
|
|
-- Assign bidirectional signals.
|
125 |
|
|
--
|
126 |
|
|
bidirs: process (db_b, db_s, db_dir_s,
|
127 |
|
|
p1_b, p1_s, p1_low_imp_s,
|
128 |
|
|
p2_b, p2_s, p2l_low_imp_s, p2h_low_imp_s)
|
129 |
|
|
|
130 |
|
|
function port_bidir_f(port_value : in std_logic_vector;
|
131 |
|
|
low_imp : in std_logic) return std_logic_vector is
|
132 |
|
|
variable result_v : std_logic_vector(port_value'range);
|
133 |
|
|
begin
|
134 |
|
|
for idx in port_value'high downto port_value'low loop
|
135 |
|
|
if low_imp = '1' then
|
136 |
|
|
result_v(idx) := port_value(idx);
|
137 |
|
|
elsif port_value(idx) = '0' then
|
138 |
|
|
result_v(idx) := '0';
|
139 |
|
|
else
|
140 |
|
|
result_v(idx) := 'Z';
|
141 |
|
|
end if;
|
142 |
|
|
end loop;
|
143 |
|
|
|
144 |
|
|
return result_v;
|
145 |
|
|
end;
|
146 |
|
|
|
147 |
|
|
begin
|
148 |
|
|
-- Data Bus ---------------------------------------------------------------
|
149 |
|
|
if db_dir_s = '1' then
|
150 |
|
|
db_b <= db_s;
|
151 |
|
|
else
|
152 |
|
|
db_b <= (others => 'Z');
|
153 |
|
|
end if;
|
154 |
|
|
|
155 |
|
|
-- Port 1 -----------------------------------------------------------------
|
156 |
|
|
p1_b <= port_bidir_f(port_value => p1_s,
|
157 |
|
|
low_imp => p1_low_imp_s);
|
158 |
|
|
|
159 |
|
|
-- Port 2 -----------------------------------------------------------------
|
160 |
|
|
p2_b(3 downto 0) <= port_bidir_f(port_value => p2_s(3 downto 0),
|
161 |
|
|
low_imp => p2l_low_imp_s);
|
162 |
|
|
p2_b(7 downto 4) <= port_bidir_f(port_value => p2_s(7 downto 4),
|
163 |
|
|
low_imp => p2h_low_imp_s);
|
164 |
|
|
|
165 |
|
|
end process bidirs;
|
166 |
|
|
--
|
167 |
|
|
-----------------------------------------------------------------------------
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
end struct;
|