Skip to content

Commit 1c87278

Browse files
Clean up FpySequencer directives (#4395)
* Remove assert and float floor div * Rename add/sub/mul --------- Co-authored-by: M Starch <LeStarch@googlemail.com>
1 parent a587677 commit 1c87278

10 files changed

+174
-326
lines changed

Svc/FpySequencer/FpySequencer.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class FpySequencer : public FpySequencerComponentBase {
6969
FpySequencer_GetFlagDirective getFlag;
7070
FpySequencer_GetFieldDirective getField;
7171
FpySequencer_PeekDirective peek;
72-
FpySequencer_AssertDirective assert;
7372
FpySequencer_StoreDirective store;
7473

7574
DirectiveUnion() {}
@@ -551,9 +550,6 @@ class FpySequencer : public FpySequencerComponentBase {
551550
//! Internal interface handler for directive_peek
552551
void directive_peek_internalInterfaceHandler(const Svc::FpySequencer_PeekDirective& directive) override;
553552

554-
//! Internal interface handler for directive_assert
555-
void directive_assert_internalInterfaceHandler(const Svc::FpySequencer_AssertDirective& directive) override;
556-
557553
//! Internal interface handler for directive_store
558554
void directive_store_internalInterfaceHandler(const Svc::FpySequencer_StoreDirective& directive) override;
559555

@@ -790,9 +786,9 @@ class FpySequencer : public FpySequencerComponentBase {
790786
DirectiveError op_fptosi();
791787
DirectiveError op_sitofp();
792788
DirectiveError op_uitofp();
793-
DirectiveError op_iadd();
794-
DirectiveError op_isub();
795-
DirectiveError op_imul();
789+
DirectiveError op_add();
790+
DirectiveError op_sub();
791+
DirectiveError op_mul();
796792
DirectiveError op_udiv();
797793
DirectiveError op_sdiv();
798794
DirectiveError op_umod();
@@ -829,7 +825,6 @@ class FpySequencer : public FpySequencerComponentBase {
829825
Signal getFlag_directiveHandler(const FpySequencer_GetFlagDirective& directive, DirectiveError& error);
830826
Signal getField_directiveHandler(const FpySequencer_GetFieldDirective& directive, DirectiveError& error);
831827
Signal peek_directiveHandler(const FpySequencer_PeekDirective& directive, DirectiveError& error);
832-
Signal assert_directiveHandler(const FpySequencer_AssertDirective& directive, DirectiveError& error);
833828
Signal store_directiveHandler(const FpySequencer_StoreDirective& directive, DirectiveError& error);
834829
};
835830

Svc/FpySequencer/FpySequencerDirectives.cpp

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,6 @@ void FpySequencer::directive_peek_internalInterfaceHandler(const Svc::FpySequenc
235235
handleDirectiveErrorCode(Fpy::DirectiveId::PEEK, error);
236236
}
237237

238-
//! Internal interface handler for directive_assert
239-
void FpySequencer::directive_assert_internalInterfaceHandler(const Svc::FpySequencer_AssertDirective& directive) {
240-
DirectiveError error = DirectiveError::NO_ERROR;
241-
this->sendSignal(this->assert_directiveHandler(directive, error));
242-
handleDirectiveErrorCode(Fpy::DirectiveId::ASSERT, error);
243-
}
244-
245238
//! Internal interface handler for directive_store
246239
void FpySequencer::directive_store_internalInterfaceHandler(const Svc::FpySequencer_StoreDirective& directive) {
247240
DirectiveError error = DirectiveError::NO_ERROR;
@@ -622,7 +615,7 @@ DirectiveError FpySequencer::op_uitofp() {
622615
this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<U64>()));
623616
return DirectiveError::NO_ERROR;
624617
}
625-
DirectiveError FpySequencer::op_iadd() {
618+
DirectiveError FpySequencer::op_add() {
626619
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
627620
return DirectiveError::STACK_ACCESS_OUT_OF_BOUNDS;
628621
}
@@ -642,7 +635,7 @@ DirectiveError FpySequencer::op_iadd() {
642635
this->m_runtime.stack.push(static_cast<I64>(lhs + rhs));
643636
return DirectiveError::NO_ERROR;
644637
}
645-
DirectiveError FpySequencer::op_isub() {
638+
DirectiveError FpySequencer::op_sub() {
646639
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
647640
return DirectiveError::STACK_ACCESS_OUT_OF_BOUNDS;
648641
}
@@ -664,7 +657,7 @@ DirectiveError FpySequencer::op_isub() {
664657
this->m_runtime.stack.push(static_cast<I64>(lhs - rhs));
665658
return DirectiveError::NO_ERROR;
666659
}
667-
DirectiveError FpySequencer::op_imul() {
660+
DirectiveError FpySequencer::op_mul() {
668661
if (this->m_runtime.stack.size < sizeof(I64) * 2) {
669662
return DirectiveError::STACK_ACCESS_OUT_OF_BOUNDS;
670663
}
@@ -789,15 +782,6 @@ DirectiveError FpySequencer::op_fdiv() {
789782
this->m_runtime.stack.push(static_cast<F64>(lhs / rhs));
790783
return DirectiveError::NO_ERROR;
791784
}
792-
DirectiveError FpySequencer::op_float_floor_div() {
793-
if (this->m_runtime.stack.size < sizeof(F64) * 2) {
794-
return DirectiveError::STACK_ACCESS_OUT_OF_BOUNDS;
795-
}
796-
F64 rhs = this->m_runtime.stack.pop<F64>();
797-
F64 lhs = this->m_runtime.stack.pop<F64>();
798-
this->m_runtime.stack.push(static_cast<F64>(floor(lhs / rhs)));
799-
return DirectiveError::NO_ERROR;
800-
}
801785
DirectiveError FpySequencer::op_fpow() {
802786
if (this->m_runtime.stack.size < sizeof(F64) * 2) {
803787
return DirectiveError::STACK_ACCESS_OUT_OF_BOUNDS;
@@ -983,14 +967,14 @@ Signal FpySequencer::stackOp_directiveHandler(const FpySequencer_StackOpDirectiv
983967
case Fpy::DirectiveId::UITOFP:
984968
error = this->op_uitofp();
985969
break;
986-
case Fpy::DirectiveId::IADD:
987-
error = this->op_iadd();
970+
case Fpy::DirectiveId::ADD:
971+
error = this->op_add();
988972
break;
989-
case Fpy::DirectiveId::ISUB:
990-
error = this->op_isub();
973+
case Fpy::DirectiveId::SUB:
974+
error = this->op_sub();
991975
break;
992-
case Fpy::DirectiveId::IMUL:
993-
error = this->op_imul();
976+
case Fpy::DirectiveId::MUL:
977+
error = this->op_mul();
994978
break;
995979
case Fpy::DirectiveId::UDIV:
996980
error = this->op_udiv();
@@ -1016,9 +1000,6 @@ Signal FpySequencer::stackOp_directiveHandler(const FpySequencer_StackOpDirectiv
10161000
case Fpy::DirectiveId::FDIV:
10171001
error = this->op_fdiv();
10181002
break;
1019-
case Fpy::DirectiveId::FLOAT_FLOOR_DIV:
1020-
error = this->op_float_floor_div();
1021-
break;
10221003
case Fpy::DirectiveId::FPOW:
10231004
error = this->op_fpow();
10241005
break;
@@ -1321,26 +1302,6 @@ Signal FpySequencer::peek_directiveHandler(const FpySequencer_PeekDirective& dir
13211302
return Signal::stmtResponse_success;
13221303
}
13231304

1324-
Signal FpySequencer::assert_directiveHandler(const FpySequencer_AssertDirective& directive, DirectiveError& error) {
1325-
if (this->m_runtime.stack.size < sizeof(U8) * 2) {
1326-
error = DirectiveError::STACK_ACCESS_OUT_OF_BOUNDS;
1327-
return Signal::stmtResponse_failure;
1328-
}
1329-
U8 errorCode = this->m_runtime.stack.pop<U8>();
1330-
U8 condition = this->m_runtime.stack.pop<U8>();
1331-
1332-
if (condition != 0) {
1333-
// proceed to next instruction
1334-
return Signal::stmtResponse_success;
1335-
}
1336-
1337-
// otherwise, kill the sequence here
1338-
// raise the user defined error code as an event
1339-
this->log_WARNING_HI_SequenceAsserted(this->m_sequenceFilePath, errorCode);
1340-
error = DirectiveError::ASSERTION_FAILURE;
1341-
return Signal::stmtResponse_failure;
1342-
}
1343-
13441305
Signal FpySequencer::store_directiveHandler(const FpySequencer_StoreDirective& directive, DirectiveError& error) {
13451306
if (this->m_runtime.stack.size < directive.get_size() + sizeof(Fpy::StackSizeType)) {
13461307
// not enough bytes to pop the value and the stack offset

Svc/FpySequencer/FpySequencerDirectives.fppi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,6 @@ struct PeekDirective {
146146
_empty: U8
147147
}
148148

149-
@ asserts that a condition is true, raise an error code if not
150-
struct AssertDirective {
151-
# pops two U8s off the stack
152-
# condition and error code
153-
_empty: U8
154-
}
155-
156149
@ stores bytes from the top of the stack into a memory location, determined by the stack
157150
struct StoreDirective {
158151
# pops an Fpy.StackSizeType offset off of stack
@@ -206,6 +199,4 @@ internal port directive_getField(directive: GetFieldDirective) priority 6 assert
206199

207200
internal port directive_peek(directive: PeekDirective) priority 6 assert
208201

209-
internal port directive_assert(directive: AssertDirective) priority 6 assert
210-
211202
internal port directive_store(directive: StoreDirective) priority 6 assert

Svc/FpySequencer/FpySequencerEvents.fppi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,6 @@ event SequenceExitedWithError(
103103
severity warning high \
104104
format "Sequence {} exited with error code {}"
105105

106-
event SequenceAsserted(
107-
filePath: string
108-
errorCode: U8
109-
) \
110-
severity warning high \
111-
format "Sequence {} failed an assertion with error code {}"
112-
113106
event UnknownSequencerDirective(
114107
$opcode: U8
115108
stmtIdx: U32

Svc/FpySequencer/FpySequencerRunState.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc
213213
case Fpy::DirectiveId::FPTOUI:
214214
case Fpy::DirectiveId::SITOFP:
215215
case Fpy::DirectiveId::UITOFP:
216-
case Fpy::DirectiveId::IADD:
217-
case Fpy::DirectiveId::ISUB:
218-
case Fpy::DirectiveId::IMUL:
216+
case Fpy::DirectiveId::ADD:
217+
case Fpy::DirectiveId::SUB:
218+
case Fpy::DirectiveId::MUL:
219219
case Fpy::DirectiveId::UDIV:
220220
case Fpy::DirectiveId::SDIV:
221221
case Fpy::DirectiveId::UMOD:
@@ -224,7 +224,6 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc
224224
case Fpy::DirectiveId::FSUB:
225225
case Fpy::DirectiveId::FMUL:
226226
case Fpy::DirectiveId::FDIV:
227-
case Fpy::DirectiveId::FLOAT_FLOOR_DIV:
228227
case Fpy::DirectiveId::FPOW:
229228
case Fpy::DirectiveId::FLOG:
230229
case Fpy::DirectiveId::FMOD:
@@ -399,16 +398,6 @@ Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, Direc
399398
}
400399
break;
401400
}
402-
case Fpy::DirectiveId::ASSERT: {
403-
new (&deserializedDirective.assert) FpySequencer_AssertDirective();
404-
if (argBuf.getDeserializeSizeLeft() != 0) {
405-
this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
406-
Fw::SerializeStatus::FW_DESERIALIZE_SIZE_MISMATCH,
407-
argBuf.getDeserializeSizeLeft(), argBuf.getSize());
408-
return Fw::Success::FAILURE;
409-
}
410-
break;
411-
}
412401
case Fpy::DirectiveId::STORE: {
413402
new (&deserializedDirective.store) FpySequencer_StoreDirective();
414403
status = argBuf.deserializeTo(deserializedDirective.store);
@@ -499,9 +488,9 @@ void FpySequencer::dispatchDirective(const DirectiveUnion& directive, const Fpy:
499488
case Fpy::DirectiveId::FPTOUI:
500489
case Fpy::DirectiveId::SITOFP:
501490
case Fpy::DirectiveId::UITOFP:
502-
case Fpy::DirectiveId::IADD:
503-
case Fpy::DirectiveId::ISUB:
504-
case Fpy::DirectiveId::IMUL:
491+
case Fpy::DirectiveId::ADD:
492+
case Fpy::DirectiveId::SUB:
493+
case Fpy::DirectiveId::MUL:
505494
case Fpy::DirectiveId::UDIV:
506495
case Fpy::DirectiveId::SDIV:
507496
case Fpy::DirectiveId::UMOD:
@@ -510,7 +499,6 @@ void FpySequencer::dispatchDirective(const DirectiveUnion& directive, const Fpy:
510499
case Fpy::DirectiveId::FSUB:
511500
case Fpy::DirectiveId::FMUL:
512501
case Fpy::DirectiveId::FDIV:
513-
case Fpy::DirectiveId::FLOAT_FLOOR_DIV:
514502
case Fpy::DirectiveId::FPOW:
515503
case Fpy::DirectiveId::FLOG:
516504
case Fpy::DirectiveId::FMOD:
@@ -578,10 +566,6 @@ void FpySequencer::dispatchDirective(const DirectiveUnion& directive, const Fpy:
578566
this->directive_peek_internalInterfaceInvoke(directive.peek);
579567
return;
580568
}
581-
case Fpy::DirectiveId::ASSERT: {
582-
this->directive_assert_internalInterfaceInvoke(directive.assert);
583-
return;
584-
}
585569
case Fpy::DirectiveId::STORE: {
586570
this->directive_store_internalInterfaceInvoke(directive.store);
587571
return;

0 commit comments

Comments
 (0)