P
Paul Marciano
Guest
Hello. A quick question from a beginner.
I've read that in order to use asynchronous signals in synchronous
logic, they must be passed through a couple of registers in order to
reduce metastability.
So you can't write:
@(posedge clk)
sync_reg <= async_source;
Instead, something like (ignoring reset):
reg [1:0] buf;
@(posedge clk)
begin
buf <= { buf[0], async_source };
sync_reg <= buf[1];
end
Does the same rule apply to signals used only in conditional clauses?
For example, is it ok to write:
reg [7:0] cnt;
always @(posedge clk)
if (async_signal)
cnt <= cnt + 1;
Or must async_signal be synchronized here too? I think the answer is
that it must be synchronized, but please advise.
Thanks,
Paul.
I've read that in order to use asynchronous signals in synchronous
logic, they must be passed through a couple of registers in order to
reduce metastability.
So you can't write:
@(posedge clk)
sync_reg <= async_source;
Instead, something like (ignoring reset):
reg [1:0] buf;
@(posedge clk)
begin
buf <= { buf[0], async_source };
sync_reg <= buf[1];
end
Does the same rule apply to signals used only in conditional clauses?
For example, is it ok to write:
reg [7:0] cnt;
always @(posedge clk)
if (async_signal)
cnt <= cnt + 1;
Or must async_signal be synchronized here too? I think the answer is
that it must be synchronized, but please advise.
Thanks,
Paul.