Skip to content

Commit c1b04ec

Browse files
committed
Fixed error in Synch module
1 parent 4a5b912 commit c1b04ec

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
**EdgeDetect.v** - edge detector, gives one-tick pulses on every signal edge
1313
**ResetSet.v** - SR trigger variant w/o metastable state, set dominates here
1414
**SetReset.v** - SR trigger variant w/o metastable state, reset dominates here
15-
**Synch.v** - input syncnronizer, standard way to get rid of metastability issues
15+
**Synch.v** - input syncnronizer (and also "static delay module"), standard way to get rid of metastability issues
16+
17+
**DynDelay.v** - dynamic delay made on general-purpose trigger elements
18+
**PulseGen.v** - generates pulses with given width and delay
19+
**SimplePulseGen.v** - generates one-cycle pulse with given delay
1620

1721

Synch.v

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
// Ñòàíäàðòíûé ìåòîä ïîäàâëåíèÿ ìåòàñòàáèëüíîñòè.
99

1010
//(* keep_hierarchy = "yes" *)
11-
module Synch(clk, in, out); // aka "static delay"
11+
module Synch(clk, nrst, in, out); // aka "static delay"
1212

1313
input wire clk;
14+
input wire nrst;
1415
input wire [(WIDTH-1):0] in;
1516
output wire [(WIDTH-1):0] out;
1617

@@ -20,11 +21,16 @@ parameter WIDTH = 1; // independent channels
2021
(* keep = "true" *) reg [(LENGTH*WIDTH-1):0] data = 0;
2122

2223
always @ (posedge clk) begin
23-
data[(LENGTH*WIDTH-1):0] << WIDTH;
24-
data[(WIDTH-1):0] <= in[(WIDTH-1):0];
24+
if (~nrst) begin
25+
data[(LENGTH*WIDTH-1):0] <= 0;
26+
end
27+
else begin
28+
data[(LENGTH*WIDTH-1):0] <= data[(LENGTH*WIDTH-1):0] << WIDTH;
29+
data[(WIDTH-1):0] <= in[(WIDTH-1):0];
30+
end
2531
end
2632

2733
assign
28-
out[(WIDTH-1):0] = data[(LENGTH*WIDTH-1):(((LENGTH-1)*WIDTH)];
34+
out[(WIDTH-1):0] = data[(LENGTH*WIDTH-1):((LENGTH-1)*WIDTH)];
2935

3036
endmodule

0 commit comments

Comments
 (0)