esiaccel 0.1.4.dev31__cp310-cp310-win_amd64.whl → 0.2.3.dev80__cp310-cp310-win_amd64.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 (58) hide show
  1. esiaccel/CosimBackend.dll +0 -0
  2. esiaccel/CosimBackend.lib +0 -0
  3. esiaccel/CosimRpc.dll +0 -0
  4. esiaccel/CosimRpc.lib +0 -0
  5. esiaccel/ESICppRuntime.dll +0 -0
  6. esiaccel/ESICppRuntime.lib +0 -0
  7. esiaccel/EsiCosimDpiServer.dll +0 -0
  8. esiaccel/EsiCosimDpiServer.lib +0 -0
  9. esiaccel/{lib/MtiPli.dll → MtiPli.dll} +0 -0
  10. esiaccel/{lib/MtiPli.lib → MtiPli.lib} +0 -0
  11. esiaccel/__init__.py +22 -4
  12. esiaccel/abseil_dll.dll +0 -0
  13. esiaccel/accelerator.py +37 -5
  14. esiaccel/cares.dll +0 -0
  15. esiaccel/cmake/esiaccelConfig.cmake +34 -0
  16. esiaccel/codegen.py +3 -3
  17. esiaccel/cosim/Cosim_CycleCount.sv +84 -0
  18. esiaccel/cosim/Cosim_Endpoint.sv +61 -32
  19. esiaccel/cosim/driver.cpp +6 -6
  20. esiaccel/cosim/driver.sv +14 -0
  21. esiaccel/cosim/questa.py +141 -0
  22. esiaccel/cosim/simulator.py +383 -0
  23. esiaccel/cosim/verilator.py +92 -0
  24. esiaccel/esi-cosim.py +104 -0
  25. esiaccel/esiCppAccel.cp312-win_amd64.pyd +0 -0
  26. esiaccel/esiquery.exe +0 -0
  27. esiaccel/include/esi/Accelerator.h +14 -17
  28. esiaccel/include/esi/CLI.h +5 -5
  29. esiaccel/include/esi/Common.h +19 -2
  30. esiaccel/include/esi/Context.h +17 -9
  31. esiaccel/include/esi/Design.h +9 -4
  32. esiaccel/include/esi/Manifest.h +0 -2
  33. esiaccel/include/esi/Ports.h +230 -23
  34. esiaccel/include/esi/Services.h +92 -31
  35. esiaccel/include/esi/Types.h +162 -10
  36. esiaccel/include/esi/Values.h +313 -0
  37. esiaccel/include/esi/backends/Cosim.h +5 -12
  38. esiaccel/include/esi/backends/RpcClient.h +97 -0
  39. esiaccel/include/esi/backends/RpcServer.h +21 -3
  40. esiaccel/libcrypto-3-x64.dll +0 -0
  41. esiaccel/libprotobuf.dll +0 -0
  42. esiaccel/libssl-3-x64.dll +0 -0
  43. esiaccel/re2.dll +0 -0
  44. esiaccel/types.py +66 -26
  45. esiaccel/utils.py +21 -3
  46. esiaccel/zlib1.dll +0 -0
  47. {esiaccel-0.1.4.dev31.dist-info → esiaccel-0.2.3.dev80.dist-info}/METADATA +1 -1
  48. esiaccel-0.2.3.dev80.dist-info/RECORD +58 -0
  49. esiaccel/bin/esi-cosim.py +0 -423
  50. esiaccel/bin/esiquery.exe +0 -0
  51. esiaccel/esiCppAccel.cp310-win_amd64.pyd +0 -0
  52. esiaccel/lib/EsiCosimDpiServer.dll +0 -0
  53. esiaccel/lib/EsiCosimDpiServer.lib +0 -0
  54. esiaccel-0.1.4.dev31.dist-info/RECORD +0 -43
  55. {esiaccel-0.1.4.dev31.dist-info → esiaccel-0.2.3.dev80.dist-info}/WHEEL +0 -0
  56. {esiaccel-0.1.4.dev31.dist-info → esiaccel-0.2.3.dev80.dist-info}/entry_points.txt +0 -0
  57. {esiaccel-0.1.4.dev31.dist-info → esiaccel-0.2.3.dev80.dist-info}/licenses/LICENSE +0 -0
  58. {esiaccel-0.1.4.dev31.dist-info → esiaccel-0.2.3.dev80.dist-info}/top_level.txt +0 -0
@@ -25,10 +25,21 @@
25
25
  #include "esi/Ports.h"
26
26
 
27
27
  #include <cstdint>
28
+ #include <list>
28
29
 
29
30
  namespace esi {
30
31
  class AcceleratorConnection;
31
32
  class Engine;
33
+ namespace services {
34
+ class Service;
35
+ }
36
+
37
+ // While building the design, keep around a std::map of active services indexed
38
+ // by the service name. When a new service is encountered during descent, add it
39
+ // to the table (perhaps overwriting one). Modifications to the table only apply
40
+ // to the current branch, so copy this and update it at each level of the tree.
41
+ using ServiceTable = std::map<std::string, services::Service *>;
42
+
32
43
  namespace services {
33
44
 
34
45
  /// Add a custom interface to a service client at a particular point in the
@@ -38,7 +49,9 @@ public:
38
49
  using BundlePort::BundlePort;
39
50
  virtual ~ServicePort() = default;
40
51
  // Get a description of the service port.
41
- virtual std::optional<std::string> toString() const { return std::nullopt; }
52
+ virtual std::optional<std::string> toString(bool oneLine = false) const {
53
+ return std::nullopt;
54
+ }
42
55
  };
43
56
 
44
57
  /// Parent class of all APIs modeled as 'services'. May or may not map to a
@@ -107,6 +120,14 @@ public:
107
120
  /// Get the ESI version number to check version compatibility.
108
121
  virtual uint32_t getEsiVersion() const = 0;
109
122
 
123
+ /// Get the current cycle count of the accelerator system.
124
+ virtual std::optional<uint64_t> getCycleCount() const { return std::nullopt; }
125
+ /// Get the "core" clock frequency of the accelerator system in Hz. Returns
126
+ /// nullopt if the accelerator does not provide this information.
127
+ virtual std::optional<uint64_t> getCoreClockFrequency() const {
128
+ return std::nullopt;
129
+ }
130
+
110
131
  /// Return the JSON-formatted system manifest.
111
132
  virtual std::string getJsonManifest() const;
112
133
 
@@ -124,7 +145,8 @@ public:
124
145
  uint32_t size;
125
146
  };
126
147
 
127
- MMIO(AcceleratorConnection &, const HWClientDetails &clients);
148
+ MMIO(AcceleratorConnection &, const AppIDPath &idPath,
149
+ const HWClientDetails &clients);
128
150
  virtual ~MMIO() = default;
129
151
 
130
152
  /// Read a 64-bit value from the global MMIO space.
@@ -169,7 +191,8 @@ public:
169
191
  /// Write a 64-bit value to this region, not the global address space.
170
192
  virtual void write(uint32_t addr, uint64_t data);
171
193
 
172
- virtual std::optional<std::string> toString() const override {
194
+ virtual std::optional<std::string>
195
+ toString(bool oneLine = false) const override {
173
196
  return "MMIO region " + toHex(desc.base) + " - " +
174
197
  toHex(desc.base + desc.size);
175
198
  }
@@ -188,6 +211,12 @@ public:
188
211
  /// Get the ESI version number to check version compatibility.
189
212
  uint32_t getEsiVersion() const override;
190
213
 
214
+ /// Get the current cycle count of the accelerator system's core clock.
215
+ std::optional<uint64_t> getCycleCount() const override;
216
+ /// Get the "core" clock frequency of the accelerator system in Hz. Returns
217
+ /// nullopt if the accelerator does not provide this information.
218
+ std::optional<uint64_t> getCoreClockFrequency() const override;
219
+
191
220
  /// Return the zlib compressed JSON system manifest.
192
221
  virtual std::vector<uint8_t> getCompressedManifest() const override;
193
222
 
@@ -270,14 +299,23 @@ public:
270
299
  void connect();
271
300
  std::future<MessageData> call(const MessageData &arg);
272
301
 
273
- virtual std::optional<std::string> toString() const override {
274
- const esi::Type *argType =
275
- dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
276
- ->getInner();
277
- const esi::Type *resultType =
278
- dynamic_cast<const ChannelType *>(type->findChannel("result").first)
279
- ->getInner();
280
- return "function " + resultType->getID() + "(" + argType->getID() + ")";
302
+ const esi::Type *getArgType() const {
303
+ return dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
304
+ ->getInner();
305
+ }
306
+
307
+ const esi::Type *getResultType() const {
308
+ return dynamic_cast<const ChannelType *>(
309
+ type->findChannel("result").first)
310
+ ->getInner();
311
+ }
312
+
313
+ virtual std::optional<std::string>
314
+ toString(bool oneLine = false) const override {
315
+ const esi::Type *argType = getArgType();
316
+ const esi::Type *resultType = getResultType();
317
+ return "function " + resultType->toString(oneLine) + "(" +
318
+ argType->toString(oneLine) + ")";
281
319
  }
282
320
 
283
321
  private:
@@ -319,14 +357,23 @@ public:
319
357
  void connect(std::function<MessageData(const MessageData &)> callback,
320
358
  bool quick = false);
321
359
 
322
- virtual std::optional<std::string> toString() const override {
323
- const esi::Type *argType =
324
- dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
325
- ->getInner();
326
- const esi::Type *resultType =
327
- dynamic_cast<const ChannelType *>(type->findChannel("result").first)
328
- ->getInner();
329
- return "callback " + resultType->getID() + "(" + argType->getID() + ")";
360
+ const esi::Type *getArgType() const {
361
+ return dynamic_cast<const ChannelType *>(type->findChannel("arg").first)
362
+ ->getInner();
363
+ }
364
+
365
+ const esi::Type *getResultType() const {
366
+ return dynamic_cast<const ChannelType *>(
367
+ type->findChannel("result").first)
368
+ ->getInner();
369
+ }
370
+
371
+ virtual std::optional<std::string>
372
+ toString(bool oneLine = false) const override {
373
+ const esi::Type *argType = getArgType();
374
+ const esi::Type *resultType = getResultType();
375
+ return "callback " + resultType->toString(oneLine) + "(" +
376
+ argType->toString(oneLine) + ")";
330
377
  }
331
378
 
332
379
  private:
@@ -350,37 +397,51 @@ public:
350
397
  virtual std::string getServiceSymbol() const override;
351
398
  virtual BundlePort *getPort(AppIDPath id,
352
399
  const BundleType *type) const override;
400
+ virtual Service *getChildService(Service::Type service, AppIDPath id = {},
401
+ std::string implName = {},
402
+ ServiceImplDetails details = {},
403
+ HWClientDetails clients = {}) override;
404
+ MMIO::MMIORegion *getMMIORegion() const;
353
405
 
354
406
  /// A telemetry port which gets attached to a service port.
355
- class Telemetry : public ServicePort {
407
+ class Metric : public ServicePort {
356
408
  friend class TelemetryService;
357
- Telemetry(AppID id, const BundleType *type, PortMap channels);
409
+ Metric(AppID id, const BundleType *type, PortMap channels,
410
+ const TelemetryService *telemetryService,
411
+ std::optional<uint64_t> offset);
358
412
 
359
413
  public:
360
- static Telemetry *get(AppID id, BundleType *type, WriteChannelPort &get,
361
- ReadChannelPort &data);
362
-
363
414
  void connect();
364
415
  std::future<MessageData> read();
416
+ uint64_t readInt();
365
417
 
366
- virtual std::optional<std::string> toString() const override {
418
+ virtual std::optional<std::string>
419
+ toString(bool oneLine = false) const override {
367
420
  const esi::Type *dataType =
368
421
  dynamic_cast<const ChannelType *>(type->findChannel("data").first)
369
422
  ->getInner();
370
- return "telemetry " + dataType->getID();
423
+ return "telemetry " + dataType->toString(oneLine);
371
424
  }
372
425
 
373
426
  private:
374
- WriteChannelPort *get_req;
375
- ReadChannelPort *data;
427
+ const TelemetryService *telemetryService;
428
+ MMIO::MMIORegion *mmio;
429
+ std::optional<uint64_t> offset;
376
430
  };
377
431
 
378
- const std::map<AppIDPath, Telemetry *> &getTelemetryPorts() {
379
- return telemetryPorts;
432
+ std::map<AppIDPath, Metric *> getTelemetryPorts() {
433
+ std::map<AppIDPath, Metric *> ports;
434
+ getTelemetryPorts(ports);
435
+ return ports;
380
436
  }
437
+ void getTelemetryPorts(std::map<AppIDPath, Metric *> &ports);
381
438
 
382
439
  private:
383
- mutable std::map<AppIDPath, Telemetry *> telemetryPorts;
440
+ AppIDPath id;
441
+ mutable MMIO::MMIORegion *mmio;
442
+ std::map<AppIDPath, uint64_t> portAddressAssignments;
443
+ mutable std::map<AppIDPath, Metric *> telemetryPorts;
444
+ std::list<TelemetryService *> children;
384
445
  };
385
446
 
386
447
  /// Registry of services which can be instantiated directly by the Accelerator
@@ -16,11 +16,18 @@
16
16
  #ifndef ESI_TYPES_H
17
17
  #define ESI_TYPES_H
18
18
 
19
+ #include <algorithm>
20
+ #include <any>
19
21
  #include <cstdint>
20
22
  #include <map>
23
+ #include <span>
24
+ #include <stdexcept>
21
25
  #include <string>
22
26
  #include <vector>
23
27
 
28
+ #include "esi/Common.h"
29
+ #include "esi/Values.h" // For BitVector / Int / UInt
30
+
24
31
  namespace esi {
25
32
 
26
33
  /// Root class of the ESI type system.
@@ -33,6 +40,52 @@ public:
33
40
  ID getID() const { return id; }
34
41
  virtual std::ptrdiff_t getBitWidth() const { return -1; }
35
42
 
43
+ /// Serialize an object to a MutableBitVector (LSB-first stream). The object
44
+ /// should be passed via std::any. Implementations append fields in the order
45
+ /// they are iterated (the first serialized field occupies the
46
+ /// least-significant bits of the result).
47
+ virtual MutableBitVector serialize(const std::any &obj) const {
48
+ throw std::runtime_error("Serialization not implemented for type " + id);
49
+ }
50
+
51
+ /// Deserialize from a BitVector stream (LSB-first). Implementations consume
52
+ /// bits from 'data' in-place (via logical right shifts) and return the
53
+ /// reconstructed value. Remaining bits stay in 'data'.
54
+ virtual std::any deserialize(BitVector &data) const {
55
+ throw std::runtime_error("Deserialization not implemented for type " + id);
56
+ }
57
+
58
+ // Deserialize from a MessageData buffer. Maps the MessageData onto a
59
+ // MutableBitVector, and proceeds with regular MutableBitVector
60
+ // deserialization.
61
+ std::any deserialize(const MessageData &data) const {
62
+ auto bv = MutableBitVector(std::vector<uint8_t>(data.getData()));
63
+ return deserialize(bv);
64
+ }
65
+
66
+ /// Ensure that a std::any object is valid for this type. Throws
67
+ /// std::runtime_error if the object is not valid.
68
+ virtual void ensureValid(const std::any &obj) const {
69
+ throw std::runtime_error("Validation not implemented for type " + id);
70
+ }
71
+
72
+ // Check if a std::any object is valid for this type. Returns an optional
73
+ // error message if the object is not valid, else, std::nullopt.
74
+ std::optional<std::string> isValid(const std::any &obj) const {
75
+ try {
76
+ ensureValid(obj);
77
+ return std::nullopt;
78
+ } catch (const std::runtime_error &e) {
79
+ return e.what();
80
+ }
81
+ }
82
+
83
+ // Dump a textual representation of this type to the provided stream.
84
+ void dump(std::ostream &os, bool oneLine = false) const;
85
+
86
+ // Return a textual representation of this type.
87
+ std::string toString(bool oneLine = false) const;
88
+
36
89
  protected:
37
90
  ID id;
38
91
  };
@@ -54,12 +107,7 @@ public:
54
107
  const ChannelVector &getChannels() const { return channels; }
55
108
  std::ptrdiff_t getBitWidth() const override { return -1; };
56
109
 
57
- std::pair<const Type *, Direction> findChannel(std::string name) const {
58
- for (auto [channelName, dir, type] : channels)
59
- if (channelName == name)
60
- return std::make_pair(type, dir);
61
- throw std::runtime_error("Channel '" + name + "' not found in bundle");
62
- }
110
+ std::pair<const Type *, Direction> findChannel(std::string name) const;
63
111
 
64
112
  protected:
65
113
  ChannelVector channels;
@@ -69,10 +117,15 @@ protected:
69
117
  /// carry one values of one type.
70
118
  class ChannelType : public Type {
71
119
  public:
120
+ using Type::deserialize;
72
121
  ChannelType(const ID &id, const Type *inner) : Type(id), inner(inner) {}
73
122
  const Type *getInner() const { return inner; }
74
123
  std::ptrdiff_t getBitWidth() const override { return inner->getBitWidth(); };
75
124
 
125
+ void ensureValid(const std::any &obj) const override;
126
+ MutableBitVector serialize(const std::any &obj) const override;
127
+ std::any deserialize(BitVector &data) const override;
128
+
76
129
  private:
77
130
  const Type *inner;
78
131
  };
@@ -80,9 +133,14 @@ private:
80
133
  /// The "void" type is a special type which can be used to represent no type.
81
134
  class VoidType : public Type {
82
135
  public:
136
+ using Type::deserialize;
83
137
  VoidType(const ID &id) : Type(id) {}
84
138
  // 'void' is 1 bit by convention.
85
139
  std::ptrdiff_t getBitWidth() const override { return 1; };
140
+
141
+ void ensureValid(const std::any &obj) const override;
142
+ MutableBitVector serialize(const std::any &obj) const override;
143
+ std::any deserialize(BitVector &data) const override;
86
144
  };
87
145
 
88
146
  /// The "any" type is a special type which can be used to represent any type, as
@@ -112,6 +170,11 @@ private:
112
170
  class BitsType : public BitVectorType {
113
171
  public:
114
172
  using BitVectorType::BitVectorType;
173
+ using Type::deserialize;
174
+
175
+ void ensureValid(const std::any &obj) const override;
176
+ MutableBitVector serialize(const std::any &obj) const override;
177
+ std::any deserialize(BitVector &data) const override;
115
178
  };
116
179
 
117
180
  /// Integers are bit vectors which may be signed or unsigned and are interpreted
@@ -125,21 +188,32 @@ public:
125
188
  class SIntType : public IntegerType {
126
189
  public:
127
190
  using IntegerType::IntegerType;
191
+ using Type::deserialize;
192
+
193
+ void ensureValid(const std::any &obj) const override;
194
+ MutableBitVector serialize(const std::any &obj) const override;
195
+ std::any deserialize(BitVector &data) const override;
128
196
  };
129
197
 
130
198
  /// Unsigned integer.
131
199
  class UIntType : public IntegerType {
132
200
  public:
133
201
  using IntegerType::IntegerType;
202
+ using Type::deserialize;
203
+
204
+ void ensureValid(const std::any &obj) const override;
205
+ MutableBitVector serialize(const std::any &obj) const override;
206
+ std::any deserialize(BitVector &data) const override;
134
207
  };
135
208
 
136
209
  /// Structs are an ordered collection of fields, each with a name and a type.
137
210
  class StructType : public Type {
138
211
  public:
139
212
  using FieldVector = std::vector<std::pair<std::string, const Type *>>;
213
+ using Type::deserialize;
140
214
 
141
- StructType(const ID &id, const FieldVector &fields)
142
- : Type(id), fields(fields) {}
215
+ StructType(const ID &id, const FieldVector &fields, bool reverse = true)
216
+ : Type(id), fields(fields), reverse(reverse) {}
143
217
 
144
218
  const FieldVector &getFields() const { return fields; }
145
219
  std::ptrdiff_t getBitWidth() const override {
@@ -153,18 +227,33 @@ public:
153
227
  return size;
154
228
  }
155
229
 
230
+ void ensureValid(const std::any &obj) const override;
231
+ MutableBitVector serialize(const std::any &obj) const override;
232
+ std::any deserialize(BitVector &data) const override;
233
+
234
+ // Returns whether this struct type should be reversed when
235
+ // serializing/deserializing.
236
+ // By default, a truthy value here makes StructType's compatible with system
237
+ // verilog, which has reversed struct field ordering, wrt. C/software struct
238
+ // ordering.
239
+ bool isReverse() const { return reverse; }
240
+
156
241
  private:
157
242
  FieldVector fields;
243
+ bool reverse;
158
244
  };
159
245
 
160
246
  /// Arrays have a compile time specified (static) size and an element type.
161
247
  class ArrayType : public Type {
162
248
  public:
163
- ArrayType(const ID &id, const Type *elementType, uint64_t size)
164
- : Type(id), elementType(elementType), size(size) {}
249
+ ArrayType(const ID &id, const Type *elementType, uint64_t size,
250
+ bool reverse = true)
251
+ : Type(id), elementType(elementType), size(size), reverse(reverse) {}
252
+ using Type::deserialize;
165
253
 
166
254
  const Type *getElementType() const { return elementType; }
167
255
  uint64_t getSize() const { return size; }
256
+ bool isReverse() const { return reverse; }
168
257
  std::ptrdiff_t getBitWidth() const override {
169
258
  std::ptrdiff_t elementSize = elementType->getBitWidth();
170
259
  if (elementSize < 0)
@@ -172,9 +261,72 @@ public:
172
261
  return elementSize * size;
173
262
  }
174
263
 
264
+ void ensureValid(const std::any &obj) const override;
265
+ MutableBitVector serialize(const std::any &obj) const override;
266
+ std::any deserialize(BitVector &data) const override;
267
+
175
268
  private:
176
269
  const Type *elementType;
177
270
  uint64_t size;
271
+ // 'reverse' controls whether array elements are reversed during
272
+ // serialization/deserialization (to match SystemVerilog/Python ordering
273
+ // expectations).
274
+ bool reverse;
275
+ };
276
+
277
+ /// Windows represent a fixed-size sliding window over a stream of data.
278
+ /// They define an "into" type (the data structure being windowed) and a
279
+ /// "loweredType" (the hardware representation including control signals).
280
+ class WindowType : public Type {
281
+ public:
282
+ /// Field information describing a field within a frame.
283
+ struct Field {
284
+ std::string name;
285
+ uint64_t numItems = 0; // 0 means not specified (use all items)
286
+ uint64_t bulkCountWidth = 0; // 0 means parallel encoding, >0 means serial
287
+ };
288
+
289
+ /// Frame information describing which fields are included in a particular
290
+ /// frame.
291
+ struct Frame {
292
+ std::string name;
293
+ std::vector<Field> fields;
294
+ };
295
+
296
+ WindowType(const ID &id, const std::string &name, const Type *intoType,
297
+ const Type *loweredType, const std::vector<Frame> &frames)
298
+ : Type(id), name(name), intoType(intoType), loweredType(loweredType),
299
+ frames(frames) {}
300
+
301
+ const std::string &getName() const { return name; }
302
+ const Type *getIntoType() const { return intoType; }
303
+ const Type *getLoweredType() const { return loweredType; }
304
+ const std::vector<Frame> &getFrames() const { return frames; }
305
+
306
+ std::ptrdiff_t getBitWidth() const override {
307
+ return loweredType->getBitWidth();
308
+ }
309
+
310
+ private:
311
+ std::string name;
312
+ const Type *intoType;
313
+ const Type *loweredType;
314
+ std::vector<Frame> frames;
315
+ };
316
+
317
+ /// Lists represent variable-length sequences of elements of a single type.
318
+ /// Unlike arrays which have a fixed size, lists can have any length.
319
+ class ListType : public Type {
320
+ public:
321
+ ListType(const ID &id, const Type *elementType)
322
+ : Type(id), elementType(elementType) {}
323
+
324
+ const Type *getElementType() const { return elementType; }
325
+
326
+ std::ptrdiff_t getBitWidth() const override { return -1; }
327
+
328
+ private:
329
+ const Type *elementType;
178
330
  };
179
331
 
180
332
  } // namespace esi