10#include <xaiefal/rsc/xaiefal-rsc-base.hpp>
11#include <xaiefal/rsc/xaiefal-rscmgr.hpp>
26 if (ENum > 4 || ENum < 2) {
27 throw std::invalid_argument(
"Combo event failed, invalid input events number");
30 State.Initialized = 1;
48 AieRC
setEvents(
const std::vector<XAie_Events> &vInEvents,
49 const std::vector<XAie_EventComboOps> &vInOps) {
51 if ((vInEvents.size() !=
vEvents.size()) || (vInOps.size() > 3) ||
52 (vInEvents.size() <= 2 && vInOps.size() > 1) ||
53 (vInEvents.size() > 2 && vInOps.size() < 2)) {
55 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
56 " Mod=" <<
Mod <<
" invalid number of input events and ops." << std::endl;
57 RC = XAIE_INVALID_ARGS;
59 for (
int i = 0; i < (int)vInEvents.size(); i++) {
62 RC = XAie_EventLogicalToPhysicalConv(
dev(),
Loc,
63 Mod, vInEvents[i], &HwEvent);
66 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
67 " Mod=" <<
Mod <<
" invalid E=" << vInEvents[i] <<
68 " (" << XAie_EventGetString(vInEvents[i]) <<
")" << std::endl;
76 for (
int i = 0; i < (int)vInOps.size(); i++) {
77 vOps.push_back(vInOps[i]);
94 AieRC
getEvents(std::vector<XAie_Events> &vOutEvents) {
98 if (
State.Reserved == 0) {
100 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
101 " Mod=" <<
Mod <<
" resource is not reserved." << std::endl;
104 XAie_Events BaseEvent;
105 XAie_EventGetComboEventBase(
dev(),
Loc,
Mod, &BaseEvent);
107 if (
vOps.size() == 1) {
108 vOutEvents.push_back((XAie_Events)((uint32_t)BaseEvent +
vRscs[0].RscId));
110 for (uint32_t i = 0; i < (uint32_t)
vOps.size(); i++) {
111 vOutEvents.push_back((XAie_Events)((uint32_t)BaseEvent + i));
120 std::vector<XAie_EventComboOps> &vOutOps) {
123 if (
State.Configured == 1) {
125 for (
int i = 0; i < (int)
vEvents.size(); i++) {
126 vOutEvents.push_back(
vEvents[i]);
129 for (
int i = 0; i < (int)
vOps.size(); i++) {
130 vOutOps.push_back(
vOps[i]);
135 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
136 " Mod=" <<
Mod <<
" no input events specified." << std::endl;
143 std::vector<XAie_EventComboOps>
vOps;
153 for (uint32_t i = 0; i <
vEvents.size(); i++) {
154 vRscs.push_back(Rsc);
157 RC =
AieHd->rscMgr()->request(*
this);
160 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
")" <<
161 " Expect Mod= " <<
Mod <<
" resource not available.\n";
164 if (
vRscs.size() <= 2) {
169 if (
vRscs[0].RscId < 2) {
183 RC =
AieHd->rscMgr()->release(*
this);
189 XAie_EventComboId StartCId;
191 for (uint32_t i = 0 ; i <
vEvents.size(); i += 2) {
192 XAie_EventComboId ComboId;
194 if (
vRscs[i].RscId == 0) {
195 ComboId = XAIE_EVENT_COMBO0;
197 ComboId = XAIE_EVENT_COMBO1;
202 RC = XAie_EventComboConfig(
dev(),
Loc,
Mod,
206 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
207 " Mod=" <<
Mod <<
" failed to config combo " << ComboId << std::endl;
208 for (XAie_EventComboId tId = StartCId;
210 tId = (XAie_EventComboId)((int)tId + i)) {
217 if (RC == XAIE_OK &&
vOps.size() == 3) {
218 RC = XAie_EventComboConfig(
dev(),
Loc,
Mod,
222 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
223 " Mod=" <<
Mod <<
" failed to config combo " << XAIE_EVENT_COMBO2 << std::endl;
229 XAie_EventComboId ComboId;
231 for (
int i = 0; i < (int)
vOps.size(); i++) {
233 if (
vRscs[i].RscId == 0) {
234 ComboId = XAIE_EVENT_COMBO0;
236 ComboId = XAIE_EVENT_COMBO1;
238 XAie_EventComboReset(
dev(),
Loc,
Mod, ComboId);
239 ComboId = (XAie_EventComboId)((uint32_t)ComboId + 1);
244 void _getReservedRscs(std::vector<XAieUserRsc> &vOutRscs)
const {
245 vOutRscs.insert(vOutRscs.end(),
vRscs.begin(),
vRscs.end());
259 State.Initialized = 1;
260 State.Configured = 1;
276 if (
State.Reserved == 0) {
278 static_cast<uint32_t
>(
Loc.Col) <<
"," <<
static_cast<uint32_t
>(
Loc.Row) <<
")" <<
279 " resource not resesrved." << std::endl;
280 RC = XAIE_INVALID_ARGS;
282 Event = _getEventFromId(
vRscs[0].RscId);
295 vRscs.push_back(Rsc);
296 RC =
AieHd->rscMgr()->request(*
this);
299 (uint32_t)
Loc.Col <<
"," << (uint32_t)
Loc.Row <<
")" <<
300 " Expect Mod= " <<
Mod <<
" resource not available.\n";
310 RC =
AieHd->rscMgr()->release(*
this);
331 uint32_t _getIdFromEvent(XAie_Events Event)
const {
332 XAie_Events UserEventStart;
333 XAie_EventGetUserEventBase(
AieHd->dev(),
Loc,
Mod, &UserEventStart);
335 return static_cast<uint32_t
>(Event - UserEventStart);
344 XAie_Events _getEventFromId(uint32_t RscId)
const {
345 XAie_Events UserEventStart;
346 XAie_EventGetUserEventBase(
AieHd->dev(),
Loc,
Mod, &UserEventStart);
348 return static_cast<XAie_Events
>(
static_cast<uint32_t
>(UserEventStart) + RscId);
static std::ostream & log(LogLevel Lvl=LogLevel::FAL_MAX)
Definition xaiefal-log.hpp:50
AieRC setEvents(const std::vector< XAie_Events > &vInEvents, const std::vector< XAie_EventComboOps > &vInOps)
Definition xaiefal-events.hpp:48
std::vector< XAie_Events > vEvents
Definition xaiefal-events.hpp:142
std::vector< XAie_EventComboOps > vOps
Definition xaiefal-events.hpp:143
XAieComboEvent(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc, XAie_ModuleType Mod, uint32_t ENum=2)
Definition xaiefal-events.hpp:23
AieRC getEvents(std::vector< XAie_Events > &vOutEvents)
Definition xaiefal-events.hpp:94
XAieComboEvent(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod, uint32_t ENum=2)
Definition xaiefal-events.hpp:32
AieRC getInputEvents(std::vector< XAie_Events > &vOutEvents, std::vector< XAie_EventComboOps > &vOutOps)
Definition xaiefal-events.hpp:119
AI engine device class. It defines AI engine device operations.
Definition xaiefal-base.hpp:259
XAieRscType Type
Definition xaiefal-rsc-base.hpp:399
std::vector< XAieUserRsc > vRscs
Definition xaiefal-rsc-base.hpp:403
XAieRscState State
Definition xaiefal-rsc-base.hpp:398
XAie_DevInst * dev()
Definition xaiefal-rsc-base.hpp:373
uint32_t preferredId
Definition xaiefal-rsc-base.hpp:401
uint32_t reservedId
Definition xaiefal-rsc-base.hpp:402
std::shared_ptr< XAieDevHandle > AieHd
Definition xaiefal-rsc-base.hpp:400
XAieSingleTileRsc()=delete
XAie_LocType Loc
Definition xaiefal-rsc-base.hpp:594
XAie_ModuleType Mod
Definition xaiefal-rsc-base.hpp:595
AieRC getEvent(XAie_Events &Event) const
Definition xaiefal-events.hpp:273
XAieUserEvent(XAieDev &Dev, XAie_LocType Loc, XAie_ModuleType Mod)
Definition xaiefal-events.hpp:262
XAieUserEvent(std::shared_ptr< XAieDevHandle > DevHd, XAie_LocType Loc, XAie_ModuleType Mod)
Definition xaiefal-events.hpp:256
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition license.txt:197
Definition xaiefal-base.hpp:23
@ XAIE_COMBOEVENT
Definition xaiefal-rsc-group.hpp:34
@ XAIE_USEREVENT
Definition xaiefal-rsc-group.hpp:29
@ FAL_ERROR
Definition xaiefal-log.hpp:14
@ FAL_WARN
Definition xaiefal-log.hpp:13
Data needed to make a resource request.
Definition xaiefal-rsc-base.hpp:27
uint32_t RscId
Definition xaiefal-rsc-base.hpp:41
XAieRscType RscType
Definition xaiefal-rsc-base.hpp:37
XAie_LocType Loc
Definition xaiefal-rsc-base.hpp:29
XAie_ModuleType Mod
Definition xaiefal-rsc-base.hpp:33