Changeset 9276

Show
Ignore:
Timestamp:
04/22/09 14:54:03 (4 years ago)
Author:
mcarrick
Message:

updating component with improved interface

Location:
ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop/CostasLoop.cpp

    r9265 r9276  
    125125    CORBA::UShort I_in_0_length; 
    126126 
    127  
    128     unsigned long i_data, q_data; 
    129     unsigned long data; 
    130  
    131127    // open FPGA interface 
    132128    openInterface(); 
     
    141137        Q_out_0.length(I_in_0_length); //must define length of output 
    142138 
    143         // get sample from FPGA 
    144         readFPGA(i_data,q_data); 
     139        openFPGAInterface(); 
    145140 
    146         // write new data 
    147         writeFPGA(data); 
     141        // different methods for transmitting data: 
     142        //     1) push all data at once over bus into FIFOs on FPGA, and 
     143        //     return all data at once from output FIFOs on FPGA 
     144        //     2) push data sample by sample to FPGA and recieve sample 
     145        //     by sample 
     146 
     147        CostasLoopProcessing(); 
     148 
     149        closeFPGAInterface(); 
    148150 
    149151        dataIn_0->bufferEmptied(); 
  • ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop/CostasLoopFPGAInterface.c

    r9264 r9276  
    55#include <unistd.h> // using 'close' 
    66#include <sys/mman.h> // using 'mmap', 'munmap' 
     7#include <math.h> 
    78 
    89#define TXDEMO_BASE_ADDRESS  0xc1a00000 
    910#define TXDEMO_SLAVE_REG0OFF 0 
    10 #define TXDEMO_SLAVE_REG1OFF 4 
     11#define TXDEMO_SLAVE_REG1OFF 12 
    1112#define TXDEMO_RESET_REG_OFF 64 
    1213 
     
    1516 
    1617void *mapped_base, *mapped_dev_base; 
     18unsigned long val; 
     19unsigned int maskI = 0xFFFF0000; 
     20unsigned int maskQ = 0x0000FFFF; 
    1721int memfd; 
    1822 
    19 void openInterface() 
     23void openFPGAInterface() 
    2024{ 
    21     // initalize interface to FPGA 
    2225 
    2326    off_t dev_base = TXDEMO_BASE_ADDRESS; 
     
    4245} 
    4346 
    44 void writeFPGA(unsigned long data) 
     47void CostasLoopProcessing() 
    4548{ 
    46     // write to the FPGA interface 
     49    char command[10]; 
     50    while(1) 
     51    { 
     52        printf("Enter test/exit: "); 
     53        scanf("%s", command); 
     54        if( strcmp( command, "test" ) == 0 ) 
     55        { 
     56            // push zeros through to flush system 
     57            *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 
     58            *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 
     59            *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 
     60            *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 
    4761 
    48     unsigned long val; 
     62            // perform reads to cycle through undefined bits 
     63            unsigned int i = 0; 
     64            for (i = 0; i < 20; i++) 
     65            { 
     66                // write zeros to circuit 
     67                *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 
    4968 
    50     // perform write 
    51     *((unsigned long*)(mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = val; 
     69                // read from circuit 
     70                val = *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG0OFF)); 
     71 
     72                printf("Value off bus: #%x", val); 
     73 
     74                // get I and Q bits 
     75                signed long iside = maskI & val; 
     76                iside = (iside >> 16); 
     77                signed short qside = maskQ & val; 
     78 
     79                // convert from hex to decimal 
     80                int isideINT = iside; 
     81                int qsideINT = qside; 
     82 
     83                // scale 
     84                float isideFloat = isideINT / pow(2,15); 
     85                float qsideFloat = qsideINT / pow(2,15); 
     86 
     87                printf(" I: %1.3f", isideFloat); 
     88                printf(" Q: %1.3f\n", qsideFloat); 
     89 
     90            } 
     91        } 
     92        else if( strcmp( command, "exit" ) == 0 ) 
     93        { 
     94            break; 
     95        } 
     96        else 
     97        { 
     98            printf("Illegal command.\n"); 
     99        } 
     100    } 
    52101} 
    53102 
    54 void readFPGA(unsigned long i_data, unsigned long q_data) 
     103void closeFPGAInterface() 
    55104{ 
    56     // read from the FPGA interface 
    57  
    58     unsigned long val; 
    59  
    60     // perform read 
    61     val = *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG0OFF)); 
    62 } 
    63  
    64 void closeInterface() 
    65 { 
    66     // close the interface 
    67105 
    68106    if( munmap(mapped_base, MAP_SIZE) == -1 ) 
  • ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop/CostasLoopFPGAInterface.h

    r9264 r9276  
    11extern "C" { 
    2         void openInterface(); 
    3         void writeFPGA(unsigned long data); 
    4         void readFPGA(unsigned long i_data, unsigned long q_data); 
    5         void closeInterface(); 
     2        void openFPGAInterface(); 
     3        void CostasLoopProcessing(); 
     4        void closeFPGAInterface(); 
    65} 
    76