aboutsummaryrefslogtreecommitdiffstats
path: root/include/ene.h
blob: e03e49b2e7704ebba22ebef8cf2acea9786f7ea0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * This file is part of the flashrom project.
 *
 * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __ENE_H__
#define __ENE_H__ 1

#define ENE_XBI_EFA0			0xfea8
#define ENE_XBI_EFA1			0xfea9
#define ENE_XBI_EFA2			0xfeaa
#define ENE_XBI_EFDAT			0xfeab
#define ENE_XBI_EFCMD			0xfeac
#define ENE_XBI_EFCFG			0xfead

#define ENE_XBI_EFCFG_CMD_WE		(1 << 3)
#define ENE_XBI_EFCFG_BUSY		(1 << 1)

#define ENE_XBI_EFCMD_HVPL_LATCH	0x02
#define ENE_XBI_EFCMD_READ		0x03
#define ENE_XBI_EFCMD_ERASE		0x20
#define ENE_XBI_EFCMD_PROGRAM		0x70
#define ENE_XBI_EFCMD_HVPL_CLEAR	0x80

#define ENE_EC_PXCFG			0xff14

#define ENE_EC_PXCFG_8051_RESET		0x01

#define ENE_EC_HWVERSION		0xff00
#define ENE_EC_EDIID			0xff24

#define ENE_KB9012_HWVERSION		0xc3
#define ENE_KB9012_EDIID		0x04

struct ene_chip {
	unsigned char hwversion;
	unsigned char ediid;
};

#endif
9' href='#n279'>279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
/**CFile****************************************************************

  FileName    [fpgaVec.c]

  PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

  Synopsis    [Technology mapping for variable-size-LUT FPGAs.]

  Author      [MVSIS Group]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 2.0. Started - August 18, 2004.]

  Revision    [$Id: fpgaVec.c,v 1.3 2005/01/23 06:59:42 alanmi Exp $]

***********************************************************************/

#include "fpgaInt.h"

ABC_NAMESPACE_IMPL_START


////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

static int Fpga_NodeVecCompareLevels( Fpga_Node_t ** pp1, Fpga_Node_t ** pp2 );

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    [Allocates a vector with the given capacity.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Fpga_NodeVec_t * Fpga_NodeVecAlloc( int nCap )
{
    Fpga_NodeVec_t * p;
    p = ABC_ALLOC( Fpga_NodeVec_t, 1 );
    if ( nCap > 0 && nCap < 16 )
        nCap = 16;
    p->nSize  = 0;
    p->nCap   = nCap;
    p->pArray = p->nCap? ABC_ALLOC( Fpga_Node_t *, p->nCap ) : NULL;
    return p;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecFree( Fpga_NodeVec_t * p )
{
    ABC_FREE( p->pArray );
    ABC_FREE( p );
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Fpga_Node_t ** Fpga_NodeVecReadArray( Fpga_NodeVec_t * p )
{
    return p->pArray;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Fpga_NodeVecReadSize( Fpga_NodeVec_t * p )
{
    return p->nSize;
}

/**Function*************************************************************

  Synopsis    [Resizes the vector to the given capacity.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecGrow( Fpga_NodeVec_t * p, int nCapMin )
{
    if ( p->nCap >= nCapMin )
        return;
    p->pArray = ABC_REALLOC( Fpga_Node_t *, p->pArray, nCapMin ); 
    p->nCap   = nCapMin;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecShrink( Fpga_NodeVec_t * p, int nSizeNew )
{
    assert( p->nSize >= nSizeNew );
    p->nSize = nSizeNew;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecClear( Fpga_NodeVec_t * p )
{
    p->nSize = 0;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecPush( Fpga_NodeVec_t * p, Fpga_Node_t * Entry )
{
    if ( p->nSize == p->nCap )
    {
        if ( p->nCap < 16 )
            Fpga_NodeVecGrow( p, 16 );
        else
            Fpga_NodeVecGrow( p, 2 * p->nCap );
    }
    p->pArray[p->nSize++] = Entry;
}

/**Function*************************************************************

  Synopsis    [Add the element while ensuring uniqueness.]

  Description [Returns 1 if the element was found, and 0 if it was new. ]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Fpga_NodeVecPushUnique( Fpga_NodeVec_t * p, Fpga_Node_t * Entry )
{
    int i;
    for ( i = 0; i < p->nSize; i++ )
        if ( p->pArray[i] == Entry )
            return 1;
    Fpga_NodeVecPush( p, Entry );
    return 0;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Fpga_Node_t * Fpga_NodeVecPop( Fpga_NodeVec_t * p )
{
    return p->pArray[--p->nSize];
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecWriteEntry( Fpga_NodeVec_t * p, int i, Fpga_Node_t * Entry )
{
    assert( i >= 0 && i < p->nSize );
    p->pArray[i] = Entry;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Fpga_Node_t * Fpga_NodeVecReadEntry( Fpga_NodeVec_t * p, int i )
{
    assert( i >= 0 && i < p->nSize );
    return p->pArray[i];
}

/**Function*************************************************************

  Synopsis    [Comparison procedure for two nodes.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Fpga_NodeVecCompareLevels( Fpga_Node_t ** pp1, Fpga_Node_t ** pp2 )
{
    int Level1 = Fpga_Regular(*pp1)->Level;
    int Level2 = Fpga_Regular(*pp2)->Level;
    if ( Level1 < Level2 )
        return -1;
    if ( Level1 > Level2 )
        return 1;
    if ( Fpga_Regular(*pp1)->Num < Fpga_Regular(*pp2)->Num )
        return -1;
    if ( Fpga_Regular(*pp1)->Num > Fpga_Regular(*pp2)->Num )
        return 1;
    return 0; 
}

/**Function*************************************************************

  Synopsis    [Sorting the entries by their integer value.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecSortByLevel( Fpga_NodeVec_t * p )
{
    qsort( (void *)p->pArray, p->nSize, sizeof(Fpga_Node_t *), 
            (int (*)(const void *, const void *)) Fpga_NodeVecCompareLevels );
}

/**Function*************************************************************

  Synopsis    [Compares the arrival times.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Fpga_NodeVecCompareArrivals( Fpga_Node_t ** ppS1, Fpga_Node_t ** ppS2 )
{
    if ( (*ppS1)->pCutBest->tArrival < (*ppS2)->pCutBest->tArrival )
        return -1;
    if ( (*ppS1)->pCutBest->tArrival > (*ppS2)->pCutBest->tArrival )
        return 1;
    return 0;
}

/**Function*************************************************************

  Synopsis    [Orders the nodes in the increasing order of the arrival times.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_SortNodesByArrivalTimes( Fpga_NodeVec_t * p )
{
    qsort( (void *)p->pArray, p->nSize, sizeof(Fpga_Node_t *), 
            (int (*)(const void *, const void *)) Fpga_NodeVecCompareArrivals );
//    assert( Fpga_CompareNodesByLevel( p->pArray, p->pArray + p->nSize - 1 ) <= 0 );
}


/**Function*************************************************************

  Synopsis    [Computes the union of nodes in two arrays.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecUnion( Fpga_NodeVec_t * p, Fpga_NodeVec_t * p1, Fpga_NodeVec_t * p2 )
{
    int i;
    Fpga_NodeVecClear( p );
    for ( i = 0; i < p1->nSize; i++ )
        Fpga_NodeVecPush( p, p1->pArray[i] );
    for ( i = 0; i < p2->nSize; i++ )
        Fpga_NodeVecPush( p, p2->pArray[i] );
}

/**Function*************************************************************

  Synopsis    [Inserts a new node in the order by arrival times.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecPushOrder( Fpga_NodeVec_t * vNodes, Fpga_Node_t * pNode, int fIncreasing )
{
    Fpga_Node_t * pNode1, * pNode2;
    int i;
    Fpga_NodeVecPush( vNodes, pNode );
    // find the place of the node
    for ( i = vNodes->nSize-1; i > 0; i-- )
    {
        pNode1 = vNodes->pArray[i  ];
        pNode2 = vNodes->pArray[i-1];
        if (( fIncreasing && pNode1->pCutBest->tArrival >= pNode2->pCutBest->tArrival) ||
            (!fIncreasing && pNode1->pCutBest->tArrival <= pNode2->pCutBest->tArrival) )
            break;
        vNodes->pArray[i  ] = pNode2;
        vNodes->pArray[i-1] = pNode1;
    }
}

/**Function*************************************************************

  Synopsis    [Inserts a new node in the order by arrival times.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Fpga_NodeVecReverse( Fpga_NodeVec_t * vNodes )
{
    Fpga_Node_t * pNode1, * pNode2;
    int i;
    for ( i = 0; i < vNodes->nSize/2; i++ )
    {
        pNode1 = vNodes->pArray[i];
        pNode2 = vNodes->pArray[vNodes->nSize-1-i];
        vNodes->pArray[i]                 = pNode2;
        vNodes->pArray[vNodes->nSize-1-i] = pNode1;
    }
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////

ABC_NAMESPACE_IMPL_END