RegisterLogin  
Update Profile
   
You are here: Forum  
Minimize 
SVUG Community Forum
Subject: decimal numbers in sv
Prev Next
You are not authorized to post a reply.

Author Messages
WilliamUser is Offline

Posts:5

02/24/2010 8:04 AM  
In a code in sv, I need to do basic math operations (+, -, * and /) with decimal numbers.

Example:
- x=a+0.2;
- y=a-0.2;
- z=b+14.4;
- w=c*255, with 0
But when I try to simulate it, the numbers are automatically truncated , and I really need the decimal part.

Is there any way to solve this situation?

Thanks!
SHALOMUser is Offline

Posts:43

02/24/2010 1:37 PM  
Declare your variables as real.

Shalom Bresticker
WilliamUser is Offline

Posts:5

02/25/2010 11:40 AM  
But in my case, these variables must be declared as 'logic'.

Still, can I do something?

Tks Shalom! o/
SHALOMUser is Offline

Posts:43

02/25/2010 11:44 AM  
Use 'real' temporary variables, then assign the 'real' results to the logic vectors.

Shalom
WilliamUser is Offline

Posts:5

03/02/2010 11:26 AM  
Right...
now here's another problem... see the simple code below:

module SystemVerilog1();
real a;
always_comb begin
a = 3.5;
end
endmodule

Now, when I declare a 'real' data type and compile the code, an error is detected:
"real variable data type values are not supported"

What's worng now? Is this my Quartus or what?

Thanks again, Shalom!
SHALOMUser is Offline

Posts:43

03/02/2010 1:05 PM  
For synthesis or simulation?

Shalom
WilliamUser is Offline

Posts:5

03/02/2010 6:42 PM  
For synthesis, Shalom.
I did not simulate it, because this code didn't even compile without errors...
SHALOMUser is Offline

Posts:43

03/03/2010 12:13 AM  
Well, real variables are not supported for synthesis.

Shalom
You are not authorized to post a reply.
Forums > General Discussion > Main Discussion Area > decimal numbers in sv



ActiveForums 3.7
  

 Copyright 2008 by SystemVerilog User Group Contact Us    Privacy Statement