Skip to content

Commit 6d933d2

Browse files
committed
snake_case naming for clock divider and main testbench template
1 parent 6ec509c commit 6d933d2

File tree

4 files changed

+106
-42
lines changed

4 files changed

+106
-42
lines changed

00_obsolete/DynDelay.v

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//--------------------------------------------------------------------------------
2+
// DynDelay.v
3+
// Konstantin Pavlov, [email protected]
4+
//--------------------------------------------------------------------------------
5+
6+
// INFO --------------------------------------------------------------------------------
7+
// Dynamic delay for arbitrary signal
8+
//
9+
10+
/* --- INSTANTIATION TEMPLATE BEGIN ---
11+
12+
DynDelay DD1 (
13+
.clk( ),
14+
.nrst( 1'b1 ),
15+
.in( ),
16+
.sel( ),
17+
.out( )
18+
);
19+
defparam DD1.LENGTH = 8;
20+
21+
--- INSTANTIATION TEMPLATE END ---*/
22+
23+
24+
//(* keep_hierarchy = "yes" *)
25+
module DynDelay(clk,nrst,in,sel,out);
26+
27+
input wire clk;
28+
input wire nrst;
29+
input wire in;
30+
input wire [(LENGTH-1):0] sel; // output selector
31+
output reg out;
32+
33+
parameter LENGTH = 8;
34+
35+
(* keep = "true" *) reg [(LENGTH-1):0] data = 0;
36+
37+
integer i;
38+
39+
always @ (posedge clk) begin
40+
if (~nrst) begin
41+
data[(LENGTH-1):0] <= 0;
42+
out <= 0;
43+
end
44+
else begin
45+
data[0] <= in;
46+
for (i=1; i<LENGTH; i=i+1) begin
47+
data[i] <= data[i-1];
48+
end
49+
out <= data[sel[(LENGTH-1):0]];
50+
end
51+
end
52+
53+
endmodule

00_obsolete/StaticDelay.v

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//--------------------------------------------------------------------------------
2+
// StaticDelay.v
3+
// Konstantin Pavlov, [email protected]
4+
//--------------------------------------------------------------------------------
5+
6+
// INFO --------------------------------------------------------------------------------
7+
// Static Delay for arbitrary signal
8+
// Also may serve as a FPGA clock domain input synchronizer - base technique to get rid of metastability issues
9+
// TIP: Do not use reset on purpose of inferring Xilinx`s SRL16E primitive
10+
11+
/* --- INSTANTIATION TEMPLATE BEGIN ---
12+
13+
StaticDelay SD1 (
14+
.clk(),
15+
.nrst( 1'b1 ),
16+
.in(),
17+
.out()
18+
);
19+
defparam SD1.LENGTH = 2;
20+
defparam SD1.WIDTH = 1;
21+
22+
--- INSTANTIATION TEMPLATE END ---*/
23+
24+
25+
//(* keep_hierarchy = "yes" *)
26+
module StaticDelay(clk,nrst,in,out);
27+
28+
input wire clk;
29+
input wire nrst;
30+
input wire [(WIDTH-1):0] in;
31+
output wire [(WIDTH-1):0] out;
32+
33+
parameter LENGTH = 2; // length of each delay/synchronizer chain
34+
parameter WIDTH = 1; // independent channels
35+
36+
(* KEEP = "TRUE" *)(* ASYNC_REG = "TRUE" *) reg [(LENGTH*WIDTH-1):0] data = 0;
37+
38+
always @ (posedge clk) begin
39+
if (~nrst) begin
40+
data[(LENGTH*WIDTH-1):0] <= 0;
41+
end
42+
else begin
43+
data[(LENGTH*WIDTH-1):0] <= data[(LENGTH*WIDTH-1):0] << WIDTH;
44+
data[(WIDTH-1):0] <= in[(WIDTH-1):0];
45+
end
46+
end
47+
48+
assign
49+
out[(WIDTH-1):0] = data[(LENGTH*WIDTH-1):((LENGTH-1)*WIDTH)];
50+
51+
endmodule

ClkDivider.sv

Lines changed: 0 additions & 40 deletions
This file was deleted.

main_tb.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ logic nrst_once;
4545
assign nrst_once = ~rst_once;
4646

4747
logic [31:0] DerivedClocks;
48-
ClkDivider #(
48+
clk_divider #(
4949
.WIDTH( 32 )
5050
) CD1 (
5151
.clk( clk200 ),
@@ -54,7 +54,7 @@ ClkDivider #(
5454
);
5555

5656
logic [31:0] E_DerivedClocks;
57-
EdgeDetect ED1[31:0] (
57+
edge_detect ED1[31:0] (
5858
.clk( {32{clk200}} ),
5959
.nrst( {32{nrst_once}} ),
6060
.in( DerivedClocks[31:0] ),

0 commit comments

Comments
 (0)