Revise top/commands test for C++ code gen

This commit is contained in:
Rob Bocchino 2025-12-04 15:12:04 -08:00
parent 7e672fa6b5
commit 5c29272470
4 changed files with 101 additions and 0 deletions

View File

@ -22,6 +22,12 @@ namespace M {
}
namespace M {
M::NoCommands c3(FW_OPTIONAL_NAME("c3"));
}
namespace M {
// ----------------------------------------------------------------------
@ -31,6 +37,7 @@ namespace M {
void initComponents(const TopologyState& state) {
M::c1.init(InstanceIds::M_c1);
M::c2.init(InstanceIds::M_c2);
M::c3.init(InstanceIds::M_c3);
}
void configComponents(const TopologyState& state) {
@ -40,6 +47,7 @@ namespace M {
void setBaseIds() {
M::c1.setIdBase(BaseIds::M_c1);
M::c2.setIdBase(BaseIds::M_c2);
M::c3.setIdBase(BaseIds::M_c3);
}
void connectComponents() {
@ -168,4 +176,40 @@ namespace M {
}
namespace M {
bool NoCommandsComponentBase::isConnected_cmdRegOut_OutputPort(FwIndexType portNum) const {
FW_ASSERT(
(0 <= portNum) && (portNum < NUM_CMDREGOUT_OUTPUT_PORTS),
static_cast<FwAssertArgType>(portNum),
static_cast<FwAssertArgType>(NUM_CMDREGOUT_OUTPUT_PORTS)
);
bool result = false;
const auto instance = this->getInstance();
switch (instance) {
default:
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
break;
}
return result;
}
bool NoCommandsComponentBase::isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const {
FW_ASSERT(
(0 <= portNum) && (portNum < NUM_CMDRESPONSEOUT_OUTPUT_PORTS),
static_cast<FwAssertArgType>(portNum),
static_cast<FwAssertArgType>(NUM_CMDRESPONSEOUT_OUTPUT_PORTS)
);
bool result = false;
const auto instance = this->getInstance();
switch (instance) {
default:
FW_ASSERT(0, static_cast<FwAssertArgType>(instance));
break;
}
return result;
}
}
#endif

View File

@ -9,6 +9,7 @@
#include "C.hpp"
#include "CommandsTopologyDefs.hpp"
#include "NoCommands.hpp"
// ----------------------------------------------------------------------
// Component instances
@ -28,6 +29,13 @@ namespace M {
}
namespace M {
//! c3
extern M::NoCommands c3;
}
namespace M {
// ----------------------------------------------------------------------
@ -38,6 +46,7 @@ namespace M {
enum {
M_c1 = 0x100,
M_c2 = 0x200,
M_c3 = 0x300,
};
}
@ -45,6 +54,7 @@ namespace M {
enum {
M_c1,
M_c2,
M_c3,
};
}

View File

@ -0,0 +1,34 @@
#ifndef M_NoCommands_HPP
#define M_NoCommands_HPP
#include "NoCommandsComponentAc.hpp"
namespace M {
class NoCommands :
public NoCommandsComponentBase
{
public:
NoCommands(const char* name) {
}
void init(U32 instanceId) {
}
void regCommandsSpecial() {
}
void NoCommands_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
}
};
}
#endif

View File

@ -12,6 +12,16 @@ module M {
}
passive component NoCommands {
command recv port cmdOut
command reg port cmdRegOut
command resp port cmdResponseOut
}
instance c1: C base id 0x100 {
phase Phases.regCommands """
@ -22,10 +32,13 @@ module M {
instance c2: C base id 0x200
instance c3: NoCommands base id 0x300
topology Commands {
instance c1
instance c2
instance c3
}