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

Subversion Repositories wb4pb

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

powered by: WebSVN 2.1.0

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