M
Matt
Guest
Reposting: Sorry for the earlier mess. The Xilinx newsgroup portal
apparently chewed my origional posting!
Greetings folks,
I am having a strange time with some code I recently wrote to implement
a UART - the code seems to be working fine now, but a problem cropped up
that is baffling me. This design is being synthesized in Xilinx ISE 5.1
and implemented into a Spartan-II XD2S50 device. I'm on something of a
learning curve with things right now so please go easy on me!
.............
when 10 => -- Stop Bit
BitPos := 11; -- next is holding pattern for breaks
if(FIFOhead = 3) then
FIFOhead := 0; -- wrap around
else
FIFOhead := FIFOhead + 1;
end if;
FIFO(FIFOhead)(8) <= RxD; -- stash the break bit
FIFO(FIFOhead)(7 downto 0) <= RReg; -- stash the received data
.............
The two FIFO array assignment statements at the bottom are the
predominant problem.... The object is to assign the break bit to the 9th
bit of the array of 9-bit words (indexed by the process variable
'FIFOhead'), and then assign the databyte to the lower part. As written
and synthesized, the above writes ONLY the received byte and NOT the
break bit. If the statements are exchanged, the opposite happens. In
short, only the SECOND assignment appears to be executing properly. If a
'dummy' statement is inserted, so the code looks like:
.............
end if;
FIFO(FIFOhead)(7 downto 0) <= RReg; -- DUMMY
FIFO(FIFOhead)(8) <= RxD; -- stash the break bit
FIFO(FIFOhead)(7 downto 0) <= RReg; -- stash the received data
.............
then both assignments work properly. There appears to be some amount of
latency inherent in updating the variable before it can be used as an
index, but why? And what is the proper way to detect or circumvent this
problem? This fix seems to work just fine, but I fear this problem may
explain similarly strange behavior in other sections of code.
If this IS a latency problem, how should I go about detecting these
sort of things in my design to ensure all code is relatively
bulletproof? All of the VHDL texts I have here really only cover
language theory and simulation synthesis, not things like proper timing
and floorplanning of the design into a physical device. What's the best
way to work on filling in my learning gaps in this area? Thanks in
advance for any insight!
-- Matt
apparently chewed my origional posting!
Greetings folks,
I am having a strange time with some code I recently wrote to implement
a UART - the code seems to be working fine now, but a problem cropped up
that is baffling me. This design is being synthesized in Xilinx ISE 5.1
and implemented into a Spartan-II XD2S50 device. I'm on something of a
learning curve with things right now so please go easy on me!
.............
when 10 => -- Stop Bit
BitPos := 11; -- next is holding pattern for breaks
if(FIFOhead = 3) then
FIFOhead := 0; -- wrap around
else
FIFOhead := FIFOhead + 1;
end if;
FIFO(FIFOhead)(8) <= RxD; -- stash the break bit
FIFO(FIFOhead)(7 downto 0) <= RReg; -- stash the received data
.............
The two FIFO array assignment statements at the bottom are the
predominant problem.... The object is to assign the break bit to the 9th
bit of the array of 9-bit words (indexed by the process variable
'FIFOhead'), and then assign the databyte to the lower part. As written
and synthesized, the above writes ONLY the received byte and NOT the
break bit. If the statements are exchanged, the opposite happens. In
short, only the SECOND assignment appears to be executing properly. If a
'dummy' statement is inserted, so the code looks like:
.............
end if;
FIFO(FIFOhead)(7 downto 0) <= RReg; -- DUMMY
FIFO(FIFOhead)(8) <= RxD; -- stash the break bit
FIFO(FIFOhead)(7 downto 0) <= RReg; -- stash the received data
.............
then both assignments work properly. There appears to be some amount of
latency inherent in updating the variable before it can be used as an
index, but why? And what is the proper way to detect or circumvent this
problem? This fix seems to work just fine, but I fear this problem may
explain similarly strange behavior in other sections of code.
If this IS a latency problem, how should I go about detecting these
sort of things in my design to ensure all code is relatively
bulletproof? All of the VHDL texts I have here really only cover
language theory and simulation synthesis, not things like proper timing
and floorplanning of the design into a physical device. What's the best
way to work on filling in my learning gaps in this area? Thanks in
advance for any insight!
-- Matt