// Automatically generated C++ file on Mon Apr 1 21:42:28 2024 // // To build with Digital Mars C++ Compiler: // // dmc -mn -WD sh_x1.cpp kernel32.lib union uData { bool b; char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; float f; double d; long long int i64; unsigned long long int ui64; char *str; unsigned char *bytes; }; // int DllMain() must exist and return 1 for a process to load the .DLL // See https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain for more information. int __stdcall DllMain(void *module, unsigned int reason, void *reserved) { return 1; } // #undef pin names lest they collide with names in any header file(s) you might include. #undef EN #undef IN #undef CLK #undef OUT bool bLastClk=0; double dLastOut=0; extern "C" __declspec(dllexport) void sh_x1(void **opaque, double t, union uData *data) { bool EN = data[0].b; // input double IN = data[1].d; // input bool CLK = data[2].b; // input double &OUT = data[3].d; // output // Implement module evaluation code here: if (EN==1) { if (CLK==1 && bLastClk==0) { dLastOut=IN; } OUT = dLastOut; bLastClk=CLK; } else { dLastOut=0; OUT=0; } }