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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [io.v] - Blame information for rev 44

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

Line No. Rev Author Line
1 44 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  IO functions                                                ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  IO functions such as IOB flip-flops                         ////
7
////                                                              ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   -                                                          ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13
////      - Michael Unneback, unneback@opencores.org              ////
14
////        ORSoC AB                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2010 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43
`ifdef O_DFF
44
`define MODULE o_dff
45
module `BASE`MODULE (d_i, o_pad, clk, rst);
46
`undef MODULE
47
parameter width = 1;
48
input [width-1:0]  d_i;
49
output [width-1:0] o_pad;
50
input clk, rst;
51
wire [width-1:0] d_i_int `SYN_KEEP;
52
assign d_i_int = d_i;
53
genvar i;
54
for (i=0;i<width;i=i+1) begin
55
    always @ (posedge clk or posedge rst)
56
    if (rst)
57
        o_pad[i] <= 1'b0;
58
    else
59
        o_pad[i] <= d_i_int[i];
60
end
61
endgenerate
62
endmodule
63
`endif
64
 
65
`ifdef IO_DFF_OE
66
`define MODULE io_dff_oe
67
module `BASE`MODULE ( d_i, d_o, oe, io_pad, clk, rst);
68
`undef MODULE
69
parameter width = 1;
70
input  [width-1:0] d_o;
71
output reg [width-1:0] d_i;
72
input oe;
73
inout [width-1:0] io_pad;
74
input clk, rst;
75
wire [width-1:0] oe_d `SYN_KEEP;
76
reg [width-1:0] oe_q;
77
reg [width-1:0] d_o_q;
78
assign oe_d = {width{oe}};
79
genvar i;
80
generate
81
for (i=0;i<width;i=i+1) begin
82
    always @ (posedge clk or posedge rst)
83
    if (rst)
84
        oe_q[i] <= 1'b0;
85
    else
86
        oe_q[i] <= oe_d[i];
87
    always @ (posedge clk or posedge rst)
88
    if (rst)
89
        d_o_q[i] <= 1'b0;
90
    else
91
        d_o_q[i] <= d_o[i];
92
    always @ (posedge clk or posedge rst)
93
    if (rst)
94
        d_i[i] <= 1'b0;
95
    else
96
        d_i[i] <= io_pad[i];
97
    assign io_pad[i] = (oe_q[i]) ? d_o_q[i] : 1'bz;
98
end
99
endgenerate
100
endmodule
101
`endif

powered by: WebSVN 2.1.0

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