bliftax 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bliftax.gemspec +1 -1
- data/lib/bliftax.rb +8 -8
- data/lib/bliftax/gate.rb +4 -1
- data/lib/bliftax/implicant.rb +1 -1
- data/lib/bliftax/implicant/bit.rb +12 -1
- data/lib/bliftax/optimizer.rb +5 -2
- data/lib/bliftax/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f21014af5db3e266688d3f20d31b817a11708c
|
4
|
+
data.tar.gz: 0d8c9011f2c4a9f36153d32f780cc843138dca3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1544c38fcc1755a1d1fb9268f211dc85025219c1aadf586edc917d3e059db9290a08b1269a32c429cd10a65c4b0c6fd39474d6a0551a4111e9bf757f95f7a9f
|
7
|
+
data.tar.gz: 7ed62be87398dd05a1a66495f5fd72d98e5f01b0a675621945b19eebd389ac82d38d4e99106044ea99a7ebb332cd76ad0285ea52594c3395af1ca1ed1ba3b9c5
|
data/bliftax.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Naoki Mizuno"]
|
10
10
|
spec.email = ["nigorojr@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = 'A library that parses BLIF files and
|
12
|
+
spec.summary = 'A library that parses BLIF files and does logic optimization'
|
13
13
|
spec.homepage = 'https://github.com/NigoroJr/bliftax'
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/bliftax.rb
CHANGED
@@ -22,7 +22,7 @@ class Bliftax
|
|
22
22
|
|
23
23
|
# Initializes the object.
|
24
24
|
#
|
25
|
-
# @param str [String] filename or text to parse
|
25
|
+
# @param str [String] filename or text to parse.
|
26
26
|
def initialize(str = nil)
|
27
27
|
@latches = []
|
28
28
|
@clocks = []
|
@@ -93,7 +93,7 @@ class Bliftax
|
|
93
93
|
|
94
94
|
# Returns a string representation of this gate in BLIF format.
|
95
95
|
#
|
96
|
-
# @return [String] this gate in BLIF format
|
96
|
+
# @return [String] this gate in BLIF format.
|
97
97
|
def to_blif
|
98
98
|
in_labels = @inputs.join(SPACE)
|
99
99
|
out_labels = @outputs.join(SPACE)
|
@@ -120,7 +120,7 @@ class Bliftax
|
|
120
120
|
|
121
121
|
# Duplicates this object.
|
122
122
|
#
|
123
|
-
# @return the deep copy of this object.
|
123
|
+
# @return [Bliftax] the deep copy of this object.
|
124
124
|
def dup
|
125
125
|
copy = Bliftax.new
|
126
126
|
copy.name = @name.dup
|
@@ -138,7 +138,7 @@ class Bliftax
|
|
138
138
|
# logical line (removing comments and joining lines that end with
|
139
139
|
# backslash with the next line).
|
140
140
|
#
|
141
|
-
# @param fh [IO]
|
141
|
+
# @param fh [IO] the file handle to read from.
|
142
142
|
#
|
143
143
|
# @return [Array] each element being the logical lines with comments and
|
144
144
|
# backslashes removed. Lines ending with a backslash gets joined with the
|
@@ -173,18 +173,18 @@ class Bliftax
|
|
173
173
|
|
174
174
|
# Removes the trailing comments from a string.
|
175
175
|
#
|
176
|
-
# @param str [String] the original string
|
176
|
+
# @param str [String] the original string.
|
177
177
|
#
|
178
|
-
# @return [String] string with the trailing whitespace and comments removed
|
178
|
+
# @return [String] string with the trailing whitespace and comments removed.
|
179
179
|
def strip_comments(str)
|
180
180
|
str.sub(/\s*\#.*$/, EMPTY).strip
|
181
181
|
end
|
182
182
|
|
183
183
|
# Removes the trailing backslash from a string.
|
184
184
|
#
|
185
|
-
# @param str [String] the original string
|
185
|
+
# @param str [String] the original string.
|
186
186
|
#
|
187
|
-
# @return [String] string with the trailing backslash removed
|
187
|
+
# @return [String] string with the trailing backslash removed.
|
188
188
|
def strip_trailing_backslash(str)
|
189
189
|
str.sub(/\\/, EMPTY)
|
190
190
|
end
|
data/lib/bliftax/gate.rb
CHANGED
@@ -24,6 +24,8 @@ class Bliftax
|
|
24
24
|
# being the output bit. For example, '010 1' represents the three inputs
|
25
25
|
# being 0, 1, 0 and the output being 1 in this case. If an Array is
|
26
26
|
# given, it will add all of the implicants.
|
27
|
+
#
|
28
|
+
# @return [Gate] the gate itself.
|
27
29
|
def add_implicant(implicant)
|
28
30
|
case implicant
|
29
31
|
when Implicant
|
@@ -34,6 +36,7 @@ class Bliftax
|
|
34
36
|
# Recursive call
|
35
37
|
implicant.each { |i| add(i) }
|
36
38
|
end
|
39
|
+
self
|
37
40
|
end
|
38
41
|
alias_method :<<, :add_implicant
|
39
42
|
|
@@ -55,7 +58,7 @@ class Bliftax
|
|
55
58
|
|
56
59
|
# Returns a string representation of this gate in BLIF format.
|
57
60
|
#
|
58
|
-
# @return [String] this gate in BLIF format
|
61
|
+
# @return [String] this gate in BLIF format.
|
59
62
|
def to_blif
|
60
63
|
str = format(".names %s %s\n",
|
61
64
|
@input_labels.join(SPACE),
|
data/lib/bliftax/implicant.rb
CHANGED
@@ -360,7 +360,7 @@ class Bliftax
|
|
360
360
|
|
361
361
|
# Checks whether all the bits are either 1, 0, or DC.
|
362
362
|
#
|
363
|
-
# @param bits [Array<String>]
|
363
|
+
# @param bits [Array<String>] the bits to be checked.
|
364
364
|
#
|
365
365
|
# @return [true, false] true if all the bits are 1, 0, or DC.
|
366
366
|
def bits_valid?(bits)
|
@@ -30,12 +30,23 @@ class Bliftax
|
|
30
30
|
|
31
31
|
# Checks for equality.
|
32
32
|
#
|
33
|
-
# @param other [Object] whatever to compare against
|
33
|
+
# @param other [Object] whatever to compare against.
|
34
|
+
#
|
35
|
+
# @return [true, false] true if two bits are equal, false otherwise.
|
34
36
|
def ==(other)
|
35
37
|
@bit == other.bit && @type == other.type
|
36
38
|
end
|
37
39
|
alias_method :eql?, :==
|
38
40
|
|
41
|
+
# Checks for inequality.
|
42
|
+
#
|
43
|
+
# @param other [Object] whatever to compare against.
|
44
|
+
#
|
45
|
+
# @return [true, false] true if two bits are not equal, false otherwise.
|
46
|
+
def !=(other)
|
47
|
+
@bit != other.bit || @type != other.type
|
48
|
+
end
|
49
|
+
|
39
50
|
# Returns the hash value of this instance.
|
40
51
|
#
|
41
52
|
# @return [Integer] the hash value of this instance.
|
data/lib/bliftax/optimizer.rb
CHANGED
@@ -5,7 +5,7 @@ class Bliftax
|
|
5
5
|
|
6
6
|
# Does 2-level logic optimization to the given gate (a set of implicants).
|
7
7
|
# This is done in the following steps (as described in the book
|
8
|
-
# Fundamentals of Digital Logic with Verilog Design.
|
8
|
+
# Fundamentals of Digital Logic with Verilog Design).
|
9
9
|
#
|
10
10
|
# 1. Find all prime implicants by using the star operator until the
|
11
11
|
# resulting set of implicants is the same as the previous round.
|
@@ -123,7 +123,7 @@ class Bliftax
|
|
123
123
|
#
|
124
124
|
# @param what [Implicant, #to_a<#cost>] the thing to be evaluated.
|
125
125
|
#
|
126
|
-
# @return the evaluated cost
|
126
|
+
# @return the evaluated cost.
|
127
127
|
def cost(what)
|
128
128
|
return what.cost if what.is_a?(Bliftax::Implicant)
|
129
129
|
|
@@ -140,6 +140,9 @@ class Bliftax
|
|
140
140
|
# @param to_cover [Set<Integer>] the set of minterms that need to be
|
141
141
|
# covered.
|
142
142
|
# @param options [Set<Implicant>] the set of implicants to choose from.
|
143
|
+
#
|
144
|
+
# @return [Set<Implicant>] a set of implicants that has achieves the cover
|
145
|
+
# in the minimum cost.
|
143
146
|
def branching(to_cover, options)
|
144
147
|
to_use = Set.new
|
145
148
|
options.dup.each do |implicant|
|
data/lib/bliftax/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bliftax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoki Mizuno
|
@@ -99,6 +99,6 @@ rubyforge_project:
|
|
99
99
|
rubygems_version: 2.4.5
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
|
-
summary: A library that parses BLIF files and
|
102
|
+
summary: A library that parses BLIF files and does logic optimization
|
103
103
|
test_files: []
|
104
104
|
has_rdoc:
|