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

Subversion Repositories wb4pb

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

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 10 ste.fis
  always@(clk)
93 2 ste.fis
    rst <= p_rst_i;
94
  assign clk = p_clk_i;
95
 
96
  // module instances
97
  ///////////////////
98
 
99
  kcpsm3 inst_kcpsm3 (
100
    .address(address),
101
    .instruction(instruction),
102
    .port_id(pb_port_id),
103
    .write_strobe(pb_write_strobe),
104
    .out_port(pb_out_port),
105
    .read_strobe(pb_read_strobe),
106
    .in_port(pb_in_port),
107
    .interrupt(interrupt),
108
    .interrupt_ack(interrupt_ack),
109
    .reset(rst),
110
    .clk(clk)
111
  );
112
 
113
  pbwbgpio inst_pbwbgpio (
114
    .address(address),
115
    .instruction(instruction),
116
    .clk(clk)
117
  );
118
 
119
  wbm_picoblaze inst_wbm_picoblaze (
120
    .rst(rst),
121
    .clk(clk),
122
 
123
    .wbm_cyc_o(wb_cyc),
124
    .wbm_stb_o(wb_stb),
125
    .wbm_we_o(wb_we),
126
    .wbm_adr_o(wb_adr),
127
    .wbm_dat_m2s_o(wb_dat_m2s),
128
    .wbm_dat_s2m_i(wb_dat_s2m),
129
    .wbm_ack_i(wb_ack),
130
 
131
    .pb_port_id_i(pb_port_id),
132
    .pb_write_strobe_i(pb_write_strobe),
133
    .pb_out_port_i(pb_out_port),
134
    .pb_read_strobe_i(pb_read_strobe),
135
    .pb_in_port_o(pb_in_port)
136
  );
137
 
138
  wbs_gpio inst_wbs_gpio (
139
    .rst(rst),
140
    .clk(clk),
141
 
142
    .wbs_cyc_i(wb_cyc),
143
    .wbs_stb_i(wb_stb),
144
    .wbs_we_i(wb_we),
145
    .wbs_adr_i(wb_adr),
146
    .wbs_dat_m2s_i(wb_dat_m2s),
147
    .wbs_dat_s2m_o(wb_dat_s2m),
148
    .wbs_ack_o(wb_ack),
149
 
150
    .gpio_in_i(gpio_in),
151
    .gpio_out_o(gpio_out),
152
    .gpio_oe_o(gpio_oe)
153
  );
154
 
155
  // i/o buffer generation
156
  assign gpio_in = p_gpio_io;
157 10 ste.fis
  always@(gpio_oe or gpio_out)
158
    for (i = 0; i <= 7; i = i + 1)
159 2 ste.fis
      if (gpio_oe[i] == IS_OUTPUT)
160
        gpio[i] = gpio_out[i];
161
      else
162
        gpio[i] = 1'bZ;
163
  assign p_gpio_io = gpio;
164
 
165
endmodule

powered by: WebSVN 2.1.0

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