1
0
mirror of https://github.com/pConst/basic_verilog.git synced 2025-02-04 07:12:56 +08:00
basic_verilog/StaticDelay.v

52 lines
1.4 KiB
Coq
Raw Normal View History

2016-01-15 19:25:06 +03:00
//--------------------------------------------------------------------------------
// StaticDelay.v
// Konstantin Pavlov, pavlovconst@gmail.com
//--------------------------------------------------------------------------------
// INFO --------------------------------------------------------------------------------
// Static Delay for arbitrary signal
// Also may serve as a FPGA clock domain input synchronizer - base technique to get rid of metastability issues
// TIP: Do not use reset on purpose of inferring Xilinx`s SRL16E primitive
2016-01-15 19:25:06 +03:00
/* --- INSTANTIATION TEMPLATE BEGIN ---
2016-01-15 19:25:06 +03:00
StaticDelay SD1 (
2016-01-15 19:25:06 +03:00
.clk(),
.nrst( 1'b1 ),
2016-01-15 19:25:06 +03:00
.in(),
.out()
);
defparam SD1.LENGTH = 2;
defparam SD1.WIDTH = 1;
2016-01-15 19:25:06 +03:00
--- INSTANTIATION TEMPLATE END ---*/
2016-01-15 19:25:06 +03:00
//(* keep_hierarchy = "yes" *)
module StaticDelay(clk,nrst,in,out);
2016-01-15 19:25:06 +03:00
input wire clk;
input wire nrst;
2016-01-15 19:25:06 +03:00
input wire [(WIDTH-1):0] in;
output wire [(WIDTH-1):0] out;
parameter LENGTH = 2; // length of each delay/synchronizer chain
2016-01-15 19:25:06 +03:00
parameter WIDTH = 1; // independent channels
(* KEEP = "TRUE" *)(* ASYNC_REG = "TRUE" *) reg [(LENGTH*WIDTH-1):0] data = 0;
2016-01-15 19:25:06 +03:00
always @ (posedge clk) begin
if (~nrst) begin
data[(LENGTH*WIDTH-1):0] <= 0;
end
else begin
2016-01-15 19:25:06 +03:00
data[(LENGTH*WIDTH-1):0] <= data[(LENGTH*WIDTH-1):0] << WIDTH;
data[(WIDTH-1):0] <= in[(WIDTH-1):0];
end
end
2016-01-15 19:25:06 +03:00
assign
out[(WIDTH-1):0] = data[(LENGTH*WIDTH-1):((LENGTH-1)*WIDTH)];
endmodule