File tree Expand file tree Collapse file tree 4 files changed +50
-50
lines changed Expand file tree Collapse file tree 4 files changed +50
-50
lines changed Original file line number Diff line number Diff line change 1
- // --------------------------------------------------------------------------------
1
+ // ------------------------------------------------------------------------------
2
2
// ClkDivider.sv
3
3
// Konstantin Pavlov, pavlovconst@gmail.com
4
- // --------------------------------------------------------------------------------
4
+ // ------------------------------------------------------------------------------
5
5
6
- // INFO --------------------------------------------------------------------------------
6
+ // INFO ------------------------------------------------------------------------
7
7
// Divides main clock to get derivative slower synchronous clocks
8
8
9
9
@@ -30,11 +30,11 @@ module ClkDivider #(
30
30
31
31
32
32
always_ff @ (posedge clk) begin
33
- if ( ~ nrst ) begin
34
- out[(WIDTH - 1 ): 0 ] <= 0 ;
35
- end else begin
36
- out[(WIDTH - 1 ): 0 ] <= out[(WIDTH - 1 ): 0 ] + 1'b1 ;
37
- end
33
+ if ( ~ nrst ) begin
34
+ out[(WIDTH - 1 ): 0 ] <= 0 ;
35
+ end else begin
36
+ out[(WIDTH - 1 ): 0 ] <= out[(WIDTH - 1 ): 0 ] + 1'b1 ;
37
+ end
38
38
end
39
39
40
40
endmodule
Original file line number Diff line number Diff line change 1
- // --------------------------------------------------------------------------------
1
+ // ------------------------------------------------------------------------------
2
2
// ClkDivider.v
3
3
// Konstantin Pavlov, pavlovconst@gmail.com
4
- // --------------------------------------------------------------------------------
4
+ // ------------------------------------------------------------------------------
5
5
6
- // INFO --------------------------------------------------------------------------------
7
- // Divides main clock to get derivative slower synchronous clocks
6
+ // INFO ------------------------------------------------------------------------
7
+ // Divides main clock to get derivative slower synchronous clocks
8
+ // See ClkDivider.sv file for SystemVerilog version of this module
8
9
9
10
10
11
/* --- INSTANTIATION TEMPLATE BEGIN ---
@@ -28,12 +29,12 @@ output reg [(WIDTH-1):0] out = 0;
28
29
parameter WIDTH = 32 ;
29
30
30
31
always @ (posedge clk) begin
31
- if (~ nrst) begin
32
- out[(WIDTH- 1 ):0 ] <= 0 ;
33
- end
34
- else begin
35
- out[(WIDTH- 1 ):0 ] <= out[(WIDTH- 1 ):0 ] + 1'b1 ;
36
- end
32
+ if (~ nrst) begin
33
+ out[(WIDTH- 1 ):0 ] <= 0 ;
34
+ end
35
+ else begin
36
+ out[(WIDTH- 1 ):0 ] <= out[(WIDTH- 1 ):0 ] + 1'b1 ;
37
+ end
37
38
end
38
39
39
- endmodule
40
+ endmodule
Original file line number Diff line number Diff line change 1
- // --------------------------------------------------------------------------------
1
+ // ------------------------------------------------------------------------------
2
2
// EdgeDetect.sv
3
3
// Konstantin Pavlov, pavlovconst@gmail.com
4
- // --------------------------------------------------------------------------------
4
+ // ------------------------------------------------------------------------------
5
5
6
- // INFO --------------------------------------------------------------------------------
7
- // Variable width edge detector
8
- // One tick propagation time
6
+ // INFO ------------------------------------------------------------------------
7
+ // Variable width edge detector
8
+ // Features one tick propagation time
9
9
10
10
11
11
/* --- INSTANTIATION TEMPLATE BEGIN ---
@@ -40,16 +40,16 @@ module EdgeDetect #(
40
40
logic [(WIDTH - 1 ): 0 ] in_prev = 0 ;
41
41
42
42
always_ff @ (posedge clk) begin
43
- if ( ~ nrst ) begin
44
- in_prev <= 0 ;
45
- rising <= 0 ;
46
- falling <= 0 ;
47
- end
48
- else begin
49
- in_prev <= in;
43
+ if ( ~ nrst ) begin
44
+ in_prev <= 0 ;
45
+ rising <= 0 ;
46
+ falling <= 0 ;
47
+ end
48
+ else begin
49
+ in_prev <= in;
50
50
rising[(WIDTH - 1 ): 0 ] <= in[(WIDTH - 1 ): 0 ] & ~ in_prev[(WIDTH - 1 ): 0 ];
51
51
falling[(WIDTH - 1 ): 0 ] <= ~ in[(WIDTH - 1 ): 0 ] & in_prev[(WIDTH - 1 ): 0 ];
52
- end
52
+ end
53
53
end
54
54
55
55
assign both[(WIDTH - 1 ): 0 ] = rising[(WIDTH - 1 ): 0 ] | falling[(WIDTH - 1 ): 0 ];
Original file line number Diff line number Diff line change 1
- // --------------------------------------------------------------------------------
1
+ // ------------------------------------------------------------------------------
2
2
// EdgeDetect.v
3
3
// Konstantin Pavlov, pavlovconst@gmail.com
4
- // --------------------------------------------------------------------------------
4
+ // ------------------------------------------------------------------------------
5
5
6
- // INFO --------------------------------------------------------------------------------
7
- // Simply edge detector
8
- // One tick propagation time
6
+ // INFO ------------------------------------------------------------------------
7
+ // Variable width edge detector
8
+ // One tick propagation time
9
+ // See EdgeDetect.sv file for SystemVerilog version of this module
9
10
10
11
11
12
/*EdgeDetect ED1 (
@@ -32,20 +33,18 @@ output wire [(WIDTH-1):0] both;
32
33
parameter WIDTH = 1 ;
33
34
34
35
reg [(WIDTH- 1 ):0 ] in_prev = 0 ;
35
-
36
+
36
37
always @ (posedge clk) begin
37
- if (~ nrst) begin
38
- in_prev <= 0 ;
39
-
40
- rising <= 0 ;
41
- falling <= 0 ;
42
- end
43
- else begin
44
- in_prev <= in;
45
-
46
- rising[(WIDTH- 1 ):0 ] <= in[(WIDTH- 1 ):0 ] & ~ in_prev[(WIDTH- 1 ):0 ];
47
- falling[(WIDTH- 1 ):0 ] <= ~ in[(WIDTH- 1 ):0 ] & in_prev[(WIDTH- 1 ):0 ];
48
- end
38
+ if ( ~ nrst ) begin
39
+ in_prev <= 0 ;
40
+ rising <= 0 ;
41
+ falling <= 0 ;
42
+ end
43
+ else begin
44
+ in_prev <= in;
45
+ rising[(WIDTH- 1 ):0 ] <= in[(WIDTH- 1 ):0 ] & ~ in_prev[(WIDTH- 1 ):0 ];
46
+ falling[(WIDTH- 1 ):0 ] <= ~ in[(WIDTH- 1 ):0 ] & in_prev[(WIDTH- 1 ):0 ];
47
+ end
49
48
end
50
49
51
50
assign
You can’t perform that action at this time.
0 commit comments