1 |
2 |
idiolatrie |
--------------------------------------------------------------------------------
|
2 |
|
|
-- Wishbone Shared Bus Intercon --
|
3 |
|
|
--------------------------------------------------------------------------------
|
4 |
|
|
-- Copyright (C)2011 Mathias Hörtnagl <mathias.hoertnagl@gmail.comt> --
|
5 |
|
|
-- --
|
6 |
|
|
-- This program is free software: you can redistribute it and/or modify --
|
7 |
|
|
-- it under the terms of the GNU General Public License as published by --
|
8 |
|
|
-- the Free Software Foundation, either version 3 of the License, or --
|
9 |
|
|
-- (at your option) any later version. --
|
10 |
|
|
-- --
|
11 |
|
|
-- This program is distributed in the hope that it will be useful, --
|
12 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
|
13 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
|
14 |
|
|
-- GNU General Public License for more details. --
|
15 |
|
|
-- --
|
16 |
|
|
-- You should have received a copy of the GNU General Public License --
|
17 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>. --
|
18 |
|
|
--------------------------------------------------------------------------------
|
19 |
|
|
library ieee;
|
20 |
|
|
use ieee.std_logic_1164.all;
|
21 |
|
|
use ieee.numeric_std.all;
|
22 |
|
|
|
23 |
|
|
library work;
|
24 |
|
|
use work.icon.all;
|
25 |
|
|
use work.iwb.all;
|
26 |
|
|
|
27 |
|
|
entity intercon is
|
28 |
|
|
port(
|
29 |
|
|
CLK50_I : in std_logic;
|
30 |
|
|
CLK25_I : in std_logic;
|
31 |
|
|
RST_I : in std_logic;
|
32 |
|
|
mi : out master_in_t;
|
33 |
|
|
mo : in master_out_t;
|
34 |
|
|
brami : out slave_in_t;
|
35 |
|
|
bramo : in slave_out_t;
|
36 |
|
|
flasi : out slave_in_t;
|
37 |
|
|
flaso : in slave_out_t;
|
38 |
|
|
ddri : out slave_in_t;
|
39 |
|
|
ddro : in slave_out_t;
|
40 |
|
|
dispi : out slave_in_t;
|
41 |
|
|
dispo : in slave_out_t;
|
42 |
|
|
keybi : out slave_in_t;
|
43 |
|
|
keybo : in slave_out_t;
|
44 |
|
|
piti : out slave_in_t;
|
45 |
|
|
pito : in slave_out_t;
|
46 |
|
|
uartri : out slave_in_t;
|
47 |
|
|
uartro : in slave_out_t;
|
48 |
|
|
uartti : out slave_in_t;
|
49 |
|
|
uartto : in slave_out_t
|
50 |
|
|
);
|
51 |
|
|
end intercon;
|
52 |
|
|
|
53 |
|
|
architecture sbus of intercon is
|
54 |
|
|
|
55 |
|
|
-- Set default slave signals.
|
56 |
|
|
function setDefault(mo : master_out_t; CLK, RST : std_logic)
|
57 |
|
|
return slave_in_t is
|
58 |
|
|
variable v : slave_in_t;
|
59 |
|
|
begin
|
60 |
|
|
v.clk := CLK;
|
61 |
|
|
v.rst := RST;
|
62 |
|
|
v.stb := '0';
|
63 |
|
|
v.we := '0';
|
64 |
|
|
v.dat := mo.dat;
|
65 |
|
|
v.sel := mo.sel;
|
66 |
|
|
v.adr := mo.adr;
|
67 |
|
|
return v;
|
68 |
|
|
end setDefault;
|
69 |
|
|
|
70 |
|
|
begin
|
71 |
|
|
mux : process(CLK50_I, RST_I, mo, bramo, dispo, keybo, pito, flaso, uartro,
|
72 |
|
|
uartto, ddro, CLK25_I)
|
73 |
|
|
|
74 |
|
|
variable padr : std_logic_vector(27 downto 0);
|
75 |
|
|
begin
|
76 |
|
|
mi.clk <= CLK50_I;
|
77 |
|
|
mi.rst <= RST_I;
|
78 |
|
|
mi.dat <= (others => '0');
|
79 |
|
|
|
80 |
|
|
-- NOTE: Set mi.ack = '1' if you want to continue execution outside the
|
81 |
|
|
-- valid address space. If set to zero and your programm reads or
|
82 |
|
|
-- writes outside the specified addresses the cpu waits infinitly
|
83 |
|
|
-- for an acknolege.
|
84 |
|
|
mi.ack <= '0';
|
85 |
|
|
|
86 |
|
|
brami <= setDefault(mo, CLK50_I, RST_I);
|
87 |
|
|
flasi <= setDefault(mo, CLK50_I, RST_I);
|
88 |
|
|
ddri <= setDefault(mo, CLK50_I, RST_I);
|
89 |
|
|
dispi <= setDefault(mo, CLK50_I, RST_I);
|
90 |
|
|
keybi <= setDefault(mo, CLK50_I, RST_I);
|
91 |
|
|
piti <= setDefault(mo, CLK50_I, RST_I);
|
92 |
|
|
uartri <= setDefault(mo, CLK50_I, RST_I);
|
93 |
|
|
uartti <= setDefault(mo, CLK50_I, RST_I);
|
94 |
|
|
|
95 |
|
|
padr := mo.adr(27 downto 0);
|
96 |
|
|
|
97 |
|
|
case mo.adr(31 downto 28) is
|
98 |
|
|
|
99 |
|
|
-----------------------------------------------------------------------
|
100 |
|
|
-- Block Memory --
|
101 |
|
|
-----------------------------------------------------------------------
|
102 |
|
|
when X"0" =>
|
103 |
|
|
-- if (padr >= X"0000000") and (padr < X"0004000") then
|
104 |
|
|
brami.stb <= mo.stb;
|
105 |
|
|
brami.we <= mo.we;
|
106 |
|
|
mi.dat <= bramo.dat;
|
107 |
|
|
mi.ack <= bramo.ack;
|
108 |
|
|
-- end if;
|
109 |
|
|
|
110 |
|
|
-----------------------------------------------------------------------
|
111 |
|
|
-- Flash Memory --
|
112 |
|
|
-----------------------------------------------------------------------
|
113 |
|
|
when X"1" =>
|
114 |
|
|
--if (padr >= X"0000000") and (padr < X"1000000") then
|
115 |
|
|
flasi.stb <= mo.stb;
|
116 |
|
|
flasi.we <= mo.we;
|
117 |
|
|
mi.dat <= flaso.dat;
|
118 |
|
|
mi.ack <= flaso.ack;
|
119 |
|
|
--end if;
|
120 |
|
|
|
121 |
|
|
-----------------------------------------------------------------------
|
122 |
|
|
-- DDR2 Memory --
|
123 |
|
|
-----------------------------------------------------------------------
|
124 |
|
|
when x"2" =>
|
125 |
|
|
ddri.stb <= mo.stb;
|
126 |
|
|
ddri.we <= mo.we;
|
127 |
|
|
mi.dat <= ddro.dat;
|
128 |
|
|
mi.ack <= ddro.ack;
|
129 |
|
|
|
130 |
|
|
-----------------------------------------------------------------------
|
131 |
|
|
-- Peripheral IO --
|
132 |
|
|
-----------------------------------------------------------------------
|
133 |
|
|
when X"F" =>
|
134 |
|
|
|
135 |
|
|
--------------------------------------------------------------------
|
136 |
|
|
-- Display --
|
137 |
|
|
--------------------------------------------------------------------
|
138 |
|
|
-- 4096 blocks, 16bit per block = 8192 (0x2000)
|
139 |
|
|
if (padr >= X"FFF0000") and (padr < X"FFF2000") then
|
140 |
|
|
dispi.stb <= mo.stb;
|
141 |
|
|
dispi.we <= mo.we;
|
142 |
|
|
mi.dat <= dispo.dat;
|
143 |
|
|
mi.ack <= dispo.ack;
|
144 |
|
|
|
145 |
|
|
-- NOTE: The following addresses are strict. If you try to load or
|
146 |
|
|
-- store a halfword or a byte, the addresses obviously do NOT
|
147 |
|
|
-- match.
|
148 |
|
|
--------------------------------------------------------------------
|
149 |
|
|
-- Keyboard --
|
150 |
|
|
--------------------------------------------------------------------
|
151 |
|
|
-- 1 block, 32bit, read only
|
152 |
|
|
elsif padr = X"FFF3000" then
|
153 |
|
|
keybi.stb <= mo.stb;
|
154 |
|
|
keybi.we <= mo.we;
|
155 |
|
|
mi.dat <= keybo.dat;
|
156 |
|
|
mi.ack <= keybo.ack;
|
157 |
|
|
|
158 |
|
|
--------------------------------------------------------------------
|
159 |
|
|
-- RS-232 Serial Port --
|
160 |
|
|
--------------------------------------------------------------------
|
161 |
|
|
-- 1 block, 32bit, read only
|
162 |
|
|
elsif padr = X"FFF4000" then
|
163 |
|
|
uartri.stb <= mo.stb;
|
164 |
|
|
uartri.we <= mo.we;
|
165 |
|
|
mi.dat <= uartro.dat;
|
166 |
|
|
mi.ack <= uartro.ack;
|
167 |
|
|
|
168 |
|
|
-- 1 block, 32bit, write only
|
169 |
|
|
elsif padr = X"FFF4004" then
|
170 |
|
|
uartti.stb <= mo.stb;
|
171 |
|
|
uartti.we <= mo.we;
|
172 |
|
|
mi.dat <= uartto.dat;
|
173 |
|
|
mi.ack <= uartto.ack;
|
174 |
|
|
|
175 |
|
|
--------------------------------------------------------------------
|
176 |
|
|
-- Timer --
|
177 |
|
|
--------------------------------------------------------------------
|
178 |
|
|
-- 1 block, 32bit, r/w
|
179 |
|
|
elsif padr = X"FFFF000" then
|
180 |
|
|
piti.stb <= mo.stb;
|
181 |
|
|
piti.we <= mo.we;
|
182 |
|
|
mi.dat <= pito.dat;
|
183 |
|
|
mi.ack <= pito.ack;
|
184 |
|
|
end if;
|
185 |
|
|
|
186 |
|
|
when others =>
|
187 |
|
|
|
188 |
|
|
end case;
|
189 |
|
|
end process;
|
190 |
|
|
end sbus;
|