///////////////////////////////////////////////////////////////////// // File: convolucao1.c // Date: 13 August 2000 // Author: Antonio Esteves, GEC-DI-UM. // // S/W part of the HW/SW implementation of a convolution // between a 256x256 image and a 3x3 Sobel filter. // // The H/W part is mapped into EDgAR-2 board. // // The accesses to EDgAR-2 is done via WinDriver functions. // //////////////////////////////////////////////////////////////////// #include #include #include #include "convolucao.h" #include "edgar2_lib.h" #include "pci_diag_lib.h" #define newline() while(getchar()!='\n') // Global variable used to sore command input by the user static char line[256]; //------------------------------------------------------------------------ // Define which Address Space (memory or i/o) and the access mode // to use on EDgAR-2 read/write operations. // Calls the function that controls CONVOLUTION execution. //------------------------------------------------------------------------ void EDGAR2A_AccessRangesForConvolution(EDGAR2A_HANDLE hEDGAR2A) { EDGAR2A_ADDR ad_sp = 0; EDGAR2A_MODE ad_mode = EDGAR2A_MODE_DWORD; for (; ad_spdwCounter); } //------------------------------------------------------------------------ // Enable/disable interrupts //------------------------------------------------------------------------ void EDGAR2A_EnableDisableInterrupts(EDGAR2A_HANDLE hEDGAR2A, BOOL intEnable) { if (EDGAR2A_IntIsEnabled(hEDGAR2A)) // interrupts are enabled { if(intEnable == FALSE) // order to disable interrupts { printf ("\n Disabling Interrupt"); EDGAR2A_IntDisable(hEDGAR2A); } else // order to enable interrupts {;} } else // interrupts are disabled { if(intEnable == TRUE) // order to enable interrupts { printf ("\n Enabling Interrupt"); if (!EDGAR2A_IntEnable(hEDGAR2A, EDGAR2A_IntHandlerRoutine)) printf ("\n Failed enabling Interrupt"); } else // order to disable interrupts {;} } } //------------------------------------------------------------------------ // Locate and Open EDgAR-2 Board //------------------------------------------------------------------------ EDGAR2A_HANDLE EDGAR2A_LocateAndOpenBoard (DWORD dwVendorID, DWORD dwDeviceID, BOOL fUseInt) { DWORD cards, my_card; EDGAR2A_HANDLE hEDGAR2A = NULL; if (dwVendorID==0) { printf ("Enter VendorID: "); gets(line); sscanf (line, "%x",&dwVendorID); if (dwVendorID==0) return NULL; printf ("Enter DeviceID: "); gets(line); sscanf (line, "%x",&dwDeviceID); } cards = EDGAR2A_CountCards (dwVendorID, dwDeviceID); if (cards==0) { printf("%s", EDGAR2A_ErrorString); return NULL; } else if (cards==1) my_card = 1; else { DWORD i; printf("\n Found %d matching PCI cards. ", cards); printf("Select card (1-%d): ", cards); i = 0; gets(line); sscanf (line, "%d",&i); if (i>=1 && i <=cards) my_card = i; else { printf ("\n Choice out of range."); return NULL; } } if (EDGAR2A_Open (&hEDGAR2A, dwVendorID, dwDeviceID, my_card - 1, fUseInt ? EDGAR2A_OPEN_USE_INT : 0 )) printf ("\n EDgAR-2 PCI card found."); else printf ("%s", EDGAR2A_ErrorString); return hEDGAR2A; } //------------------------------------------------------------------------ // Function that sends configuration bytes to all FPGAs bytes, from // a file that contains the junction of the 4 FPGAs configurations. //------------------------------------------------------------------------ int programar4Fpgas(EDGAR2A_HANDLE hEDGAR2, char *nome) { FILE *fp; unsigned int i=0, num, n, tmp=0; DWORD data[512], status; if((fp=fopen(nome,"rb")) == NULL) { printf("\n Error when opening %s file.",nome); return(0); } for(n=0;;) { num = fread( data, sizeof(DWORD), 512, fp); for(i=0;ifUseInt) // EDGAR2A_EnableDisableInterrupts(hEDGAR2A); //----------------------------------------------------- // Access EDgAR-2 local registers //----------------------------------------------------- //if (hEDGAR2A) EDGAR2A_AccessRegistersForConvolution(hEDGAR2A); //----------------------------------------------------- // Access EDgAR-2 memory and i/o ranges //----------------------------------------------------- if (hEDGAR2A) EDGAR2A_AccessRangesForConvolution(hEDGAR2A); //----------------------------------------------------- // Close EDgAR-2 Board Access //----------------------------------------------------- if (hEDGAR2A) EDGAR2A_Close(hEDGAR2A); WD_Close (hWD); printf ("\n "); printf ("\n END OF CODESIGN SESSION "); printf ("\n+--------------------------------------------------------+ \n"); getchar(); return 0; }