yowasp-yosys 0.39.0.0.post694__py3-none-any.whl → 0.39.0.183.post706.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.
yowasp_yosys/sby.py CHANGED
@@ -422,8 +422,7 @@ def start_task(taskloop, taskname):
422
422
 
423
423
  if opt_force and not reusedir:
424
424
  early_log(my_workdir, f"Removing directory '{os.path.abspath(my_workdir)}'.")
425
- if sbyfile:
426
- shutil.rmtree(my_workdir, ignore_errors=True)
425
+ shutil.rmtree(my_workdir, ignore_errors=True)
427
426
 
428
427
  if reusedir:
429
428
  pass
@@ -0,0 +1,54 @@
1
+ /*
2
+ * yosys -- Yosys Open SYnthesis Suite
3
+ *
4
+ * Copyright (C) 2024 Martin Povišer <povik@cutebit.org>
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
+ (* techmap_celltype = "$lcu" *)
21
+ module _80_lcu_kogge_stone (P, G, CI, CO);
22
+ parameter WIDTH = 2;
23
+
24
+ (* force_downto *)
25
+ input [WIDTH-1:0] P, G;
26
+ input CI;
27
+
28
+ (* force_downto *)
29
+ output [WIDTH-1:0] CO;
30
+
31
+ integer i, j;
32
+ (* force_downto *)
33
+ reg [WIDTH-1:0] p, g;
34
+
35
+ wire [1023:0] _TECHMAP_DO_ = "proc; opt -fast";
36
+
37
+ always @* begin
38
+ p = P;
39
+ g = G;
40
+
41
+ // in almost all cases CI will be constant zero
42
+ g[0] = g[0] | (p[0] & CI);
43
+
44
+ for (i = 0; i < $clog2(WIDTH); i = i + 1) begin
45
+ // iterate in reverse so we don't confuse a result from this stage and the previous
46
+ for (j = WIDTH - 1; j >= 2**i; j = j - 1) begin
47
+ g[j] = g[j] | p[j] & g[j - 2**i];
48
+ p[j] = p[j] & p[j - 2**i];
49
+ end
50
+ end
51
+ end
52
+
53
+ assign CO = g;
54
+ endmodule
@@ -113,7 +113,31 @@ module EFX_GBUFCE(
113
113
 
114
114
  endmodule
115
115
 
116
- module EFX_RAM_5K(
116
+ module EFX_RAM_5K
117
+ # (
118
+ parameter READ_WIDTH = 20,
119
+ parameter WRITE_WIDTH = 20,
120
+ localparam READ_ADDR_WIDTH =
121
+ (READ_WIDTH == 16) ? 8 : // 256x16
122
+ (READ_WIDTH == 8) ? 9 : // 512x8
123
+ (READ_WIDTH == 4) ? 10 : // 1024x4
124
+ (READ_WIDTH == 2) ? 11 : // 2048x2
125
+ (READ_WIDTH == 1) ? 12 : // 4096x1
126
+ (READ_WIDTH == 20) ? 8 : // 256x20
127
+ (READ_WIDTH == 10) ? 9 : // 512x10
128
+ (READ_WIDTH == 5) ? 10 : -1, // 1024x5
129
+
130
+ localparam WRITE_ADDR_WIDTH =
131
+ (WRITE_WIDTH == 16) ? 8 : // 256x16
132
+ (WRITE_WIDTH == 8) ? 9 : // 512x8
133
+ (WRITE_WIDTH == 4) ? 10 : // 1024x4
134
+ (WRITE_WIDTH == 2) ? 11 : // 2048x2
135
+ (WRITE_WIDTH == 1) ? 12 : // 4096x1
136
+ (WRITE_WIDTH == 20) ? 8 : // 256x20
137
+ (WRITE_WIDTH == 10) ? 9 : // 512x10
138
+ (WRITE_WIDTH == 5) ? 10 : -1 // 1024x5
139
+ )
140
+ (
117
141
  input [WRITE_WIDTH-1:0] WDATA,
118
142
  input [WRITE_ADDR_WIDTH-1:0] WADDR,
119
143
  input WE,
@@ -126,8 +150,6 @@ module EFX_RAM_5K(
126
150
  (* clkbuf_sink *)
127
151
  input RCLK
128
152
  );
129
- parameter READ_WIDTH = 20;
130
- parameter WRITE_WIDTH = 20;
131
153
  parameter OUTPUT_REG = 1'b0;
132
154
  parameter RCLK_POLARITY = 1'b1;
133
155
  parameter RE_POLARITY = 1'b1;
@@ -155,25 +177,4 @@ module EFX_RAM_5K(
155
177
  parameter INIT_11 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
156
178
  parameter INIT_12 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
157
179
  parameter INIT_13 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
158
-
159
- localparam READ_ADDR_WIDTH =
160
- (READ_WIDTH == 16) ? 8 : // 256x16
161
- (READ_WIDTH == 8) ? 9 : // 512x8
162
- (READ_WIDTH == 4) ? 10 : // 1024x4
163
- (READ_WIDTH == 2) ? 11 : // 2048x2
164
- (READ_WIDTH == 1) ? 12 : // 4096x1
165
- (READ_WIDTH == 20) ? 8 : // 256x20
166
- (READ_WIDTH == 10) ? 9 : // 512x10
167
- (READ_WIDTH == 5) ? 10 : -1; // 1024x5
168
-
169
- localparam WRITE_ADDR_WIDTH =
170
- (WRITE_WIDTH == 16) ? 8 : // 256x16
171
- (WRITE_WIDTH == 8) ? 9 : // 512x8
172
- (WRITE_WIDTH == 4) ? 10 : // 1024x4
173
- (WRITE_WIDTH == 2) ? 11 : // 2048x2
174
- (WRITE_WIDTH == 1) ? 12 : // 4096x1
175
- (WRITE_WIDTH == 20) ? 8 : // 256x20
176
- (WRITE_WIDTH == 10) ? 9 : // 512x10
177
- (WRITE_WIDTH == 5) ? 10 : -1; // 1024x5
178
-
179
180
  endmodule
@@ -625,11 +625,11 @@ struct value : public expr_base<value<Bits>> {
625
625
  value<Bits + 1> remainder;
626
626
  value<Bits + 1> dividend = sext<Bits + 1>();
627
627
  value<Bits + 1> divisor = other.template sext<Bits + 1>();
628
- if (dividend.is_neg()) dividend = dividend.neg();
629
- if (divisor.is_neg()) divisor = divisor.neg();
628
+ if (is_neg()) dividend = dividend.neg();
629
+ if (other.is_neg()) divisor = divisor.neg();
630
630
  std::tie(quotient, remainder) = dividend.udivmod(divisor);
631
- if (dividend.is_neg() != divisor.is_neg()) quotient = quotient.neg();
632
- if (dividend.is_neg()) remainder = remainder.neg();
631
+ if (is_neg() != other.is_neg()) quotient = quotient.neg();
632
+ if (is_neg()) remainder = remainder.neg();
633
633
  return {quotient.template trunc<Bits>(), remainder.template trunc<Bits>()};
634
634
  }
635
635
  };
@@ -1010,22 +1010,24 @@ struct observer {
1010
1010
  // Default member initializers would make this a non-aggregate-type in C++11, so they are commented out.
1011
1011
  struct fmt_part {
1012
1012
  enum {
1013
- STRING = 0,
1013
+ LITERAL = 0,
1014
1014
  INTEGER = 1,
1015
- CHARACTER = 2,
1016
- VLOG_TIME = 3,
1015
+ STRING = 2,
1016
+ UNICHAR = 3,
1017
+ VLOG_TIME = 4,
1017
1018
  } type;
1018
1019
 
1019
- // STRING type
1020
+ // LITERAL type
1020
1021
  std::string str;
1021
1022
 
1022
- // INTEGER/CHARACTER types
1023
+ // INTEGER/STRING/UNICHAR types
1023
1024
  // + value<Bits> val;
1024
1025
 
1025
- // INTEGER/CHARACTER/VLOG_TIME types
1026
+ // INTEGER/STRING/VLOG_TIME types
1026
1027
  enum {
1027
1028
  RIGHT = 0,
1028
1029
  LEFT = 1,
1030
+ NUMERIC = 2,
1029
1031
  } justify; // = RIGHT;
1030
1032
  char padding; // = '\0';
1031
1033
  size_t width; // = 0;
@@ -1033,7 +1035,14 @@ struct fmt_part {
1033
1035
  // INTEGER type
1034
1036
  unsigned base; // = 10;
1035
1037
  bool signed_; // = false;
1036
- bool plus; // = false;
1038
+ enum {
1039
+ MINUS = 0,
1040
+ PLUS_MINUS = 1,
1041
+ SPACE_MINUS = 2,
1042
+ } sign; // = MINUS;
1043
+ bool hex_upper; // = false;
1044
+ bool show_base; // = false;
1045
+ bool group; // = false;
1037
1046
 
1038
1047
  // VLOG_TIME type
1039
1048
  bool realtime; // = false;
@@ -1049,11 +1058,12 @@ struct fmt_part {
1049
1058
  // We might want to replace some of these bit() calls with direct
1050
1059
  // chunk access if it turns out to be slow enough to matter.
1051
1060
  std::string buf;
1061
+ std::string prefix;
1052
1062
  switch (type) {
1053
- case STRING:
1063
+ case LITERAL:
1054
1064
  return str;
1055
1065
 
1056
- case CHARACTER: {
1066
+ case STRING: {
1057
1067
  buf.reserve(Bits/8);
1058
1068
  for (int i = 0; i < Bits; i += 8) {
1059
1069
  char ch = 0;
@@ -1067,35 +1077,76 @@ struct fmt_part {
1067
1077
  break;
1068
1078
  }
1069
1079
 
1080
+ case UNICHAR: {
1081
+ uint32_t codepoint = val.template get<uint32_t>();
1082
+ if (codepoint >= 0x10000)
1083
+ buf += (char)(0xf0 | (codepoint >> 18));
1084
+ else if (codepoint >= 0x800)
1085
+ buf += (char)(0xe0 | (codepoint >> 12));
1086
+ else if (codepoint >= 0x80)
1087
+ buf += (char)(0xc0 | (codepoint >> 6));
1088
+ else
1089
+ buf += (char)codepoint;
1090
+ if (codepoint >= 0x10000)
1091
+ buf += (char)(0x80 | ((codepoint >> 12) & 0x3f));
1092
+ if (codepoint >= 0x800)
1093
+ buf += (char)(0x80 | ((codepoint >> 6) & 0x3f));
1094
+ if (codepoint >= 0x80)
1095
+ buf += (char)(0x80 | ((codepoint >> 0) & 0x3f));
1096
+ break;
1097
+ }
1098
+
1070
1099
  case INTEGER: {
1071
- size_t width = Bits;
1100
+ bool negative = signed_ && val.is_neg();
1101
+ if (negative) {
1102
+ prefix = "-";
1103
+ val = val.neg();
1104
+ } else {
1105
+ switch (sign) {
1106
+ case MINUS: break;
1107
+ case PLUS_MINUS: prefix = "+"; break;
1108
+ case SPACE_MINUS: prefix = " "; break;
1109
+ }
1110
+ }
1111
+
1112
+ size_t val_width = Bits;
1072
1113
  if (base != 10) {
1073
- width = 0;
1114
+ val_width = 1;
1074
1115
  for (size_t index = 0; index < Bits; index++)
1075
1116
  if (val.bit(index))
1076
- width = index + 1;
1117
+ val_width = index + 1;
1077
1118
  }
1078
1119
 
1079
1120
  if (base == 2) {
1080
- for (size_t i = width; i > 0; i--)
1081
- buf += (val.bit(i - 1) ? '1' : '0');
1121
+ if (show_base)
1122
+ prefix += "0b";
1123
+ for (size_t index = 0; index < val_width; index++) {
1124
+ if (group && index > 0 && index % 4 == 0)
1125
+ buf += '_';
1126
+ buf += (val.bit(index) ? '1' : '0');
1127
+ }
1082
1128
  } else if (base == 8 || base == 16) {
1129
+ if (show_base)
1130
+ prefix += (base == 16) ? (hex_upper ? "0X" : "0x") : "0o";
1083
1131
  size_t step = (base == 16) ? 4 : 3;
1084
- for (size_t index = 0; index < width; index += step) {
1132
+ for (size_t index = 0; index < val_width; index += step) {
1133
+ if (group && index > 0 && index % (4 * step) == 0)
1134
+ buf += '_';
1085
1135
  uint8_t value = val.bit(index) | (val.bit(index + 1) << 1) | (val.bit(index + 2) << 2);
1086
1136
  if (step == 4)
1087
1137
  value |= val.bit(index + 3) << 3;
1088
- buf += "0123456789abcdef"[value];
1138
+ buf += (hex_upper ? "0123456789ABCDEF" : "0123456789abcdef")[value];
1089
1139
  }
1090
- std::reverse(buf.begin(), buf.end());
1091
1140
  } else if (base == 10) {
1092
- bool negative = signed_ && val.is_neg();
1093
- if (negative)
1094
- val = val.neg();
1141
+ if (show_base)
1142
+ prefix += "0d";
1095
1143
  if (val.is_zero())
1096
1144
  buf += '0';
1097
1145
  value<(Bits > 4 ? Bits : 4)> xval = val.template zext<(Bits > 4 ? Bits : 4)>();
1146
+ size_t index = 0;
1098
1147
  while (!xval.is_zero()) {
1148
+ if (group && index > 0 && index % 3 == 0)
1149
+ buf += '_';
1099
1150
  value<(Bits > 4 ? Bits : 4)> quotient, remainder;
1100
1151
  if (Bits >= 4)
1101
1152
  std::tie(quotient, remainder) = xval.udivmod(value<(Bits > 4 ? Bits : 4)>{10u});
@@ -1103,11 +1154,18 @@ struct fmt_part {
1103
1154
  std::tie(quotient, remainder) = std::make_pair(value<(Bits > 4 ? Bits : 4)>{0u}, xval);
1104
1155
  buf += '0' + remainder.template trunc<4>().template get<uint8_t>();
1105
1156
  xval = quotient;
1157
+ index++;
1106
1158
  }
1107
- if (negative || plus)
1108
- buf += negative ? '-' : '+';
1109
- std::reverse(buf.begin(), buf.end());
1110
1159
  } else assert(false && "Unsupported base for fmt_part");
1160
+ if (justify == NUMERIC && group && padding == '0') {
1161
+ int group_size = base == 10 ? 3 : 4;
1162
+ while (prefix.size() + buf.size() < width) {
1163
+ if (buf.size() % (group_size + 1) == group_size)
1164
+ buf += '_';
1165
+ buf += '0';
1166
+ }
1167
+ }
1168
+ std::reverse(buf.begin(), buf.end());
1111
1169
  break;
1112
1170
  }
1113
1171
 
@@ -1123,17 +1181,29 @@ struct fmt_part {
1123
1181
 
1124
1182
  std::string str;
1125
1183
  assert(width == 0 || padding != '\0');
1126
- if (justify == RIGHT && buf.size() < width) {
1127
- size_t pad_width = width - buf.size();
1128
- if (padding == '0' && (buf.front() == '+' || buf.front() == '-')) {
1129
- str += buf.front();
1130
- buf.erase(0, 1);
1131
- }
1132
- str += std::string(pad_width, padding);
1184
+ if (prefix.size() + buf.size() < width) {
1185
+ size_t pad_width = width - prefix.size() - buf.size();
1186
+ switch (justify) {
1187
+ case LEFT:
1188
+ str += prefix;
1189
+ str += buf;
1190
+ str += std::string(pad_width, padding);
1191
+ break;
1192
+ case RIGHT:
1193
+ str += std::string(pad_width, padding);
1194
+ str += prefix;
1195
+ str += buf;
1196
+ break;
1197
+ case NUMERIC:
1198
+ str += prefix;
1199
+ str += std::string(pad_width, padding);
1200
+ str += buf;
1201
+ break;
1202
+ }
1203
+ } else {
1204
+ str += prefix;
1205
+ str += buf;
1133
1206
  }
1134
- str += buf;
1135
- if (justify == LEFT && buf.size() < width)
1136
- str += std::string(width - buf.size(), padding);
1137
1207
  return str;
1138
1208
  }
1139
1209
  };
@@ -53,22 +53,24 @@ struct VerilogFmtArg {
53
53
  // Must be kept in sync with `struct fmt_part` in backends/cxxrtl/runtime/cxxrtl/cxxrtl.h!
54
54
  struct FmtPart {
55
55
  enum {
56
- STRING = 0,
56
+ LITERAL = 0,
57
57
  INTEGER = 1,
58
- CHARACTER = 2,
59
- VLOG_TIME = 3,
58
+ STRING = 2,
59
+ UNICHAR = 3,
60
+ VLOG_TIME = 4,
60
61
  } type;
61
62
 
62
- // STRING type
63
+ // LITERAL type
63
64
  std::string str;
64
65
 
65
- // INTEGER/CHARACTER types
66
+ // INTEGER/STRING/UNICHAR types
66
67
  RTLIL::SigSpec sig;
67
68
 
68
- // INTEGER/CHARACTER/VLOG_TIME types
69
+ // INTEGER/STRING/VLOG_TIME types
69
70
  enum {
70
71
  RIGHT = 0,
71
72
  LEFT = 1,
73
+ NUMERIC = 2,
72
74
  } justify = RIGHT;
73
75
  char padding = '\0';
74
76
  size_t width = 0;
@@ -76,7 +78,14 @@ struct FmtPart {
76
78
  // INTEGER type
77
79
  unsigned base = 10;
78
80
  bool signed_ = false;
79
- bool plus = false;
81
+ enum {
82
+ MINUS = 0,
83
+ PLUS_MINUS = 1,
84
+ SPACE_MINUS = 2,
85
+ } sign = MINUS;
86
+ bool hex_upper = false;
87
+ bool show_base = false;
88
+ bool group = false;
80
89
 
81
90
  // VLOG_TIME type
82
91
  bool realtime = false;
@@ -86,7 +95,7 @@ struct Fmt {
86
95
  public:
87
96
  std::vector<FmtPart> parts;
88
97
 
89
- void append_string(const std::string &str);
98
+ void append_literal(const std::string &str);
90
99
 
91
100
  void parse_rtlil(const RTLIL::Cell *cell);
92
101
  void emit_rtlil(RTLIL::Cell *cell) const;
@@ -17,11 +17,11 @@
17
17
  *
18
18
  */
19
19
 
20
- #include "kernel/yosys.h"
21
-
22
20
  #ifndef LOG_H
23
21
  #define LOG_H
24
22
 
23
+ #include "kernel/yosys_common.h"
24
+
25
25
  #include <time.h>
26
26
 
27
27
  #include <regex>
@@ -449,4 +449,6 @@ void log_dump_args_worker(const char *p, T first, Args ... args)
449
449
 
450
450
  YOSYS_NAMESPACE_END
451
451
 
452
+ #include "kernel/yosys.h"
453
+
452
454
  #endif
@@ -17,11 +17,12 @@
17
17
  *
18
18
  */
19
19
 
20
- #include "kernel/yosys.h"
21
-
22
20
  #ifndef REGISTER_H
23
21
  #define REGISTER_H
24
22
 
23
+ #include "kernel/yosys_common.h"
24
+ #include "kernel/yosys.h"
25
+
25
26
  YOSYS_NAMESPACE_BEGIN
26
27
 
27
28
  struct Pass
@@ -17,11 +17,12 @@
17
17
  *
18
18
  */
19
19
 
20
- #include "kernel/yosys.h"
21
-
22
20
  #ifndef RTLIL_H
23
21
  #define RTLIL_H
24
22
 
23
+ #include "kernel/yosys_common.h"
24
+ #include "kernel/yosys.h"
25
+
25
26
  YOSYS_NAMESPACE_BEGIN
26
27
 
27
28
  namespace RTLIL
@@ -149,7 +149,7 @@ template <typename T, typename C = std::less<T>, typename OPS = hash_ops<T>> cla
149
149
  std::map<T, int, C> node_to_index;
150
150
  std::vector<std::set<int, IndirectCmp>> edges;
151
151
  std::vector<T> sorted;
152
- std::set<std::set<T, C>> loops;
152
+ std::set<std::vector<T>> loops;
153
153
 
154
154
  TopoSort() : indirect_cmp(nodes)
155
155
  {
@@ -220,10 +220,10 @@ template <typename T, typename C = std::less<T>, typename OPS = hash_ops<T>> cla
220
220
  if (active_cells[root_index]) {
221
221
  found_loops = true;
222
222
  if (analyze_loops) {
223
- std::set<T, C> loop;
223
+ std::vector<T> loop;
224
224
  for (int i = GetSize(active_stack) - 1; i >= 0; i--) {
225
225
  const int index = active_stack[i];
226
- loop.insert(nodes[index]);
226
+ loop.push_back(nodes[index]);
227
227
  if (index == root_index)
228
228
  break;
229
229
  }