mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
875e4213a5
- Otherwise tool was throwing away logic and timing incorretly. - This is why you HAVE to isolate this logic! Solve the problem once for all logic and for everyone.
42 lines
794 B
Verilog
42 lines
794 B
Verilog
//Variable pipeline depth syncrhonizer
|
|
module dsync (/*AUTOARG*/
|
|
// Outputs
|
|
dout,
|
|
// Inputs
|
|
clk, din
|
|
);
|
|
|
|
parameter PS = 2; //number of sync pipeline stages
|
|
parameter DW = 1; //number of bits to synchronize
|
|
|
|
input clk;
|
|
input [DW-1:0] din;
|
|
output [DW-1:0] dout;
|
|
|
|
|
|
`ifdef TARGET_SIM
|
|
reg [PS-1:0] sync_pipe[DW-1:0];
|
|
`else
|
|
(* ASYNC_REG = "TRUE" *) (* DONT_TOUCH = "TRUE" *) reg [PS-1:0] sync_pipe[DW-1:0];
|
|
`endif
|
|
|
|
|
|
genvar i;
|
|
integer j;
|
|
|
|
generate
|
|
for(i=0;i<DW;i=i+1)
|
|
begin
|
|
always @ (posedge clk)
|
|
begin
|
|
sync_pipe[i][0] = din;
|
|
for(j=1;j<PS;j=j+1)
|
|
sync_pipe[i][j] = sync_pipe[i][j-1];
|
|
end
|
|
assign dout[i] = sync_pipe[i][PS-1];
|
|
end
|
|
endgenerate
|
|
|
|
endmodule // dsync
|
|
|