Forum Discussion
Altera_Forum
Honored Contributor
15 years agoAdding Hex number- carry problem
Hi, I want to add two hex numbers inside the process. Attached herewith is my code: " signal TX_checkSum: std_logic_vector (7 downto 0); begin process... case loop_back is when stage...
Altera_Forum
Honored Contributor
15 years agoFor a start, why add two constants in code (hardware) when you can just insert a precomputed result. This is a basic resource usage principle.
However, if you want to add two values then sign extend the inputs by one bit and add up to a result one bit wider than input. Result <= A(7) & A + B(7) & B; -- assuming 8 bit inputs also be warned that if you add up in every case statement then you are asking for an adder instant per case. The compiler is not clever enough to use fewer adders with inputs switching.