diff options
| author | Private Island Networks <opensource@privateisland.tech> | 2025-09-01 12:34:17 -0400 |
|---|---|---|
| committer | Private Island Networks <opensource@privateisland.tech> | 2025-09-01 12:34:17 -0400 |
| commit | c8b273c80abe98e53828f46079a187975938a56a (patch) | |
| tree | 410577af8067ee001ba473dcf0c7bcae46d83de1 /src/link_timer.v | |
| parent | ac2bbbd2f816c223ef4dcfa2f8440d9c0c73bffe (diff) | |
rename source to src
Diffstat (limited to 'src/link_timer.v')
| -rw-r--r-- | src/link_timer.v | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/link_timer.v b/src/link_timer.v new file mode 100644 index 0000000..7b501ff --- /dev/null +++ b/src/link_timer.v @@ -0,0 +1,67 @@ +/* + * link_timer.v + * + * Copyright 2020 Mind Chasers Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * function: Generate link timer pulse (1.6 and 10 ms) per SGMII and IEEE 802.3 + * + */ + +module link_timer( + input rstn, + input clk, // 125 MHz data clock + output pulse_1_6ms, + output pulse_10ms +); + + reg [13:0] cnt; // 0.1 ms counter + reg [3:0] cnt_1_6ms; + reg [6:0] cnt_10ms; + + // 0.1 ms counter + always @ (posedge clk or negedge rstn) + if ( !rstn ) + cnt <= 'd0; + else if (cnt == 'd12500) + cnt <= 'd0; + else + cnt <= cnt + 1; + + // 1.6 ms counter + always @ (posedge clk or negedge rstn) + if ( !rstn ) + cnt_1_6ms <= 'd0; + else if (cnt == 'd12500) + if (cnt_1_6ms == 'd16) + cnt_1_6ms <= 'd0; + else + cnt_1_6ms <= cnt_1_6ms + 1; + + assign pulse_1_6ms = (cnt == 'd12500 && cnt_1_6ms == 'd15); + + // 10 ms counter + always @ (posedge clk or negedge rstn) + if ( !rstn ) + cnt_10ms <= 'd0; + else if (cnt == 'd12500) + if (cnt_10ms == 'd99) + cnt_10ms <= 'd0; + else + cnt_10ms <= cnt_10ms + 1; + + assign pulse_10ms = (cnt == 'd12500 && cnt_10ms == 'd99); + + +endmodule
\ No newline at end of file |



