Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions include/circt/Dialect/Sim/SimOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,29 @@ def FormatHierPathOp : SimOp<"fmt.hier_path", [Pure]> {
let assemblyFormat = "(`escaped` $useEscapes^)? attr-dict";
}

def TimeOp : SimOp<"time", [Pure]> {
let summary = "Current simulation time";
let description = [{
Returns the current simulation time as an `i64` value.
}];

let results = (outs I64:$result);
let assemblyFormat = "attr-dict";
}

def CastSignedOp : SimOp<"cast.signed", [Pure, SameOperandsAndResultType]> {
Comment thread
nanjo712 marked this conversation as resolved.
let summary = "Cast integer for signed interpretation";
let description = [{
Reinterprets an integer as signed while preserving the bit pattern.
Backends lower this to the native signed-cast mechanism.
}];

let arguments = (ins AnyInteger:$input);
let results = (outs AnyInteger:$result);

let assemblyFormat = "$input attr-dict `:` qualified(type($input))";
}

def FormatStringConcatOp : SimOp<"fmt.concat", [Pure]> {
let summary = "Concatenate format strings";
let description = [{
Expand Down Expand Up @@ -560,11 +583,13 @@ def PrintFormattedOp : SimOp<"print"> {
}];
let arguments = (ins
FormatStringType:$input,
Optional<I32>:$stream,
ClockType:$clock,
I1:$condition
I1:$condition,
DefaultValuedAttr<BoolAttr, "false">:$usePrintfCond
);
let hasCanonicalizeMethod = true;
let assemblyFormat = "$input `on` $clock `if` $condition attr-dict";
let assemblyFormat = "$input (`to` $stream^)? `on` $clock `if` $condition attr-dict";
}

def PrintFormattedProcOp : SimOp<"proc.print"> {
Expand All @@ -574,10 +599,39 @@ def PrintFormattedProcOp : SimOp<"proc.print"> {

This operation must be within a procedural region.
}];
let arguments = (ins FormatStringType:$input);
let arguments = (ins FormatStringType:$input, Optional<I32>:$stream);
let hasVerifier = true;
let hasCanonicalizeMethod = true;
let assemblyFormat = "$input attr-dict";
let assemblyFormat = "$input (`to` $stream^)? attr-dict";
}

def GetFileOp : SimOp<"get_file"> {
let summary = "Get a file descriptor for a formatted file name";
let description = [{
Looks up the descriptor for a file name in a process-global mapping.
If no descriptor exists, opens the file and records the new descriptor.
}];

let arguments = (ins StrAttr:$fileNameFormat,
Variadic<AnyType>:$fileNameOperands);
let results = (outs I32:$descriptor);
let assemblyFormat = [{
$fileNameFormat `(` $fileNameOperands `)` attr-dict
`:` functional-type($fileNameOperands, results)
}];
}

def FFlushOp : SimOp<"fflush"> {
let summary = "Flush a file stream on a given clock and condition";
let arguments = (ins I32:$stream, ClockType:$clock, I1:$condition);
let assemblyFormat = "$stream `on` $clock `if` $condition attr-dict";
}

def FFlushProcOp : SimOp<"proc.fflush"> {
let summary = "Flush a file stream within a procedural region";
let arguments = (ins I32:$stream);
let hasVerifier = 1;
let assemblyFormat = "$stream attr-dict";
}

//===----------------------------------------------------------------------===//
Expand Down
Loading
Loading