Skip to content

Commit 14abc13

Browse files
FpySequencer push FW_SERIALIZE_TRUE/FALSE for boolean ops (#4712)
* Make boolean binary value FW_SERIALIZE_TRUE/FALSE, add nextStatementIdx tlm to debug * Update docs * fmt
1 parent 0e3eb89 commit 14abc13

File tree

6 files changed

+159
-126
lines changed

6 files changed

+159
-126
lines changed

Svc/FpySequencer/FpySequencer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ void FpySequencer::tlmWrite_handler(FwIndexType portNum, //!< The port number
426426
this->tlmWrite_Debug_NextCmdOpcode(this->m_debug.nextCmdOpcode);
427427
this->tlmWrite_Debug_NextStatementOpcode(this->m_debug.nextStatementOpcode);
428428
this->tlmWrite_Debug_NextStatementReadSuccess(this->m_debug.nextStatementReadSuccess);
429+
this->tlmWrite_Debug_NextStatementIndex(this->m_debug.nextStatementIndex);
429430
this->tlmWrite_Debug_ReachedEndOfFile(this->m_debug.reachedEndOfFile);
430431
this->tlmWrite_Debug_StackSize(this->m_debug.stackSize);
431432
}
@@ -439,6 +440,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
439440
this->m_debug.nextStatementReadSuccess = false;
440441
this->m_debug.nextStatementOpcode = 0;
441442
this->m_debug.nextCmdOpcode = 0;
443+
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
442444
this->m_debug.stackSize = this->m_runtime.stack.size;
443445
return;
444446
}
@@ -452,6 +454,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
452454
this->m_debug.nextStatementReadSuccess = false;
453455
this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
454456
this->m_debug.nextCmdOpcode = 0;
457+
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
455458
this->m_debug.stackSize = this->m_runtime.stack.size;
456459
return;
457460
}
@@ -462,6 +465,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
462465
this->m_debug.nextStatementReadSuccess = true;
463466
this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
464467
this->m_debug.nextCmdOpcode = directiveUnion.constCmd.get_opCode();
468+
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
465469
this->m_debug.stackSize = this->m_runtime.stack.size;
466470
return;
467471
}
@@ -470,6 +474,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
470474
this->m_debug.nextStatementReadSuccess = true;
471475
this->m_debug.nextStatementOpcode = nextStmt.get_opCode();
472476
this->m_debug.nextCmdOpcode = 0;
477+
this->m_debug.nextStatementIndex = this->m_runtime.nextStatementIndex;
473478
this->m_debug.stackSize = this->m_runtime.stack.size;
474479
return;
475480
}
@@ -478,6 +483,7 @@ void FpySequencer::updateDebugTelemetryStruct() {
478483
this->m_debug.nextStatementReadSuccess = false;
479484
this->m_debug.nextStatementOpcode = 0;
480485
this->m_debug.nextCmdOpcode = 0;
486+
this->m_debug.nextStatementIndex = 0;
481487
this->m_debug.stackSize = 0;
482488
}
483489

Svc/FpySequencer/FpySequencer.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ class FpySequencer : public FpySequencerComponentBase {
679679
U8 nextStatementOpcode = 0;
680680
// if the next statement is a cmd directive, the opcode of that cmd
681681
FwOpcodeType nextCmdOpcode = 0;
682+
// the index of the next statement we're going to execute
683+
U32 nextStatementIndex = 0;
682684
// the size of the stack. store this separately from the real stack size
683685
// so we can avoid changing this during runtime, only modify it during
684686
// debug

Svc/FpySequencer/FpySequencerDirectives.cpp

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,18 @@ DirectiveError FpySequencer::op_ieq() {
463463
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
464464
return DirectiveError::STACK_UNDERFLOW;
465465
}
466-
this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>()));
466+
this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>())
467+
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
468+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
467469
return DirectiveError::NO_ERROR;
468470
}
469471
DirectiveError FpySequencer::op_ine() {
470472
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
471473
return DirectiveError::STACK_UNDERFLOW;
472474
}
473-
this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>()));
475+
this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>())
476+
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
477+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
474478
return DirectiveError::NO_ERROR;
475479
}
476480
DirectiveError FpySequencer::op_ult() {
@@ -479,7 +483,8 @@ DirectiveError FpySequencer::op_ult() {
479483
}
480484
U64 rhs = this->m_runtime.stack.pop<U64>();
481485
U64 lhs = this->m_runtime.stack.pop<U64>();
482-
this->m_runtime.stack.push(static_cast<U8>(lhs < rhs));
486+
this->m_runtime.stack.push(static_cast<U8>((lhs < rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
487+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
483488
return DirectiveError::NO_ERROR;
484489
}
485490
DirectiveError FpySequencer::op_ule() {
@@ -488,7 +493,8 @@ DirectiveError FpySequencer::op_ule() {
488493
}
489494
U64 rhs = this->m_runtime.stack.pop<U64>();
490495
U64 lhs = this->m_runtime.stack.pop<U64>();
491-
this->m_runtime.stack.push(static_cast<U8>(lhs <= rhs));
496+
this->m_runtime.stack.push(static_cast<U8>((lhs <= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
497+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
492498
return DirectiveError::NO_ERROR;
493499
}
494500
DirectiveError FpySequencer::op_ugt() {
@@ -497,7 +503,8 @@ DirectiveError FpySequencer::op_ugt() {
497503
}
498504
U64 rhs = this->m_runtime.stack.pop<U64>();
499505
U64 lhs = this->m_runtime.stack.pop<U64>();
500-
this->m_runtime.stack.push(static_cast<U8>(lhs > rhs));
506+
this->m_runtime.stack.push(static_cast<U8>((lhs > rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
507+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
501508
return DirectiveError::NO_ERROR;
502509
}
503510
DirectiveError FpySequencer::op_uge() {
@@ -506,7 +513,8 @@ DirectiveError FpySequencer::op_uge() {
506513
}
507514
U64 rhs = this->m_runtime.stack.pop<U64>();
508515
U64 lhs = this->m_runtime.stack.pop<U64>();
509-
this->m_runtime.stack.push(static_cast<U8>(lhs >= rhs));
516+
this->m_runtime.stack.push(static_cast<U8>((lhs >= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
517+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
510518
return DirectiveError::NO_ERROR;
511519
}
512520
DirectiveError FpySequencer::op_slt() {
@@ -515,7 +523,8 @@ DirectiveError FpySequencer::op_slt() {
515523
}
516524
I64 rhs = this->m_runtime.stack.pop<I64>();
517525
I64 lhs = this->m_runtime.stack.pop<I64>();
518-
this->m_runtime.stack.push(static_cast<U8>(lhs < rhs));
526+
this->m_runtime.stack.push(static_cast<U8>((lhs < rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
527+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
519528
return DirectiveError::NO_ERROR;
520529
}
521530
DirectiveError FpySequencer::op_sle() {
@@ -524,7 +533,8 @@ DirectiveError FpySequencer::op_sle() {
524533
}
525534
I64 rhs = this->m_runtime.stack.pop<I64>();
526535
I64 lhs = this->m_runtime.stack.pop<I64>();
527-
this->m_runtime.stack.push(static_cast<U8>(lhs <= rhs));
536+
this->m_runtime.stack.push(static_cast<U8>((lhs <= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
537+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
528538
return DirectiveError::NO_ERROR;
529539
}
530540
DirectiveError FpySequencer::op_sgt() {
@@ -533,7 +543,8 @@ DirectiveError FpySequencer::op_sgt() {
533543
}
534544
I64 rhs = this->m_runtime.stack.pop<I64>();
535545
I64 lhs = this->m_runtime.stack.pop<I64>();
536-
this->m_runtime.stack.push(static_cast<U8>(lhs > rhs));
546+
this->m_runtime.stack.push(static_cast<U8>((lhs > rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
547+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
537548
return DirectiveError::NO_ERROR;
538549
}
539550
DirectiveError FpySequencer::op_sge() {
@@ -542,7 +553,8 @@ DirectiveError FpySequencer::op_sge() {
542553
}
543554
I64 rhs = this->m_runtime.stack.pop<I64>();
544555
I64 lhs = this->m_runtime.stack.pop<I64>();
545-
this->m_runtime.stack.push(static_cast<U8>(lhs >= rhs));
556+
this->m_runtime.stack.push(static_cast<U8>((lhs >= rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
557+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
546558
return DirectiveError::NO_ERROR;
547559
}
548560
DirectiveError FpySequencer::op_feq() {
@@ -552,7 +564,8 @@ DirectiveError FpySequencer::op_feq() {
552564
F64 rhs = this->m_runtime.stack.pop<F64>();
553565
F64 lhs = this->m_runtime.stack.pop<F64>();
554566
// eq is true if they are equal and neither is nan
555-
this->m_runtime.stack.push(static_cast<U8>((lhs == rhs) ? 1 : 0));
567+
this->m_runtime.stack.push(static_cast<U8>((lhs == rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
568+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
556569
return DirectiveError::NO_ERROR;
557570
}
558571
DirectiveError FpySequencer::op_fne() {
@@ -562,7 +575,8 @@ DirectiveError FpySequencer::op_fne() {
562575
F64 rhs = this->m_runtime.stack.pop<F64>();
563576
F64 lhs = this->m_runtime.stack.pop<F64>();
564577
// ne is true if they are not equal or either is nan
565-
this->m_runtime.stack.push(static_cast<U8>((lhs != rhs) ? 1 : 0));
578+
this->m_runtime.stack.push(static_cast<U8>((lhs != rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
579+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
566580
return DirectiveError::NO_ERROR;
567581
}
568582
DirectiveError FpySequencer::op_flt() {
@@ -571,7 +585,8 @@ DirectiveError FpySequencer::op_flt() {
571585
}
572586
F64 rhs = this->m_runtime.stack.pop<F64>();
573587
F64 lhs = this->m_runtime.stack.pop<F64>();
574-
this->m_runtime.stack.push(static_cast<U8>(std::isless(lhs, rhs)));
588+
this->m_runtime.stack.push(static_cast<U8>(std::isless(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
589+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
575590
return DirectiveError::NO_ERROR;
576591
}
577592
DirectiveError FpySequencer::op_fle() {
@@ -580,7 +595,8 @@ DirectiveError FpySequencer::op_fle() {
580595
}
581596
F64 rhs = this->m_runtime.stack.pop<F64>();
582597
F64 lhs = this->m_runtime.stack.pop<F64>();
583-
this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs)));
598+
this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
599+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
584600
return DirectiveError::NO_ERROR;
585601
}
586602
DirectiveError FpySequencer::op_fgt() {
@@ -589,7 +605,8 @@ DirectiveError FpySequencer::op_fgt() {
589605
}
590606
F64 rhs = this->m_runtime.stack.pop<F64>();
591607
F64 lhs = this->m_runtime.stack.pop<F64>();
592-
this->m_runtime.stack.push(static_cast<U8>(std::isgreater(lhs, rhs)));
608+
this->m_runtime.stack.push(static_cast<U8>(std::isgreater(lhs, rhs) ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
609+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
593610
return DirectiveError::NO_ERROR;
594611
}
595612
DirectiveError FpySequencer::op_fge() {
@@ -598,14 +615,18 @@ DirectiveError FpySequencer::op_fge() {
598615
}
599616
F64 rhs = this->m_runtime.stack.pop<F64>();
600617
F64 lhs = this->m_runtime.stack.pop<F64>();
601-
this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)));
618+
this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)
619+
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
620+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
602621
return DirectiveError::NO_ERROR;
603622
}
604623
DirectiveError FpySequencer::op_not() {
605624
if (this->m_runtime.stack.size < sizeof(U8)) {
606625
return DirectiveError::STACK_UNDERFLOW;
607626
}
608-
this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<U8>() == 0));
627+
this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<U8>() == 0)
628+
? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
629+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE)));
609630
return DirectiveError::NO_ERROR;
610631
}
611632
DirectiveError FpySequencer::op_fpext() {
@@ -1212,12 +1233,12 @@ Signal FpySequencer::memCmp_directiveHandler(const FpySequencer_MemCmpDirective&
12121233
// after the byte arrays
12131234
this->m_runtime.stack.size -= directive.get_size() * 2;
12141235

1215-
// memcmp the two byte arrays, push 1 if they were equal, 0 otherwise
1236+
// memcmp the two byte arrays, push FW_SERIALIZE_TRUE_VALUE if they were equal, FW_SERIALIZE_FALSE_VALUE otherwise
12161237
if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
12171238
directive.get_size()) == 0) {
1218-
this->m_runtime.stack.push<U8>(1);
1239+
this->m_runtime.stack.push<U8>(static_cast<U8>(FW_SERIALIZE_TRUE_VALUE));
12191240
} else {
1220-
this->m_runtime.stack.push<U8>(0);
1241+
this->m_runtime.stack.push<U8>(static_cast<U8>(FW_SERIALIZE_FALSE_VALUE));
12211242
}
12221243
return Signal::stmtResponse_success;
12231244
}
@@ -1303,7 +1324,8 @@ Signal FpySequencer::getFlag_directiveHandler(const FpySequencer_GetFlagDirectiv
13031324
}
13041325

13051326
bool flagVal = this->m_runtime.flags[directive.get_flagIdx()];
1306-
this->m_runtime.stack.push<U8>(flagVal);
1327+
this->m_runtime.stack.push<U8>(flagVal ? static_cast<U8>(FW_SERIALIZE_TRUE_VALUE)
1328+
: static_cast<U8>(FW_SERIALIZE_FALSE_VALUE));
13071329
return Signal::stmtResponse_success;
13081330
}
13091331

Svc/FpySequencer/FpySequencerTelemetry.fppi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ telemetry Debug_ReachedEndOfFile: bool update on change
3838
telemetry Debug_NextStatementReadSuccess: bool update on change
3939
@ the opcode of the next statement to dispatch.
4040
telemetry Debug_NextStatementOpcode: U8 update on change
41+
@ the index of the next statement to be executed
42+
telemetry Debug_NextStatementIndex: U32 update on change
4143
@ if the next statement is a cmd directive, the opcode of that cmd
4244
telemetry Debug_NextCmdOpcode: FwOpcodeType update on change
4345
@ the size of the stack in bytes

0 commit comments

Comments
 (0)