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

Subversion Repositories wb4pb

[/] [wb4pb/] [trunk/] [rtl/] [picoblaze_wb_gpio.v] - Blame information for rev 2

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.v
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
module picoblaze_wb_gpio (
45
  p_rst_i,
46
  p_clk_i,
47
 
48
  p_gpio_io
49
);
50
 
51
  input p_rst_i;
52
  wire  p_rst_i;
53
  input p_clk_i;
54
  wire  p_clk_i;
55
 
56
  inout[7:0] p_gpio_io;
57
  wire [7:0] p_gpio_io;
58
 
59
  reg rst;
60
  wire clk;
61
 
62
  wire wb_cyc;
63
  wire wb_stb;
64
  wire wb_we;
65
  wire[7:0] wb_adr;
66
  wire[7:0] wb_dat_m2s;
67
  wire[7:0] wb_dat_s2m;
68
  wire wb_ack;
69
 
70
  wire pb_write_strobe;
71
  wire pb_read_strobe;
72
  wire[7:0] pb_port_id;
73
  wire[7:0] pb_in_port;
74
  wire[7:0] pb_out_port;
75
 
76
  wire[17:0] instruction;
77
  wire[9:0] address;
78
 
79
  wire interrupt;
80
  wire interrupt_ack;
81
 
82
  wire[7:0] gpio_in;
83
  wire[7:0] gpio_out;
84
  wire[7:0] gpio_oe;
85
  reg [7:0] gpio;
86
 
87
  parameter IS_INPUT = 1'b0;
88
  parameter IS_OUTPUT = ! IS_INPUT;
89
  integer i;
90
 
91
  // reset synchronisation
92
  always@(clk) begin
93
    rst <= p_rst_i;
94
  end
95
  assign clk = p_clk_i;
96
 
97
  // module instances
98
  ///////////////////
99
 
100
  kcpsm3 inst_kcpsm3 (
101
    .address(address),
102
    .instruction(instruction),
103
    .port_id(pb_port_id),
104
    .write_strobe(pb_write_strobe),
105
    .out_port(pb_out_port),
106
    .read_strobe(pb_read_strobe),
107
    .in_port(pb_in_port),
108
    .interrupt(interrupt),
109
    .interrupt_ack(interrupt_ack),
110
    .reset(rst),
111
    .clk(clk)
112
  );
113
 
114
  pbwbgpio inst_pbwbgpio (
115
    .address(address),
116
    .instruction(instruction),
117
    .clk(clk)
118
  );
119
 
120
  wbm_picoblaze inst_wbm_picoblaze (
121
    .rst(rst),
122
    .clk(clk),
123
 
124
    .wbm_cyc_o(wb_cyc),
125
    .wbm_stb_o(wb_stb),
126
    .wbm_we_o(wb_we),
127
    .wbm_adr_o(wb_adr),
128
    .wbm_dat_m2s_o(wb_dat_m2s),
129
    .wbm_dat_s2m_i(wb_dat_s2m),
130
    .wbm_ack_i(wb_ack),
131
 
132
    .pb_port_id_i(pb_port_id),
133
    .pb_write_strobe_i(pb_write_strobe),
134
    .pb_out_port_i(pb_out_port),
135
    .pb_read_strobe_i(pb_read_strobe),
136
    .pb_in_port_o(pb_in_port)
137
  );
138
 
139
  wbs_gpio inst_wbs_gpio (
140
    .rst(rst),
141
    .clk(clk),
142
 
143
    .wbs_cyc_i(wb_cyc),
144
    .wbs_stb_i(wb_stb),
145
    .wbs_we_i(wb_we),
146
    .wbs_adr_i(wb_adr),
147
    .wbs_dat_m2s_i(wb_dat_m2s),
148
    .wbs_dat_s2m_o(wb_dat_s2m),
149
    .wbs_ack_o(wb_ack),
150
 
151
    .gpio_in_i(gpio_in),
152
    .gpio_out_o(gpio_out),
153
    .gpio_oe_o(gpio_oe)
154
  );
155
 
156
  // i/o buffer generation
157
  assign gpio_in = p_gpio_io;
158
  always@(gpio_oe or gpio_out) begin
159
    for (i = 0; i <= 7; i = i + 1) begin
160
      if (gpio_oe[i] == IS_OUTPUT)
161
        gpio[i] = gpio_out[i];
162
      else
163
        gpio[i] = 1'bZ;
164
    end
165
  end
166
  assign p_gpio_io = gpio;
167
 
168
endmodule

powered by: WebSVN 2.1.0

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