Home > Community > Forums > Functional Verification > Type conversion from hex String to uint (32 bits) in Specman e

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Type conversion from hex String to uint (32 bits) in Specman e 

Last post Wed, Apr 18 2012 11:14 PM by bharathwajan. 2 replies.
Started by bharathwajan 18 Apr 2012 09:17 PM. Topic has 2 replies and 3081 views
Page 1 of 1 (3 items)
Sort Posts:
  • Wed, Apr 18 2012 9:17 PM

    Type conversion from hex String to uint (32 bits) in Specman e Reply

    Hi All,

     

    I am trying to read a file which has address and data in hex separated by space as shown below :

    0001FF 0x47295784

    I am having problem with converting the hex string 0001FFF to uint 32 bits and send this to my driver for further action. I have tried the following syntax from the cadence docs:

    int = %{string};

    int = pack(packing.low,string)

     Neither of them helped. In the both cases, the string is converted to a signed int. The doc doesnt help me convert string to uint (32 bits).

    Could you pelase help me? 

    Could anyone please help me do this type conversion?  

     Thank you !!! 

     Best Regards,

    Bharath. 

    • Post Points: 20
  • Wed, Apr 18 2012 10:43 PM

    • danielpoe2
    • Not Ranked
    • Joined on Mon, Apr 11 2011
    • Posts 2
    • Points 40
    Re: Type conversion from hex String to uint (32 bits) in Specman e Reply

     Hi,

     what you want is specman to interpret the string as a number. You can do this easily with "<string>".as_a(uint). However you need to consider how specman wants a hex to look like, namely it should be prefixed with "0x". So if you do "append("0x", string).as_a(uint)" you should get what you want. You can try it out on the specman console as well 'print "0xcafecafe".as_a(uint)'.

     

    Hope this helps,

    Daniel

    • Post Points: 20
  • Wed, Apr 18 2012 11:14 PM

    Re: Type conversion from hex String to uint (32 bits) in Specman e Reply

    Hi Daniel,

     

    Thank a lot. It worked. I had tried this way but i didnot append "ox" to the string. Now it works.

     

    Thanks again !!!

     

    Best Regards,

    Bharath. 

    • Post Points: 5
Page 1 of 1 (3 items)
Sort Posts:
Started by bharathwajan at 18 Apr 2012 09:17 PM. Topic has 2 replies.