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

VHDL for a Digital rev counter

Altera_Forum
Honored Contributor II
1,453 Views

I am trying to constructed a digital rev couter from a previous project ( a digital read but analogue displayed rev counter in VHDL) the number of pulses are counter in a location that is defined as an integer (0 to 65536) 

 

I will be outputting the value that's in this integer on 4 7 segment displays.  

 

As i understand i can just devide the amount in the integer by 1000 to get thousand's and then the remainder by devied 100 to get the hundered's and the then the remainder of that divided by 10 to get the 10's but i have no idea on what to do next, would some one be able to suggest some code to make this alot easier. 

 

I was thinking if you replaced the integer with a (0 to 15) std_logic_vector then i might be able to just split the (0 to 15) in to (0 to 3)(4 to 7)(8 to 11) & (12 to 15) convert the binary to BCD in to the 4 7 segments. Would this work? 

 

Many thanks http://www.alteraforum.com/forum//images/icons/icon7.gif
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
764 Views

 

--- Quote Start ---  

 

I was thinking if you replaced the integer with a (0 to 15) std_logic_vector then i might be able to just split the (0 to 15) in to (0 to 3)(4 to 7)(8 to 11) & (12 to 15) convert the binary to BCD in to the 4 7 segments. Would this work? 

 

--- Quote End ---  

 

This way you simply extract the 4 hex digits, but the displayed number would still be hexadecimal. A BCD conversion would even lead to a wrong hex reading, since it trims hex digits between 0 and 9, then losing values from 0xA to 0xF. 

If you are please with a hex readout, then the above solution (without the BCD conversion!!!) is fair. If you really require a decimal value you must perform the true hex to dec conversion, with the mentioned divisions or any other equivalent method.
0 Kudos
Altera_Forum
Honored Contributor II
764 Views

Hi there,  

 

Thank you for your reply, would you be able to show me an example of how to device the amount in the integer up, i don't think i will be able to use the (/) symbol as i have use in other programing language. 

 

Many thanks
0 Kudos
Reply