• 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. function for thermometric code from digital bus

Stats

  • Locked Locked
  • Replies 7
  • Subscribers 126
  • Views 3214
  • 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

function for thermometric code from digital bus

NewScreenName
NewScreenName 8 months ago

Hi all,


I have found this code to convert a bus into its decimal representation, which is quite useful: RE: Convert Digital Bus to an Integer value - Calculator Viva 
However it misses the option to take the bus as a thermometric code, Andrew Beckett  if you had the bandwidth, would it be possible to update the script accordingly?

What could also be useful would be (with lower priority than the previous thermometric feature) to have a function which re-converts this digital decimal output into an analog voltage (maybe with a scaling factor). This would allow some useful data processing (e.g. and ADC input voltage minus its digital output code).

In case you had the bandwidth to update it it would be greatly appreciated.

BR

  • Cancel
  • henker
    henker 8 months ago

    You can easily convert a number to the nearest thermo value, with e.g.
    floor(log( <number> )/log(2))+1

    This just looks at the highest bit and would thus also work for one-hot encoding. Other encodings of the bus value, e.g. gray code, could be handled similarly.
    If you, however, want error handling, e.g. doing some majority decision, or just check if all bits of the thermo sequence are set with e.g. !(<number> & (<number> + 1)), it will get a bit more complicated. But for this the question is not specific enough.


    For the second, to convert a digital waveform to an analog, you can use the Measurements > Digital To Analog in the ViVA menu, the corresponding skill function is awvDigital2Analog.

    Regards,

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • NewScreenName
    NewScreenName 8 months ago in reply to henker

    Thank you!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett 8 months ago in reply to NewScreenName

    By the way, I didn't see the original post (there's a bug in the forums at the moment where some notifications are not being sent), but I think it's not trivial to adapt the code you reference to handle thermometer encoded data (particularly with the points that henker makes about error handling).

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • henker
    henker 8 months ago in reply to Andrew Beckett


    It might be an option to apply a separate bus conversion module e.g. in veriloga, which takes a thermo-coded bus as input and outputs the value as binary-coded bus. This can than be displayed with the existing functionality.
    There is an example for the opposite conversion on edaboard (look for verilog-a-model-for-binary-to-thermometer-decoder, the external link is classified as spam), which might be a good starting point.

    Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • NewScreenName
    NewScreenName 8 months ago in reply to henker

    I have tried using awvDigital2Analog, unfortunately such function seems to convert the bus to an analog voltage taking its value as if it were an unsigned decimal, whereas most of the times I am using signed decimals.
    Is there any way to get the signed values instead?

    (I could also create my own verilogA model to process the digital bus, however I am running AMS simulations and the digital bus is actually a net within a systemverilog precompiled module, therefore I am not even aware of a way to bring out to the testbench level such net and connect it as input to the aforementioned verilogA model). Besides this, I feel this should be a built-in function as it seems something of quite general utility, maybe is there already something to do this?

    numConv seems to work on single numbers only, not on a waveform.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • henker
    henker 8 months ago in reply to NewScreenName

    awvDigital2Analog has e.g. arguments ?mode and ?outWaveType to determine the type of the output, please look up the corresponding values in the manual that fit your requirements.

    Further, the veriloga is the way to handle this completely within analog domain.
    If you run an ams simulation than you have more options:

    1) a verilogams module with electrical input and logic output for the thermo-to-binary translation. The logic output signal would then directly plot as digital waveform. This would remove the hassle with the extra conversion for waveform display of the output.

    2) use pure digital verilog with all logic ports. The simulator will than take care of the connected signals:
    - when connecting to a digital net, no signal conversion is required and everything is handled in digital domain
    - when connecting to an analog net, then the simulator will automatically insert connect modules for a2d / d2a conversion on the ports of the modules. So no need for manual conversion inside, although you have less control on load, timing, thresholds, etc.
    This is also how the connection of the digital signal from your current systemverilog to the veriloga would be handled.

    Each option has advantages and disadvantages and you may choose depending on your requirements.

    Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett 8 months ago in reply to NewScreenName
    NewScreenName said:
    Besides this, I feel this should be a built-in function as it seems something of quite general utility, maybe is there already something to do this?

    It does not seem to have been widely requested - I can find a single request from a number of years ago, Cadence Change Request #1174536. You could contact customer support and request a duplicate.

    Since the digital thermometer encoded bus is within the SystemVerilog, you could write some Verilog or SystemVerilog code to reference that bus (via an out-of-module-reference) and convert it to a conventional signed or unsigned bus, or even just an integer or real value directly. That way you can accommodate whatever error correction scheme you wish to adopt (this is one challenge with a built-in function; how do you determine which error correction mechanism you're going to adopt - for example if you have gaps in the coding such as 1111101 for just one example; you kind of need to know how the destination for this encoded signal is going to handle invalid codes).

    Andrew

    • 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