On Thursday, September 20, 2012 7:08:21 PM UTC+2, Andy wrote:
> By having some statements that are only executed on some events, and other statements that are only executed on other events, you are going to have a devil of a time avoiding latches when the process triggers but the concurrent assignment is not executed.
The idea is that the concurrent assignments are always executed when the process triggers, while the synchronous assignments are only executed on clock events. Do you still believe this would make it harder to avoid latches? Synchronous signal assignments in VHDL always result in registers, so that these assignments aren't always executed when the process triggers shouldn't really create any problems as far as I can see.
> In your example, the sensitiviy list (apparently you want it to be implied) would also need to contain the state signal.
Yes. And yes, the idea is that the sensitivity list is implied, much like process(all) in VHDL-2008.
> If your example had a reset for the registers, then you would have some conditional logic surrounding the concurrent statement that would have to be ignored for the concurrent assignment (e.g. you want to concurrently assign it whether reset is active or not). Yet you also have conditional logic (the case statement) that you don't want to ignore. And yet when the state is not s_idle, you want to concurrently assign it to something, right? (to avoid the latch!)
Good point, I didn't think of that. I think it should still be possible to model resets though, although you would have to use a different coding style. Specifically you could add an independent "if reset then" at the end of the process where you do your resets. These assignments would override any assignments that may have been executed earlier in the process.
> VHDL (and verilog) synthesis starts to make a lot more sense when you understand how hardware is inferred from code BEHAVIOR, instead of from code structure.
I'm not sure what you mean. I recently realized that it actually is possible to mix concurrent and sequential assignments in a single process in VHDL. See the example below.
process (clk, state, a)
begin
case state is
when s_one =>
x <= '1';
if rising_edge(clk) then
state <= s_two;
end if;
when s_two =>
x <= a;
if rising_edge(clk) then
state <= s_one;
end if;
end case;
end process;
This isn't very pretty, but it's close to what I want, I guess. This is valid VHDL, it can be simulated and works as expected in Modelsim, with no warnings. The problem is that this code won't synthesize, at least not with Altera's tools. In the documentation for the error message this code produces they have written that "You might be attempting to infer a register using a coding style that Integrated Synthesis does not support".
By the way, contrary to what you wrote earlier, this works:
process (clk, state, a)
begin
if rising_edge(clk) then
case state is
when s_one =>
state <= s_two;
when s_two =>
state <= s_one;
end case;
end if;
case state is
when s_one => x <= '1';
when s_two => x <= a;
end case;
end process;
It will compile fine with Altera's tools with no warnings and the generated circuit looks like what I'm expecting. I wouldn't be surprised if it doesn't compile in other synthesis tools, however, because frankly, the code structure does make a difference.