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

Subversion Repositories wb4pb

[/] [wb4pb/] [trunk/] [impl/] [avnet_sp3a_eval_gpio_vhd.vhd] - Blame information for rev 24

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

Line No. Rev Author Line
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
    rst <= FPGA_RESET;
172
  end process;
173
  clk <= CLK_16MHZ;
174
 
175
  -- module instances
176
  -------------------
177
 
178
  inst_kcpsm3 : kcpsm3
179
    port map
180
    (
181
      address => address,
182
      instruction => instruction,
183
      port_id => pb_port_id,
184
      write_strobe => pb_write_strobe,
185
      out_port => pb_out_port,
186
      read_strobe => pb_read_strobe,
187
      in_port => pb_in_port,
188
      interrupt => interrupt,
189
      interrupt_ack => interrupt_ack,
190
      reset => rst,
191
      clk => clk
192
    );
193
 
194
  inst_pbwbgpio : pbwbgpio
195
    port map
196
    (
197
      address => address,
198
      instruction => instruction,
199
      clk => clk
200
    );
201
 
202
  inst_wbm_picoblaze : wbm_picoblaze
203
    port map
204
    (
205
      rst => rst,
206
      clk => clk,
207
 
208
      wbm_cyc_o => wb_cyc,
209
      wbm_stb_o => wb_stb,
210
      wbm_we_o => wb_we,
211
      wbm_adr_o => wb_adr,
212
      wbm_dat_m2s_o => wb_dat_m2s,
213
      wbm_dat_s2m_i => wb_dat_s2m,
214
      wbm_ack_i => wb_ack,
215
 
216
      pb_port_id_i => pb_port_id,
217
      pb_write_strobe_i => pb_write_strobe,
218
      pb_out_port_i => pb_out_port,
219
      pb_read_strobe_i => pb_read_strobe,
220
      pb_in_port_o => pb_in_port
221
    );
222
 
223
  inst_wbs_gpio : wbs_gpio
224
    port map
225
    (
226
      rst => rst,
227
      clk => clk,
228
 
229
      wbs_cyc_i => wb_cyc,
230
      wbs_stb_i => wb_stb,
231
      wbs_we_i => wb_we,
232
      wbs_adr_i => wb_adr,
233
      wbs_dat_m2s_i => wb_dat_m2s,
234
      wbs_dat_s2m_o => wb_dat_s2m,
235
      wbs_ack_o => wb_ack,
236
 
237
      gpio_in_i => gpio_in,
238
      gpio_out_o => gpio_out,
239
      gpio_oe_o => gpio_oe
240
    );
241
 
242
  -- i/o buffer generation
243
 
244
  gpio_in <= (
245
    4 => FPGA_PUSH_A,
246
    5 => FPGA_PUSH_B,
247
    6 => FPGA_PUSH_C,
248
    others => '0'
249
  );
250
 
251
  LED1 <= gpio_out(0);
252
  LED2 <= gpio_out(1);
253
  LED3 <= gpio_out(2);
254
  LED4 <= timer(23);
255
 
256
  led_blinker : process(clk)
257
  begin
258
    if rising_edge(clk) then
259
      timer <= timer + 1;
260
      if rst = '1' then
261
        timer <= (others => '0');
262
      end if;
263
    end if;
264
  end process;
265
 
266
end rtl;

powered by: WebSVN 2.1.0

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