Skip to content

Commit 9c65624

Browse files
committed
Adding binary encoded 2:1 vectorized mux
- More efficient than one hot when it's not possible for synthesis to do global optimization.
1 parent 8d9759b commit 9c65624

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

lambdalib/veclib/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .la_vinv.la_vinv import Vinv
33
from .la_vmux.la_vmux import Vmux
44
from .la_vmux2.la_vmux2 import Vmux2
5+
from .la_vmux2.la_vmux2b import Vmux2b
56
from .la_vmux3.la_vmux3 import Vmux3
67
from .la_vmux4.la_vmux4 import Vmux4
78
from .la_vmux5.la_vmux5 import Vmux5
@@ -13,6 +14,7 @@
1314
'Vinv',
1415
'Vmux',
1516
'Vmux2',
17+
'Vmux2b',
1618
'Vmux3',
1719
'Vmux4',
1820
'Vmux5',
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from lambdalib import Lambda
2+
3+
4+
class Vmux2b(Lambda):
5+
def __init__(self):
6+
name = 'la_vmux2'
7+
sources = [f'rtl/{name}.v']
8+
super().__init__(name, sources, __file__)
9+
10+
11+
if __name__ == "__main__":
12+
d = Vmux2b()
13+
d.write_fileset(f"{d.name()}.f", fileset="rtl")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//############################################################################
2+
//# Function: 2-Input one-hot vectorized mux #
3+
//# Copyright: Lambda Project Authors. All rights Reserved. #
4+
//# License: MIT (see LICENSE file in Lambda repository) #
5+
//############################################################################
6+
7+
module la_vmux2 #(parameter W = 1, // width of mux
8+
parameter PROP = "DEFAULT" // cell property
9+
)
10+
(
11+
input sel,
12+
input [W-1:0] in1,
13+
input [W-1:0] in0,
14+
output [W-1:0] out
15+
);
16+
17+
assign out[W-1:0] = ({(W) {~sel}} & in0[W-1:0] |
18+
{(W) {sel}} & in1[W-1:0]);
19+
20+
endmodule

0 commit comments

Comments
 (0)