ruby_abc 0.0.4 → 0.0.6

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/bin/ruby_abc +32 -17
  4. data/ext/ruby_abc.c +7 -2
  5. data/lib/ruby_abc.rb +29 -24
  6. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53a8e79cf40c11f4fb22f3d5a1e55763de58a763
4
- data.tar.gz: 353361f5895d90f4acb08db4b5234e1a3fc0b553
3
+ metadata.gz: 9fd5883ec3a3da72ba747cc3de5d52f7dc467b66
4
+ data.tar.gz: e6d50ed52c1ac424870f97e40314eb466c989d26
5
5
  SHA512:
6
- metadata.gz: 69d80d3aa276f0dc302a6e750bad0751a8f8b04426846d6f1763a58061aa5e67a66a07b2d09d86268766497fd85bcedff9f49cb688ab92bd9ede790b1254bc9b
7
- data.tar.gz: f1f182e8071c7f8a526b0d7cc93491cb0945a9ae6b87eceb4992bbb788033f40bd3e98febbd2f599c9aebea291f4fbe2b7f707b3fa25eed449332c81c8272548
6
+ metadata.gz: adaebecb0852ab57632b491da54a02fca3e2eb89ff3cae799847a69df248e5214a27c8447b62d7c277de478c146fb7aeca4830ea4611936067061bfcacae55d4
7
+ data.tar.gz: 86df84083bec60c1f1e74998dd20dd387d02956c2546a5c3ec049febf56363e9f5180654ea59749166f6cedced47c2065c5f057a3ade3085f2279646473bc201
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ desc 'compile libabc.so and abc'
38
38
  task libabc => abcsrc do
39
39
  abort "Library libpthread was not found" if !have_library('pthread')
40
40
  abort "Library libdl was not found" if !have_library('dl')
41
- abort "Library librt was not found" if !have_library('rt')
41
+ #abort "Library librt was not found" if !have_library('rt') ## librt.a is not on Mac OS
42
42
  wd = Dir.getwd
43
43
  Dir.chdir(abc_path)
44
44
  sh "make -j4 ABC_USE_PIC=true OPTFLAGS='-O2' ABC_USE_NO_READLINE=true libabc.so"
@@ -3,49 +3,61 @@
3
3
  require 'ruby_abc'
4
4
  require 'optparse'
5
5
 
6
+ STDOUT.sync = true
7
+
6
8
  options = {}
7
9
 
8
10
  optparse = OptionParser.new do |opts|
9
11
  opts.banner = "Usage: #{File.basename(__FILE__)} [options] -i <input_file> -o <output_file>"
10
12
 
11
13
  options[:inputFileName] = nil
12
- opts.on('-i', '--input FILE', 'Input file name') do |file|
14
+ opts.on('-i', '--input FILE', 'Input file') do |file|
13
15
  options[:inputFileName] = file
14
16
  end
15
17
 
16
18
  options[:outputFileName] = nil
17
- opts.on('-o', '--output FILE', 'Output file name') do |file|
19
+ opts.on('-o', '--output FILE', 'Write processed netlist to FILE') do |file|
18
20
  options[:outputFileName] = file
19
21
  end
20
22
 
23
+ options[:sweep] = false
24
+ opts.on('-s', '--sweep', 'Sweep logic network to remove dangling nodes') do
25
+ options[:sweep] = true
26
+ end
27
+
28
+ options[:k] = nil
29
+ opts.on('-k', '--lut_inputs K', "Map to K-input LUTs.") do |k|
30
+ options[:k] = k.to_i
31
+ end
32
+
33
+ options[:area] = false
34
+ opts.on('-a', '--area', 'Optimize in area') do
35
+ options[:area] = true
36
+ end
37
+
21
38
  options[:retime] = false
22
39
  opts.on('-r', '--retime', 'Retime netlist') do
23
40
  options[:retime] = true
24
41
  end
25
42
 
26
- options[:zero] = false
27
- opts.on('-z', '--zero', 'Set latches initial value to zero') do
28
- options[:zero] = true
29
- end
30
-
31
43
  options[:lcorr] = false
32
44
  opts.on('-l', '--lcorr', 'Computes latch correspondence using 1-step induction') do
33
45
  options[:lcorr] = true
34
46
  end
35
47
 
36
- options[:area] = false
37
- opts.on('-a', '--area', 'Optimize in area') do
38
- options[:area] = true
48
+ options[:zero] = false
49
+ opts.on('-z', '--zero', 'Set latches initial value to zero') do
50
+ options[:zero] = true
39
51
  end
40
52
 
41
- options[:sweep] = false
42
- opts.on('-w', '--sweep', 'Sweep logic network to remove dangling nodes') do
43
- options[:sweep] = true
53
+ options[:echo] = false
54
+ opts.on('-e', '--echo', 'Echo commands sent to ABC') do
55
+ options[:echo] = true
44
56
  end
45
57
 
46
- options[:k] = nil
47
- opts.on('-k', '--lut_inputs K', "Map to K-input LUTs.") do |k|
48
- options[:k] = k.to_i
58
+ options[:quiet] = false
59
+ opts.on('-q', '--quiet', 'Do not print netlist statistics during synthesis') do
60
+ options[:quiet] = true
49
61
  end
50
62
 
51
63
  opts.on( '-h', '--help', 'Display this help' ) do
@@ -58,6 +70,8 @@ optparse.parse!
58
70
 
59
71
  abort "Missing input file name.\n#{optparse}" if options[:inputFileName].nil?
60
72
 
73
+ ABC::echo_commands = not(not(options[:echo]))
74
+
61
75
  ABC::synthesis(
62
76
  input: options[:inputFileName],
63
77
  output: options[:outputFileName],
@@ -66,6 +80,7 @@ ABC::synthesis(
66
80
  retime: options[:retime],
67
81
  lcorr: options[:lcorr],
68
82
  area: options[:area],
69
- lut_map: options[:k]
83
+ lut_map: options[:k],
84
+ verbose: not(options[:quiet])
70
85
  )
71
86
 
@@ -137,10 +137,15 @@ static VALUE rubyabc_n_levels(VALUE self)
137
137
  */
138
138
  static VALUE rubyabc_run_command(VALUE self, VALUE cmd)
139
139
  {
140
+ VALUE printed_str;
141
+
140
142
  Check_Type(cmd, T_STRING);
141
143
 
142
- if (rubyabc_echo_commands)
143
- rb_io_puts(1, &cmd, rb_stdout);
144
+
145
+ if (rubyabc_echo_commands) {
146
+ printed_str = rb_sprintf("Command: \"%"PRIsVALUE"\"", cmd);
147
+ rb_io_puts(1, &printed_str, rb_stdout);
148
+ }
144
149
 
145
150
  if (rubyabc_c_run_command(StringValueCStr(cmd)))
146
151
  return Qfalse;
@@ -4,7 +4,7 @@ require_relative 'ruby_abc/ruby_abc.so'
4
4
 
5
5
 
6
6
  module ABC
7
- VERSION = '0.0.4'
7
+ VERSION = '0.0.6'
8
8
 
9
9
  ##
10
10
  # call-seq:
@@ -36,15 +36,15 @@ module ABC
36
36
  puts "Outputs: ..#{(' ' + n_pos.to_s).rjust(max_len, '.')}" if n_pos
37
37
  puts "Nodes: ....#{(' ' + n_nodes.to_s).rjust(max_len, '.')}" if n_nodes
38
38
  puts "Latches: ..#{(' ' + n_latches.to_s).rjust(max_len, '.')}" if n_latches
39
- puts "Levels: ...#{(' ' + n_levels.to_s).rjust(max_len, '.')}" if n_levels
40
39
  puts "And gates: #{(' ' + n_ands.to_s).rjust(max_len, '.')}" if n_ands
40
+ puts "Levels: ...#{(' ' + n_levels.to_s).rjust(max_len, '.')}" if n_levels
41
41
  return nil
42
42
  end # ABC::print_stats
43
43
 
44
44
 
45
45
  ##
46
46
  # call-seq:
47
- # optimize -> nb_ands
47
+ # optimize (verbose: true) -> nb_ands
48
48
  #
49
49
  # Combinatorial synthesis of the network.
50
50
  # This method loops the command "resyn; resyn2, resyn3, print_stats" and stops when the number of AND gates stop decreasing.
@@ -58,10 +58,11 @@ module ABC
58
58
  #
59
59
  # ABC.optimize
60
60
  #
61
- def self.optimize
61
+ def self.optimize (verbose: true)
62
+ cmd = 'resyn; resyn2; resyn3' + (verbose ? '; ps' : '')
62
63
  n_ands = ABC::nb_ands
63
64
  loop do
64
- ABC::run_command('resyn; resyn2; resyn3; ps')
65
+ ABC::run_command(cmd)
65
66
  new_n_ands = ABC::nb_ands
66
67
  break unless new_n_ands < n_ands
67
68
  n_ands = new_n_ands
@@ -72,19 +73,19 @@ module ABC
72
73
 
73
74
  ##
74
75
  # call-seq:
75
- # map (lut_size, optimize_for_area = false) -> nb_nodes
76
+ # map (lut_size, optimize_for_area = false, verbose: true) -> nb_nodes
76
77
  #
77
78
  # Map the logic network to nodes with at most +lut_size+ inputs.
78
79
  # If +optimize_for_area+ is true, minimize the number of nodes instead of minimizing the logic level of the network.
79
80
  #
80
81
  # This method loops the command:
81
- # "choice; if -K #{lut_size}#{optimize_for_area ? ' -a':''}; ps"
82
+ # "choice2; if -K #{lut_size}#{optimize_for_area ? ' -a':''}; ps"
82
83
  # and stops when the number of nodes stop decreasing.
83
84
  #
84
85
  # ABC.map(4)
85
86
  #
86
- def self.map (k, optimize_area = false)
87
- map_cmd = "choice; if -K #{k}#{optimize_area ? ' -a':''}; ps"
87
+ def self.map (k, optimize_area = false, verbose: true)
88
+ map_cmd = "choice2; if -K #{k}#{optimize_area ? ' -a':''}#{verbose ? '; ps':''}"
88
89
 
89
90
  n_nodes = -1
90
91
  loop do
@@ -117,7 +118,7 @@ module ABC
117
118
 
118
119
  ##
119
120
  # call-seq:
120
- # synthesis (input: nil, output: nil, zero: false, sweep: false, retime: false, lcorr: false, area: false, lut_map: nil, help: nil)
121
+ # synthesis (input: nil, output: nil, zero: false, sweep: false, retime: false, lcorr: false, area: false, lut_map: nil, verbose: true, help: nil)
121
122
  #
122
123
  # This method is an atempt to automate the logic synthesis process (combinatorial and sequential) according to some parameters.
123
124
  #
@@ -133,7 +134,7 @@ module ABC
133
134
  #
134
135
  # ABC.synthesis(input: 'generic.blif', output: 'maped.blif', lcorr: true, lut_map: 4, area: true)
135
136
  #
136
- def self.synthesis(input: nil, output: nil, zero: false, sweep: false, retime: false, lcorr: false, area: false, lut_map: nil, help: nil)
137
+ def self.synthesis(input: nil, output: nil, zero: false, sweep: false, retime: false, lcorr: false, area: false, lut_map: nil, help: nil, verbose: true)
137
138
  if help then
138
139
  puts <<EOS
139
140
  ABC::synthesis keyword arguments:
@@ -158,7 +159,7 @@ EOS
158
159
  ABC::print_stats
159
160
  puts "-----------------------"
160
161
 
161
- ABC::ps
162
+ ABC::ps if verbose
162
163
 
163
164
  if sweep then
164
165
  ABC::sweep
@@ -166,43 +167,47 @@ EOS
166
167
  end
167
168
 
168
169
  if zero and ABC::nb_latches > 0 then
169
- ABC::run_command 'strash; zero; ps'
170
+ ABC::run_command 'strash; zero'
170
171
  else
171
- ABC::run_command 'strash; ps'
172
+ ABC::run_command 'strash'
172
173
  end
174
+ ABC::ps if verbose
173
175
 
174
176
  ABC::lcorr if (lcorr and ABC::nb_latches > 0)
175
177
 
176
178
  if sweep then
177
179
  ABC::ssweep
178
180
  ABC::csweep
179
- ABC::ps
181
+ ABC::ps if verbose
180
182
  end
181
183
 
182
- ABC::optimize
184
+ ABC::optimize(verbose: verbose)
183
185
 
184
186
  if retime and ABC::nb_latches > 0 then
185
187
  level = ABC::nb_levels
186
- ABC::run_command('retime; strash; ps')
188
+ ABC::run_command('retime; strash')
189
+ ABC::ps if verbose
187
190
  if ABC::nb_levels >= level then
188
- ABC::run_command('dretime; strash; ps')
191
+ ABC::run_command('dretime; strash')
192
+ ABC::ps if verbose
189
193
  end
190
- ABC::optimize
194
+ ABC::optimize(verbose: verbose)
191
195
  end
192
196
 
193
197
  ABC::zero if zero
194
198
 
195
199
  if lut_map then
196
200
  raise "Expecting a strictly positive integer for argument :lut_map" unless (lut_map.kind_of?(Integer) and lut_map > 0)
197
- ABC::map(lut_map, not(not(area)))
201
+ ABC::map(lut_map, not(not(area)), verbose: verbose)
198
202
  end
199
203
 
200
204
  if sweep then
201
- ABC::run_command 'sop; sweep; resyn; resyn2; resyn3; scleanup; resyn; scleanup; scleanup; scleanup; strash; ssweep; csweep; ps'
202
- ABC::optimize
205
+ ABC::run_command 'sop; sweep; resyn; resyn2; resyn3; scleanup; resyn; scleanup; scleanup; scleanup; strash; ssweep; csweep'
206
+ ABC::ps if verbose
207
+ ABC::optimize(verbose: verbose)
203
208
  if lut_map then
204
209
  raise "Expecting a strictly positive integer for argument :lut_map" unless (lut_map.kind_of?(Integer) and lut_map > 0)
205
- ABC::map(lut_map, not(not(area)))
210
+ ABC::map(lut_map, not(not(area)), verbose: verbose)
206
211
  end
207
212
  end
208
213
 
@@ -210,7 +215,7 @@ EOS
210
215
  ABC::run_command 'strash; lcorr'
211
216
  if lut_map then
212
217
  raise "Expecting a strictly positive integer for argument :lut_map" unless (lut_map.kind_of?(Integer) and lut_map > 0)
213
- ABC::map(lut_map, not(not(area)))
218
+ ABC::map(lut_map, not(not(area)), verbose: verbose)
214
219
  end
215
220
  end
216
221
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_abc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Théotime Bollengier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  ruby_abc is a ruby C extension intended to allow the use of ABC from Ruby.