yowasp-yosys 0.55.0.3.post946.dev0__py3-none-any.whl → 0.56.0.141.post974.dev0__py3-none-any.whl

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 (32) hide show
  1. yowasp_yosys/sby.py +39 -8
  2. yowasp_yosys/share/include/frontends/ast/ast.h +34 -38
  3. yowasp_yosys/share/include/kernel/celltypes.h +6 -0
  4. yowasp_yosys/share/include/kernel/consteval.h +5 -1
  5. yowasp_yosys/share/include/kernel/constids.inc +1 -0
  6. yowasp_yosys/share/include/kernel/ffinit.h +3 -3
  7. yowasp_yosys/share/include/kernel/ffmerge.h +1 -1
  8. yowasp_yosys/share/include/kernel/hashlib.h +43 -16
  9. yowasp_yosys/share/include/kernel/io.h +382 -8
  10. yowasp_yosys/share/include/kernel/json.h +2 -2
  11. yowasp_yosys/share/include/kernel/log.h +1 -0
  12. yowasp_yosys/share/include/kernel/register.h +42 -4
  13. yowasp_yosys/share/include/kernel/rtlil.h +6 -2
  14. yowasp_yosys/share/include/kernel/satgen.h +6 -4
  15. yowasp_yosys/share/include/kernel/sigtools.h +130 -26
  16. yowasp_yosys/share/include/kernel/yosys_common.h +9 -0
  17. yowasp_yosys/share/include/passes/techmap/libparse.h +235 -0
  18. yowasp_yosys/share/python3/sby_autotune.py +1 -1
  19. yowasp_yosys/share/python3/sby_cmdline.py +13 -0
  20. yowasp_yosys/share/python3/sby_core.py +208 -85
  21. yowasp_yosys/share/python3/sby_design.py +4 -0
  22. yowasp_yosys/share/python3/sby_engine_abc.py +15 -4
  23. yowasp_yosys/share/python3/sby_engine_aiger.py +14 -9
  24. yowasp_yosys/share/python3/sby_engine_btor.py +15 -4
  25. yowasp_yosys/share/python3/sby_engine_smtbmc.py +40 -27
  26. yowasp_yosys/share/python3/sby_status.py +388 -115
  27. yowasp_yosys/yosys.wasm +0 -0
  28. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/METADATA +1 -1
  29. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/RECORD +32 -31
  30. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/WHEEL +0 -0
  31. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/entry_points.txt +0 -0
  32. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/top_level.txt +0 -0
@@ -237,6 +237,42 @@ using sort_by_name_id_guard = typename std::enable_if<std::is_same<T,RTLIL::Cell
237
237
  template<typename T>
238
238
  class SigSet<T, sort_by_name_id_guard<T>> : public SigSet<T, RTLIL::sort_by_name_id<typename std::remove_pointer<T>::type>> {};
239
239
 
240
+ struct SigMapView
241
+ {
242
+ mfp<SigBit> database;
243
+
244
+ // Modify bit to its representative
245
+ void apply(RTLIL::SigBit &bit) const
246
+ {
247
+ bit = database.find(bit);
248
+ }
249
+
250
+ void apply(RTLIL::SigSpec &sig) const
251
+ {
252
+ for (auto &bit : sig)
253
+ apply(bit);
254
+ }
255
+
256
+ RTLIL::SigBit operator()(RTLIL::SigBit bit) const
257
+ {
258
+ apply(bit);
259
+ return bit;
260
+ }
261
+
262
+ RTLIL::SigSpec operator()(RTLIL::SigSpec sig) const
263
+ {
264
+ apply(sig);
265
+ return sig;
266
+ }
267
+
268
+ RTLIL::SigSpec operator()(RTLIL::Wire *wire) const
269
+ {
270
+ SigSpec sig(wire);
271
+ apply(sig);
272
+ return sig;
273
+ }
274
+ };
275
+
240
276
  /**
241
277
  * SigMap wraps a union-find "database"
242
278
  * to map SigBits of a module to canonical representative SigBits.
@@ -244,10 +280,8 @@ class SigSet<T, sort_by_name_id_guard<T>> : public SigSet<T, RTLIL::sort_by_name
244
280
  * If a SigBit has a const state (impl: bit.wire is nullptr),
245
281
  * it's promoted to a representative.
246
282
  */
247
- struct SigMap
283
+ struct SigMap final : public SigMapView
248
284
  {
249
- mfp<SigBit> database;
250
-
251
285
  SigMap(RTLIL::Module *module = NULL)
252
286
  {
253
287
  if (module != NULL)
@@ -320,45 +354,115 @@ struct SigMap
320
354
 
321
355
  inline void add(Wire *wire) { return add(RTLIL::SigSpec(wire)); }
322
356
 
323
- // Modify bit to its representative
324
- void apply(RTLIL::SigBit &bit) const
357
+ // All non-const bits
358
+ RTLIL::SigSpec allbits() const
325
359
  {
326
- bit = database.find(bit);
360
+ RTLIL::SigSpec sig;
361
+ for (const auto &bit : database)
362
+ if (bit.wire != nullptr)
363
+ sig.append(bit);
364
+ return sig;
327
365
  }
366
+ };
328
367
 
329
- void apply(RTLIL::SigSpec &sig) const
368
+ /**
369
+ * SiValgMap wraps a union-find "database" to map SigBits of a module to
370
+ * canonical representative SigBits plus some optional Val value associated with the bits.
371
+ * Val has a commutative, associative, idempotent operator|=, a default constructor
372
+ * which constructs an identity element, and a copy constructor.
373
+ * SigBits that are connected share a set in the underlying database;
374
+ * the associated value is the "sum" of all the values associated with the contributing bits.
375
+ * If any of the SigBits in a set are a constant, the canonical SigBit is a constant.
376
+ */
377
+ template <class Val>
378
+ struct SigValMap final : public SigMapView
379
+ {
380
+ dict<SigBit, Val> values;
381
+
382
+ void swap(SigValMap<Val> &other)
330
383
  {
331
- for (auto &bit : sig)
332
- apply(bit);
384
+ database.swap(other.database);
385
+ values.swap(other.values);
333
386
  }
334
387
 
335
- RTLIL::SigBit operator()(RTLIL::SigBit bit) const
388
+ void clear()
336
389
  {
337
- apply(bit);
338
- return bit;
390
+ database.clear();
391
+ values.clear();
339
392
  }
340
393
 
341
- RTLIL::SigSpec operator()(RTLIL::SigSpec sig) const
394
+ // Rebuild SigMap for all connections in module
395
+ void set(RTLIL::Module *module)
342
396
  {
343
- apply(sig);
344
- return sig;
397
+ int bitcount = 0;
398
+ for (auto &it : module->connections())
399
+ bitcount += it.first.size();
400
+
401
+ database.clear();
402
+ values.clear();
403
+ database.reserve(bitcount);
404
+
405
+ for (auto &it : module->connections())
406
+ add(it.first, it.second);
345
407
  }
346
408
 
347
- RTLIL::SigSpec operator()(RTLIL::Wire *wire) const
409
+ // Add connections from "from" to "to", bit-by-bit.
410
+ void add(const RTLIL::SigSpec& from, const RTLIL::SigSpec& to)
348
411
  {
349
- SigSpec sig(wire);
350
- apply(sig);
351
- return sig;
412
+ log_assert(GetSize(from) == GetSize(to));
413
+
414
+ for (int i = 0; i < GetSize(from); i++)
415
+ {
416
+ int bfi = database.lookup(from[i]);
417
+ int bti = database.lookup(to[i]);
418
+ if (bfi == bti) {
419
+ continue;
420
+ }
421
+
422
+ const RTLIL::SigBit &bf = database[bfi];
423
+ const RTLIL::SigBit &bt = database[bti];
424
+ if (bf.wire == nullptr) {
425
+ // bf is constant so make it the canonical representative.
426
+ database.imerge(bti, bfi);
427
+ merge_value(bt, bf);
428
+ } else {
429
+ // Make bt the canonical representative.
430
+ database.imerge(bfi, bti);
431
+ merge_value(bf, bt);
432
+ }
433
+ }
352
434
  }
353
435
 
354
- // All non-const bits
355
- RTLIL::SigSpec allbits() const
436
+ void addVal(const RTLIL::SigBit &bit, const Val &val)
356
437
  {
357
- RTLIL::SigSpec sig;
358
- for (const auto &bit : database)
359
- if (bit.wire != nullptr)
360
- sig.append(bit);
361
- return sig;
438
+ values[database.find(bit)] |= val;
439
+ }
440
+
441
+ void addVal(const RTLIL::SigSpec &sig, const Val &val)
442
+ {
443
+ for (const auto &bit : sig)
444
+ addVal(bit, val);
445
+ }
446
+
447
+ Val apply_and_get_value(RTLIL::SigBit &bit) const
448
+ {
449
+ bit = database.find(bit);
450
+ auto it = values.find(bit);
451
+ return it == values.end() ? Val() : it->second;
452
+ }
453
+
454
+ private:
455
+ void merge_value(const RTLIL::SigBit &from, const RTLIL::SigBit &to)
456
+ {
457
+ auto it = values.find(from);
458
+ if (it == values.end()) {
459
+ return;
460
+ }
461
+ // values[to] could resize the underlying `entries` so
462
+ // finish using `it` first.
463
+ Val v = it->second;
464
+ values.erase(it);
465
+ values[to] |= v;
362
466
  }
363
467
  };
364
468
 
@@ -134,6 +134,15 @@
134
134
  # define YS_COLD
135
135
  #endif
136
136
 
137
+ #ifdef __cpp_consteval
138
+ #define YOSYS_CONSTEVAL consteval
139
+ #else
140
+ // If we can't use consteval we can at least make it constexpr.
141
+ #define YOSYS_CONSTEVAL constexpr
142
+ #endif
143
+
144
+ #define YOSYS_ABORT(s) abort()
145
+
137
146
  #include "kernel/io.h"
138
147
 
139
148
  YOSYS_NAMESPACE_BEGIN
@@ -0,0 +1,235 @@
1
+ /*
2
+ * yosys -- Yosys Open SYnthesis Suite
3
+ *
4
+ * Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
5
+ *
6
+ * Permission to use, copy, modify, and/or distribute this software for any
7
+ * purpose with or without fee is hereby granted, provided that the above
8
+ * copyright notice and this permission notice appear in all copies.
9
+ *
10
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
+ *
18
+ */
19
+
20
+ #ifndef LIBPARSE_H
21
+ #define LIBPARSE_H
22
+
23
+ #include "kernel/yosys.h"
24
+ #include <stdio.h>
25
+ #include <string>
26
+ #include <vector>
27
+ #include <set>
28
+
29
+ /**
30
+ * This file is likely to change in the near future.
31
+ * Rely on it in your plugins at your own peril
32
+ */
33
+
34
+ namespace Yosys
35
+ {
36
+ struct LibertyAst
37
+ {
38
+ std::string id, value;
39
+ std::vector<std::string> args;
40
+ std::vector<LibertyAst*> children;
41
+ ~LibertyAst();
42
+ const LibertyAst *find(std::string name) const;
43
+
44
+ typedef std::set<std::string> sieve;
45
+ void dump(FILE *f, sieve &blacklist, sieve &whitelist, std::string indent = "", std::string path = "", bool path_ok = false) const;
46
+ };
47
+
48
+ struct LibertyExpression
49
+ {
50
+ struct Lexer {
51
+ std::string s, expr;
52
+
53
+ Lexer(std::string s) : s{s}, expr{s} {}
54
+
55
+ bool empty() { return s.empty();}
56
+ char peek() { return s[0]; }
57
+ std::string full_expr() { return expr; }
58
+
59
+ char next() {
60
+ char c = s[0];
61
+ s = s.substr(1, s.size());
62
+ return c;
63
+ }
64
+
65
+ std::string pin() {
66
+ auto length = s.find_first_of("\t()'!^*& +|");
67
+ if (length == std::string::npos) {
68
+ // nothing found so use size of s
69
+ length = s.size();
70
+ }
71
+ auto pin = s.substr(0, length);
72
+ s = s.substr(length, s.size());
73
+ return pin;
74
+ }
75
+ };
76
+
77
+ enum Kind {
78
+ AND,
79
+ OR,
80
+ NOT,
81
+ XOR,
82
+ // the standard specifies constants, but they're probably rare in practice.
83
+ PIN,
84
+ EMPTY
85
+ };
86
+
87
+ Kind kind;
88
+ std::string name;
89
+ std::vector<LibertyExpression> children;
90
+
91
+ LibertyExpression() : kind(Kind::EMPTY) {}
92
+
93
+ static LibertyExpression parse(Lexer &s, int min_prio = 0);
94
+ void get_pin_names(pool<std::string>& names);
95
+ bool eval(dict<std::string, bool>& values);
96
+ std::string str(int indent = 0);
97
+ private:
98
+ static bool is_nice_binop(char c);
99
+ };
100
+
101
+ class LibertyInputStream {
102
+ std::istream &f;
103
+ std::vector<unsigned char> buffer;
104
+ size_t buf_pos = 0;
105
+ size_t buf_end = 0;
106
+ bool eof = false;
107
+
108
+ bool extend_buffer_once();
109
+ bool extend_buffer_at_least(size_t size = 1);
110
+
111
+ YS_COLD int get_cold();
112
+ YS_COLD int peek_cold(size_t offset);
113
+
114
+ public:
115
+ LibertyInputStream(std::istream &f) : f(f) {}
116
+
117
+ size_t buffered_size() { return buf_end - buf_pos; }
118
+ const unsigned char *buffered_data() { return buffer.data() + buf_pos; }
119
+
120
+ int get() {
121
+ if (buf_pos == buf_end)
122
+ return get_cold();
123
+ int c = buffer[buf_pos];
124
+ buf_pos += 1;
125
+ return c;
126
+ }
127
+
128
+ int peek(size_t offset = 0) {
129
+ if (buf_pos + offset >= buf_end)
130
+ return peek_cold(offset);
131
+ return buffer[buf_pos + offset];
132
+ }
133
+
134
+ void consume(size_t n = 1) {
135
+ buf_pos += n;
136
+ }
137
+
138
+ void unget() {
139
+ buf_pos -= 1;
140
+ }
141
+ };
142
+
143
+ #ifndef FILTERLIB
144
+ class LibertyAstCache {
145
+ LibertyAstCache() {};
146
+ ~LibertyAstCache() {};
147
+ public:
148
+ dict<std::string, std::shared_ptr<const LibertyAst>> cached;
149
+
150
+ bool cache_by_default = false;
151
+ bool verbose = false;
152
+ dict<std::string, bool> cache_path;
153
+
154
+ std::shared_ptr<const LibertyAst> cached_ast(const std::string &fname);
155
+ void parsed_ast(const std::string &fname, const std::shared_ptr<const LibertyAst> &ast);
156
+ static LibertyAstCache instance;
157
+ };
158
+ #endif
159
+
160
+ class LibertyMergedCells;
161
+ class LibertyParser
162
+ {
163
+ friend class LibertyMergedCells;
164
+ private:
165
+ LibertyInputStream f;
166
+ int line;
167
+
168
+ /* lexer return values:
169
+ 'v': identifier, string, array range [...] -> str holds the token string
170
+ 'n': newline
171
+ anything else is a single character.
172
+ */
173
+ int lexer(std::string &str);
174
+
175
+ void report_unexpected_token(int tok);
176
+ void parse_vector_range(int tok);
177
+ LibertyAst *parse(bool top_level);
178
+ void error() const;
179
+ void error(const std::string &str) const;
180
+
181
+ public:
182
+ std::shared_ptr<const LibertyAst> shared_ast;
183
+ const LibertyAst *ast = nullptr;
184
+
185
+ LibertyParser(std::istream &f) : f(f), line(1) {
186
+ shared_ast.reset(parse(true));
187
+ ast = shared_ast.get();
188
+ if (!ast) {
189
+ #ifdef FILTERLIB
190
+ fprintf(stderr, "No entries found in liberty file.\n");
191
+ exit(1);
192
+ #else
193
+ log_error("No entries found in liberty file.\n");
194
+ #endif
195
+ }
196
+ }
197
+
198
+ #ifndef FILTERLIB
199
+ LibertyParser(std::istream &f, const std::string &fname) : f(f), line(1) {
200
+ shared_ast = LibertyAstCache::instance.cached_ast(fname);
201
+ if (!shared_ast) {
202
+ shared_ast.reset(parse(true));
203
+ LibertyAstCache::instance.parsed_ast(fname, shared_ast);
204
+ }
205
+ ast = shared_ast.get();
206
+ if (!ast) {
207
+ log_error("No entries found in liberty file `%s'.\n", fname.c_str());
208
+ }
209
+ }
210
+ #endif
211
+ };
212
+
213
+ class LibertyMergedCells
214
+ {
215
+ std::vector<std::shared_ptr<const LibertyAst>> asts;
216
+
217
+ public:
218
+ std::vector<const LibertyAst *> cells;
219
+ void merge(LibertyParser &parser)
220
+ {
221
+ if (parser.ast) {
222
+ const LibertyAst *ast = parser.ast;
223
+ asts.push_back(parser.shared_ast);
224
+ if (ast->id != "library")
225
+ parser.error("Top level entity isn't \"library\".\n");
226
+ for (const LibertyAst *cell : ast->children)
227
+ if (cell->id == "cell" && cell->args.size() == 1)
228
+ cells.push_back(cell);
229
+ }
230
+ }
231
+ };
232
+
233
+ }
234
+
235
+ #endif
@@ -649,7 +649,7 @@ class SbyAutotuneTask(SbyTask):
649
649
  def engine_list(self):
650
650
  return [(self.candidate.engine_idx, self.candidate.engine)]
651
651
 
652
- def copy_src(self):
652
+ def copy_src(self, _):
653
653
  pass
654
654
 
655
655
  def model(self, model_name):
@@ -29,6 +29,8 @@ def parser_func(release_version='unknown SBY version'):
29
29
  help="maximum number of processes to run in parallel")
30
30
  parser.add_argument("--sequential", action="store_true", dest="sequential",
31
31
  help="run tasks in sequence, not in parallel")
32
+ parser.add_argument("--live", action="append", choices=["csv", "jsonl"], dest="live_formats",
33
+ help="print live updates of property statuses during task execution, may be specified multiple times")
32
34
 
33
35
  parser.add_argument("--autotune", action="store_true", dest="autotune",
34
36
  help="automatically find a well performing engine and engine configuration for each task")
@@ -70,11 +72,22 @@ def parser_func(release_version='unknown SBY version'):
70
72
  help="print the list of source files")
71
73
  parser.add_argument("--setup", action="store_true", dest="setupmode",
72
74
  help="set up the working directory and exit")
75
+ parser.add_argument("--link", action="store_true", dest="linkmode",
76
+ help="make symbolic links to source files instead of copying them")
73
77
 
74
78
  parser.add_argument("--status", action="store_true", dest="status",
75
79
  help="summarize the contents of the status database")
80
+ parser.add_argument("--statusfmt", action="store", default="", choices=["csv", "jsonl"], dest="status_format",
81
+ help="print the most recent status for each property in specified format")
82
+ parser.add_argument("--latest", action="store_true", dest="status_latest",
83
+ help="only check statuses from the most recent run of a task")
76
84
  parser.add_argument("--statusreset", action="store_true", dest="status_reset",
77
85
  help="reset the contents of the status database")
86
+ parser.add_argument("--statuscancels", action="store_true", dest="status_cancels",
87
+ help="intertask cancellations can be triggered by the status database")
88
+
89
+ parser.add_argument("--taskstatus", action="store_true", dest="task_status",
90
+ help="display the status of tasks in the status database")
78
91
 
79
92
  parser.add_argument("--init-config-file", dest="init_config_file",
80
93
  help="create a default .sby config file")