Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what's wrong with this interger counter?

Status
Not open for further replies.

clarksa

Programmer
Jan 31, 2010
2
CA
In this part of my state machine for controlling a UART. I am expecting my count variable to well... the code is pretty simple:

when stReceive =>
rdSig <= '0';
wrSig <= '0';

-- If new data is available for reading
if (rdaSig = '1') then

-- Later want to read the length, then keep reading until we see a full packet

aucDataPacketBuf(brCount) <= dbOutSig;

-- This check never passes... why?
if (brCount < 15) then
brCount <= brCount + 1;
stNext <= stReceive;
else
brCount <= 0;
-- Ready to send data
dbInSig <= "01111001"; -- 'y'
stNext <= stSend;
end if;

else
stNext <= stReceive;
end if;

I have declared the signal between architecture and begin in my top-level component as follows:

-- RXD packet counter signal, bytes remaining
signal brCount : integer range 0 to 15 := 0;

Should this be working? the if (brCount < 15) statement fails every single time, but I set it to 0 in the else. I am certain the else is hitting as I get a y character back in hyperterm every time I send a character.


 
You should use a reset clause to initialize your counter.

[tt]if reset=1 then
counter <= 0;
elsif rising_edge(clk) then
...
end if;[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top