OpenCores
URL https://opencores.org/ocsvn/wb4pb/wb4pb/trunk

Subversion Repositories wb4pb

[/] [wb4pb/] [trunk/] [rtl/] [picoblaze_wb_gpio.vhd] - Blame information for rev 19

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 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_gpio.vhd
35
-- description: synthesizable PicoBlaze (TM) general purpose i/o example using 
36
--              wishbone
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
 
47
 
48
entity picoblaze_wb_gpio is
49
  port
50
  (
51 19 ste.fis
    p_rst_n_i : in std_logic;
52 2 ste.fis
    p_clk_i : in std_logic;
53
 
54
    p_gpio_io : inout std_logic_vector(7 downto 0)
55
  );
56
end picoblaze_wb_gpio;
57
 
58
 
59
architecture rtl of picoblaze_wb_gpio 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 pbwbgpio 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_gpio 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
      gpio_in_i : in std_logic_vector(7 downto 0);
124
      gpio_out_o : out std_logic_vector(7 downto 0);
125
      gpio_oe_o : out std_logic_vector(7 downto 0)
126
    );
127
  end component;
128
 
129
  signal rst : std_logic := '1';
130
  signal clk : std_logic := '1';
131
 
132
  signal wb_cyc : std_logic := '0';
133
  signal wb_stb : std_logic := '0';
134
  signal wb_we : std_logic := '0';
135
  signal wb_adr : std_logic_vector(7 downto 0) := (others => '0');
136
  signal wb_dat_m2s : std_logic_vector(7 downto 0) := (others => '0');
137
  signal wb_dat_s2m : std_logic_vector(7 downto 0) := (others => '0');
138
  signal wb_ack : std_logic := '0';
139
 
140
  signal pb_write_strobe : std_logic := '0';
141
  signal pb_read_strobe : std_logic := '0';
142
  signal pb_port_id : std_logic_vector(7 downto 0) := (others => '0');
143
  signal pb_in_port : std_logic_vector(7 downto 0) := (others => '0');
144
  signal pb_out_port : std_logic_vector(7 downto 0) := (others => '0');
145
 
146
  signal instruction : std_logic_vector(17 downto 0) := (others => '0');
147
  signal address : std_logic_vector(9 downto 0) := (others => '0');
148
 
149
  signal interrupt : std_logic := '0';
150
  signal interrupt_ack : std_logic := '0';
151
 
152
  signal gpio_in : std_logic_vector(7 downto 0) := (others => '0');
153
  signal gpio_out : std_logic_vector(7 downto 0) := (others => '0');
154
  signal gpio_oe : std_logic_vector(7 downto 0) := (others => '0');
155
 
156
  constant IS_INPUT : std_logic := '0';
157
  constant IS_OUTPUT : std_logic := not IS_INPUT;
158
 
159
begin
160
 
161
  -- reset synchronisation
162
  process(clk)
163
  begin
164 19 ste.fis
    rst <= not p_rst_n_i;
165 2 ste.fis
  end process;
166
  clk <= p_clk_i;
167
 
168
  -- module instances
169
  -------------------
170
 
171
  inst_kcpsm3 : kcpsm3
172
    port map
173
    (
174
      address => address,
175
      instruction => instruction,
176
      port_id => pb_port_id,
177
      write_strobe => pb_write_strobe,
178
      out_port => pb_out_port,
179
      read_strobe => pb_read_strobe,
180
      in_port => pb_in_port,
181
      interrupt => interrupt,
182
      interrupt_ack => interrupt_ack,
183
      reset => rst,
184
      clk => clk
185
    );
186
 
187
  inst_pbwbgpio : pbwbgpio
188
    port map
189
    (
190
      address => address,
191
      instruction => instruction,
192
      clk => clk
193
    );
194
 
195
  inst_wbm_picoblaze : wbm_picoblaze
196
    port map
197
    (
198
      rst => rst,
199
      clk => clk,
200
 
201
      wbm_cyc_o => wb_cyc,
202
      wbm_stb_o => wb_stb,
203
      wbm_we_o => wb_we,
204
      wbm_adr_o => wb_adr,
205
      wbm_dat_m2s_o => wb_dat_m2s,
206
      wbm_dat_s2m_i => wb_dat_s2m,
207
      wbm_ack_i => wb_ack,
208
 
209
      pb_port_id_i => pb_port_id,
210
      pb_write_strobe_i => pb_write_strobe,
211
      pb_out_port_i => pb_out_port,
212
      pb_read_strobe_i => pb_read_strobe,
213
      pb_in_port_o => pb_in_port
214
    );
215
 
216
  inst_wbs_gpio : wbs_gpio
217
    port map
218
    (
219
      rst => rst,
220
      clk => clk,
221
 
222
      wbs_cyc_i => wb_cyc,
223
      wbs_stb_i => wb_stb,
224
      wbs_we_i => wb_we,
225
      wbs_adr_i => wb_adr,
226
      wbs_dat_m2s_i => wb_dat_m2s,
227
      wbs_dat_s2m_o => wb_dat_s2m,
228
      wbs_ack_o => wb_ack,
229
 
230
      gpio_in_i => gpio_in,
231
      gpio_out_o => gpio_out,
232
      gpio_oe_o => gpio_oe
233
    );
234
 
235
  -- i/o buffer generation
236
  gpio_in <= p_gpio_io;
237
  process(gpio_oe, gpio_out)
238
  begin
239
    for i in 0 to 7 loop
240
      if gpio_oe(i) = IS_OUTPUT then
241
        p_gpio_io(i) <= gpio_out(i);
242
      else
243
        p_gpio_io(i) <= 'Z';
244
      end if;
245
    end loop;
246
  end process;
247
 
248
end rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.