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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_diligent_s3board/] [rtl/] [verilog/] [io_mux.v] - Blame information for rev 94

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

Line No. Rev Author Line
1 2 olivier.gi
//----------------------------------------------------------------------------
2
// Copyright (C) 2001 Authors
3
//
4
// This source file may be used and distributed without restriction provided
5
// that this copyright statement is not removed from the file and that any
6
// derivative work contains the original copyright notice and the associated
7
// disclaimer.
8
//
9
// This source file is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU Lesser General Public License as published
11
// by the Free Software Foundation; either version 2.1 of the License, or
12
// (at your option) any later version.
13
//
14
// This source is distributed in the hope that it will be useful, but WITHOUT
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
// License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public License
20
// along with this source; if not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
//
23
//----------------------------------------------------------------------------
24
//
25
// *File Name: io_mux.v
26
// 
27
// *Module Description:
28
//                      I/O mux for port function selection.
29
//
30
// *Author(s):
31
//              - Olivier Girard,    olgirard@gmail.com
32
//
33
//----------------------------------------------------------------------------
34 16 olivier.gi
// $Rev: 23 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2009-08-30 18:39:26 +0200 (Sun, 30 Aug 2009) $
37
//----------------------------------------------------------------------------
38 23 olivier.gi
`include "timescale.v"
39 2 olivier.gi
 
40
module  io_mux (
41
 
42
// Function A (typically GPIO)
43
    a_din,
44
    a_dout,
45
    a_dout_en,
46
 
47
// Function B (Timer A, ...)
48
    b_din,
49
    b_dout,
50
    b_dout_en,
51
 
52
// IO Cell
53
    io_din,
54
    io_dout,
55
    io_dout_en,
56
 
57
// Function selection (0=A, 1=B)
58
    sel
59
);
60
 
61
// PARAMETERs
62
//============
63
parameter          WIDTH = 8;
64
 
65
// Function A (typically GPIO)
66
//===============================
67
output [WIDTH-1:0] a_din;
68
input  [WIDTH-1:0] a_dout;
69
input  [WIDTH-1:0] a_dout_en;
70
 
71
// Function B (Timer A, ...)
72
//===============================
73
output [WIDTH-1:0] b_din;
74
input  [WIDTH-1:0] b_dout;
75
input  [WIDTH-1:0] b_dout_en;
76
 
77
// IO Cell
78
//===============================
79
input  [WIDTH-1:0] io_din;
80
output [WIDTH-1:0] io_dout;
81
output [WIDTH-1:0] io_dout_en;
82
 
83
// Function selection (0=A, 1=B)
84
//===============================
85
input  [WIDTH-1:0] sel;
86
 
87
 
88
//=============================================================================
89
// 1)  I/O FUNCTION SELECTION MUX
90
//=============================================================================
91
 
92
function [WIDTH-1:0] mux (
93
   input [WIDTH-1:0] A,
94
   input [WIDTH-1:0] B,
95
   input [WIDTH-1:0] SEL
96
);
97
   integer i;
98
   begin
99
      mux = {WIDTH{1'b0}};
100
      for (i = 0; i < WIDTH; i = i + 1)
101
        mux[i] = sel[i] ? B[i] : A[i];
102
   end
103
endfunction
104
 
105
 
106
assign a_din      = mux(       io_din, {WIDTH{1'b0}}, sel);
107
assign b_din      = mux({WIDTH{1'b0}},        io_din, sel);
108
assign io_dout    = mux(       a_dout,        b_dout, sel);
109
assign io_dout_en = mux(    a_dout_en,     b_dout_en, sel);
110
 
111
 
112
endmodule // io_mux

powered by: WebSVN 2.1.0

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