1 |
12 |
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) 2010, 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: picoblaze_wb_uart.vhd
|
35 |
|
|
-- description: synthesizable PicoBlaze (TM) uart example using wishbone
|
36 |
|
|
-- todo4user: add other modules as needed
|
37 |
|
|
-- version: 0.0.0
|
38 |
|
|
-- changelog: - 0.0.0, initial release
|
39 |
|
|
-- - ...
|
40 |
|
|
--------------------------------------------------------------------------------
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
library ieee;
|
44 |
|
|
use ieee.std_logic_1164.all;
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
entity picoblaze_wb_uart is
|
48 |
|
|
port
|
49 |
|
|
(
|
50 |
|
|
p_rst_n_i : in std_logic;
|
51 |
|
|
p_clk_i : in std_logic;
|
52 |
|
|
|
53 |
|
|
p_uart_rx_si_i : in std_logic;
|
54 |
|
|
p_uart_tx_so_o : out std_logic
|
55 |
|
|
);
|
56 |
|
|
end picoblaze_wb_uart;
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
architecture rtl of picoblaze_wb_uart is
|
60 |
|
|
|
61 |
|
|
component kcpsm3 is
|
62 |
|
|
port
|
63 |
|
|
(
|
64 |
|
|
address : out std_logic_vector(9 downto 0);
|
65 |
|
|
instruction : in std_logic_vector(17 downto 0);
|
66 |
|
|
port_id : out std_logic_vector(7 downto 0);
|
67 |
|
|
write_strobe : out std_logic;
|
68 |
|
|
out_port : out std_logic_vector(7 downto 0);
|
69 |
|
|
read_strobe : out std_logic;
|
70 |
|
|
in_port : in std_logic_vector(7 downto 0);
|
71 |
|
|
interrupt : in std_logic;
|
72 |
|
|
interrupt_ack : out std_logic;
|
73 |
|
|
reset : in std_logic;
|
74 |
|
|
clk : in std_logic
|
75 |
|
|
);
|
76 |
|
|
end component;
|
77 |
|
|
|
78 |
|
|
component pbwbuart is
|
79 |
|
|
port
|
80 |
|
|
(
|
81 |
|
|
address : in std_logic_vector(9 downto 0);
|
82 |
|
|
instruction : out std_logic_vector(17 downto 0);
|
83 |
|
|
clk : in std_logic
|
84 |
|
|
);
|
85 |
|
|
end component;
|
86 |
|
|
|
87 |
|
|
component wbm_picoblaze is
|
88 |
|
|
port
|
89 |
|
|
(
|
90 |
|
|
rst : in std_logic;
|
91 |
|
|
clk : in std_logic;
|
92 |
|
|
|
93 |
|
|
wbm_cyc_o : out std_logic;
|
94 |
|
|
wbm_stb_o : out std_logic;
|
95 |
|
|
wbm_we_o : out std_logic;
|
96 |
|
|
wbm_adr_o : out std_logic_vector(7 downto 0);
|
97 |
|
|
wbm_dat_m2s_o : out std_logic_vector(7 downto 0);
|
98 |
|
|
wbm_dat_s2m_i : in std_logic_vector(7 downto 0);
|
99 |
|
|
wbm_ack_i : in std_logic;
|
100 |
|
|
|
101 |
|
|
pb_port_id_i : in std_logic_vector(7 downto 0);
|
102 |
|
|
pb_write_strobe_i : in std_logic;
|
103 |
|
|
pb_out_port_i : in std_logic_vector(7 downto 0);
|
104 |
|
|
pb_read_strobe_i : in std_logic;
|
105 |
|
|
pb_in_port_o : out std_logic_vector(7 downto 0)
|
106 |
|
|
);
|
107 |
|
|
end component;
|
108 |
|
|
|
109 |
|
|
component wbs_uart is
|
110 |
|
|
port
|
111 |
|
|
(
|
112 |
|
|
rst : in std_logic;
|
113 |
|
|
clk : in std_logic;
|
114 |
|
|
|
115 |
|
|
wbs_cyc_i : in std_logic;
|
116 |
|
|
wbs_stb_i : in std_logic;
|
117 |
|
|
wbs_we_i : in std_logic;
|
118 |
|
|
wbs_adr_i : in std_logic_vector(7 downto 0);
|
119 |
|
|
wbs_dat_m2s_i : in std_logic_vector(7 downto 0);
|
120 |
|
|
wbs_dat_s2m_o : out std_logic_vector(7 downto 0);
|
121 |
|
|
wbs_ack_o : out std_logic;
|
122 |
|
|
|
123 |
|
|
uart_rx_si_i : in std_logic;
|
124 |
|
|
uart_tx_so_o : out std_logic
|
125 |
|
|
);
|
126 |
|
|
end component;
|
127 |
|
|
|
128 |
|
|
signal rst : std_logic := '1';
|
129 |
|
|
signal clk : std_logic := '1';
|
130 |
|
|
|
131 |
|
|
signal wb_cyc : std_logic := '0';
|
132 |
|
|
signal wb_stb : std_logic := '0';
|
133 |
|
|
signal wb_we : std_logic := '0';
|
134 |
|
|
signal wb_adr : std_logic_vector(7 downto 0) := (others => '0');
|
135 |
|
|
signal wb_dat_m2s : std_logic_vector(7 downto 0) := (others => '0');
|
136 |
|
|
signal wb_dat_s2m : std_logic_vector(7 downto 0) := (others => '0');
|
137 |
|
|
signal wb_ack : std_logic := '0';
|
138 |
|
|
|
139 |
|
|
signal pb_write_strobe : std_logic := '0';
|
140 |
|
|
signal pb_read_strobe : std_logic := '0';
|
141 |
|
|
signal pb_port_id : std_logic_vector(7 downto 0) := (others => '0');
|
142 |
|
|
signal pb_in_port : std_logic_vector(7 downto 0) := (others => '0');
|
143 |
|
|
signal pb_out_port : std_logic_vector(7 downto 0) := (others => '0');
|
144 |
|
|
|
145 |
|
|
signal instruction : std_logic_vector(17 downto 0) := (others => '0');
|
146 |
|
|
signal address : std_logic_vector(9 downto 0) := (others => '0');
|
147 |
|
|
|
148 |
|
|
signal interrupt : std_logic := '0';
|
149 |
|
|
signal interrupt_ack : std_logic := '0';
|
150 |
|
|
|
151 |
|
|
begin
|
152 |
|
|
|
153 |
|
|
-- reset synchronisation
|
154 |
|
|
process(clk)
|
155 |
|
|
begin
|
156 |
|
|
rst <= not p_rst_n_i;
|
157 |
|
|
end process;
|
158 |
|
|
clk <= p_clk_i;
|
159 |
|
|
|
160 |
|
|
-- module instances
|
161 |
|
|
-------------------
|
162 |
|
|
|
163 |
|
|
inst_kcpsm3 : kcpsm3
|
164 |
|
|
port map
|
165 |
|
|
(
|
166 |
|
|
address => address,
|
167 |
|
|
instruction => instruction,
|
168 |
|
|
port_id => pb_port_id,
|
169 |
|
|
write_strobe => pb_write_strobe,
|
170 |
|
|
out_port => pb_out_port,
|
171 |
|
|
read_strobe => pb_read_strobe,
|
172 |
|
|
in_port => pb_in_port,
|
173 |
|
|
interrupt => interrupt,
|
174 |
|
|
interrupt_ack => interrupt_ack,
|
175 |
|
|
reset => rst,
|
176 |
|
|
clk => clk
|
177 |
|
|
);
|
178 |
|
|
|
179 |
|
|
inst_pbwbuart : pbwbuart
|
180 |
|
|
port map
|
181 |
|
|
(
|
182 |
|
|
address => address,
|
183 |
|
|
instruction => instruction,
|
184 |
|
|
clk => clk
|
185 |
|
|
);
|
186 |
|
|
|
187 |
|
|
inst_wbm_picoblaze : wbm_picoblaze
|
188 |
|
|
port map
|
189 |
|
|
(
|
190 |
|
|
rst => rst,
|
191 |
|
|
clk => clk,
|
192 |
|
|
|
193 |
|
|
wbm_cyc_o => wb_cyc,
|
194 |
|
|
wbm_stb_o => wb_stb,
|
195 |
|
|
wbm_we_o => wb_we,
|
196 |
|
|
wbm_adr_o => wb_adr,
|
197 |
|
|
wbm_dat_m2s_o => wb_dat_m2s,
|
198 |
|
|
wbm_dat_s2m_i => wb_dat_s2m,
|
199 |
|
|
wbm_ack_i => wb_ack,
|
200 |
|
|
|
201 |
|
|
pb_port_id_i => pb_port_id,
|
202 |
|
|
pb_write_strobe_i => pb_write_strobe,
|
203 |
|
|
pb_out_port_i => pb_out_port,
|
204 |
|
|
pb_read_strobe_i => pb_read_strobe,
|
205 |
|
|
pb_in_port_o => pb_in_port
|
206 |
|
|
);
|
207 |
|
|
|
208 |
|
|
inst_wbs_uart : wbs_uart
|
209 |
|
|
port map
|
210 |
|
|
(
|
211 |
|
|
rst => rst,
|
212 |
|
|
clk => clk,
|
213 |
|
|
|
214 |
|
|
wbs_cyc_i => wb_cyc,
|
215 |
|
|
wbs_stb_i => wb_stb,
|
216 |
|
|
wbs_we_i => wb_we,
|
217 |
|
|
wbs_adr_i => wb_adr,
|
218 |
|
|
wbs_dat_m2s_i => wb_dat_m2s,
|
219 |
|
|
wbs_dat_s2m_o => wb_dat_s2m,
|
220 |
|
|
wbs_ack_o => wb_ack,
|
221 |
|
|
|
222 |
|
|
uart_rx_si_i => p_uart_rx_si_i,
|
223 |
|
|
uart_tx_so_o => p_uart_tx_so_o
|
224 |
|
|
);
|
225 |
|
|
|
226 |
|
|
end rtl;
|