• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC Design
  3. verilog-a syntax to read a 64-bit binary value from a f...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 126
  • Views 6884
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

verilog-a syntax to read a 64-bit binary value from a file

MikeVP
MikeVP over 2 years ago

I have a text file with this format:

1511874.802,0000000000000000000000000000000000000000000000000000000000000000
1512541.468,0000000000000001000000100000001100000100000001010000011000000111
1513208.134,0000100000001001000010100000101100001100000011010000111000001111

I want to read the 64-bit binary value, and then use a genvar to set an output vector, like this:

 for(i=0;i<64;i=i+1)
V(txdata[i]) <+ transition( binVal & (1<<i)?voh:vol, 0, 10n, 10n );

Using this to read the file:

$fscanf( file, "%f,%b", timeVal, binVal );

Here is where I am stuck.  What data type do I use for binVal?  I cannot read the binary value into an integer, since that is only 32 bits.  Reading it as a string or real will work, but it is not obvious how I convert a real/string back to an integer. 

Using a real returns a very small number, like 1e-316, since the MSB is a 0.

Is it possible to read it as a string, then do a character comparison?

Any ideas?

  • Cancel
  • GeoffreyC
    GeoffreyC over 2 years ago

    Yes, I think reading it in as a string would work; you can use .substr(i,i) to get the ith bit.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MikeVP
    MikeVP over 2 years ago in reply to GeoffreyC

    Thank you very much, that works great.  I've now bookmarked the Cadence Verilog-A manual instead of using what comes up on Google.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information