The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 4:19am
Pages: 1
Send Topic Print
Decimal to binary conversion (Read 1201 times)
nishant22
New Member
*
Offline



Posts: 8

Decimal to binary conversion
Aug 11th, 2009, 3:06am
 
hi,
I am writing a testbench, with  stimulus in VA in which I have few buses of width around 69 bits, so I want user to specify the decimal value and my resepective data paths get ON or off basically get 1 or 0. So I want to carry out Decimal to binary conversion in VA. So if u specify decimal value of 4 and my bus is 40 bits, i shud get 0...0100 . I want to write this model in pure verilog-A not ams for some restrictions. Can anyone please help or send me a code, its re\ally urgent.It would be really useful. I have seen many C/C++ codes, but VA restrictions don't allow me to use those functions.

Thanks ,
NIshant
Back to top
 
 
View Profile   IP Logged
nishant22
New Member
*
Offline



Posts: 8

Re: Decimal to binary conversion
Reply #1 - Aug 14th, 2009, 2:27am
 
Hello All.

can anyone please help?

Thanks,
Back to top
 
 
View Profile   IP Logged
Sumit Adhikari
Community Member
***
Offline



Posts: 44

Re: Decimal to binary conversion
Reply #2 - Aug 14th, 2009, 6:03am
 
use it like following

integer val_int  ;
real     val_real ;
logic  [68:00]  your_bus ;

always @(val_int) your_bus = val_int ;

analog
begin//{
  val_int = val_real ;
end//}

Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Decimal to binary conversion
Reply #3 - Aug 14th, 2009, 7:20am
 
Please note that real does not have a resolution of 69 bits (Standard IEEE double precision real has a 52-bit mantissa).
BOE

Added: Verilog-A does not guarantee integers to be larger than 32 bit either.

PS: Is your signal constant?
Back to top
 
« Last Edit: Aug 14th, 2009, 9:46am by boe »  
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.