Forum Discussion
14 Replies
- Altera_Forum
Honored Contributor
What exactly is the context? What are you trying to do?
You could extract 1 2 0 out in VHDL - but why? - Altera_Forum
Honored Contributor
From the AD converter to read 8-bit vector and the need to get him on the numbers in an integer. I need to send individual characters to UART
- Altera_Forum
Honored Contributor
--- Quote Start --- From the AD converter to read 8-bit vector and the need to get him on the numbers in an integer. I need to send individual characters to UART --- Quote End --- Problem solved. This is example. library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity test is port( INput:in integer range 0 to 999:=123); end test; architecture main of test is signal hundred:integer range 0 to 9; signal ten :integer range 0 to 9 ; signal unit : integer range 0 to 9; begin hundred<=INput/100; --1 ten<=((INput rem 100)/(10)); --2 unit<=(INput rem 10) ; --3 end main; - Altera_Forum
Honored Contributor
Hello please.
I need to show 12 -bit value (integer) of the AD converter to the 4 - digit display. This is my functional code, but takes 756 total logic elements (many). I need a way to effectively divide the number and use the minimum number of logic elements. library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity Number_converter is port( INPUT12bit: in unsigned (11 downto 0); digit1: out unsigned (11 downto 0); digit2: out unsigned (11 downto 0); digit3: out unsigned (11 downto 0); digit4: out unsigned (11 downto 0)); end entity; architecture main of Number_converter is signal INPUT12bit_INT:integer range 0 to 4096; attribute ramstyle: string; attribute ramstyle of digit4 : signal is "M9K"; begin digit1<=(INPUT12bit rem 10)/1; digit2<=(INPUT12bit rem 100)/10; digit3<=(INPUT12bit rem 1000)/100; digit4<=(INPUT12bit/1000); end main; - Altera_Forum
Honored Contributor
I can't read VHDL, sorry. But if you want to trade logic elements for hard memory blocks you could use a look-up table. It would need to be 2^12 deep (4096) and wide enough to drive your 4-digit display. I would think this would take 4 bits per digit, but you've got your output digits defined as 12 bits each. Assuming you only need 16 bits out (4 bits per digit) the look-up table would consume 8 M9Ks I believe. They're there so you may as well use them.
- Altera_Forum
Honored Contributor
Why don't you simply use the standard function to_string() ?
This way, each number can be addressed by indexes representing each descending decimal order. - Altera_Forum
Honored Contributor
--- Quote Start --- Why don't you simply use the standard function to_string() ? This way, each number can be addressed by indexes representing each descending decimal order. --- Quote End --- Because to_string is not synthesisable. To the op.. Why not just have it in hex? That way you just need a small lut for each hex digit. - Altera_Forum
Honored Contributor
If you don't need it fast, you can use a double dabble algorithm, which cqn help you convert binary to the base of your choice, even bcd.
- Altera_Forum
Honored Contributor
--- Quote Start --- If you don't need it fast, you can use a double dabble algorithm, which cqn help you convert binary to the base of your choice, even bcd. --- Quote End --- Please, How to? - Altera_Forum
Honored Contributor
use your favorite web search engine an enter double dabble as keywords, you'll find plenty of resources there.