yowasp-yosys 0.56.0.0.post964__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.
@@ -28,6 +28,7 @@
28
28
 
29
29
  #include "kernel/rtlil.h"
30
30
  #include "kernel/fmt.h"
31
+ #include "frontends/verilog/verilog_location.h"
31
32
  #include <stdint.h>
32
33
  #include <set>
33
34
 
@@ -153,6 +154,7 @@ namespace AST
153
154
  AST_MODPORT,
154
155
  AST_MODPORTMEMBER,
155
156
  AST_PACKAGE,
157
+ AST_IMPORT,
156
158
 
157
159
  AST_WIRETYPE,
158
160
  AST_TYPEDEF,
@@ -162,12 +164,7 @@ namespace AST
162
164
  AST_BIND
163
165
  };
164
166
 
165
- struct AstSrcLocType {
166
- unsigned int first_line, last_line;
167
- unsigned int first_column, last_column;
168
- AstSrcLocType() : first_line(0), last_line(0), first_column(0), last_column(0) {}
169
- AstSrcLocType(int _first_line, int _first_column, int _last_line, int _last_column) : first_line(_first_line), last_line(_last_line), first_column(_first_column), last_column(_last_column) {}
170
- };
167
+ using AstSrcLocType = Location;
171
168
 
172
169
  // convert an node type to a string (e.g. for debug output)
173
170
  std::string type2str(AstNodeType type);
@@ -183,10 +180,10 @@ namespace AST
183
180
  AstNodeType type;
184
181
 
185
182
  // the list of child nodes for this node
186
- std::vector<AstNode*> children;
183
+ std::vector<std::unique_ptr<AstNode>> children;
187
184
 
188
185
  // the list of attributes assigned to this node
189
- std::map<RTLIL::IdString, AstNode*> attributes;
186
+ std::map<RTLIL::IdString, std::unique_ptr<AstNode>> attributes;
190
187
  bool get_bool_attribute(RTLIL::IdString id);
191
188
 
192
189
  // node content - most of it is unused in most node types
@@ -212,7 +209,7 @@ namespace AST
212
209
  int unpacked_dimensions;
213
210
 
214
211
  // this is set by simplify and used during RTLIL generation
215
- AstNode *id2ast;
212
+ AstNode* id2ast;
216
213
 
217
214
  // this is used by simplify to detect if basic analysis has been performed already on the node
218
215
  bool basic_prep;
@@ -223,7 +220,6 @@ namespace AST
223
220
  // this is the original sourcecode location that resulted in this AST node
224
221
  // it is automatically set by the constructor using AST::current_filename and
225
222
  // the AST::get_line_num() callback function.
226
- std::string filename;
227
223
  AstSrcLocType location;
228
224
 
229
225
  // are we embedded in an lvalue, param?
@@ -234,9 +230,9 @@ namespace AST
234
230
  bool in_param_from_above;
235
231
 
236
232
  // creating and deleting nodes
237
- AstNode(AstNodeType type = AST_NONE, AstNode *child1 = nullptr, AstNode *child2 = nullptr, AstNode *child3 = nullptr, AstNode *child4 = nullptr);
238
- AstNode *clone() const;
239
- void cloneInto(AstNode *other) const;
233
+ AstNode(AstSrcLocType loc, AstNodeType type = AST_NONE, std::unique_ptr<AstNode> child1 = nullptr, std::unique_ptr<AstNode> child2 = nullptr, std::unique_ptr<AstNode> child3 = nullptr, std::unique_ptr<AstNode> child4 = nullptr);
234
+ std::unique_ptr<AstNode> clone() const;
235
+ void cloneInto(AstNode &other) const;
240
236
  void delete_children();
241
237
  ~AstNode();
242
238
 
@@ -265,14 +261,14 @@ namespace AST
265
261
  // it also sets the id2ast pointers so that identifier lookups are fast in genRTLIL()
266
262
  bool simplify(bool const_fold, int stage, int width_hint, bool sign_hint);
267
263
  void replace_result_wire_name_in_function(const std::string &from, const std::string &to);
268
- AstNode *readmem(bool is_readmemh, std::string mem_filename, AstNode *memory, int start_addr, int finish_addr, bool unconditional_init);
264
+ std::unique_ptr<AstNode> readmem(bool is_readmemh, std::string mem_filename, AstNode *memory, int start_addr, int finish_addr, bool unconditional_init);
269
265
  void expand_genblock(const std::string &prefix);
270
266
  void label_genblks(std::set<std::string>& existing, int &counter);
271
267
  void mem2reg_as_needed_pass1(dict<AstNode*, pool<std::string>> &mem2reg_places,
272
268
  dict<AstNode*, uint32_t> &mem2reg_flags, dict<AstNode*, uint32_t> &proc_flags, uint32_t &status_flags);
273
- bool mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block, AstNode *&async_block);
269
+ bool mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block, AstNode* async_block);
274
270
  bool mem2reg_check(pool<AstNode*> &mem2reg_set);
275
- void mem2reg_remove(pool<AstNode*> &mem2reg_set, vector<AstNode*> &delnodes);
271
+ void mem2reg_remove(pool<AstNode*> &mem2reg_set);
276
272
  void meminfo(int &mem_width, int &mem_size, int &addr_bits);
277
273
  bool detect_latch(const std::string &var);
278
274
  const RTLIL::Module* lookup_cell_module();
@@ -288,7 +284,7 @@ namespace AST
288
284
  };
289
285
  bool has_const_only_constructs();
290
286
  bool replace_variables(std::map<std::string, varinfo_t> &variables, AstNode *fcall, bool must_succeed);
291
- AstNode *eval_const_function(AstNode *fcall, bool must_succeed);
287
+ std::unique_ptr<AstNode> eval_const_function(AstNode *fcall, bool must_succeed);
292
288
  bool is_simple_const_expr();
293
289
 
294
290
  // helper for parsing format strings
@@ -305,29 +301,30 @@ namespace AST
305
301
  std::vector<RTLIL::Binding *> genBindings() const;
306
302
 
307
303
  // used by genRTLIL() for detecting expression width and sign
308
- void detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *found_real = NULL);
309
- void detectSignWidth(int &width_hint, bool &sign_hint, bool *found_real = NULL);
304
+ void detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *found_real = nullptr);
305
+ void detectSignWidth(int &width_hint, bool &sign_hint, bool *found_real = nullptr);
310
306
 
311
307
  // create RTLIL code for this AST node
312
308
  // for expressions the resulting signal vector is returned
313
309
  // all generated cell instances, etc. are written to the RTLIL::Module pointed to by AST_INTERNAL::current_module
314
310
  RTLIL::SigSpec genRTLIL(int width_hint = -1, bool sign_hint = false);
315
- RTLIL::SigSpec genWidthRTLIL(int width, bool sgn, const dict<RTLIL::SigBit, RTLIL::SigBit> *new_subst_ptr = NULL);
311
+ RTLIL::SigSpec genWidthRTLIL(int width, bool sgn, const dict<RTLIL::SigBit, RTLIL::SigBit> *new_subst_ptr = nullptr);
316
312
 
317
313
  // compare AST nodes
318
314
  bool operator==(const AstNode &other) const;
319
315
  bool operator!=(const AstNode &other) const;
320
316
  bool contains(const AstNode *other) const;
317
+ AstNode operator=(AstNode) = delete;
321
318
 
322
319
  // helper functions for creating AST nodes for constants
323
- static AstNode *mkconst_int(uint32_t v, bool is_signed, int width = 32);
324
- static AstNode *mkconst_bits(const std::vector<RTLIL::State> &v, bool is_signed, bool is_unsized);
325
- static AstNode *mkconst_bits(const std::vector<RTLIL::State> &v, bool is_signed);
326
- static AstNode *mkconst_str(const std::vector<RTLIL::State> &v);
327
- static AstNode *mkconst_str(const std::string &str);
320
+ static std::unique_ptr<AstNode> mkconst_int(AstSrcLocType loc, uint32_t v, bool is_signed, int width = 32);
321
+ static std::unique_ptr<AstNode> mkconst_bits(AstSrcLocType loc, const std::vector<RTLIL::State> &v, bool is_signed, bool is_unsized);
322
+ static std::unique_ptr<AstNode> mkconst_bits(AstSrcLocType loc, const std::vector<RTLIL::State> &v, bool is_signed);
323
+ static std::unique_ptr<AstNode> mkconst_str(AstSrcLocType loc, const std::vector<RTLIL::State> &v);
324
+ static std::unique_ptr<AstNode> mkconst_str(AstSrcLocType loc, const std::string &str);
328
325
 
329
326
  // helper function to create an AST node for a temporary register
330
- AstNode *mktemp_logic(const std::string &name, AstNode *mod, bool nosync, int range_left, int range_right, bool is_signed);
327
+ std::unique_ptr<AstNode> mktemp_logic(AstSrcLocType loc, const std::string &name, AstNode *mod, bool nosync, int range_left, int range_right, bool is_signed);
331
328
 
332
329
  // helper function for creating sign-extended const objects
333
330
  RTLIL::Const bitsAsConst(int width, bool is_signed);
@@ -356,12 +353,12 @@ namespace AST
356
353
 
357
354
  // helper to clone the node with some of its subexpressions replaced with zero (this is used
358
355
  // to evaluate widths of dynamic ranges)
359
- AstNode *clone_at_zero();
356
+ std::unique_ptr<AstNode> clone_at_zero();
360
357
 
361
- void set_attribute(RTLIL::IdString key, AstNode *node)
358
+ void set_attribute(RTLIL::IdString key, std::unique_ptr<AstNode> node)
362
359
  {
363
- attributes[key] = node;
364
360
  node->set_in_param_flag(true);
361
+ attributes[key] = std::move(node);
365
362
  }
366
363
 
367
364
  // helper to set in_lvalue/in_param flags from the hierarchy context (the actual flag
@@ -377,7 +374,7 @@ namespace AST
377
374
  void fixup_hierarchy_flags(bool force_descend = false);
378
375
 
379
376
  // helpers for indexing
380
- AstNode *make_index_range(AstNode *node, bool unpacked_range = false);
377
+ std::unique_ptr<AstNode> make_index_range(AstNode *node, bool unpacked_range = false);
381
378
  AstNode *get_struct_member() const;
382
379
 
383
380
  // helper to print errors from simplify/genrtlil code
@@ -391,12 +388,11 @@ namespace AST
391
388
  // parametric modules are supported directly by the AST library
392
389
  // therefore we need our own derivate of RTLIL::Module with overloaded virtual functions
393
390
  struct AstModule : RTLIL::Module {
394
- AstNode *ast;
391
+ std::unique_ptr<AstNode> ast;
395
392
  bool nolatches, nomeminit, nomem2reg, mem2reg, noblackbox, lib, nowb, noopt, icells, pwires, autowire;
396
- ~AstModule() override;
397
393
  RTLIL::IdString derive(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Const> &parameters, bool mayfail) override;
398
394
  RTLIL::IdString derive(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Const> &parameters, const dict<RTLIL::IdString, RTLIL::Module*> &interfaces, const dict<RTLIL::IdString, RTLIL::IdString> &modports, bool mayfail) override;
399
- std::string derive_common(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Const> &parameters, AstNode **new_ast_out, bool quiet = false);
395
+ std::string derive_common(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Const> &parameters, std::unique_ptr<AstNode>* new_ast_out, bool quiet = false);
400
396
  void expand_interfaces(RTLIL::Design *design, const dict<RTLIL::IdString, RTLIL::Module *> &local_interfaces) override;
401
397
  bool reprocess_if_necessary(RTLIL::Design *design) override;
402
398
  RTLIL::Module *clone() const override;
@@ -406,9 +402,9 @@ namespace AST
406
402
  // this must be set by the language frontend before parsing the sources
407
403
  // the AstNode constructor then uses current_filename and get_line_num()
408
404
  // to initialize the filename and linenum properties of new nodes
409
- extern std::string current_filename;
410
- extern void (*set_line_num)(int);
411
- extern int (*get_line_num)();
405
+ // extern std::string current_filename;
406
+ // also set by the language frontend to control some AST processing
407
+ extern bool sv_mode_but_global_and_used_for_literally_one_condition;
412
408
 
413
409
  // for stats
414
410
  unsigned long long astnode_count();
@@ -418,7 +414,7 @@ namespace AST
418
414
  void use_internal_line_num();
419
415
 
420
416
  // call a DPI function
421
- AstNode *dpi_call(const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<AstNode*> &args);
417
+ std::unique_ptr<AstNode> dpi_call(AstSrcLocType loc, const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<std::unique_ptr<AstNode>> &args);
422
418
 
423
419
  // Helper functions related to handling SystemVerilog interfaces
424
420
  std::pair<std::string,std::string> split_modport_from_type(std::string name_type);
@@ -464,7 +460,7 @@ namespace AST_INTERNAL
464
460
  process_and_replace_module(RTLIL::Design *design,
465
461
  RTLIL::Module *old_module,
466
462
  AST::AstNode *new_ast,
467
- AST::AstNode *original_ast = nullptr);
463
+ std::unique_ptr<AST::AstNode> original_ast = nullptr);
468
464
  }
469
465
 
470
466
  YOSYS_NAMESPACE_END
@@ -334,6 +334,7 @@ struct CellTypes
334
334
  return v;
335
335
  }
336
336
 
337
+ // Consider using the ConstEval struct instead if you need named ports and/or multiple outputs
337
338
  static RTLIL::Const eval(RTLIL::IdString type, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len, bool *errp = nullptr)
338
339
  {
339
340
  if (type == ID($sshr) && !signed1)
@@ -416,6 +417,7 @@ struct CellTypes
416
417
  log_abort();
417
418
  }
418
419
 
420
+ // Consider using the ConstEval struct instead if you need named ports and/or multiple outputs
419
421
  static RTLIL::Const eval(RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool *errp = nullptr)
420
422
  {
421
423
  if (cell->type == ID($slice)) {
@@ -503,10 +505,13 @@ struct CellTypes
503
505
  return eval(cell->type, arg1, arg2, signed_a, signed_b, result_len, errp);
504
506
  }
505
507
 
508
+ // Consider using the ConstEval struct instead if you need named ports and/or multiple outputs
506
509
  static RTLIL::Const eval(RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2, const RTLIL::Const &arg3, bool *errp = nullptr)
507
510
  {
508
511
  if (cell->type.in(ID($mux), ID($_MUX_)))
509
512
  return const_mux(arg1, arg2, arg3);
513
+ if (cell->type == ID($_NMUX_))
514
+ return eval_not(const_mux(arg1, arg2, arg3));
510
515
  if (cell->type == ID($bwmux))
511
516
  return const_bwmux(arg1, arg2, arg3);
512
517
  if (cell->type == ID($pmux))
@@ -520,6 +525,7 @@ struct CellTypes
520
525
  return eval(cell, arg1, arg2, errp);
521
526
  }
522
527
 
528
+ // Consider using the ConstEval struct instead if you need named ports and/or multiple outputs
523
529
  static RTLIL::Const eval(RTLIL::Cell *cell, const RTLIL::Const &arg1, const RTLIL::Const &arg2, const RTLIL::Const &arg3, const RTLIL::Const &arg4, bool *errp = nullptr)
524
530
  {
525
531
  if (cell->type == ID($_AOI4_))
@@ -349,7 +349,11 @@ struct ConstEval
349
349
  return false;
350
350
 
351
351
  bool eval_err = false;
352
- RTLIL::Const eval_ret = CellTypes::eval(cell, sig_a.as_const(), sig_b.as_const(), sig_c.as_const(), sig_d.as_const(), &eval_err);
352
+ RTLIL::Const eval_ret;
353
+ if (sig_s.size() > 0 && eval(sig_s, undef, cell)) {
354
+ eval_ret = CellTypes::eval(cell, sig_a.as_const(), sig_b.as_const(), sig_s.as_const(), &eval_err);
355
+ } else
356
+ eval_ret = CellTypes::eval(cell, sig_a.as_const(), sig_b.as_const(), sig_c.as_const(), sig_d.as_const(), &eval_err);
353
357
 
354
358
  if (eval_err)
355
359
  return false;
@@ -27,10 +27,10 @@ YOSYS_NAMESPACE_BEGIN
27
27
 
28
28
  struct FfInitVals
29
29
  {
30
- const SigMap *sigmap;
30
+ const SigMapView *sigmap;
31
31
  dict<SigBit, std::pair<State,SigBit>> initbits;
32
32
 
33
- void set(const SigMap *sigmap_, RTLIL::Module *module)
33
+ void set(const SigMapView *sigmap_, RTLIL::Module *module)
34
34
  {
35
35
  sigmap = sigmap_;
36
36
  initbits.clear();
@@ -126,7 +126,7 @@ struct FfInitVals
126
126
  initbits.clear();
127
127
  }
128
128
 
129
- FfInitVals (const SigMap *sigmap, RTLIL::Module *module)
129
+ FfInitVals (const SigMapView *sigmap, RTLIL::Module *module)
130
130
  {
131
131
  set(sigmap, module);
132
132
  }
@@ -58,7 +58,7 @@ YOSYS_NAMESPACE_BEGIN
58
58
 
59
59
  struct FfMergeHelper
60
60
  {
61
- const SigMap *sigmap;
61
+ const SigMapView *sigmap;
62
62
  RTLIL::Module *module;
63
63
  FfInitVals *initvals;
64
64
 
@@ -451,16 +451,21 @@ class dict {
451
451
  return 1;
452
452
  }
453
453
 
454
- int do_lookup(const K &key, Hasher::hash_t &hash) const
454
+ int do_lookup(const K &key, Hasher::hash_t &hash)
455
455
  {
456
456
  if (hashtable.empty())
457
457
  return -1;
458
458
 
459
459
  if (entries.size() * hashtable_size_trigger > hashtable.size()) {
460
- ((dict*)this)->do_rehash();
460
+ do_rehash();
461
461
  hash = do_hash(key);
462
462
  }
463
463
 
464
+ return do_lookup_internal(key, hash);
465
+ }
466
+
467
+ int do_lookup_internal(const K &key, Hasher::hash_t hash) const
468
+ {
464
469
  int index = hashtable[hash];
465
470
 
466
471
  while (index >= 0 && !ops.cmp(entries[index].udata.first, key)) {
@@ -471,6 +476,14 @@ class dict {
471
476
  return index;
472
477
  }
473
478
 
479
+ int do_lookup_no_rehash(const K &key, Hasher::hash_t hash) const
480
+ {
481
+ if (hashtable.empty())
482
+ return -1;
483
+
484
+ return do_lookup_internal(key, hash);
485
+ }
486
+
474
487
  int do_insert(const K &key, Hasher::hash_t &hash)
475
488
  {
476
489
  if (hashtable.empty()) {
@@ -694,14 +707,14 @@ public:
694
707
  int count(const K &key) const
695
708
  {
696
709
  Hasher::hash_t hash = do_hash(key);
697
- int i = do_lookup(key, hash);
710
+ int i = do_lookup_no_rehash(key, hash);
698
711
  return i < 0 ? 0 : 1;
699
712
  }
700
713
 
701
714
  int count(const K &key, const_iterator it) const
702
715
  {
703
716
  Hasher::hash_t hash = do_hash(key);
704
- int i = do_lookup(key, hash);
717
+ int i = do_lookup_no_rehash(key, hash);
705
718
  return i < 0 || i > it.index ? 0 : 1;
706
719
  }
707
720
 
@@ -717,7 +730,7 @@ public:
717
730
  const_iterator find(const K &key) const
718
731
  {
719
732
  Hasher::hash_t hash = do_hash(key);
720
- int i = do_lookup(key, hash);
733
+ int i = do_lookup_no_rehash(key, hash);
721
734
  if (i < 0)
722
735
  return end();
723
736
  return const_iterator(this, i);
@@ -735,7 +748,7 @@ public:
735
748
  const T& at(const K &key) const
736
749
  {
737
750
  Hasher::hash_t hash = do_hash(key);
738
- int i = do_lookup(key, hash);
751
+ int i = do_lookup_no_rehash(key, hash);
739
752
  if (i < 0)
740
753
  throw std::out_of_range("dict::at()");
741
754
  return entries[i].udata.second;
@@ -744,7 +757,7 @@ public:
744
757
  const T& at(const K &key, const T &defval) const
745
758
  {
746
759
  Hasher::hash_t hash = do_hash(key);
747
- int i = do_lookup(key, hash);
760
+ int i = do_lookup_no_rehash(key, hash);
748
761
  if (i < 0)
749
762
  return defval;
750
763
  return entries[i].udata.second;
@@ -906,16 +919,21 @@ protected:
906
919
  return 1;
907
920
  }
908
921
 
909
- int do_lookup(const K &key, Hasher::hash_t &hash) const
922
+ int do_lookup(const K &key, Hasher::hash_t &hash)
910
923
  {
911
924
  if (hashtable.empty())
912
925
  return -1;
913
926
 
914
927
  if (entries.size() * hashtable_size_trigger > hashtable.size()) {
915
- ((pool*)this)->do_rehash();
928
+ do_rehash();
916
929
  hash = do_hash(key);
917
930
  }
918
931
 
932
+ return do_lookup_internal(key, hash);
933
+ }
934
+
935
+ int do_lookup_internal(const K &key, Hasher::hash_t hash) const
936
+ {
919
937
  int index = hashtable[hash];
920
938
 
921
939
  while (index >= 0 && !ops.cmp(entries[index].udata, key)) {
@@ -926,6 +944,14 @@ protected:
926
944
  return index;
927
945
  }
928
946
 
947
+ int do_lookup_no_rehash(const K &key, Hasher::hash_t hash) const
948
+ {
949
+ if (hashtable.empty())
950
+ return -1;
951
+
952
+ return do_lookup_internal(key, hash);
953
+ }
954
+
929
955
  int do_insert(const K &value, Hasher::hash_t &hash)
930
956
  {
931
957
  if (hashtable.empty()) {
@@ -1087,14 +1113,14 @@ public:
1087
1113
  int count(const K &key) const
1088
1114
  {
1089
1115
  Hasher::hash_t hash = do_hash(key);
1090
- int i = do_lookup(key, hash);
1116
+ int i = do_lookup_no_rehash(key, hash);
1091
1117
  return i < 0 ? 0 : 1;
1092
1118
  }
1093
1119
 
1094
1120
  int count(const K &key, const_iterator it) const
1095
1121
  {
1096
1122
  Hasher::hash_t hash = do_hash(key);
1097
- int i = do_lookup(key, hash);
1123
+ int i = do_lookup_no_rehash(key, hash);
1098
1124
  return i < 0 || i > it.index ? 0 : 1;
1099
1125
  }
1100
1126
 
@@ -1110,7 +1136,7 @@ public:
1110
1136
  const_iterator find(const K &key) const
1111
1137
  {
1112
1138
  Hasher::hash_t hash = do_hash(key);
1113
- int i = do_lookup(key, hash);
1139
+ int i = do_lookup_no_rehash(key, hash);
1114
1140
  if (i < 0)
1115
1141
  return end();
1116
1142
  return const_iterator(this, i);
@@ -1222,7 +1248,7 @@ public:
1222
1248
  int at(const K &key) const
1223
1249
  {
1224
1250
  Hasher::hash_t hash = database.do_hash(key);
1225
- int i = database.do_lookup(key, hash);
1251
+ int i = database.do_lookup_no_rehash(key, hash);
1226
1252
  if (i < 0)
1227
1253
  throw std::out_of_range("idict::at()");
1228
1254
  return i + offset;
@@ -1231,7 +1257,7 @@ public:
1231
1257
  int at(const K &key, int defval) const
1232
1258
  {
1233
1259
  Hasher::hash_t hash = database.do_hash(key);
1234
- int i = database.do_lookup(key, hash);
1260
+ int i = database.do_lookup_no_rehash(key, hash);
1235
1261
  if (i < 0)
1236
1262
  return defval;
1237
1263
  return i + offset;
@@ -1240,7 +1266,7 @@ public:
1240
1266
  int count(const K &key) const
1241
1267
  {
1242
1268
  Hasher::hash_t hash = database.do_hash(key);
1243
- int i = database.do_lookup(key, hash);
1269
+ int i = database.do_lookup_no_rehash(key, hash);
1244
1270
  return i < 0 ? 0 : 1;
1245
1271
  }
1246
1272
 
@@ -1327,7 +1353,8 @@ public:
1327
1353
  return p;
1328
1354
  }
1329
1355
 
1330
- // Merge sets if the given indices belong to different sets
1356
+ // Merge sets if the given indices belong to different sets.
1357
+ // Makes ifind(j) the root of the merged set.
1331
1358
  void imerge(int i, int j)
1332
1359
  {
1333
1360
  i = ifind(i);
@@ -201,6 +201,7 @@ struct LogExpectedItem
201
201
  };
202
202
 
203
203
  extern dict<std::string, LogExpectedItem> log_expect_log, log_expect_warning, log_expect_error;
204
+ extern dict<std::string, LogExpectedItem> log_expect_prefix_log, log_expect_prefix_warning, log_expect_prefix_error;
204
205
  void log_check_expected();
205
206
 
206
207
  const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true);
@@ -1334,7 +1334,7 @@ struct RTLIL::Design
1334
1334
  dict<RTLIL::IdString, RTLIL::Module*> modules_;
1335
1335
  std::vector<RTLIL::Binding*> bindings_;
1336
1336
 
1337
- std::vector<AST::AstNode*> verilog_packages, verilog_globals;
1337
+ std::vector<std::unique_ptr<AST::AstNode>> verilog_packages, verilog_globals;
1338
1338
  std::unique_ptr<define_map_t> verilog_defines;
1339
1339
 
1340
1340
  std::vector<RTLIL::Selection> selection_stack;
@@ -64,7 +64,7 @@ struct ezSatPtr : public std::unique_ptr<ezSAT> {
64
64
  struct SatGen
65
65
  {
66
66
  ezSAT *ez;
67
- SigMap *sigmap;
67
+ const SigMap *sigmap;
68
68
  std::string prefix;
69
69
  SigPool initial_state;
70
70
  std::map<std::string, RTLIL::SigSpec> asserts_a, asserts_en;
@@ -75,12 +75,12 @@ struct SatGen
75
75
  bool model_undef;
76
76
  bool def_formal = false;
77
77
 
78
- SatGen(ezSAT *ez, SigMap *sigmap, std::string prefix = std::string()) :
78
+ SatGen(ezSAT *ez, const SigMap *sigmap, std::string prefix = std::string()) :
79
79
  ez(ez), sigmap(sigmap), prefix(prefix), ignore_div_by_zero(false), model_undef(false)
80
80
  {
81
81
  }
82
82
 
83
- void setContext(SigMap *sigmap, std::string prefix = std::string())
83
+ void setContext(const SigMap *sigmap, std::string prefix = std::string())
84
84
  {
85
85
  this->sigmap = sigmap;
86
86
  this->prefix = prefix;
@@ -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
 
yowasp_yosys/yosys.wasm CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yowasp-yosys
3
- Version: 0.56.0.0.post964
3
+ Version: 0.56.0.141.post974.dev0
4
4
  Summary: Yosys Open SYnthesis Suite
5
5
  Author-email: Catherine <whitequark@whitequark.org>
6
6
  License-Expression: ISC
@@ -2,7 +2,7 @@ yowasp_yosys/__init__.py,sha256=cxu6bMlZ6zRpCzKp2wdFs7LNt5-btnJD6ghvdkDs6Y0,1189
2
2
  yowasp_yosys/sby.py,sha256=BZwSqLk064cKvGITogDi3OqlQtRJJ-8J4_KG5Z7ktoc,19736
3
3
  yowasp_yosys/smtbmc.py,sha256=yiI93tHys5c8aXfCdk2dNtw2mwukRXqeT8YGx5Th8eg,74231
4
4
  yowasp_yosys/witness.py,sha256=m3iV2Nydm0p4G79VRaaX3lGul-nGnuxeKnx20MCJgi0,17279
5
- yowasp_yosys/yosys.wasm,sha256=g5VDCRlmu6vbH2ewagXlh-hz6w2saUFj5_RWVPhCySM,37878780
5
+ yowasp_yosys/yosys.wasm,sha256=5vKVdIYg6gv3qPrsjNRngy3DZjLFzlXhKcFFphQ1cB4,38066495
6
6
  yowasp_yosys/share/abc9_map.v,sha256=uWDqMpBQTeeadH1BlHVwkCy2StKF892xbgBgMKLK5-w,923
7
7
  yowasp_yosys/share/abc9_model.v,sha256=IfMyEGOEUBdZyiVule0wMhrVYVYQpmSIcxygbgtHItI,653
8
8
  yowasp_yosys/share/abc9_unmap.v,sha256=w107Y3iJjMU6D_6_aYLf2NziXTnAhpa5_CFAwaYO1iU,638
@@ -115,37 +115,37 @@ yowasp_yosys/share/include/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.h,sha
115
115
  yowasp_yosys/share/include/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi_vcd.cc,sha256=5A6IK46tg8BWgs_vzS183p9HMZfWP7FZfJzCjnB3vW8,2815
116
116
  yowasp_yosys/share/include/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi_vcd.h,sha256=P6KBEs-76IK4LwKBhXbju9nwkH3rmmqUm4uSuiaS88M,4286
117
117
  yowasp_yosys/share/include/backends/rtlil/rtlil_backend.h,sha256=h-kkdWtAosSZDzvAW511jAHao-dDUm3fyTJhfMXsZDk,2407
118
- yowasp_yosys/share/include/frontends/ast/ast.h,sha256=rjvkPnIrXBsH3TosMTsuoKpgKyUBUmiWw8rxBgDhuxg,16930
118
+ yowasp_yosys/share/include/frontends/ast/ast.h,sha256=p_nm0-fYc1xyPngvCtvzKFH5rWgydpNq5Q9XPBzokcc,17216
119
119
  yowasp_yosys/share/include/frontends/ast/ast_binding.h,sha256=NdII3-d38NWB_87m9AOzqQLjkkYaYToz3xHTsHNelU0,1756
120
120
  yowasp_yosys/share/include/frontends/blif/blifparse.h,sha256=GGceOEm-flPK0QdPIVDZ6ZGpkTphT14oTxJhAYIb2RY,1139
121
121
  yowasp_yosys/share/include/kernel/binding.h,sha256=BKfMhNf_HflihwCXEqyZuB1zp9xzVi0NRKe-5MvIidM,1947
122
122
  yowasp_yosys/share/include/kernel/bitpattern.h,sha256=V_gds0rvxcrRMTFhIm8Zv4PRFowNspJldfURho00lqo,3900
123
123
  yowasp_yosys/share/include/kernel/cellaigs.h,sha256=CdYos67IpmAgLvBbJ8EC3hWg6WhBIBy9jmhdoZ36HVE,1391
124
124
  yowasp_yosys/share/include/kernel/celledges.h,sha256=fF_sHJOpN_qQ1P0x8KKoJE9ulDMusfjkF0dBpTMs19E,2216
125
- yowasp_yosys/share/include/kernel/celltypes.h,sha256=W44T0u789-fy_tj7fGRTNI7s1jshewrPwmS3_-Oz6-A,18561
126
- yowasp_yosys/share/include/kernel/consteval.h,sha256=oEPSKbbgqvNmlLqYFSozZX2cjFQA5IM-d69HmyuZiGo,10864
125
+ yowasp_yosys/share/include/kernel/celltypes.h,sha256=sDqHEa3XqKD-0l-w5bvle5TI-wVABEpF6W1-ThvO7Eg,19027
126
+ yowasp_yosys/share/include/kernel/consteval.h,sha256=nYMALfx9WfaEr4c5VagL0lJta2QT_YdB0MdfXgEO0lU,11046
127
127
  yowasp_yosys/share/include/kernel/constids.inc,sha256=lW_aOEkMMVFonK8BAhc6JgmP95X9Q2yBJWg-xfhCc5c,3745
128
128
  yowasp_yosys/share/include/kernel/cost.h,sha256=TRW3KGPVLv5MxAmNbSh1mnzwTc-QHvZXSh9Wfc6mw3U,2921
129
129
  yowasp_yosys/share/include/kernel/drivertools.h,sha256=jHGOmnyVCjfvUvoBfQvD9O-Tu6pfs4WVbPbQZv1Mhd4,33537
130
130
  yowasp_yosys/share/include/kernel/ff.h,sha256=vVJqxmyfJ1z9qnnUA3CAoX5NavU33_J4U1Sd7TgPp5M,7631
131
- yowasp_yosys/share/include/kernel/ffinit.h,sha256=2JWt6YDjYYBtmQYzR68Apnq6S6y2gCvMkod6Qc3oWCw,3489
132
- yowasp_yosys/share/include/kernel/ffmerge.h,sha256=I3mXyytzRyP92T9XhSQTlv7EN2G31nJhspBxlLYiMEY,6305
131
+ yowasp_yosys/share/include/kernel/ffinit.h,sha256=wf_zlDDUGrmz__IH81008Hf2EiHzVJ8g8xmn23_BDLU,3501
132
+ yowasp_yosys/share/include/kernel/ffmerge.h,sha256=xl1_h88ZmLIxpli7vpiiU35R_Y4cZq728-A72abuzMg,6309
133
133
  yowasp_yosys/share/include/kernel/fmt.h,sha256=0UT-aDVX7_KnzlaNyK3iMsSzoICa4Q0HhqsFIrwHBMw,2790
134
134
  yowasp_yosys/share/include/kernel/gzip.h,sha256=wpAZ9hA13HEpWgZnth46JHvVLSA_qdS-JZB5gh83-QA,1847
135
- yowasp_yosys/share/include/kernel/hashlib.h,sha256=LgN2dYAg8r0YZnOd1r8DFI0qy7nyWO--SMghZaD7P9k,35719
135
+ yowasp_yosys/share/include/kernel/hashlib.h,sha256=g-I_i1zxQaiJ_s24j02DZrAZPyV2R4jTyIAPBYEAkJk,36365
136
136
  yowasp_yosys/share/include/kernel/io.h,sha256=8yQ9hISjrJKqsUbgQq4XaK8_VTRYE-jcSR-kP-Oq2FA,15010
137
137
  yowasp_yosys/share/include/kernel/json.h,sha256=i2wmIMZ2SCE5zc6IIIVLx4XZ2-HQiZEFJ0ao_cMInK0,2849
138
- yowasp_yosys/share/include/kernel/log.h,sha256=NZNJPBf-F_sISwfmJ_GQPm1Z9UzUCYQD6jHiWnsVorY,15380
138
+ yowasp_yosys/share/include/kernel/log.h,sha256=o2FuugF5IM1K_rnioDtRj8Vsu72VXOvLICcPpdaTG9k,15497
139
139
  yowasp_yosys/share/include/kernel/macc.h,sha256=LHm507daCT57lGCNNwia1LJVk3pkBB5ZteCZihxD5Qw,8926
140
140
  yowasp_yosys/share/include/kernel/mem.h,sha256=xKz0HxXap_PTdzpK-NUcbxybF3YisRc2JoCv17TXOc4,15505
141
141
  yowasp_yosys/share/include/kernel/modtools.h,sha256=mRnzc5TIsdIbHlFSTk2Yc0y85ttknhK-dAlti3neSI8,14388
142
142
  yowasp_yosys/share/include/kernel/qcsat.h,sha256=ibhpJRu0youjDXPllXrDJi851VpwW1kbJ_y94_X6JhU,2804
143
143
  yowasp_yosys/share/include/kernel/register.h,sha256=jc3S7uED5yT-60fY_DhfrgRoy3Q_h8kVFaF_lc5JZyY,6789
144
- yowasp_yosys/share/include/kernel/rtlil.h,sha256=SlvFoc97XNI1mYyp-fUmC3Jy9aRhUUAHe8PRyYkD9xY,99512
145
- yowasp_yosys/share/include/kernel/satgen.h,sha256=O7h0qkcsaX5g4XsUiLumlj8RAg63fxkFCLgZds5xgL8,10525
144
+ yowasp_yosys/share/include/kernel/rtlil.h,sha256=mnok7FWmr4jh7auCipSXV8HfcPhNyfOKb-Hy-N0XtSk,99528
145
+ yowasp_yosys/share/include/kernel/satgen.h,sha256=IPl4fWKQMyRFalyxwGJEJQt9MXIOKi3BKmqfkDbm7m4,10543
146
146
  yowasp_yosys/share/include/kernel/scopeinfo.h,sha256=EAU3vSTIwH1RrbSC7HVoTWh4SLfHMSIoidQPvT1Mo7g,11797
147
147
  yowasp_yosys/share/include/kernel/sexpr.h,sha256=CUDKFehVoGmakYBYLpEKUtlM0Dd3oI6TNW_cKz-qe0g,4720
148
- yowasp_yosys/share/include/kernel/sigtools.h,sha256=Tb1hUOLJD-AV4ojLVcjx0Dc00QSy6nGJyTwNMa4eqw0,8074
148
+ yowasp_yosys/share/include/kernel/sigtools.h,sha256=5s1qkeGjV2pbwrWRNaNgay8qHfKzk7TgK1jQM-C2Dco,10652
149
149
  yowasp_yosys/share/include/kernel/timinginfo.h,sha256=JNRktUWp7ow_wn4P5BxlOkv7hNS7qKbws7Gjs6VSUx8,7367
150
150
  yowasp_yosys/share/include/kernel/utils.h,sha256=5bJFi7SNf18SL7icrEQEDDYnqT9TrjBMlPZGHbinFK8,7315
151
151
  yowasp_yosys/share/include/kernel/yosys.h,sha256=bx9lTnEhsorxUoLhz2hu0__pSvVAyrthvGjoqaOL6oQ,3438
@@ -336,8 +336,8 @@ yowasp_yosys/share/xilinx/xc5v_dsp_map.v,sha256=I4lg0RQ54fBBba_7NNvUgwS4tQ1yLIsU
336
336
  yowasp_yosys/share/xilinx/xc6s_dsp_map.v,sha256=gTxHocB-Dn5G4BplWgri_tLhT6DIO2S0X-yu4iBKYyk,562
337
337
  yowasp_yosys/share/xilinx/xc7_dsp_map.v,sha256=zrzreQi7mElrAMtrayxtiO_Bw00S6zsjSjSVcjmJPH0,884
338
338
  yowasp_yosys/share/xilinx/xcu_dsp_map.v,sha256=gzCgl1emrHGcigVmU0nP0pW7dlhQ01SaWwXzHHcqt-o,882
339
- yowasp_yosys-0.56.0.0.post964.dist-info/METADATA,sha256=WszNwKNEceAy9MIYakwpaWAXaGqefifrcEkle7IX8tQ,2522
340
- yowasp_yosys-0.56.0.0.post964.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
341
- yowasp_yosys-0.56.0.0.post964.dist-info/entry_points.txt,sha256=p_9sIVi2ZqsqgYYo14PywYkwHYTa76fMEq3LxweXJpc,220
342
- yowasp_yosys-0.56.0.0.post964.dist-info/top_level.txt,sha256=_yiNT8kLYkcD1TEuUCzQ_MkON1c3xuIRV59zXds4zd4,13
343
- yowasp_yosys-0.56.0.0.post964.dist-info/RECORD,,
339
+ yowasp_yosys-0.56.0.141.post974.dev0.dist-info/METADATA,sha256=vLNx6yFAEnaSbM_DLFuCTdNyU_E2qCCrs6vuGrF7o28,2529
340
+ yowasp_yosys-0.56.0.141.post974.dev0.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
341
+ yowasp_yosys-0.56.0.141.post974.dev0.dist-info/entry_points.txt,sha256=p_9sIVi2ZqsqgYYo14PywYkwHYTa76fMEq3LxweXJpc,220
342
+ yowasp_yosys-0.56.0.141.post974.dev0.dist-info/top_level.txt,sha256=_yiNT8kLYkcD1TEuUCzQ_MkON1c3xuIRV59zXds4zd4,13
343
+ yowasp_yosys-0.56.0.141.post974.dev0.dist-info/RECORD,,