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

Subversion Repositories sata_phy

[/] [sata_phy/] [trunk/] [hdl/] [mux.v] - Blame information for rev 15

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

Line No. Rev Author Line
1 9 beandigita
////////////////////////////////////////////////////////////
2
//
3
// This confidential and proprietary software may be used
4
// only as authorized by a licensing agreement from
5
// Bean Digital Ltd
6
// In the event of publication, the following notice is
7
// applicable:
8
//
9
// (C)COPYRIGHT 2009 BEAN DIGITAL LTD.
10
// ALL RIGHTS RESERVED
11
//
12
// The entire notice above must be reproduced on all
13
// authorized copies.
14
//
15
// File        : mux.v
16
// Author      : J.Bean
17
// Date        : Sep 2009
18
// Description : Multiplexer
19
////////////////////////////////////////////////////////////
20
 
21
`resetall
22
`timescale 1ns/10ps
23
 
24
module mux
25
  #(parameter DATA_BITS  = 16,                // Data bits
26
    parameter IP_NUM     = 4,                 // Number of inputs
27
    parameter USE_OP_REG = 0)(                // Enable Register on Output 
28
  input  wire                        clk,     // Clock
29
  input  wire [IP_NUM*DATA_BITS-1:0] data_i,  // Data Input
30
  input  wire [7:0]                  sel_i,   // Input Select
31
  output wire [DATA_BITS-1:0]        data_o   // Data Output
32
);
33
 
34
////////////////////////////////////////////////////////////
35
// Signals
36
//////////////////////////////////////////////////////////// 
37
 
38
genvar i;
39
reg  [DATA_BITS-1:0] ip_array [0:IP_NUM-1];
40
wire [DATA_BITS-1:0] data_c;
41
reg  [DATA_BITS-1:0] data_r;
42
 
43
////////////////////////////////////////////////////////////
44
// Comb Assign : Data Output
45
// Description : 
46
////////////////////////////////////////////////////////////
47
 
48
assign data_o = (USE_OP_REG == 1) ? data_r : data_c;
49
 
50
////////////////////////////////////////////////////////////
51
// Comb Assign : Data Comb
52
// Description : Assign an input vector from the array.
53
////////////////////////////////////////////////////////////
54
 
55
assign data_c = ip_array[sel_i];
56
 
57
////////////////////////////////////////////////////////////
58
// Generate    : Input array
59
// Description : Create an array of input vectors.
60
////////////////////////////////////////////////////////////
61
 
62
generate
63
  for(i=0; i<IP_NUM; i=i+1) begin: mux_gen
64
    always @(*)
65
    begin
66
      ip_array[i] = data_i[(i+1)*DATA_BITS-1:i*DATA_BITS];
67
    end
68
  end
69
endgenerate
70
 
71
////////////////////////////////////////////////////////////
72
// Seq Block   : Data Registered
73
// Description : 
74
// Assign an input vector from the array.
75
////////////////////////////////////////////////////////////
76
 
77
always @(posedge clk)
78
begin
79
  data_r <= ip_array[sel_i];
80
end
81
 
82
endmodule

powered by: WebSVN 2.1.0

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