Dose impulse supports pointer to functions??
I tested it but when I try to compile it for hardware the program terminates??
Pointer To functions????
Started by MEMS, Sep 04 2008 02:26 AM
3 replies to this topic
#1
Posted 04 September 2008 - 02:26 AM
#2
Posted 04 September 2008 - 07:56 AM
Function pointers are not supported in hardware processes.
Can you post the output from the compiler so we can see how it failed, and fix it to fail more gracefully?
Thanks,
Ralph
Can you post the output from the compiler so we can see how it failed, and fix it to fail more gracefully?
Thanks,
Ralph
Ralph Bodenner
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#3
Posted 04 September 2008 - 11:19 PM
this is the file and error::
/////////////////////
I created a simple project from template:
The HW file is:
///////////////////////////////////////////////////////////////////////////////
//
// Generated by Impulse CoDeveloper
// Impulse C is Copyright© 2003-2007 Impulse Accelerated Technologies, Inc.
//
// pFunctions_hw.c: includes the hardware process and configuration
// function.
//
// See additional comments in pFunctions.h.
//
#include "co.h"
#include "cosim_log.h"
#include "pFunctions.h"
// Software process declarations (see pFunctions_sw.c)
extern void Producer(co_stream inTest);
extern void Consumer(co_stream outTest);
void (*pFunc) (int); // pointer to function
void TestFunction (int x) // a function
{
x=x+1;
}
//
// This is the hardware process.
//
void Test(co_stream inTest, co_stream outTest)
{
co_int32 nSample;
IF_SIM(int samplesread; int sampleswritten;)
IF_SIM(cosim_logwindow log;)
IF_SIM(log = cosim_logwindow_create("Test")
do { // Hardware processes run forever
IF_SIM(samplesread=0; sampleswritten=0;)
co_stream_open(inTest, O_RDONLY, INT_TYPE(STREAMWIDTH));
co_stream_open(outTest, O_WRONLY, INT_TYPE(STREAMWIDTH));
// Read values from the stream
while ( co_stream_read(inTest, &nSample, sizeof(co_int32)) == co_err_none ) {
#pragma CO PIPELINE
IF_SIM(samplesread++
// Sample is now in variable nSample.
// Add your processing code here.
pFunc = TestFunction; /// it does not work
pFunc (10);
co_stream_write(outTest, &nSample, sizeof(co_int32));
IF_SIM(sampleswritten++
}
co_stream_close(inTest);
co_stream_close(outTest);
IF_SIM(cosim_logwindow_fwrite(log,
"Closing filter process, samples read: %d, samples written: %d\n",
samplesread, sampleswritten)
IF_SIM(break;) // Only run once for desktop simulation
} while(1);
}
//
// Impulse C configuration function
//
void config_pFunctions(void *arg)
{
co_stream inTest;
co_stream outTest;
co_process Test_process;
co_process producer_process;
co_process consumer_process;
IF_SIM(cosim_logwindow_init()
inTest = co_stream_create("inTest", INT_TYPE(STREAMWIDTH), STREAMDEPTH);
outTest = co_stream_create("outTest", INT_TYPE(STREAMWIDTH), STREAMDEPTH);
producer_process = co_process_create("Producer", (co_function)Producer,
1,
inTest);
Test_process = co_process_create("Test", (co_function)Test,
2,
inTest,
outTest);
consumer_process = co_process_create("Consumer",(co_function)Consumer,
1,
outTest);
co_process_config(Test_process, co_loc, "pe0");
}
co_architecture co_initialize(int param)
{
return(co_architecture_create("pFunctions_arch","Generic",config_pFunctions,(void *)param));
}
I can build the exe file but when i press HDL this hapens and windows says that it has to close the program
.I am using vista
//////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
this the error::
======== Building target 'build' in file _Makefile ========
mkdir hw
HW_SRC="pFunctions_hw.c"; \
for i in $HW_SRC; do CPP_INCLUDES="$CPP_INCLUDES -include $i"; done; \
echo | "C:/Impulse/CoDeveloper3/MinGW/bin/gcc" -E -DIMPULSE_C_SYNTHESIS -DRC_INVOKED -DBYTE="unsigned char" -DWORD="unsigned short" -DDWORD="unsigned int" -Dsize_t="long unsigned int" -DNULL=0 -Dstdin=NULL "-IC:\Impulse\CoDeveloper3\Include" "-IC:/Impulse/CoDeveloper3/StageMaster/include" $CPP_INCLUDES - > pFunctions.i
"C:/Impulse/CoDeveloper3/bin/impulse_snoot" -Timpulse-c pFunctions.i pFunctions.snt
**** Program: C:\Impulse\CoDeveloper3\bin\impulse_snoot.exe
**** Assertion failure in file "..\decl.cc" at line 720
**** False expression: decld->suif_symbol->is_proc()
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
/////////////////////
I created a simple project from template:
The HW file is:
///////////////////////////////////////////////////////////////////////////////
//
// Generated by Impulse CoDeveloper
// Impulse C is Copyright© 2003-2007 Impulse Accelerated Technologies, Inc.
//
// pFunctions_hw.c: includes the hardware process and configuration
// function.
//
// See additional comments in pFunctions.h.
//
#include "co.h"
#include "cosim_log.h"
#include "pFunctions.h"
// Software process declarations (see pFunctions_sw.c)
extern void Producer(co_stream inTest);
extern void Consumer(co_stream outTest);
void (*pFunc) (int); // pointer to function
void TestFunction (int x) // a function
{
x=x+1;
}
//
// This is the hardware process.
//
void Test(co_stream inTest, co_stream outTest)
{
co_int32 nSample;
IF_SIM(int samplesread; int sampleswritten;)
IF_SIM(cosim_logwindow log;)
IF_SIM(log = cosim_logwindow_create("Test")
do { // Hardware processes run forever
IF_SIM(samplesread=0; sampleswritten=0;)
co_stream_open(inTest, O_RDONLY, INT_TYPE(STREAMWIDTH));
co_stream_open(outTest, O_WRONLY, INT_TYPE(STREAMWIDTH));
// Read values from the stream
while ( co_stream_read(inTest, &nSample, sizeof(co_int32)) == co_err_none ) {
#pragma CO PIPELINE
IF_SIM(samplesread++
// Sample is now in variable nSample.
// Add your processing code here.
pFunc = TestFunction; /// it does not work
pFunc (10);
co_stream_write(outTest, &nSample, sizeof(co_int32));
IF_SIM(sampleswritten++
}
co_stream_close(inTest);
co_stream_close(outTest);
IF_SIM(cosim_logwindow_fwrite(log,
"Closing filter process, samples read: %d, samples written: %d\n",
samplesread, sampleswritten)
IF_SIM(break;) // Only run once for desktop simulation
} while(1);
}
//
// Impulse C configuration function
//
void config_pFunctions(void *arg)
{
co_stream inTest;
co_stream outTest;
co_process Test_process;
co_process producer_process;
co_process consumer_process;
IF_SIM(cosim_logwindow_init()
inTest = co_stream_create("inTest", INT_TYPE(STREAMWIDTH), STREAMDEPTH);
outTest = co_stream_create("outTest", INT_TYPE(STREAMWIDTH), STREAMDEPTH);
producer_process = co_process_create("Producer", (co_function)Producer,
1,
inTest);
Test_process = co_process_create("Test", (co_function)Test,
2,
inTest,
outTest);
consumer_process = co_process_create("Consumer",(co_function)Consumer,
1,
outTest);
co_process_config(Test_process, co_loc, "pe0");
}
co_architecture co_initialize(int param)
{
return(co_architecture_create("pFunctions_arch","Generic",config_pFunctions,(void *)param));
}
I can build the exe file but when i press HDL this hapens and windows says that it has to close the program
.I am using vista
//////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
this the error::
======== Building target 'build' in file _Makefile ========
mkdir hw
HW_SRC="pFunctions_hw.c"; \
for i in $HW_SRC; do CPP_INCLUDES="$CPP_INCLUDES -include $i"; done; \
echo | "C:/Impulse/CoDeveloper3/MinGW/bin/gcc" -E -DIMPULSE_C_SYNTHESIS -DRC_INVOKED -DBYTE="unsigned char" -DWORD="unsigned short" -DDWORD="unsigned int" -Dsize_t="long unsigned int" -DNULL=0 -Dstdin=NULL "-IC:\Impulse\CoDeveloper3\Include" "-IC:/Impulse/CoDeveloper3/StageMaster/include" $CPP_INCLUDES - > pFunctions.i
"C:/Impulse/CoDeveloper3/bin/impulse_snoot" -Timpulse-c pFunctions.i pFunctions.snt
**** Program: C:\Impulse\CoDeveloper3\bin\impulse_snoot.exe
**** Assertion failure in file "..\decl.cc" at line 720
**** False expression: decld->suif_symbol->is_proc()
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
#4
Posted 05 September 2008 - 03:48 PM
Thanks for the detailed report. We'll log this as an improvement to make in the compiler's error messages.
If you'd like some help with accomplishing what your design needs without the use of function pointers, let us know.
Regards,
Ralph
If you'd like some help with accomplishing what your design needs without the use of function pointers, let us know.
Regards,
Ralph
Ralph Bodenner
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












