1 Star 5 Fork 5

yhp/basic_verilog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
delay.sv 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
//------------------------------------------------------------------------------
// delay.v
// Konstantin Pavlov, pavlovconst@gmail.com
//------------------------------------------------------------------------------
// INFO -------------------------------------------------------------------------
// Static Delay for arbitrary signal
// Another equivalent names for this module:
// conveyor.sv
// synchronizer.sv
//
// Tip for Xilinx-based implementations: Leave nrst=1'b1 and ena=1'b1 on
// purpose of inferring Xilinx`s SRL16E/SRL32E primitives
//
//
// CAUTION: delay module is widely used for synchronizing signals across clock
// domains. To automatically exclude input data paths from timing analisys
// set_false_path SDC constraint is integrated into this module. Applicable
// only to Intel/Altera Quartus IDE. Xilinx users still should write the
// constraints manually
//
/* --- INSTANTIATION TEMPLATE BEGIN ---
delay #(
.LENGTH( 2 )
) S1 (
.clk( clk ),
.nrst( 1'b1 ),
.ena( 1'b1 ),
.in( ),
.out( )
);
--- INSTANTIATION TEMPLATE END ---*/
module delay #( parameter
LENGTH = 2 // delay/synchronizer chain length
// default length for synchronizer chain is 2
)(
input clk,
input nrst,
input ena,
input in,
output out
);
generate
if ( LENGTH == 0 ) begin
assign out = in;
end else if( LENGTH == 1 ) begin
logic data = 0;
always_ff @(posedge clk) begin
if (~nrst) begin
data <= 0;
end else if (ena) begin
data <= in;
end
end
assign out = data;
end else begin
logic [LENGTH:1] data = 0;
always_ff @(posedge clk) begin
if (~nrst) begin
data[LENGTH:1] <= 0;
end else if (ena) begin
data[LENGTH:1] <= {data[LENGTH-1:1],in};
end
end
assign out = data[LENGTH];
end // if
endgenerate
endmodule
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuan_hp/basic_verilog.git
git@gitee.com:yuan_hp/basic_verilog.git
yuan_hp
basic_verilog
basic_verilog
master

搜索帮助