Skip to content
Merged
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
6 changes: 6 additions & 0 deletions Svc/FpySequencer/FpySequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ void FpySequencer::tlmWrite_handler(FwIndexType portNum, //!< The port number
this->tlmWrite_Debug_NextCmdOpcode(this->m_debug.nextCmdOpcode);
this->tlmWrite_Debug_NextStatementOpcode(this->m_debug.nextStatementOpcode);
this->tlmWrite_Debug_NextStatementReadSuccess(this->m_debug.nextStatementReadSuccess);
this->tlmWrite_Debug_NextStatementIndex(this->m_debug.nextStatementIndex);
this->tlmWrite_Debug_ReachedEndOfFile(this->m_debug.reachedEndOfFile);
this->tlmWrite_Debug_StackSize(this->m_debug.stackSize);
}
Expand All @@ -439,6 +440,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
this->m_debug.nextStatementReadSuccess = false;
this->m_debug.nextStatementOpcode = 0;
this->m_debug.nextCmdOpcode = 0;
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
this->m_debug.stackSize = this->m_runtime.stack.size;
return;
}
Expand All @@ -452,6 +454,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
this->m_debug.nextStatementReadSuccess = false;
this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
this->m_debug.nextCmdOpcode = 0;
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
this->m_debug.stackSize = this->m_runtime.stack.size;
return;
}
Expand All @@ -462,6 +465,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
this->m_debug.nextStatementReadSuccess = true;
this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
this->m_debug.nextCmdOpcode = directiveUnion.constCmd.get_opCode();
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
this->m_debug.stackSize = this->m_runtime.stack.size;
return;
}
Expand All @@ -470,6 +474,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
this->m_debug.nextStatementReadSuccess = true;
this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
this->m_debug.nextCmdOpcode = 0;
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
this->m_debug.stackSize = this->m_runtime.stack.size;
return;
}
Expand All @@ -478,6 +483,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
this->m_debug.nextStatementReadSuccess = false;
this->m_debug.nextStatementOpcode = 0;
this->m_debug.nextCmdOpcode = 0;
this->m_debug.nextStatementIndex = 0;
this->m_debug.stackSize = 0;
}

Expand Down
2 changes: 2 additions & 0 deletions Svc/FpySequencer/FpySequencer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ class FpySequencer : public FpySequencerComponentBase {
U8 nextStatementOpcode = 0;
// if the next statement is a cmd directive, the opcode of that cmd
FwOpcodeType nextCmdOpcode = 0;
// the index of the next statement we're going to execute
U32 nextStatementIndex = 0;
// the size of the stack. store this separately from the real stack size
// so we can avoid changing this during runtime, only modify it during
// debug
Expand Down
64 changes: 43 additions & 21 deletions Svc/FpySequencer/FpySequencerDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,18 @@
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
return DirectiveError::STACK_UNDERFLOW;
}
this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>()));
this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>())
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_ine() {
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
return DirectiveError::STACK_UNDERFLOW;
}
this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>()));
this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>())
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_ult() {
Expand All @@ -479,7 +483,8 @@
}
U64 rhs = this->m_runtime.stack.pop<U64>();
U64 lhs = this->m_runtime.stack.pop<U64>();
this->m_runtime.stack.push(static_cast<U8>(lhs < rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs < rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_ule() {
Expand All @@ -488,7 +493,8 @@
}
U64 rhs = this->m_runtime.stack.pop<U64>();
U64 lhs = this->m_runtime.stack.pop<U64>();
this->m_runtime.stack.push(static_cast<U8>(lhs <= rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs <= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_ugt() {
Expand All @@ -497,7 +503,8 @@
}
U64 rhs = this->m_runtime.stack.pop<U64>();
U64 lhs = this->m_runtime.stack.pop<U64>();
this->m_runtime.stack.push(static_cast<U8>(lhs > rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs > rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_uge() {
Expand All @@ -506,7 +513,8 @@
}
U64 rhs = this->m_runtime.stack.pop<U64>();
U64 lhs = this->m_runtime.stack.pop<U64>();
this->m_runtime.stack.push(static_cast<U8>(lhs >= rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs >= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_slt() {
Expand All @@ -515,7 +523,8 @@
}
I64 rhs = this->m_runtime.stack.pop<I64>();
I64 lhs = this->m_runtime.stack.pop<I64>();
this->m_runtime.stack.push(static_cast<U8>(lhs < rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs < rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_sle() {
Expand All @@ -524,7 +533,8 @@
}
I64 rhs = this->m_runtime.stack.pop<I64>();
I64 lhs = this->m_runtime.stack.pop<I64>();
this->m_runtime.stack.push(static_cast<U8>(lhs <= rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs <= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_sgt() {
Expand All @@ -533,7 +543,8 @@
}
I64 rhs = this->m_runtime.stack.pop<I64>();
I64 lhs = this->m_runtime.stack.pop<I64>();
this->m_runtime.stack.push(static_cast<U8>(lhs > rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs > rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_sge() {
Expand All @@ -542,7 +553,8 @@
}
I64 rhs = this->m_runtime.stack.pop<I64>();
I64 lhs = this->m_runtime.stack.pop<I64>();
this->m_runtime.stack.push(static_cast<U8>(lhs >= rhs));
this->m_runtime.stack.push(static_cast<U8>((lhs >= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_feq() {
Expand All @@ -552,7 +564,8 @@
F64 rhs = this->m_runtime.stack.pop<F64>();
F64 lhs = this->m_runtime.stack.pop<F64>();
// eq is true if they are equal and neither is nan
this->m_runtime.stack.push(static_cast<U8>((lhs == rhs) ? 1 : 0));
this->m_runtime.stack.push(static_cast<U8>((lhs == rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)

Check notice

Code scanning / CodeQL

Equality test on floating-point values Note

Equality checks on floating point values can yield unexpected results.
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_fne() {
Expand All @@ -562,7 +575,8 @@
F64 rhs = this->m_runtime.stack.pop<F64>();
F64 lhs = this->m_runtime.stack.pop<F64>();
// ne is true if they are not equal or either is nan
this->m_runtime.stack.push(static_cast<U8>((lhs != rhs) ? 1 : 0));
this->m_runtime.stack.push(static_cast<U8>((lhs != rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)

Check notice

Code scanning / CodeQL

Equality test on floating-point values Note

Equality checks on floating point values can yield unexpected results.
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_flt() {
Expand All @@ -571,7 +585,8 @@
}
F64 rhs = this->m_runtime.stack.pop<F64>();
F64 lhs = this->m_runtime.stack.pop<F64>();
this->m_runtime.stack.push(static_cast<U8>(std::isless(lhs, rhs)));
this->m_runtime.stack.push(static_cast<U8>(std::isless(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_fle() {
Expand All @@ -580,7 +595,8 @@
}
F64 rhs = this->m_runtime.stack.pop<F64>();
F64 lhs = this->m_runtime.stack.pop<F64>();
this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs)));
this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_fgt() {
Expand All @@ -589,7 +605,8 @@
}
F64 rhs = this->m_runtime.stack.pop<F64>();
F64 lhs = this->m_runtime.stack.pop<F64>();
this->m_runtime.stack.push(static_cast<U8>(std::isgreater(lhs, rhs)));
this->m_runtime.stack.push(static_cast<U8>(std::isgreater(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_fge() {
Expand All @@ -598,14 +615,18 @@
}
F64 rhs = this->m_runtime.stack.pop<F64>();
F64 lhs = this->m_runtime.stack.pop<F64>();
this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)));
this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_not() {
if (this->m_runtime.stack.size < sizeof(U8)) {
return DirectiveError::STACK_UNDERFLOW;
}
this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<U8>() == 0));
this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<U8>() == 0)
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
return DirectiveError::NO_ERROR;
}
DirectiveError FpySequencer::op_fpext() {
Expand Down Expand Up @@ -1212,12 +1233,12 @@
// after the byte arrays
this->m_runtime.stack.size -= directive.get_size() * 2;

// memcmp the two byte arrays, push 1 if they were equal, 0 otherwise
// memcmp the two byte arrays, push FW_SERIALIZE_TRUE_VALUE if they were equal, FW_SERIALIZE_FALSE_VALUE otherwise
if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
directive.get_size()) == 0) {
this->m_runtime.stack.push<U8>(1);
this->m_runtime.stack.push<U8>(static_cast<U8>(FW_SERIALIZE_TRUE_VALUE));
} else {
this->m_runtime.stack.push<U8>(0);
this->m_runtime.stack.push<U8>(static_cast<U8>(FW_SERIALIZE_FALSE_VALUE));
}
return Signal::stmtResponse_success;
}
Expand Down Expand Up @@ -1303,7 +1324,8 @@
}

bool flagVal = this->m_runtime.flags[directive.get_flagIdx()];
this->m_runtime.stack.push<U8>(flagVal);
this->m_runtime.stack.push<U8>(flagVal ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE));
return Signal::stmtResponse_success;
}

Expand Down
2 changes: 2 additions & 0 deletions Svc/FpySequencer/FpySequencerTelemetry.fppi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ telemetry Debug_ReachedEndOfFile: bool update on change
telemetry Debug_NextStatementReadSuccess: bool update on change
@ the opcode of the next statement to dispatch.
telemetry Debug_NextStatementOpcode: U8 update on change
@ the index of the next statement to be executed
telemetry Debug_NextStatementIndex: U32 update on change
@ if the next statement is a cmd directive, the opcode of that cmd
telemetry Debug_NextCmdOpcode: FwOpcodeType update on change
@ the size of the stack in bytes
Expand Down
Loading
Loading