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

Subversion Repositories wb4pb

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

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 26 ste.fis
    if rising_edge(clk) then
165
      rst <= not p_rst_n_i;
166
    end if;
167 2 ste.fis
  end process;
168
  clk <= p_clk_i;
169
 
170
  -- module instances
171
  -------------------
172
 
173
  inst_kcpsm3 : kcpsm3
174
    port map
175
    (
176
      address => address,
177
      instruction => instruction,
178
      port_id => pb_port_id,
179
      write_strobe => pb_write_strobe,
180
      out_port => pb_out_port,
181
      read_strobe => pb_read_strobe,
182
      in_port => pb_in_port,
183
      interrupt => interrupt,
184
      interrupt_ack => interrupt_ack,
185
      reset => rst,
186
      clk => clk
187
    );
188
 
189
  inst_pbwbgpio : pbwbgpio
190
    port map
191
    (
192
      address => address,
193
      instruction => instruction,
194
      clk => clk
195
    );
196
 
197
  inst_wbm_picoblaze : wbm_picoblaze
198
    port map
199
    (
200
      rst => rst,
201
      clk => clk,
202
 
203
      wbm_cyc_o => wb_cyc,
204
      wbm_stb_o => wb_stb,
205
      wbm_we_o => wb_we,
206
      wbm_adr_o => wb_adr,
207
      wbm_dat_m2s_o => wb_dat_m2s,
208
      wbm_dat_s2m_i => wb_dat_s2m,
209
      wbm_ack_i => wb_ack,
210
 
211
      pb_port_id_i => pb_port_id,
212
      pb_write_strobe_i => pb_write_strobe,
213
      pb_out_port_i => pb_out_port,
214
      pb_read_strobe_i => pb_read_strobe,
215
      pb_in_port_o => pb_in_port
216
    );
217
 
218
  inst_wbs_gpio : wbs_gpio
219
    port map
220
    (
221
      rst => rst,
222
      clk => clk,
223
 
224
      wbs_cyc_i => wb_cyc,
225
      wbs_stb_i => wb_stb,
226
      wbs_we_i => wb_we,
227
      wbs_adr_i => wb_adr,
228
      wbs_dat_m2s_i => wb_dat_m2s,
229
      wbs_dat_s2m_o => wb_dat_s2m,
230
      wbs_ack_o => wb_ack,
231
 
232
      gpio_in_i => gpio_in,
233
      gpio_out_o => gpio_out,
234
      gpio_oe_o => gpio_oe
235
    );
236
 
237
  -- i/o buffer generation
238
  gpio_in <= p_gpio_io;
239
  process(gpio_oe, gpio_out)
240
  begin
241
    for i in 0 to 7 loop
242
      if gpio_oe(i) = IS_OUTPUT then
243
        p_gpio_io(i) <= gpio_out(i);
244
      else
245
        p_gpio_io(i) <= 'Z';
246
      end if;
247
    end loop;
248
  end process;
249
 
250
end rtl;

powered by: WebSVN 2.1.0

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