Thanks for your advise. I've been going through the Pico E-14/E-16 PSP and browsing through other available examples for genlib.tcl scripts. Even so, I still dont really a clear picture on how am i going to implement it. Hope you could fill me in on the questions below
Is it possible to automatically add codes to example_sw.c when compiling in Impulse C? I need to add a list of codes in the beginning that'll locate, open, configure and reset the FPGA card before data transfer and another list of codes at the end that'll close the FPGA card.
If it's not possible, then I'm thinking of putting all that codes in a C file which will be called by a function in example_sw.c.
So, the user will only need to add some single line function call and #include.
For example,
int main (int argc, char *argv[]) {
int param = 0;
co_architecture my_arch;
SETUP_FPGA;
my_arch = co_initialize(param);
co_execute(my_arch);
CLOSE_FPGA;
return(0);
}What do you think? Please advise....
You can use the co_init.c to do any creating of viDIME and DMA channel objects, and storing those objects either in a custom version of the co_stream structure, or as global variables. Then co_stream_write and friends will be able to pass those objects to the Nallatech API as needed.
For the Nallatech Comm Core that I'm using, there are 5 specific functions that I'll use:
viDIME_Open - Returns a valid viDIME handle. On error returns NULL.I'll add this to the SETUP_FPGA function
viDIME_Close - Closes down a valid viDIME handle.I'll add this to the CLOSE_FPGA function
viDIME_DMAAbort - Terminates any DMA and resets the FIFOs within the Core.link with co_stream_open and co_stream_close
viDIME_DMARead - Reads data from the FPGA to the PClink with co_stream_read
viDIME_DMAWrite - Writes data from the PC to the FPGAlink with co_stream_write
However to use viDIME_DMARead and viDIME_DMAWrite i need to pass some the following arguments to it.
viDIME handle - from viDIME_Open
Data - pointer to the PC memory that receives data or contains the data to be written
WordCount - the number of words to be written
DMAChannel - The channel used to transmit or receive data
Timeout -
My concern is with the WordCount and the DMAChannel.
For the WordCount in DMAWrite, i think i can add codes to count the number of words to be written from co_stream_write.
For the WordCount in DMARead, maybe i can retain back the last word count value from DMAWrite?
For the DMAChannel, the way i coded the hardware wrapper is such that the first input and output stream will get channel 0 and will increment with the respective input or output streams. Looking at the genlib.tcl script, i guess this shouldnt be a problem either.
The Pico E-14/E-16 PSP implements a customized co_stream structure as specified in co_stream.c. If i were to follow this example, i would only need to change the co_stream.c. The two other common files are co_process.c and co_type.c but they look kinda similar in other PSP, so i assume i dont have to change anything there.
The co_stream_attach function is used to associate things like addresses, handles, pointers, IDs, etc. with a particular stream.
The Impulse C user guide states that the co_stream_attach function associates a stream object with a specific hardware location.
In the Pico E-14/E-16 PSP, the hardware location or the io parameter values starts with 10 and increments with a new stream. I'm not sure where the value 10 points to but i guess it is defined in some Pico library or header file? PicoStream.h? For my case, i think i'll be using the io parameter to associate the DMA channel value with the input/stream.
Looking at the example, co_stream_attach in co_init.c passes the stream object from example_sw.c to co_stream.c which uses that object to associate any reading or writing of that stream.
In a nutshell, I need to include the co_stream_attach statement in my genlib.tcl script with the appropriate DMA channel numbering as the io parameter. Then i need to modify the co_stream.c to define the data transfer procedures when any co_stream_read/write is called. The data transfer procedures must include a way i can count the data prior to actual data write, while the number of data to be read will retain the last value of the data count in data write.
Please comment and advise. Hopefully i got my understanding of the problem right.
Sincerely,
Justin