CIRCT 24.0.0git
Loading...
Searching...
No Matches
AssertionExpr.cpp
Go to the documentation of this file.
1//===- AssertionExpr.cpp - Slang assertion expression conversion ----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "slang/ast/expressions/AssertionExpr.h"
10
15#include "circt/Support/LLVM.h"
16#include "mlir/IR/BuiltinAttributes.h"
17#include "mlir/Support/LLVM.h"
18#include "slang/analysis/AnalysisManager.h"
19#include "slang/analysis/AnalyzedAssertion.h"
20#include "slang/ast/ASTVisitor.h"
21#include "slang/ast/SystemSubroutine.h"
22#include "slang/parsing/KnownSystemName.h"
23
24#include <optional>
25#include <utility>
26
27using namespace circt;
28using namespace ImportVerilog;
29
30// NOLINTBEGIN(misc-no-recursion)
31namespace {
32struct AssertionExprVisitor {
33 Context &context;
34 Location loc;
35 OpBuilder &builder;
36
37 AssertionExprVisitor(Context &context, Location loc)
38 : context(context), loc(loc), builder(context.builder) {}
39
40 /// Helper to convert a range (min, optional max) to MLIR integer attributes
41 std::pair<mlir::IntegerAttr, mlir::IntegerAttr>
42 convertRangeToAttrs(uint32_t min,
43 std::optional<uint32_t> max = std::nullopt) {
44 auto minAttr = builder.getI64IntegerAttr(min);
45 mlir::IntegerAttr rangeAttr;
46 if (max.has_value()) {
47 rangeAttr = builder.getI64IntegerAttr(max.value() - min);
48 }
49 return {minAttr, rangeAttr};
50 }
51
52 /// Add repetition operation to a sequence
53 Value createRepetition(Location loc,
54 const slang::ast::SequenceRepetition &repetition,
55 Value &inputSequence) {
56 // Extract cycle range
57 auto [minRepetitions, repetitionRange] =
58 convertRangeToAttrs(repetition.range.min, repetition.range.max);
59
60 using slang::ast::SequenceRepetition;
61
62 // Check if repetition range is required
63 if ((repetition.kind == SequenceRepetition::Nonconsecutive ||
64 repetition.kind == SequenceRepetition::GoTo) &&
65 !repetitionRange) {
66 mlir::emitError(loc,
67 repetition.kind == SequenceRepetition::Nonconsecutive
68 ? "Nonconsecutive repetition requires a maximum value"
69 : "GoTo repetition requires a maximum value");
70 return {};
71 }
72
73 switch (repetition.kind) {
74 case SequenceRepetition::Consecutive:
75 return ltl::RepeatOp::create(builder, loc, inputSequence, minRepetitions,
76 repetitionRange);
77 case SequenceRepetition::Nonconsecutive:
78 return ltl::NonConsecutiveRepeatOp::create(
79 builder, loc, inputSequence, minRepetitions, repetitionRange);
80 case SequenceRepetition::GoTo:
81 return ltl::GoToRepeatOp::create(builder, loc, inputSequence,
82 minRepetitions, repetitionRange);
83 }
84 llvm_unreachable("All enum values handled in switch");
85 }
86
87 Value visit(const slang::ast::SimpleAssertionExpr &expr) {
88 // Handle expression
89 auto value = context.convertRvalueExpression(expr.expr);
90 if (!value)
91 return {};
92 auto loc = context.convertLocation(expr.expr.sourceRange);
93 auto valueType = value.getType();
94 // For assertion instances the value is already the expected type, convert
95 // boolean value
96 if (!mlir::isa<ltl::SequenceType, ltl::PropertyType, mlir::IntegerType>(
97 valueType)) {
98 value = context.convertToBool(value);
99 value = context.convertToI1(value);
100 }
101 if (!value)
102 return {};
103
104 // Handle repetition
105 // The optional repetition is empty, return the converted expression
106 if (!expr.repetition.has_value()) {
107 return value;
108 }
109
110 // There is a repetition, embed the expression into the kind of given
111 // repetition
112 return createRepetition(loc, expr.repetition.value(), value);
113 }
114
115 Value visit(const slang::ast::SequenceConcatExpr &expr) {
116 // Create a sequence of delayed operations, combined with a concat operation
117 assert(!expr.elements.empty());
118
119 SmallVector<Value> sequenceElements;
120
121 for (const auto &concatElement : expr.elements) {
122 Value sequenceValue =
123 context.convertAssertionExpression(*concatElement.sequence, loc);
124 if (!sequenceValue)
125 return {};
126
127 [[maybe_unused]] Type valueType = sequenceValue.getType();
128 assert(valueType.isInteger(1) || mlir::isa<ltl::SequenceType>(valueType));
129
130 auto [delayMin, delayRange] =
131 convertRangeToAttrs(concatElement.delay.min, concatElement.delay.max);
132 auto delayedSequence = ltl::DelayOp::create(builder, loc, sequenceValue,
133 delayMin, delayRange);
134 sequenceElements.push_back(delayedSequence);
135 }
136
137 return builder.createOrFold<ltl::ConcatOp>(loc, sequenceElements);
138 }
139
140 Value visit(const slang::ast::UnaryAssertionExpr &expr) {
141 auto value = context.convertAssertionExpression(expr.expr, loc);
142 if (!value)
143 return {};
144 using slang::ast::UnaryAssertionOperator;
145 switch (expr.op) {
146 case UnaryAssertionOperator::Not:
147 return ltl::NotOp::create(builder, loc, value);
148 case UnaryAssertionOperator::SEventually:
149 if (expr.range.has_value()) {
150 mlir::emitError(loc, "Strong eventually with range not supported");
151 return {};
152 } else {
153 return ltl::EventuallyOp::create(builder, loc, value);
154 }
155 case UnaryAssertionOperator::Always: {
156 std::pair<mlir::IntegerAttr, mlir::IntegerAttr> attr = {
157 builder.getI64IntegerAttr(0), mlir::IntegerAttr{}};
158 if (expr.range.has_value()) {
159 attr =
160 convertRangeToAttrs(expr.range.value().min, expr.range.value().max);
161 }
162 return ltl::RepeatOp::create(builder, loc, value, attr.first,
163 attr.second);
164 }
165 case UnaryAssertionOperator::NextTime: {
166 auto minRepetitions = builder.getI64IntegerAttr(1);
167 if (expr.range.has_value()) {
168 minRepetitions = builder.getI64IntegerAttr(expr.range.value().min);
169 }
170 return ltl::DelayOp::create(builder, loc, value, minRepetitions,
171 builder.getI64IntegerAttr(0));
172 }
173 case UnaryAssertionOperator::Eventually:
174 case UnaryAssertionOperator::SNextTime:
175 case UnaryAssertionOperator::SAlways:
176 mlir::emitError(loc, "unsupported unary operator: ")
177 << slang::ast::toString(expr.op);
178 return {};
179 }
180 llvm_unreachable("All enum values handled in switch");
181 }
182
183 Value visit(const slang::ast::BinaryAssertionExpr &expr) {
184 auto lhs = context.convertAssertionExpression(expr.left, loc);
185 auto rhs = context.convertAssertionExpression(expr.right, loc);
186 if (!lhs || !rhs)
187 return {};
188 SmallVector<Value, 2> operands = {lhs, rhs};
189 using slang::ast::BinaryAssertionOperator;
190 switch (expr.op) {
191 case BinaryAssertionOperator::And:
192 return ltl::AndOp::create(builder, loc, operands);
193 case BinaryAssertionOperator::Or:
194 return ltl::OrOp::create(builder, loc, operands);
195 case BinaryAssertionOperator::Intersect:
196 return ltl::IntersectOp::create(builder, loc, operands);
197 case BinaryAssertionOperator::Throughout: {
198 auto lhsRepeat = ltl::RepeatOp::create(
199 builder, loc, lhs, builder.getI64IntegerAttr(0), mlir::IntegerAttr{});
200 return ltl::IntersectOp::create(builder, loc,
201 SmallVector<Value, 2>{lhsRepeat, rhs});
202 }
203 case BinaryAssertionOperator::Within: {
204 auto constOne =
205 hw::ConstantOp::create(builder, loc, builder.getI1Type(), 1);
206 auto oneRepeat = ltl::RepeatOp::create(builder, loc, constOne,
207 builder.getI64IntegerAttr(0),
208 mlir::IntegerAttr{});
209 auto repeatDelay = ltl::DelayOp::create(builder, loc, oneRepeat,
210 builder.getI64IntegerAttr(1),
211 builder.getI64IntegerAttr(0));
212 auto lhsDelay =
213 ltl::DelayOp::create(builder, loc, lhs, builder.getI64IntegerAttr(1),
214 builder.getI64IntegerAttr(0));
215 auto combined = ltl::ConcatOp::create(
216 builder, loc, SmallVector<Value, 3>{repeatDelay, lhsDelay, constOne});
217 return ltl::IntersectOp::create(builder, loc,
218 SmallVector<Value, 2>{combined, rhs});
219 }
220 case BinaryAssertionOperator::Iff: {
221 auto ored = ltl::OrOp::create(builder, loc, operands);
222 auto notOred = ltl::NotOp::create(builder, loc, ored);
223 auto anded = ltl::AndOp::create(builder, loc, operands);
224 return ltl::OrOp::create(builder, loc,
225 SmallVector<Value, 2>{notOred, anded});
226 }
227 case BinaryAssertionOperator::Until:
228 return ltl::UntilOp::create(builder, loc, operands);
229 case BinaryAssertionOperator::UntilWith: {
230 auto untilOp = ltl::UntilOp::create(builder, loc, operands);
231 auto andOp = ltl::AndOp::create(builder, loc, operands);
232 auto notUntil = ltl::NotOp::create(builder, loc, untilOp);
233 return ltl::OrOp::create(builder, loc,
234 SmallVector<Value, 2>{notUntil, andOp});
235 }
236 case BinaryAssertionOperator::Implies: {
237 auto notLhs = ltl::NotOp::create(builder, loc, lhs);
238 return ltl::OrOp::create(builder, loc,
239 SmallVector<Value, 2>{notLhs, rhs});
240 }
241 case BinaryAssertionOperator::OverlappedImplication:
242 return ltl::ImplicationOp::create(builder, loc, operands);
243 case BinaryAssertionOperator::NonOverlappedImplication: {
244 auto constOne =
245 hw::ConstantOp::create(builder, loc, builder.getI1Type(), 1);
246 auto oneDelay = ltl::DelayOp::create(builder, loc, constOne,
247 builder.getI64IntegerAttr(1),
248 builder.getI64IntegerAttr(0));
249 auto antecedent = ltl::ConcatOp::create(
250 builder, loc, SmallVector<Value, 2>{lhs, oneDelay});
251 return ltl::ImplicationOp::create(builder, loc,
252 SmallVector<Value, 2>{antecedent, rhs});
253 }
254 case BinaryAssertionOperator::OverlappedFollowedBy: {
255 auto notRhs = ltl::NotOp::create(builder, loc, rhs);
256 auto implication = ltl::ImplicationOp::create(
257 builder, loc, SmallVector<Value, 2>{lhs, notRhs});
258 return ltl::NotOp::create(builder, loc, implication);
259 }
260 case BinaryAssertionOperator::NonOverlappedFollowedBy: {
261 auto constOne =
262 hw::ConstantOp::create(builder, loc, builder.getI1Type(), 1);
263 auto notRhs = ltl::NotOp::create(builder, loc, rhs);
264 auto oneDelay = ltl::DelayOp::create(builder, loc, constOne,
265 builder.getI64IntegerAttr(1),
266 builder.getI64IntegerAttr(0));
267 auto antecedent = ltl::ConcatOp::create(
268 builder, loc, SmallVector<Value, 2>{lhs, oneDelay});
269 auto implication = ltl::ImplicationOp::create(
270 builder, loc, SmallVector<Value, 2>{antecedent, notRhs});
271 return ltl::NotOp::create(builder, loc, implication);
272 }
273 case BinaryAssertionOperator::SUntil:
274 case BinaryAssertionOperator::SUntilWith:
275 mlir::emitError(loc, "unsupported binary operator: ")
276 << slang::ast::toString(expr.op);
277 return {};
278 }
279 llvm_unreachable("All enum values handled in switch");
280 }
281
282 Value visit(const slang::ast::ClockingAssertionExpr &expr) {
283 auto assertionExpr = context.convertAssertionExpression(expr.expr, loc);
284 if (!assertionExpr)
285 return {};
286 return context.convertLTLTimingControl(expr.clocking, assertionExpr);
287 }
288
289 /// Emit an error for all other expressions.
290 template <typename T>
291 Value visit(T &&node) {
292 mlir::emitError(loc, "unsupported expression: ")
293 << slang::ast::toString(node.kind);
294 return {};
295 }
296
297 Value visitInvalid(const slang::ast::AssertionExpr &expr) {
298 mlir::emitError(loc, "invalid expression");
299 return {};
300 }
301};
302} // namespace
303
304/// Helper to cast a builtin integer result back to Moore integer types.
305static inline Value castToMoore(OpBuilder &builder, Location loc,
306 Type originalType, Value v) {
307 if (auto ty = dyn_cast<moore::IntType>(originalType)) {
308 v = moore::FromBuiltinIntOp::create(builder, loc, v);
309 if (ty.getDomain() == Domain::FourValued)
310 v = moore::IntToLogicOp::create(builder, loc, v);
311 }
312 return v;
313}
314
316 const slang::ast::SystemSubroutine &subroutine, Location loc, Value value,
317 Type originalType, Value clockVal) {
318 using ksn = slang::parsing::KnownSystemName;
319 auto nameId = subroutine.knownNameId;
320
321 // Helper to cast a builtin integer result to a two-valued Moore integer type.
322 auto castToTwoValued = [&](Value v) -> Value {
323 return moore::FromBuiltinIntOp::create(builder, loc, v);
324 };
325
326 switch (nameId) {
327 case ksn::Sampled:
328 return castToMoore(builder, loc, originalType,
329 ltl::SampledOp::create(builder, loc, value));
330
331 // Translate $fell to ¬x[0] ∧ x[-1]
332 case ksn::Fell: {
333 auto past =
334 ltl::PastOp::create(builder, loc, value, 1, clockVal).getResult();
335 return castToTwoValued(comb::ICmpOp::create(
336 builder, loc, comb::ICmpPredicate::ugt, past, value, false));
337 }
338
339 // Translate $rose to x[0] ∧ ¬x[-1]
340 case ksn::Rose: {
341 auto past =
342 ltl::PastOp::create(builder, loc, value, 1, clockVal).getResult();
343 return castToTwoValued(comb::ICmpOp::create(
344 builder, loc, comb::ICmpPredicate::ult, past, value, false));
345 }
346
347 // Translate $changed to x[0] ≠ x[-1]
348 case ksn::Changed: {
349 auto past =
350 ltl::PastOp::create(builder, loc, value, 1, clockVal).getResult();
351 return castToTwoValued(comb::ICmpOp::create(
352 builder, loc, comb::ICmpPredicate::ne, past, value, false));
353 }
354
355 // Translate $stable to x[0] = x[-1]
356 case ksn::Stable: {
357 auto past =
358 ltl::PastOp::create(builder, loc, value, 1, clockVal).getResult();
359 return castToTwoValued(comb::ICmpOp::create(
360 builder, loc, comb::ICmpPredicate::eq, past, value, false));
361 }
362
363 case ksn::Past:
364 return castToMoore(builder, loc, originalType,
365 ltl::PastOp::create(builder, loc, value, 1, clockVal));
366
367 default:
368 return Value{};
369 }
370}
371
373 const slang::ast::SystemSubroutine &subroutine, Location loc,
374 Value firstArgVal, Type originalType, Value clockVal,
375 const slang::ast::Expression &secondArgExpr) {
376 using ksn = slang::parsing::KnownSystemName;
377 auto nameId = subroutine.knownNameId;
378
379 switch (nameId) {
380 case ksn::Past: {
381 // Slang already checks that `number_of_ticks` is a constant integral > 0
382 auto ticks = evaluateConstant(secondArgExpr).integer().as<int64_t>();
383 assert(ticks && *ticks >= 1 && "slang should reject invalid tick counts");
384
385 return castToMoore(
386 builder, loc, originalType,
387 ltl::PastOp::create(builder, loc, firstArgVal, *ticks, clockVal));
388 }
389
390 default:
391 return mlir::emitError(loc) << "second argument for `" << subroutine.name
392 << "` is not yet supported";
393 }
394}
395
397 const slang::ast::CallExpression &expr,
398 const slang::ast::CallExpression::SystemCallInfo &info, Location loc) {
399
400 const slang::ast::TimingControl *clock = nullptr;
401 auto clockIt = sampledValueCallClocks.find(&expr);
402 if (clockIt != sampledValueCallClocks.end())
403 clock = clockIt->second;
404
405 // Non-procedural expressions don't have a clock registered in
406 // sampledValueCallClocks but we can get it from their scope's default clock
407 if (!clock && !info.scope->isProceduralContext())
408 if (auto defClk =
409 info.scope->getCompilation().getDefaultClocking(*info.scope))
410 clock = &defClk->as<slang::ast::ClockingBlockSymbol>().getEvent();
411
412 if (!clock) {
413 mlir::emitError(loc) << "could not determine clocking event for `"
414 << expr.getSubroutineName() << "`";
415 return {};
416 }
417
418 Value clockVal;
419 const slang::ast::SignalEventControl *signal = nullptr;
420 if (clock->kind == slang::ast::TimingControlKind::SignalEvent) {
421 signal = &clock->as<slang::ast::SignalEventControl>();
422 } else if (clock->kind == slang::ast::TimingControlKind::EventList) {
423 mlir::emitError(loc, "sampled value functions with multiple event "
424 "triggers are not supported");
425 return {};
426 } else {
427 llvm_unreachable("unexpected clock kind for assertion");
428 }
429
430 if (signal->edge != slang::ast::EdgeKind::PosEdge) {
431 mlir::emitError(
432 loc, "sampled value functions are only supported with posedge clocks");
433 return {};
434 }
435 clockVal = convertRvalueExpression(signal->expr);
436 if (clockVal)
437 clockVal = convertToI1(clockVal);
438 if (!clockVal)
439 return {};
440
441 const auto &subroutine = *info.subroutine;
442 auto args = expr.arguments();
443
444 FailureOr<Value> result;
445 Value firstArgVal;
446 Value firstArgIntVal;
447 Type originalType;
448 moore::IntType firstArgTy;
449
450 // Slang rejects sampled value calls with no arguments during elaboration.
451 assert(!args.empty() && "sampled value call must have at least 1 argument");
452
453 // Convert the first argument to int type.
454 firstArgVal = this->convertRvalueExpression(*args[0]);
455 if (isa<moore::PackedType>(firstArgVal.getType())) {
456 firstArgVal = materializePackedToSBVConversion(firstArgVal, loc,
457 /*fallible=*/false);
458 if (!firstArgVal)
459 return {};
460 }
461 firstArgTy = dyn_cast<moore::IntType>(firstArgVal.getType());
462 if (!firstArgTy) {
463 mlir::emitError(loc) << "expected integer argument for `" << subroutine.name
464 << "`";
465 return {};
466 }
467 // Use the simple bit vector type for converting the result back from a
468 // builtin integer. Packed aggregates are converted back to their original
469 // type at the end, together with all other results.
470 originalType = firstArgTy;
471 // If the value is four-valued, we need to map it to two-valued before we
472 // cast it to a builtin int
473 if (firstArgTy.getDomain() == Domain::FourValued) {
474 firstArgVal = builder.createOrFold<moore::LogicToIntOp>(loc, firstArgVal);
475 }
476 firstArgIntVal =
477 builder.createOrFold<moore::ToBuiltinIntOp>(loc, firstArgVal);
478 if (!firstArgIntVal)
479 return {};
480
481 // Handle sampled value call depending on number of arguments.
482 if (args.size() == 1) {
483 result = this->convertSampledValueCallArity1(
484 subroutine, loc, firstArgIntVal, originalType, clockVal);
485 } else if (args.size() == 2) {
486 result = this->convertSampledValueCallArity2(
487 subroutine, loc, firstArgIntVal, originalType, clockVal, *args[1]);
488 } else {
489 mlir::emitError(loc) << "`" << subroutine.name << "` with " << args.size()
490 << " arguments is not yet supported";
491 return {};
492 }
493
494 if (failed(result))
495 return {};
496 if (*result) {
497 auto expectedTy = convertType(*expr.type);
498 return materializeConversion(expectedTy, *result, expr.type->isSigned(),
499 loc);
500 }
501
502 mlir::emitError(loc) << "unsupported system call `" << subroutine.name << "`";
503 return {};
504}
505
506Value Context::convertAssertionExpression(const slang::ast::AssertionExpr &expr,
507 Location loc) {
508 AssertionExprVisitor visitor{*this, loc};
509 return expr.visit(visitor);
510}
511// NOLINTEND(misc-no-recursion)
512
513/// Helper function to convert a value to an i1 value.
514Value Context::convertToI1(Value value) {
515 if (!value)
516 return {};
517 auto loc = value.getLoc();
518 auto type = dyn_cast<moore::IntType>(value.getType());
519 if (!type || type.getBitSize() != 1) {
520 mlir::emitError(loc, "expected a 1-bit integer");
521 return {};
522 }
523 if (type.getDomain() == Domain::FourValued) {
524 value = moore::LogicToIntOp::create(builder, loc, value);
525 }
526 return moore::ToBuiltinIntOp::create(builder, loc, value);
527}
528
529namespace {
530struct AssertionClockVisitor
531 : slang::ast::ASTVisitor<AssertionClockVisitor,
532 slang::ast::VisitFlags::AllGood> {
534 const slang::analysis::AnalyzedAssertion &assertion;
535 const slang::ast::TimingControl *currentClock = nullptr;
536
537 AssertionClockVisitor(Context &context,
538 const slang::analysis::AnalyzedAssertion &assertion)
539 : context(context), assertion(assertion) {}
540
541 void handle(const slang::ast::CallExpression &node) {
542 if (currentClock)
543 context.sampledValueCallClocks[&node] = currentClock;
544 visitDefault(node);
545 }
546
547 template <typename T>
548 std::enable_if_t<std::is_base_of_v<slang::ast::AssertionExpr, T>>
549 handle(const T &node) {
550 auto *prevClock = currentClock;
551 if (auto *clk = assertion.getClock(node))
552 currentClock = clk;
553 visitDefault(node);
554 currentClock = prevClock;
555 }
556};
557} // namespace
558
560 compilation.freeze();
561 slang::analysis::AnalysisManager am;
562 am.addListener([this](const slang::analysis::AnalyzedAssertion &assertion) {
563 AssertionClockVisitor visitor{*this, assertion};
564 assertion.getRoot().visit(visitor);
565 });
566 // AnalyzedProcedure captures both procedures and continuous assignments
567 am.addListener([this](const slang::analysis::AnalyzedProcedure &procedure) {
568 if (const auto clock = procedure.getInferredClock())
569 for (const auto *call : procedure.getCallExpressions())
570 sampledValueCallClocks[call] = clock;
571 });
572 am.analyze(compilation);
573 compilation.unfreeze();
574}
static Value castToMoore(OpBuilder &builder, Location loc, Type originalType, Value v)
Helper to cast a builtin integer result back to Moore integer types.
assert(baseType &&"element must be base type")
static std::unique_ptr< Context > context
create(data_type, value)
Definition hw.py:433
@ FourValued
Four-valued types such as logic or integer.
Definition MooreTypes.h:55
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
A helper class to facilitate the conversion from a Slang AST to MLIR operations.
Value convertToI1(Value value)
Helper function to convert a value to a MLIR I1 value.
void populateSampledValueClocks()
Generates a map from sampled value system calls to clocks using Slang's analysis.
slang::ConstantValue evaluateConstant(const slang::ast::Expression &expr)
Evaluate the constant value of an expression.
FailureOr< Value > convertSampledValueCallArity2(const slang::ast::SystemSubroutine &subroutine, Location loc, Value firstArgVal, Type originalType, Value clockVal, const slang::ast::Expression &secondArgExpr)
Convert sampled value system function calls with two arguments.
slang::ast::Compilation & compilation
OpBuilder builder
The builder used to create IR operations.
Value convertSampledValueCallExpression(const slang::ast::CallExpression &expr, const slang::ast::CallExpression::SystemCallInfo &info, Location loc)
Type convertType(const slang::ast::Type &type, LocationAttr loc={})
Convert a slang type into an MLIR type.
Definition Types.cpp:224
Value materializePackedToSBVConversion(Value value, Location loc, bool fallible)
Helper function to convert a PackedType value to its simple bit vector representation,...
Value convertRvalueExpression(const slang::ast::Expression &expr, Type requiredType={})
DenseMap< const slang::ast::CallExpression *, const slang::ast::TimingControl * > sampledValueCallClocks
Maps sampled value system calls to their corresponding clocks.
Value materializeConversion(Type type, Value value, bool isSigned, Location loc, bool fallible=false)
Helper function to insert the necessary operations to cast a value from one type to another.
Value convertAssertionExpression(const slang::ast::AssertionExpr &expr, Location loc)
FailureOr< Value > convertSampledValueCallArity1(const slang::ast::SystemSubroutine &subroutine, Location loc, Value value, Type originalType, Value clockVal)
Convert sampled value system function calls with a single argument.