Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17042 Discussions

using multiple conversion statements

Altera_Forum
Honored Contributor II
2,090 Views

I'm trying to pass an integer through multiple conversions. 

i placed an integer counter (mone) of 0 to 9 

Which i control with a push button(that act as a clock_in). 

i basically need every time that i get a new integer(0 to 9) 

lets say 3 for example to multiply by 0.000305(same as 61/200000). 

and then convert the result integer to std_logic_vector 16bit. 

it eventually will go to an D/A the has a resolution of 2^15. 

the code is fine if i run compilation. 

but don't see the result in the simulation waveform. 

or in the leds in my cyclone 2. 

you can see the code and the simulation waveform in the photos attached . 

 

hlap me please.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
947 Views

when you say result <= temp2 * (61/200000): do you know what it settles to? or rather if you do it by hand what is 3 * 61/200000? is'nt it < 1 

so how to expect <1 to go on 15bit bus? 

in short you need to scale up the value 0.000305 to your 15 bit resolution.
0 Kudos
Altera_Forum
Honored Contributor II
947 Views

you you are right 

i originally wrote it like this 

3/0.000305 and the result is >0 

but quartus does not let me write it like this so i did it like this 

3/(61/200000). 

i think i forgot to place "/" between them/ 

 

do you think that it might fix it? 

 

 

so do you have any other suggestions?
0 Kudos
Altera_Forum
Honored Contributor II
947 Views

61/200000 = 0.000305 

I think 3/0.000305 is not same as 3*.000305 so which way you want to go?
0 Kudos
Altera_Forum
Honored Contributor II
947 Views

Let go with  

3/(61/200000) 

The result is bigger the 0
0 Kudos
Altera_Forum
Honored Contributor II
947 Views

ok then you have range 0~9 from counter (in fact your code is 0~8 for calculation logic) 

now 1/0.000305 = 3279 

 

so multiply each count value by 3279 and you will get 0~26232 or if 0~9 will need 0~29511 

so you are lucky now since 15 bits covers 0~32767
0 Kudos
Altera_Forum
Honored Contributor II
947 Views

If you want an alternative you can avoid the mult and now use: 

count <= count + 3279 then pass it to the DAC
0 Kudos
Altera_Forum
Honored Contributor II
947 Views

Thanks man I'll try it and write here if it worked

0 Kudos
Reply