cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
uliuni
Observer
Observer
8,109 Views
Registered: ‎09-30-2008

XHWIcap on Virtex5

Hi together,

I'm trying to write a new value to specific LUT on a Virtex5 ML507 Evalutation Board.

I have a LUT which output is connected to an LED. As inputs I use two of the 6 inputs and conncet them to two DIP-Switches.,

This is necessary because xst is otherwise eliminating this LUT. The other 4 inputs of the Lut I just set to '0'.

 

 

 

LUT6_inst : LUT6
   generic map (
      INIT => X"FFFF000000000000") -- Specify LUT Contents
   port map (
      O  => led1,                -- LUT general output
      I0 => gnd0,               -- LUT input
      I1 => gnd0,               -- LUT input
      I2 => gnd0,               -- LUT input
      I3 => gnd0,               -- LUT input
      I4 => switch1,           -- LUT input
      I5 => switch2            -- LUT input
   );

 

 

I set the init value in that way, that the led1 signal will get '1' when both switch1 and switch2 are '1' (simple AND-Gate).

When synthesiszed the LED turns on.

What I want to do now is: I want to rewrite the value of this specific LUT with zeros, so that as an effect the LED will turn off.

Therefore I modify the UCF-file in the following way since I want to use the first LUT in the Slice X=1 Y=1:

 

INST "LUT6_inst" LOC=SLICE_X1Y1 | BEL = A6LUT;

 

Then I added a Microplaze-projekt with an HWICap-IP-Core in it and I used the "xhwicap_lut.c"  example from EDK and modified it with my specific LUT X=1 and Y=1 and I assigned the value to be written to '0':

So when I start the system I get the message that "HwIcapLutExample Passed Successfully", but my LED is still turned on.

So I tried everything I could think off to find out why its not turning off but I ran out of Ideas.

Does anyone has an Idea?

 

Thanks and best regards,

Uli

 

 

Here the porgramm:



#include <xparameters.h>
#include <xhwicap.h>
#include <xhwicap_clb_lut.h>
#include <stdio.h>

 
#define HWICAP_DEVICEID        XPAR_HWICAP_0_DEVICE_ID

#define TEST_COL    1    /* Test Column for LUT */
#define TEST_ROW    1    /* Test Row for LUT    */

#if XHI_FAMILY == XHI_DEV_FAMILY_V4
#define TEST_LUT    XHI_CLB_LUT_F    /* Test LUT */
#define LUT_SIZE    16    /* The number of bits in a LUT */
#elif XHI_FAMILY == XHI_DEV_FAMILY_V5
#define TEST_LUT    XHI_CLB_LUT_A    /* Test LUT */  //kennt nur A und B
#define LUT_SIZE    64    /* The number of bits in a LUT */
#endif


#define MAX_TEST_COUNT    0xFF



int HwIcapLutExample(u16 DeviceId);



static XHwIcap HwIcap;

u8 LutWriteBuffer[LUT_SIZE];       /* Value written to the LUT     */
u8 LutReadBuffer[LUT_SIZE];        /* Value read back from the LUT */

/*****************************************************************************/
int main(void)
{
    int Status;
   
   
    Status = HwIcapLutExample(HWICAP_DEVICEID);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    return XST_SUCCESS;
}

/******************************************************************************/
int HwIcapLutExample(u16 DeviceId)
{
    XHwIcap_Config *CfgPtr;    /* Pointer to HwIcap Config */
    u32 Count;                       /* Current value to test */
    int Status;                       /* Return value          */
    u32 Index;                       /* Counter               */
    u32 RowNum;                   /* CLB Row location      */
    u32 ColNum;                    /* CLB Column location   */
    u32 Slice;                        /* CLB Slice location    */

    printf("\n\r Starting HwIcapLutExample. \n\r");
    /*
     * Initialize the HwIcap instance.
     */
    CfgPtr = XHwIcap_LookupConfig(DeviceId);
    if (CfgPtr == NULL) {
        return XST_FAILURE;
    }


    Status = XHwIcap_CfgInitialize(&HwIcap, CfgPtr, CfgPtr->BaseAddress);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    /*
     * Perform a self-test to ensure that the hardware was built correctly.
     */
    Status = XHwIcap_SelfTest(&HwIcap);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    /*
     * Identify the LUT to change: LUT in SLICE_X1Y1.
     */
    ColNum = XHwIcap_mSliceX2Col(TEST_COL);
    RowNum = XHwIcap_mSliceY2Row(&HwIcap, TEST_ROW);
    Slice  = XHwIcap_mSliceXY2Slice(TEST_COL, TEST_ROW);


        for (Index = 0; Index < LUT_SIZE; Index++) {
            LutWriteBuffer[Index] = 0x00;
        }
       
       
        /*
         * Set LUT
         */
        Status = XHwIcap_SetClbBits(&HwIcap, RowNum, ColNum,
                     XHI_CLB_LUT.CONTENTS[Slice][TEST_LUT],
                     LutWriteBuffer, LUT_SIZE);
        if (Status != XST_SUCCESS) {
            return XST_FAILURE;
        }
            
       
        /*
         * Read back LUT value
         */
        Status = XHwIcap_GetClbBits(&HwIcap, RowNum, ColNum,
                    XHI_CLB_LUT.CONTENTS[Slice][TEST_LUT],
                    LutReadBuffer, LUT_SIZE);
        if (Status != XST_SUCCESS) {
            return XST_FAILURE;
        }

        /*
         * Compare the written and read values
         */
        for (Index = 0; Index < LUT_SIZE; Index++) {
            if (LutWriteBuffer[Index] != LutReadBuffer[Index]) {
            printf("\n\r HwIcapLutExample Failed.\n\r");
            return XST_FAILURE;
            }
        }
    printf("\n\r HwIcapLutExample Passed Successfully.\n\r");
    return XST_SUCCESS;
}



 

 

 

0 Kudos
5 Replies
uliuni
Observer
Observer
8,033 Views
Registered: ‎09-30-2008

I found out whats wrong.

The functions:

 

    ColNum = XHwIcap_mSliceX2Col(TEST_COL);
    RowNum = XHwIcap_mSliceY2Row(&HwIcap, TEST_ROW);
    Slice  = XHwIcap_mSliceXY2Slice(TEST_COL, TEST_ROW);

 

calculate wrong Row,Column and Sclice Numbers.

Greets

Uli

 

 

0 Kudos
faisalnawaz
Visitor
Visitor
7,856 Views
Registered: ‎04-12-2008

Hi Uli,

 

Would you like to share your experience on how you fixed the problem?

 

Thank you

Faisal

0 Kudos
uliuni
Observer
Observer
7,835 Views
Registered: ‎09-30-2008

Hi,

i made 4 loops, one inside the other and used the  XHwIcap_SetClbBits function directly with the loop values. So it was basically a brute force trying. At some point my LED went off and I was able to read out the values of RowNum, ColNum, Slice and TEST_LUT. I did this a few times and found an expression to calculate the values.

There are two coordinate systems. First the one from the Virtex 5 Datasheet with the three parameters: X, Y, LUT

This one starts in the down left corner like explained in ug190 page 172.

 

Second there is the coordinate system from the XHwIcap_SetClbBits function. This one uses the four parameters: Row, Col, Slice, Test_Lut

This system starts in the top left corner. In Col (to the right) direction it counts the CLBs  (not the Slices!!!)  and in Row (down) direction it also counts the CLBs.

The Slice inside the CLB is selected by the "Test_Lut" parameter (!!!!) .  A one means the top Slice, a two means the buttom Slice inside the CLB.

To select a special LUT inside the Slice I thought the parameter "Slice" would be responsible. But I figured out that this parameter needs to be 0 for configuring the A-Lut inside a Slice.

I tried out to configure a B,C and D Lut by varying the different parameters. But it did not work. So i was only able to use the A-Luts.

 

Here are my new functions that calculate the values for the SetCLB function out of the X,Y and Lut Values:

 

 -----------------------------------------

int calcRow(int y)
{
return 160-y;   
}

------------------------------------------

 

int calcCol(int x)
{   
   
return ((x/2)+1);          //Works because integer divided by integer cuts the after point numbers.

}   

 

---------------------------------------- 

 

int calcTestLut(int x)
{
    return (2 - (x % 2));
}

 

---------------------------------------

 

The "Slice" value i set constantly to 0.

 

Hope I could help you,

Greets

Uli

 

0 Kudos
faisalnawaz
Visitor
Visitor
7,666 Views
Registered: ‎04-12-2008

Hi Uri,

 

Thanks for your reply. I think I got the problem. Here I am sharing my thoughts so people like you and me can benefit.

 

The core problem is how we were using the following definitions

 

***********************

    ColNum = XHwIcap_mSliceX2Col(TEST_COL);
    RowNum = XHwIcap_mSliceY2Row(&HwIcap, TEST_ROW);
    Slice  = XHwIcap_mSliceXY2Slice(TEST_COL, TEST_ROW);

**********************

 

The first two functions (that are basically definitions) take slice-x and slice-y coordinates and return CLB co-ordinates. Looking at the Virtex-5 documentation, slice level co-ordinates start from lower left portion of FPGA which is marked as (0,0). However, the ClbBits() functions that we were using in the code interpret the top left CLB as (1,1). It is a straightforward conversion but one needs to keep in mind that we are supposed to give slice values and not CLB column/rows in these definitions. I would suggest to someone to completely do away with these two functions if he can do so in his design.

 

The third function (again basically a definition in one of the header file) is problematic. It seems to me that this was written with Virtex-4 architecture in mind and they forget to update it for Virtex-5. It can return 4 values of slices (0 to 3) corresponding to 4 slices available in Virtext-4 CLB. However, there are only slice 0 and 1 in Virtex-5. Thus instead of using that definition, I would suggest to use the following

 

 

#define  V5_ mSliceXY2Slice(SliceX) \
    ( ((SliceX % 2)

 

 

Let me know if I can clarify anything further. Thanks

0 Kudos
butters
Contributor
Contributor
7,325 Views
Registered: ‎11-05-2008

sorry for bumping an old topic, but what am I exactly reading calling just LutWriteBuffer or LutReadBuffer?

 

I'm trying to figure out a way to write size-64 bit number at once instead of giving 1 or 0 in a for-loop.

 

Is there any way to write a random value to an unused LUT?

0 Kudos