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

Subversion Repositories wb4pb

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

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 31 ste.fis
--    and/or other materials provided with the distribution.
17 2 ste.fis
--
18
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
19
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
20
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
21
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
22
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
23
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
24
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
25
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
26
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
27
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
28
-- POSSIBILITY OF SUCH DAMAGE.
29
--
30
--------------------------------------------------------------------------------
31
-- filename: picoblaze_wb_gpio.vhd
32
-- description: synthesizable PicoBlaze (TM) general purpose i/o example using 
33
--              wishbone
34
-- todo4user: add other modules as needed
35
-- version: 0.0.0
36
-- changelog: - 0.0.0, initial release
37
--            - ...
38
--------------------------------------------------------------------------------
39
 
40
 
41
library ieee;
42
use ieee.std_logic_1164.all;
43
 
44
 
45
entity picoblaze_wb_gpio is
46
  port
47
  (
48 19 ste.fis
    p_rst_n_i : in std_logic;
49 2 ste.fis
    p_clk_i : in std_logic;
50
 
51
    p_gpio_io : inout std_logic_vector(7 downto 0)
52
  );
53
end picoblaze_wb_gpio;
54
 
55
 
56
architecture rtl of picoblaze_wb_gpio is
57
 
58
  component kcpsm3 is
59
    port
60
    (
61
      address : out std_logic_vector(9 downto 0);
62
      instruction : in std_logic_vector(17 downto 0);
63
      port_id : out std_logic_vector(7 downto 0);
64
      write_strobe : out std_logic;
65
      out_port : out std_logic_vector(7 downto 0);
66
      read_strobe : out std_logic;
67
      in_port : in std_logic_vector(7 downto 0);
68
      interrupt : in std_logic;
69
      interrupt_ack : out std_logic;
70
      reset : in std_logic;
71
      clk : in std_logic
72
    );
73
  end component;
74
 
75
  component pbwbgpio is
76
    port
77
    (
78
      address : in std_logic_vector(9 downto 0);
79
      instruction : out std_logic_vector(17 downto 0);
80
      clk : in std_logic
81
    );
82
  end component;
83
 
84
  component wbm_picoblaze is
85
    port
86
    (
87
      rst : in std_logic;
88
      clk : in std_logic;
89
 
90
      wbm_cyc_o : out std_logic;
91
      wbm_stb_o : out std_logic;
92
      wbm_we_o : out std_logic;
93
      wbm_adr_o : out std_logic_vector(7 downto 0);
94
      wbm_dat_m2s_o : out std_logic_vector(7 downto 0);
95
      wbm_dat_s2m_i : in std_logic_vector(7 downto 0);
96
      wbm_ack_i : in std_logic;
97
 
98
      pb_port_id_i : in std_logic_vector(7 downto 0);
99
      pb_write_strobe_i : in std_logic;
100
      pb_out_port_i : in std_logic_vector(7 downto 0);
101
      pb_read_strobe_i : in std_logic;
102
      pb_in_port_o : out std_logic_vector(7 downto 0)
103
    );
104
  end component;
105
 
106
  component wbs_gpio is
107
    port
108
    (
109
      rst : in std_logic;
110
      clk : in std_logic;
111
 
112
      wbs_cyc_i : in std_logic;
113
      wbs_stb_i : in std_logic;
114
      wbs_we_i : in std_logic;
115
      wbs_adr_i : in std_logic_vector(7 downto 0);
116
      wbs_dat_m2s_i : in std_logic_vector(7 downto 0);
117
      wbs_dat_s2m_o : out std_logic_vector(7 downto 0);
118
      wbs_ack_o : out std_logic;
119
 
120
      gpio_in_i : in std_logic_vector(7 downto 0);
121
      gpio_out_o : out std_logic_vector(7 downto 0);
122
      gpio_oe_o : out std_logic_vector(7 downto 0)
123
    );
124
  end component;
125
 
126
  signal rst : std_logic := '1';
127
  signal clk : std_logic := '1';
128
 
129
  signal wb_cyc : std_logic := '0';
130
  signal wb_stb : std_logic := '0';
131
  signal wb_we : std_logic := '0';
132
  signal wb_adr : std_logic_vector(7 downto 0) := (others => '0');
133
  signal wb_dat_m2s : std_logic_vector(7 downto 0) := (others => '0');
134
  signal wb_dat_s2m : std_logic_vector(7 downto 0) := (others => '0');
135
  signal wb_ack : std_logic := '0';
136
 
137
  signal pb_write_strobe : std_logic := '0';
138
  signal pb_read_strobe : std_logic := '0';
139
  signal pb_port_id : std_logic_vector(7 downto 0) := (others => '0');
140
  signal pb_in_port : std_logic_vector(7 downto 0) := (others => '0');
141
  signal pb_out_port : std_logic_vector(7 downto 0) := (others => '0');
142
 
143
  signal instruction : std_logic_vector(17 downto 0) := (others => '0');
144
  signal address : std_logic_vector(9 downto 0) := (others => '0');
145
 
146
  signal interrupt : std_logic := '0';
147
  signal interrupt_ack : std_logic := '0';
148
 
149
  signal gpio_in : std_logic_vector(7 downto 0) := (others => '0');
150
  signal gpio_out : std_logic_vector(7 downto 0) := (others => '0');
151
  signal gpio_oe : std_logic_vector(7 downto 0) := (others => '0');
152
 
153
  constant IS_INPUT : std_logic := '0';
154
  constant IS_OUTPUT : std_logic := not IS_INPUT;
155
 
156
begin
157
 
158
  -- reset synchronisation
159
  process(clk)
160
  begin
161 26 ste.fis
    if rising_edge(clk) then
162
      rst <= not p_rst_n_i;
163
    end if;
164 2 ste.fis
  end process;
165
  clk <= p_clk_i;
166
 
167
  -- module instances
168
  -------------------
169
 
170
  inst_kcpsm3 : kcpsm3
171
    port map
172
    (
173
      address => address,
174
      instruction => instruction,
175
      port_id => pb_port_id,
176
      write_strobe => pb_write_strobe,
177
      out_port => pb_out_port,
178
      read_strobe => pb_read_strobe,
179
      in_port => pb_in_port,
180
      interrupt => interrupt,
181
      interrupt_ack => interrupt_ack,
182
      reset => rst,
183
      clk => clk
184
    );
185
 
186
  inst_pbwbgpio : pbwbgpio
187
    port map
188
    (
189
      address => address,
190
      instruction => instruction,
191
      clk => clk
192
    );
193
 
194
  inst_wbm_picoblaze : wbm_picoblaze
195
    port map
196
    (
197
      rst => rst,
198
      clk => clk,
199
 
200
      wbm_cyc_o => wb_cyc,
201
      wbm_stb_o => wb_stb,
202
      wbm_we_o => wb_we,
203
      wbm_adr_o => wb_adr,
204
      wbm_dat_m2s_o => wb_dat_m2s,
205
      wbm_dat_s2m_i => wb_dat_s2m,
206
      wbm_ack_i => wb_ack,
207
 
208
      pb_port_id_i => pb_port_id,
209
      pb_write_strobe_i => pb_write_strobe,
210
      pb_out_port_i => pb_out_port,
211
      pb_read_strobe_i => pb_read_strobe,
212
      pb_in_port_o => pb_in_port
213
    );
214
 
215
  inst_wbs_gpio : wbs_gpio
216
    port map
217
    (
218
      rst => rst,
219
      clk => clk,
220
 
221
      wbs_cyc_i => wb_cyc,
222
      wbs_stb_i => wb_stb,
223
      wbs_we_i => wb_we,
224
      wbs_adr_i => wb_adr,
225
      wbs_dat_m2s_i => wb_dat_m2s,
226
      wbs_dat_s2m_o => wb_dat_s2m,
227
      wbs_ack_o => wb_ack,
228
 
229
      gpio_in_i => gpio_in,
230
      gpio_out_o => gpio_out,
231
      gpio_oe_o => gpio_oe
232
    );
233
 
234
  -- i/o buffer generation
235
  gpio_in <= p_gpio_io;
236
  process(gpio_oe, gpio_out)
237
  begin
238
    for i in 0 to 7 loop
239
      if gpio_oe(i) = IS_OUTPUT then
240
        p_gpio_io(i) <= gpio_out(i);
241
      else
242
        p_gpio_io(i) <= 'Z';
243
      end if;
244
    end loop;
245
  end process;
246
 
247
end rtl;

powered by: WebSVN 2.1.0

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