OpenCores
URL https://opencores.org/ocsvn/ha1588/ha1588/trunk

Subversion Repositories ha1588

[/] [ha1588/] [trunk/] [rtl/] [top/] [ha1588.v] - Blame information for rev 70

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 edn_walter
/*
2 38 edn_walter
 * ha1588.v
3 34 edn_walter
 *
4 37 edn_walter
 * Copyright (c) 2012, BABY&HW. All rights reserved.
5 34 edn_walter
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301  USA
20
 */
21
 
22 18 edn_walter
`timescale 1ns/1ns
23
 
24 39 edn_walter
// TODO: add define to generate rtc only or tsu only.
25
 
26 18 edn_walter
module ha1588 (
27
  input         rst,clk,
28
  input         wr_in,rd_in,
29 21 edn_walter
  input  [ 7:0] addr_in,
30 18 edn_walter
  input  [31:0] data_in,
31
  output [31:0] data_out,
32
 
33 32 edn_walter
  input         rtc_clk,
34
  output [31:0] rtc_time_ptp_ns,
35
  output [47:0] rtc_time_ptp_sec,
36 58 edn_walter
  output        rtc_time_one_pps,
37 18 edn_walter
 
38
  input       rx_gmii_clk,
39
  input       rx_gmii_ctrl,
40
  input [7:0] rx_gmii_data,
41 54 edn_walter
  input       rx_giga_mode,
42 39 edn_walter
 
43 18 edn_walter
  input       tx_gmii_clk,
44
  input       tx_gmii_ctrl,
45 54 edn_walter
  input [7:0] tx_gmii_data,
46
  input       tx_giga_mode
47 18 edn_walter
);
48
 
49 48 edn_walter
parameter addr_is_in_word = 0;
50
wire [ 5: 0] word_addr_in;
51
wire [ 7: 0] byte_addr_in;
52
generate
53
  if (addr_is_in_word)
54
    assign word_addr_in = addr_in[ 5: 0];
55
  else
56
    assign word_addr_in = addr_in[ 7: 2];
57
endgenerate
58
assign byte_addr_in = {word_addr_in, 2'b00};
59
 
60 18 edn_walter
wire rtc_rst;
61 41 edn_walter
wire rtc_time_ld, rtc_period_ld, rtc_adj_ld, adj_ld_done;
62 18 edn_walter
wire [37:0] rtc_time_reg_ns;
63
wire [47:0] rtc_time_reg_sec;
64
wire [39:0] rtc_period;
65
wire [31:0] rtc_adj_ld_data;
66
wire [39:0] rtc_period_adj;
67
wire [37:0] rtc_time_reg_ns_val;
68
wire [47:0] rtc_time_reg_sec_val;
69 32 edn_walter
wire [79:0] rtc_time_ptp_val = {rtc_time_ptp_sec[47:0], rtc_time_ptp_ns[31:0]};
70 18 edn_walter
 
71
wire rx_q_rst, rx_q_clk;
72
wire rx_q_rd_en;
73 43 edn_walter
wire [  7:0] rx_q_ptp_msgid_mask;
74 37 edn_walter
wire [  7:0] rx_q_stat;
75
wire [127:0] rx_q_data;
76 18 edn_walter
wire tx_q_rst, tx_q_clk;
77
wire tx_q_rd_en;
78 43 edn_walter
wire [  7:0] tx_q_ptp_msgid_mask;
79 37 edn_walter
wire [  7:0] tx_q_stat;
80
wire [127:0] tx_q_data;
81 18 edn_walter
 
82
rgs u_rgs
83
(
84
  .rst(rst),
85
  .clk(clk),
86
  .wr_in(wr_in),
87
  .rd_in(rd_in),
88 48 edn_walter
  .addr_in(byte_addr_in),
89 18 edn_walter
  .data_in(data_in),
90
  .data_out(data_out),
91
  .rtc_clk_in(rtc_clk),
92
  .rtc_rst_out(rtc_rst),
93
  .time_ld_out(rtc_time_ld),
94
  .time_reg_ns_out(rtc_time_reg_ns),
95
  .time_reg_sec_out(rtc_time_reg_sec),
96
  .period_ld_out(rtc_period_ld),
97
  .period_out(rtc_period),
98
  .adj_ld_out(rtc_adj_ld),
99
  .adj_ld_data_out(rtc_adj_ld_data),
100
  .period_adj_out(rtc_period_adj),
101 38 edn_walter
  .adj_ld_done_in(adj_ld_done),
102 18 edn_walter
  .time_reg_ns_in(rtc_time_reg_ns_val),
103
  .time_reg_sec_in(rtc_time_reg_sec_val),
104
  .rx_q_rst_out(rx_q_rst),
105
  .rx_q_rd_clk_out(rx_q_clk),
106
  .rx_q_rd_en_out(rx_q_rd_en),
107 43 edn_walter
  .rx_q_ptp_msgid_mask_out(rx_q_ptp_msgid_mask),
108 18 edn_walter
  .rx_q_stat_in(rx_q_stat),
109
  .rx_q_data_in(rx_q_data),
110
  .tx_q_rst_out(tx_q_rst),
111
  .tx_q_rd_clk_out(tx_q_clk),
112
  .tx_q_rd_en_out(tx_q_rd_en),
113 43 edn_walter
  .tx_q_ptp_msgid_mask_out(tx_q_ptp_msgid_mask),
114 18 edn_walter
  .tx_q_stat_in(tx_q_stat),
115
  .tx_q_data_in(tx_q_data)
116
);
117
 
118
rtc u_rtc
119
(
120
  .rst(rtc_rst),
121
  .clk(rtc_clk),
122
  .time_ld(rtc_time_ld),
123
  .time_reg_ns_in(rtc_time_reg_ns),
124
  .time_reg_sec_in(rtc_time_reg_sec),
125
  .period_ld(rtc_period_ld),
126
  .period_in(rtc_period),
127
  .adj_ld(rtc_adj_ld),
128
  .adj_ld_data(rtc_adj_ld_data),
129 38 edn_walter
  .adj_ld_done(adj_ld_done),
130 18 edn_walter
  .period_adj(rtc_period_adj),
131
  .time_reg_ns(rtc_time_reg_ns_val),
132 32 edn_walter
  .time_reg_sec(rtc_time_reg_sec_val),
133 58 edn_walter
  .time_one_pps(rtc_time_one_pps),
134 32 edn_walter
  .time_ptp_ns(rtc_time_ptp_ns),
135
  .time_ptp_sec(rtc_time_ptp_sec)
136 18 edn_walter
);
137
 
138
tsu u_rx_tsu
139
(
140
  .rst(rst),
141
  .gmii_clk(rx_gmii_clk),
142
  .gmii_ctrl(rx_gmii_ctrl),
143
  .gmii_data(rx_gmii_data),
144 54 edn_walter
  .giga_mode(rx_giga_mode),
145 43 edn_walter
  .ptp_msgid_mask(rx_q_ptp_msgid_mask),
146 18 edn_walter
  .rtc_timer_clk(rtc_clk),
147 32 edn_walter
  .rtc_timer_in(rtc_time_ptp_val),
148 18 edn_walter
  .q_rst(rx_q_rst),
149
  .q_rd_clk(rx_q_clk),
150
  .q_rd_en(rx_q_rd_en),
151
  .q_rd_stat(rx_q_stat),
152
  .q_rd_data(rx_q_data)
153
);
154
 
155
tsu u_tx_tsu
156
(
157
  .rst(rst),
158
  .gmii_clk(tx_gmii_clk),
159
  .gmii_ctrl(tx_gmii_ctrl),
160
  .gmii_data(tx_gmii_data),
161 54 edn_walter
  .giga_mode(tx_giga_mode),
162 43 edn_walter
  .ptp_msgid_mask(tx_q_ptp_msgid_mask),
163 18 edn_walter
  .rtc_timer_clk(rtc_clk),
164 32 edn_walter
  .rtc_timer_in(rtc_time_ptp_val),
165 18 edn_walter
  .q_rst(tx_q_rst),
166
  .q_rd_clk(tx_q_clk),
167
  .q_rd_en(tx_q_rd_en),
168
  .q_rd_stat(tx_q_stat),
169
  .q_rd_data(tx_q_data)
170
);
171
 
172
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.