bko wrote:
> Lattice User wrote:
>
>>
>> Hardware does nothing, because the synthesizer uses the sensitivity list
>> only to infer flip-flops and ignores it if you don't follow the required
>> coding style. Also a flip-flop with two clock inputs doesn't exist in a
>> fpga.
> Ok for VHDL but -
> not correct for verilog, coding for a flipflop with async reset
> see e.g:
> http://www.asic-world.com/examples/verilog/d_ff.html
This is the coding style for a dff with an async reset. Remove the
from the body, and you will get a synthesis error. But you don't get a
ff with two clock inputs.
@Joe
There are no coding style issue with your last code. (apart with my
personal opinion that old module style declaration should be outlawed)
It will however still have some issues.
If on powerup the two state registers will have different values, your
output is inverted. This depends on the actual FPGA family.
Also it is very sensitive to spikes on the two inputs, assuming they
come from the outside.
Better would be to synchronise the two inputs to your system clock, and
use edge detection.
1 | reg [2:0] sync_cref;
|
2 | wire edge_cref;
|
3 | always @(posedge sys_clk) sync_cref <= { sync_cref[1:0], cref} ;
|
4 | assign edge_cref = sync_cref[1] & ~sync_cref[2];
|
On the edge for one signal you then can set your output to 1, and on the
edge for the other signal reset it to 0. This solves both issues.