K
Karol Hennessy
I'm currently trying to work through some examples in one of Pong Chu's books. There's one thing I'm not quite clear on. In many of his exampleshe uses lots of if .. else statements, but hardly ever for loops. In some of the questions, you're asked to extend some example he has given, e.g.going from say 4bit input to 12bit or something like that.
For this kind of example, it seems natural to me to use some sort of loop for each of the 12bits. Is this poor practice?
One example he gives is a priority encoder, where you output the highest bit that is set to 1. If we have 4 bit input and 3 bit output, we would have
in out
"1XXX" "100" (4)
"01XX" "011" (3)
"001X" "010" (2)
"0001" "001" (1)
"0000" "000" (0)
If we had some 32bit input std_logic_vector, would we really have to explicitly code each case or is there some sort of looping we can use? What isthe preferred method to deal with long std_logic_vectors?
For this kind of example, it seems natural to me to use some sort of loop for each of the 12bits. Is this poor practice?
One example he gives is a priority encoder, where you output the highest bit that is set to 1. If we have 4 bit input and 3 bit output, we would have
in out
"1XXX" "100" (4)
"01XX" "011" (3)
"001X" "010" (2)
"0001" "001" (1)
"0000" "000" (0)
If we had some 32bit input std_logic_vector, would we really have to explicitly code each case or is there some sort of looping we can use? What isthe preferred method to deal with long std_logic_vectors?