Is it possible to write a code segment and call it, instead of writing that segment many times? Ie. I want to reuse a segment of code as shown below:
process (currentState)
begin
case currentState is
when requiredCoinsTensAnode => anodes <= "100000";--turn on the tens display
case tensCount is
when "0000" => segDisplay <= "1111110"; --0
when "0001" => segDisplay <= "0110000"; --1
when "0010" => segDisplay <= "1101101"; --2
when "0011" => segDisplay <= "1111001"; --3
when "0100" => segDisplay <= "0110011"; --4
when "0101" => segDisplay <= "1011011"; --5
when "0110" => segDisplay <= "1011111"; --6
when "0111" => segDisplay <= "1110000"; --7
when "1000" => segDisplay <= "1111111"; --8
when others => segDisplay <= "1111011"; --9
end case;
nextState <= requiredCoinsUnitsAnode;--just displayed the tens digit, next we need to display the units digit
when requiredCoinsUnitsAnode => anodes <= "010000";--turn on the units display
case unitsCount is
when "0000" => segDisplay <= "1111110"; --0
when "0001" => segDisplay <= "0110000"; --1
when "0010" => segDisplay <= "1101101"; --2
when "0011" => segDisplay <= "1111001"; --3
when "0100" => segDisplay <= "0110011"; --4
when "0101" => segDisplay <= "1011011"; --5
when "0110" => segDisplay <= "1011111"; --6
when "0111" => segDisplay <= "1110000"; --7
when "1000" => segDisplay <= "1111111"; --8
when others => segDisplay <= "1111011"; --9
end case;
nextState <= insertedCoinsTensAnode;
end case;
end process;
Functions are one option, as ravi has pointed out.
Depending on the compiler and options, it may decide to put the function code in-line. This would cause multiple instances of the logic to be placed, much like your original code.
An alternative is that you take the common code out into another process:
BTW: You need tensCount and unitsCount in your sensitivity list.
Abstracting a common resource like this is a useful technique when doing area or power concious designs.
Both should work in the same way, and perfect tools would produce the same logic from the two, but we rarely have perfect tools. Experiment with different styles. Some produce better results on some tools, some on others.