number conversion for use in property values in skill ?

Discussion in 'Cadence' started by RolfK, Oct 11, 2008.

  1. RolfK

    RolfK Guest

    Dear All,

    I'm unfortunately found myself still a skill beginner.
    Please have alook at the following snipet:
    #################################
    procedure( CreateRCNetwork(Width BaseR BaseC MetalNumber )
    let( ( ScaleFactor RValue CValueRL CValueMid
    SchematicName )

    ScaleFactor = 80/Width;
    printf("%f" scaleFactor )

    ;RValue = sprintf(nil "%fm" baseR * ScaleFactor) ;
    ;CValueMid =sprintf(nil "%fp" baseC * ScaleFactor) ;
    ;CValueRL =sprintf(nil "%fp" baseC * ScaleFactor / 2) ;


    ;SchematicName= sprintf(nil "RCBASE80R%dC%dM%d" RValue CValueMid
    MetalNumber);
    ;cvID= dbOpenCellViewByType("GENERIC" SchematicName "schematic"
    "schematic" "w")

    ); let
    );procedure

    CreateRCNetwork(160 100 2 1)

    ###########################################

    I already got stuk at the simple first print statement (just for test)
    ==> *Error* fprintf/sprintf: format spec. incompatible with data - 0
    My final goal is to calculate the schematicname and to calculate some
    property values for
    the values of R and C to be instanciated later.

    In general I have a lot of diificulties to undertand how strings and
    numbers are handled in skill.
    Also it looks like that there in no function to avoid sprintf just to
    create a value string like 100p for e.g a capacitance property value.

    Could someone help me on that please ?

    Thanks a lot
    Rolf
     
    RolfK, Oct 11, 2008
    #1
  2. Rolf,
    There are two types of numbers in SKILL. fixnum (integers) and float.
    The arithmetic operations become integer operations when both the
    operands are integers (fixnum).

    For example, 2/1 => 0

    When at least one of the operands is a float, then it becomes a
    floating point arithmetic operation and which is what we want in most
    of the times.

    So, its better to convert unknown number values to avoid possible
    integer operation. To do so, we can use float()

    In your function, just change ScaleFactor = 80/Width; to ScaleFactor =
    80.0/Width or ScaleFactor = 80/float(Width)

    Regards,
    Suresh
     
    Suresh Jeevanandam, Oct 11, 2008
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.