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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [logic.v] - Blame information for rev 38

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

Line No. Rev Author Line
1 32 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Logic functions                                             ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  Logic functions such as multiplexers                        ////
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 36 unneback
module vl_mux_andor ( a, sel, dout);
43
 
44
parameter width = 32;
45
parameter nr_of_ports = 4;
46
 
47
input [nr_of_ports*width-1:0] a;
48
input [nr_of_ports-1:0] sel;
49
output reg [width-1:0] dout;
50
 
51 38 unneback
integer i,j;
52
 
53 36 unneback
always @ (a, sel)
54
begin
55
    dout = a[width-1:0] & {width{sel[0]}};
56
    for (i=nr_of_ports-2;i<nr_of_ports;i=i+1)
57 38 unneback
        for (j=0;j<32;j=j+1)
58
            dout[j] = (a[(i-1)*width + j] & sel[i]) | dout[j];
59 36 unneback
end
60
 
61
endmodule
62
 
63 34 unneback
module vl_mux2_andor ( a1, a0, sel, dout);
64 32 unneback
 
65 34 unneback
parameter width = 32;
66 35 unneback
localparam nr_of_ports = 2;
67 34 unneback
input [width-1:0] a1, a0;
68
input [nr_of_ports-1:0] sel;
69
output [width-1:0] dout;
70
 
71 36 unneback
vl_mux_andor
72 38 unneback
    # ( .width(width), .nr_of_ports(nr_of_ports))
73 36 unneback
    mux0( .a({a1,a0}), .sel(sel), .dout(dout));
74 38 unneback
 
75 34 unneback
endmodule
76
 
77
module vl_mux3_andor ( a2, a1, a0, sel, dout);
78
 
79
parameter width = 32;
80 35 unneback
localparam nr_of_ports = 3;
81 34 unneback
input [width-1:0] a2, a1, a0;
82
input [nr_of_ports-1:0] sel;
83
output [width-1:0] dout;
84
 
85 36 unneback
vl_mux_andor
86 38 unneback
    # ( .width(width), .nr_of_ports(nr_of_ports))
87 36 unneback
    mux0( .a({a2,a1,a0}), .sel(sel), .dout(dout));
88 38 unneback
 
89 34 unneback
endmodule
90
 
91 32 unneback
module vl_mux4_andor ( a3, a2, a1, a0, sel, dout);
92
 
93
parameter width = 32;
94 35 unneback
localparam nr_of_ports = 4;
95 32 unneback
input [width-1:0] a3, a2, a1, a0;
96
input [nr_of_ports-1:0] sel;
97
output [width-1:0] dout;
98
 
99 36 unneback
vl_mux_andor
100 38 unneback
    # ( .width(width), .nr_of_ports(nr_of_ports))
101 36 unneback
    mux0( .a({a3,a2,a1,a0}), .sel(sel), .dout(dout));
102 32 unneback
 
103
endmodule
104
 
105
module vl_mux5_andor ( a4, a3, a2, a1, a0, sel, dout);
106
 
107
parameter width = 32;
108 35 unneback
localparam nr_of_ports = 5;
109 32 unneback
input [width-1:0] a4, a3, a2, a1, a0;
110
input [nr_of_ports-1:0] sel;
111
output [width-1:0] dout;
112
 
113 36 unneback
vl_mux_andor
114 38 unneback
    # ( .width(width), .nr_of_ports(nr_of_ports))
115 36 unneback
    mux0( .a({a4,a3,a2,a1,a0}), .sel(sel), .dout(dout));
116 32 unneback
 
117
endmodule
118
 
119
module vl_mux6_andor ( a5, a4, a3, a2, a1, a0, sel, dout);
120
 
121
parameter width = 32;
122 35 unneback
localparam nr_of_ports = 6;
123 32 unneback
input [width-1:0] a5, a4, a3, a2, a1, a0;
124
input [nr_of_ports-1:0] sel;
125
output [width-1:0] dout;
126
 
127 36 unneback
vl_mux_andor
128 38 unneback
    # ( .width(width), .nr_of_ports(nr_of_ports))
129 36 unneback
    mux0( .a({a5,a4,a3,a2,a1,a0}), .sel(sel), .dout(dout));
130 32 unneback
 
131
endmodule

powered by: WebSVN 2.1.0

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