1 |
24 |
ste.fis |
--------------------------------------------------------------------------------
|
2 |
|
|
-- This sourcecode is released under BSD license.
|
3 |
|
|
-- Please see http://www.opensource.org/licenses/bsd-license.php for details!
|
4 |
|
|
--------------------------------------------------------------------------------
|
5 |
|
|
--
|
6 |
|
|
-- Copyright (c) 2011, Stefan Fischer <Ste.Fis@OpenCores.org>
|
7 |
|
|
-- All rights reserved.
|
8 |
|
|
--
|
9 |
|
|
-- Redistribution and use in source and binary 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 |
|
|
-- * Redistributions in binary form must reproduce the above copyright notice,
|
15 |
|
|
-- this list of conditions and the following disclaimer in the documentation
|
16 |
|
|
-- and/or other materials provided with the distribution.
|
17 |
|
|
-- * Neither the name of the author nor the names of his contributors may be
|
18 |
|
|
-- used to endorse or promote products derived from this software without
|
19 |
|
|
-- specific prior written permission.
|
20 |
|
|
--
|
21 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22 |
|
|
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23 |
|
|
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
24 |
|
|
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
25 |
|
|
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
26 |
|
|
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27 |
|
|
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28 |
|
|
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29 |
|
|
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30 |
|
|
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31 |
|
|
-- POSSIBILITY OF SUCH DAMAGE.
|
32 |
|
|
--
|
33 |
|
|
--------------------------------------------------------------------------------
|
34 |
|
|
-- filename: avnet_sp3a_eval_gpio_vhd.vhd
|
35 |
|
|
-- description: synthesizable PicoBlaze (TM) general purpose i/o example using
|
36 |
|
|
-- wishbone / AVNET (R) Sp3A-Eval-Kit version
|
37 |
|
|
-- todo4user: add other modules as needed
|
38 |
|
|
-- version: 0.0.0
|
39 |
|
|
-- changelog: - 0.0.0, initial release
|
40 |
|
|
-- - ...
|
41 |
|
|
--------------------------------------------------------------------------------
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
library ieee;
|
45 |
|
|
use ieee.std_logic_1164.all;
|
46 |
|
|
use ieee.numeric_std.all;
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
entity avnet_sp3a_eval_gpio_vhd is
|
50 |
|
|
port
|
51 |
|
|
(
|
52 |
|
|
FPGA_RESET : in std_logic;
|
53 |
|
|
CLK_16MHZ : in std_logic;
|
54 |
|
|
|
55 |
|
|
FPGA_PUSH_A : in std_logic;
|
56 |
|
|
FPGA_PUSH_B : in std_logic;
|
57 |
|
|
FPGA_PUSH_C : in std_logic;
|
58 |
|
|
|
59 |
|
|
LED1 : out std_logic;
|
60 |
|
|
LED2 : out std_logic;
|
61 |
|
|
LED3 : out std_logic;
|
62 |
|
|
LED4 : out std_logic
|
63 |
|
|
);
|
64 |
|
|
end avnet_sp3a_eval_gpio_vhd;
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
architecture rtl of avnet_sp3a_eval_gpio_vhd is
|
68 |
|
|
|
69 |
|
|
component kcpsm3 is
|
70 |
|
|
port
|
71 |
|
|
(
|
72 |
|
|
address : out std_logic_vector(9 downto 0);
|
73 |
|
|
instruction : in std_logic_vector(17 downto 0);
|
74 |
|
|
port_id : out std_logic_vector(7 downto 0);
|
75 |
|
|
write_strobe : out std_logic;
|
76 |
|
|
out_port : out std_logic_vector(7 downto 0);
|
77 |
|
|
read_strobe : out std_logic;
|
78 |
|
|
in_port : in std_logic_vector(7 downto 0);
|
79 |
|
|
interrupt : in std_logic;
|
80 |
|
|
interrupt_ack : out std_logic;
|
81 |
|
|
reset : in std_logic;
|
82 |
|
|
clk : in std_logic
|
83 |
|
|
);
|
84 |
|
|
end component;
|
85 |
|
|
|
86 |
|
|
component pbwbgpio is
|
87 |
|
|
port
|
88 |
|
|
(
|
89 |
|
|
address : in std_logic_vector(9 downto 0);
|
90 |
|
|
instruction : out std_logic_vector(17 downto 0);
|
91 |
|
|
clk : in std_logic
|
92 |
|
|
);
|
93 |
|
|
end component;
|
94 |
|
|
|
95 |
|
|
component wbm_picoblaze is
|
96 |
|
|
port
|
97 |
|
|
(
|
98 |
|
|
rst : in std_logic;
|
99 |
|
|
clk : in std_logic;
|
100 |
|
|
|
101 |
|
|
wbm_cyc_o : out std_logic;
|
102 |
|
|
wbm_stb_o : out std_logic;
|
103 |
|
|
wbm_we_o : out std_logic;
|
104 |
|
|
wbm_adr_o : out std_logic_vector(7 downto 0);
|
105 |
|
|
wbm_dat_m2s_o : out std_logic_vector(7 downto 0);
|
106 |
|
|
wbm_dat_s2m_i : in std_logic_vector(7 downto 0);
|
107 |
|
|
wbm_ack_i : in std_logic;
|
108 |
|
|
|
109 |
|
|
pb_port_id_i : in std_logic_vector(7 downto 0);
|
110 |
|
|
pb_write_strobe_i : in std_logic;
|
111 |
|
|
pb_out_port_i : in std_logic_vector(7 downto 0);
|
112 |
|
|
pb_read_strobe_i : in std_logic;
|
113 |
|
|
pb_in_port_o : out std_logic_vector(7 downto 0)
|
114 |
|
|
);
|
115 |
|
|
end component;
|
116 |
|
|
|
117 |
|
|
component wbs_gpio is
|
118 |
|
|
port
|
119 |
|
|
(
|
120 |
|
|
rst : in std_logic;
|
121 |
|
|
clk : in std_logic;
|
122 |
|
|
|
123 |
|
|
wbs_cyc_i : in std_logic;
|
124 |
|
|
wbs_stb_i : in std_logic;
|
125 |
|
|
wbs_we_i : in std_logic;
|
126 |
|
|
wbs_adr_i : in std_logic_vector(7 downto 0);
|
127 |
|
|
wbs_dat_m2s_i : in std_logic_vector(7 downto 0);
|
128 |
|
|
wbs_dat_s2m_o : out std_logic_vector(7 downto 0);
|
129 |
|
|
wbs_ack_o : out std_logic;
|
130 |
|
|
|
131 |
|
|
gpio_in_i : in std_logic_vector(7 downto 0);
|
132 |
|
|
gpio_out_o : out std_logic_vector(7 downto 0);
|
133 |
|
|
gpio_oe_o : out std_logic_vector(7 downto 0)
|
134 |
|
|
);
|
135 |
|
|
end component;
|
136 |
|
|
|
137 |
|
|
signal rst : std_logic := '1';
|
138 |
|
|
signal clk : std_logic := '1';
|
139 |
|
|
|
140 |
|
|
signal wb_cyc : std_logic := '0';
|
141 |
|
|
signal wb_stb : std_logic := '0';
|
142 |
|
|
signal wb_we : std_logic := '0';
|
143 |
|
|
signal wb_adr : std_logic_vector(7 downto 0) := (others => '0');
|
144 |
|
|
signal wb_dat_m2s : std_logic_vector(7 downto 0) := (others => '0');
|
145 |
|
|
signal wb_dat_s2m : std_logic_vector(7 downto 0) := (others => '0');
|
146 |
|
|
signal wb_ack : std_logic := '0';
|
147 |
|
|
|
148 |
|
|
signal pb_write_strobe : std_logic := '0';
|
149 |
|
|
signal pb_read_strobe : std_logic := '0';
|
150 |
|
|
signal pb_port_id : std_logic_vector(7 downto 0) := (others => '0');
|
151 |
|
|
signal pb_in_port : std_logic_vector(7 downto 0) := (others => '0');
|
152 |
|
|
signal pb_out_port : std_logic_vector(7 downto 0) := (others => '0');
|
153 |
|
|
|
154 |
|
|
signal instruction : std_logic_vector(17 downto 0) := (others => '0');
|
155 |
|
|
signal address : std_logic_vector(9 downto 0) := (others => '0');
|
156 |
|
|
|
157 |
|
|
signal interrupt : std_logic := '0';
|
158 |
|
|
signal interrupt_ack : std_logic := '0';
|
159 |
|
|
|
160 |
|
|
signal gpio_in : std_logic_vector(7 downto 0) := (others => '0');
|
161 |
|
|
signal gpio_out : std_logic_vector(7 downto 0) := (others => '0');
|
162 |
|
|
signal gpio_oe : std_logic_vector(7 downto 0) := (others => '0');
|
163 |
|
|
|
164 |
|
|
signal timer : unsigned(23 downto 0) := (others => '0');
|
165 |
|
|
|
166 |
|
|
begin
|
167 |
|
|
|
168 |
|
|
-- reset synchronisation
|
169 |
|
|
process(clk)
|
170 |
|
|
begin
|
171 |
28 |
ste.fis |
if rising_edge(clk) then
|
172 |
|
|
rst <= FPGA_RESET;
|
173 |
|
|
end if;
|
174 |
24 |
ste.fis |
end process;
|
175 |
|
|
clk <= CLK_16MHZ;
|
176 |
|
|
|
177 |
|
|
-- module instances
|
178 |
|
|
-------------------
|
179 |
|
|
|
180 |
|
|
inst_kcpsm3 : kcpsm3
|
181 |
|
|
port map
|
182 |
|
|
(
|
183 |
|
|
address => address,
|
184 |
|
|
instruction => instruction,
|
185 |
|
|
port_id => pb_port_id,
|
186 |
|
|
write_strobe => pb_write_strobe,
|
187 |
|
|
out_port => pb_out_port,
|
188 |
|
|
read_strobe => pb_read_strobe,
|
189 |
|
|
in_port => pb_in_port,
|
190 |
|
|
interrupt => interrupt,
|
191 |
|
|
interrupt_ack => interrupt_ack,
|
192 |
|
|
reset => rst,
|
193 |
|
|
clk => clk
|
194 |
|
|
);
|
195 |
|
|
|
196 |
|
|
inst_pbwbgpio : pbwbgpio
|
197 |
|
|
port map
|
198 |
|
|
(
|
199 |
|
|
address => address,
|
200 |
|
|
instruction => instruction,
|
201 |
|
|
clk => clk
|
202 |
|
|
);
|
203 |
|
|
|
204 |
|
|
inst_wbm_picoblaze : wbm_picoblaze
|
205 |
|
|
port map
|
206 |
|
|
(
|
207 |
|
|
rst => rst,
|
208 |
|
|
clk => clk,
|
209 |
|
|
|
210 |
|
|
wbm_cyc_o => wb_cyc,
|
211 |
|
|
wbm_stb_o => wb_stb,
|
212 |
|
|
wbm_we_o => wb_we,
|
213 |
|
|
wbm_adr_o => wb_adr,
|
214 |
|
|
wbm_dat_m2s_o => wb_dat_m2s,
|
215 |
|
|
wbm_dat_s2m_i => wb_dat_s2m,
|
216 |
|
|
wbm_ack_i => wb_ack,
|
217 |
|
|
|
218 |
|
|
pb_port_id_i => pb_port_id,
|
219 |
|
|
pb_write_strobe_i => pb_write_strobe,
|
220 |
|
|
pb_out_port_i => pb_out_port,
|
221 |
|
|
pb_read_strobe_i => pb_read_strobe,
|
222 |
|
|
pb_in_port_o => pb_in_port
|
223 |
|
|
);
|
224 |
|
|
|
225 |
|
|
inst_wbs_gpio : wbs_gpio
|
226 |
|
|
port map
|
227 |
|
|
(
|
228 |
|
|
rst => rst,
|
229 |
|
|
clk => clk,
|
230 |
|
|
|
231 |
|
|
wbs_cyc_i => wb_cyc,
|
232 |
|
|
wbs_stb_i => wb_stb,
|
233 |
|
|
wbs_we_i => wb_we,
|
234 |
|
|
wbs_adr_i => wb_adr,
|
235 |
|
|
wbs_dat_m2s_i => wb_dat_m2s,
|
236 |
|
|
wbs_dat_s2m_o => wb_dat_s2m,
|
237 |
|
|
wbs_ack_o => wb_ack,
|
238 |
|
|
|
239 |
|
|
gpio_in_i => gpio_in,
|
240 |
|
|
gpio_out_o => gpio_out,
|
241 |
|
|
gpio_oe_o => gpio_oe
|
242 |
|
|
);
|
243 |
|
|
|
244 |
|
|
-- i/o buffer generation
|
245 |
|
|
|
246 |
|
|
gpio_in <= (
|
247 |
|
|
4 => FPGA_PUSH_A,
|
248 |
|
|
5 => FPGA_PUSH_B,
|
249 |
|
|
6 => FPGA_PUSH_C,
|
250 |
|
|
others => '0'
|
251 |
|
|
);
|
252 |
|
|
|
253 |
|
|
LED1 <= gpio_out(0);
|
254 |
|
|
LED2 <= gpio_out(1);
|
255 |
|
|
LED3 <= gpio_out(2);
|
256 |
|
|
LED4 <= timer(23);
|
257 |
|
|
|
258 |
|
|
led_blinker : process(clk)
|
259 |
|
|
begin
|
260 |
|
|
if rising_edge(clk) then
|
261 |
|
|
timer <= timer + 1;
|
262 |
|
|
if rst = '1' then
|
263 |
|
|
timer <= (others => '0');
|
264 |
|
|
end if;
|
265 |
|
|
end if;
|
266 |
|
|
end process;
|
267 |
|
|
|
268 |
|
|
end rtl;
|