FranzH wrote:
> On Mon, 20 Aug 2007 11:28:38 +0200, Pieter Hulshoff
> <> wrote:
>
>> FranzH wrote:
>>> SEND: process (write_to_uart, BUSVAL)
>>> begin
>>> if (BUSVAL /= BUFBUS) then
>>> if (tx_half_full = '0' AND SEND_A_BYTE_NOW = '0') then
>>> SEND_A_BYTE_NOW <= '1';
>>> BYTE_TO_SEND_NOW <= BYTE_TO_SEND_NOW + '1';
>>> end if;
>>> BUFBUS <= BUSVAL;
>>> elsif (rising_edge(write_to_uart)) then
>>> SEND_A_BYTE_NOW <= '0';
>>> end if;
>>> end process;
>> This can never work. You are using a combinatorial process to change the value
>> of BUFBUS while using that same BUFBUS to check on what to do in the process.
>> Within the simulator, this will cause a 1 delta cycle time during which your
>> BYTE_TO_SEND_NOW counter is incremented and SEND_A_BYTE_NOW is set to 1. Now try
>> to think of what this should look like in hardware...
>
> Thanks very much Pieter. I am a complete newbie in VHDL. I have great
> difficulty to see what can be synthesized and what can not be
> synthesized. I also don't know much about what the synthesis tool will
> make out of my code. Can you point me to some book or tutorial where I
> can learn what VHDL constructs will be synthesizable and what will not
> work ? Or is this all a question of experience and I have to learn it
> the hard way ? It is very confusing for me that a synthesis tool does
> not create an error if it can not synthesize something. I hope this
> doesn't sound too stupid
I can't think of a good book on that off the top of my head, but usually it
helps if you just draw a little hardware schematic of what you think you are
designing. If you see a combinatorial loopback anywhere (as you have created
here) you may want to think long and hard about if that's truly what you had in
mind.
Drawing things also helps prevent timing problems due to long paths. As a little
example, consider the schematic and timing implications of the two following
functionally identical processes:
cnt := cnt + 1;
IF cnt = 5 THEN
cnt := 0;
END IF;
cnt <= cnt + 1;
IF cnt = 4 THEN
cnt <= 0;
END IF;
The first process increments first, then uses the incremented result to clear
the counter. The second uses the counter value in the flip-flops to do the
check. The second process will therefore probably function at a higher clock
frequency than the first one.
Regards,
Pieter