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 95

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 45 unneback
`timescale 1ns/1ns
43 44 unneback
`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 45 unneback
parameter reset_value = {width{1'b0}};
49
input  [width-1:0]  d_i;
50 44 unneback
output [width-1:0] o_pad;
51
input clk, rst;
52
wire [width-1:0] d_i_int `SYN_KEEP;
53 45 unneback
reg  [width-1:0] o_pad_int;
54 44 unneback
assign d_i_int = d_i;
55
genvar i;
56 45 unneback
generate
57 44 unneback
for (i=0;i<width;i=i+1) begin
58
    always @ (posedge clk or posedge rst)
59
    if (rst)
60 45 unneback
        o_pad_int[i] <= reset_value[i];
61 44 unneback
    else
62 45 unneback
        o_pad_int[i] <= d_i_int[i];
63
    assign #1 o_pad[i] = o_pad_int[i];
64 44 unneback
end
65
endgenerate
66
endmodule
67
`endif
68
 
69 45 unneback
`timescale 1ns/1ns
70 44 unneback
`ifdef IO_DFF_OE
71
`define MODULE io_dff_oe
72
module `BASE`MODULE ( d_i, d_o, oe, io_pad, clk, rst);
73
`undef MODULE
74
parameter width = 1;
75
input  [width-1:0] d_o;
76
output reg [width-1:0] d_i;
77
input oe;
78
inout [width-1:0] io_pad;
79
input clk, rst;
80
wire [width-1:0] oe_d `SYN_KEEP;
81
reg [width-1:0] oe_q;
82
reg [width-1:0] d_o_q;
83
assign oe_d = {width{oe}};
84
genvar i;
85
generate
86
for (i=0;i<width;i=i+1) begin
87
    always @ (posedge clk or posedge rst)
88
    if (rst)
89
        oe_q[i] <= 1'b0;
90
    else
91
        oe_q[i] <= oe_d[i];
92
    always @ (posedge clk or posedge rst)
93
    if (rst)
94
        d_o_q[i] <= 1'b0;
95
    else
96
        d_o_q[i] <= d_o[i];
97
    always @ (posedge clk or posedge rst)
98
    if (rst)
99
        d_i[i] <= 1'b0;
100
    else
101
        d_i[i] <= io_pad[i];
102 45 unneback
    assign #1 io_pad[i] = (oe_q[i]) ? d_o_q[i] : 1'bz;
103 44 unneback
end
104
endgenerate
105
endmodule
106
`endif

powered by: WebSVN 2.1.0

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