Forum Discussion
Altera_Forum
Honored Contributor
9 years ago --- Quote Start --- signal iCntBCD: natural (3 downto 0); Is illegal. naturals and other integer types do not have accessible bits. Also, 3 downto 0 is illegal for an integer type. did you mean signal iCntBCD : natural range 0 to 3; --- Quote End --- No, not with range. With range means, only the value 0, 1, 2 and 3 is available. AM I RIGHT? My thaught was: I want an unsigned integer counter with 4 bits. (And, in plus, init at 0) But if I write: signal iCntBCD : unsigned integer :=0;--I have a counter of 32 bits. AM I RIGHT? When I want to add 1 to iCntBCD, I have to write: iCntBCD = iCntBCD + 1 ; When I want to send iCntBCD to Q output, I have to cast iCntBCD, like this: Q <= std_logic_vector (iCntBCD);--Like I did. I hope it send to Q only the 4 LSB and ignorre the others bits without any error during compilation! If I want only 4 bits, I must write: signal iCntBCD : std_logic_vector(3 downto 0) := '0000'; -- AM I RIGHT? When I want to add 1 to iCntBCD, I have to write: iCntBCD <= (iCntBCD + '1') :--IS IT CORRECT? When I want to send iCntBCD to Q output, I have to do, without cast, like this: Q <= iCntBCD; --No cast, because both have the same type. Which methode, do you think is better? IF EVERY THING IS OK, I will modify my software and test it tomorrow, if the classroom is open. If not I will do it Monday afternoon, swiss time. I think, I'm starting to understand what's going on! thank you very much. I will send you an other message with your second answer soon.