URL
https://opencores.org/ocsvn/ha1588/ha1588/trunk
Subversion Repositories ha1588
Compare Revisions
- This comparison shows the changes necessary to convert path
/ha1588
- from Rev 9 to Rev 10
- ↔ Reverse comparison
Rev 9 → Rev 10
/trunk/rtl/tsu/ptp_parser.v
2,92 → 2,168
|
module ptp_parser ( |
input clk, rst, |
input [31:0] ptp_data, |
input ptp_valid, |
input ptp_sop, |
input ptp_eop, |
input [ 1:0] ptp_mod, |
input [31:0] ptp_time, |
input [31:0] int_data, |
input int_valid, |
input int_sop, |
input int_eop, |
input [ 1:0] int_mod, |
input [31:0] sop_time, |
|
output reg ptp_found, |
output reg [51:0] ptp_infor |
); |
|
reg [31:0] ptp_data_d1; |
reg ptp_valid_d1; |
reg ptp_sop_d1; |
reg ptp_eop_d1; |
reg [ 1:0] ptp_mod_d1; |
reg [31:0] int_data_d1; |
reg int_valid_d1; |
reg int_sop_d1; |
reg int_eop_d1; |
reg [ 1:0] int_mod_d1; |
always @(posedge rst or posedge clk) begin |
if (rst) begin |
ptp_data_d1 <= 32'h00000000; |
ptp_valid_d1 <= 1'b0; |
ptp_sop_d1 <= 1'b0; |
ptp_eop_d1 <= 1'b0; |
ptp_mod_d1 <= 2'b00; |
int_data_d1 <= 32'h00000000; |
int_valid_d1 <= 1'b0; |
int_sop_d1 <= 1'b0; |
int_eop_d1 <= 1'b0; |
int_mod_d1 <= 2'b00; |
end |
else begin |
if (ptp_valid) begin |
ptp_data_d1 <= ptp_data; |
ptp_mod_d1 <= ptp_mod; |
if (int_valid) begin |
int_data_d1 <= int_data; |
int_mod_d1 <= int_mod; |
end |
ptp_valid_d1 <= ptp_valid; |
ptp_sop_d1 <= ptp_sop; |
ptp_eop_d1 <= ptp_eop; |
int_valid_d1 <= int_valid; |
int_sop_d1 <= int_sop; |
int_eop_d1 <= int_eop; |
end |
end |
|
reg [ 9:0] ptp_cnt; |
reg ptp_vlan, ptp_ip, ptp_udp, ptp_port, ptp_event; |
reg [ 9:0] int_cnt, bypass_ipv4_cnt, bypass_ipv6_cnt, bypass_udp_cnt, ptp_cnt; |
reg bypass_vlan, ptp_l2, bypass_ipv4, bypass_ipv6, found_udp, bypass_udp, ptp_l4, ptp_event; |
reg [ 3:0] ptp_msgid; |
reg [15:0] ptp_seqid; |
always @(posedge rst or posedge clk) begin |
if (rst) |
ptp_cnt <= 10'd0; |
else |
if (ptp_valid && ptp_sop) |
ptp_cnt <= 10'd0; |
else if (ptp_valid) |
ptp_cnt <= ptp_cnt + 10'd1 - ptp_vlan; |
if (rst) begin |
int_cnt <= 10'd0; |
bypass_ipv4_cnt <= 10'd0; |
bypass_udp_cnt <= 10'd0; |
end |
else begin |
if (int_valid_d1 && int_sop_d1) |
int_cnt <= 10'd0; |
else if (int_valid_d1) |
int_cnt <= int_cnt + 10'd1 - bypass_vlan - (bypass_ipv4 || bypass_udp); |
|
if (int_valid_d1 && int_sop_d1) |
bypass_ipv4_cnt <= 10'd0; |
else if (int_valid_d1 && bypass_ipv4) |
bypass_ipv4_cnt <= bypass_ipv4_cnt + 10'd1; |
|
if (int_valid_d1 && int_sop_d1) |
bypass_udp_cnt <= 10'd0; |
else if (int_valid_d1 && bypass_udp) |
bypass_udp_cnt <= bypass_udp_cnt + 10'd1; |
end |
end |
|
always @(posedge rst or posedge clk) begin |
if (rst) begin |
ptp_vlan <= 1'b0; |
ptp_ip <= 1'b0; |
ptp_udp <= 1'b0; |
ptp_port <= 1'b0; |
bypass_vlan <= 1'b0; |
bypass_ipv4 <= 1'b0; |
found_udp <= 1'b0; |
bypass_udp <= 1'b0; |
ptp_l2 <= 1'b0; |
ptp_l4 <= 1'b0; |
ptp_event <= 1'b0; |
end |
else if (int_valid_d1 && int_sop_d1) begin |
bypass_vlan <= 1'b0; |
bypass_ipv4 <= 1'b0; |
found_udp <= 1'b0; |
bypass_udp <= 1'b0; |
ptp_l2 <= 1'b0; |
ptp_l4 <= 1'b0; |
ptp_event <= 1'b0; |
end |
else begin |
// bypass vlan |
// ether_type == cvlan |
if (int_valid_d1 && int_cnt==10'd3 && int_data_d1[31:16]==16'h8100) |
bypass_vlan <= 1'b1; |
else |
bypass_vlan <= 1'b0; |
// ether_type == svlan |
// TO BE ADDED HERE |
|
// bypass ipv4 |
// ether_type == ip, ip_version == 4 |
if (int_valid_d1 && int_cnt==10'd3 && bypass_ipv4_cnt==10'd0 && |
int_data_d1[31:16]==16'h0800 && int_data_d1[15:12]==4'h4) |
bypass_ipv4 <= 1'b1; |
else if (int_valid_d1 && bypass_ipv4_cnt==10'd4) |
bypass_ipv4 <= 1'b0; |
|
// bypass ipv6 |
// ether_type == ip, ip_version == 6 |
// TO BE ADDED HERE |
|
// check if it is UDP |
// ipv4_protocol == udp |
if (int_valid_d1 && bypass_ipv4_cnt==10'd1 && int_data_d1[ 7: 0]== 8'h11) |
found_udp <= 1'b1; |
// ipv6_protocol == udp |
// TO BE ADDED HERE |
|
// bypass udp |
// ipv4_udp |
if (int_valid_d1 && bypass_ipv4_cnt==10'd4 && bypass_udp_cnt==10'd0 && found_udp) |
bypass_udp <= 1'b1; |
else if (int_valid_d1 && bypass_udp_cnt==10'd2) |
bypass_udp <= 1'b0; |
// ipv6_udp |
// TO BE ADDED HERE |
|
// check if it is L2 PTP |
// ether_type == ptp |
if (int_valid_d1 && int_cnt==10'd3 && int_data_d1[31:16]==16'h88F7) |
ptp_l2 <= 1'b1; |
// check if it is L4 PTP |
// ipv4_udp_dest_port == ptp_event |
if (int_valid_d1 && bypass_udp_cnt==10'd0 && bypass_udp && int_data_d1[31:16]==16'h013f) |
ptp_l4 <= 1'b1; |
// ipv6_udp_dest_port == ptp_event |
// TO BE ADDED HERE |
|
// check if it is PTP Event message |
if (int_valid_d1 && int_cnt==10'd3 && int_data_d1[31:16]==16'h88F7 && (int_data_d1[11: 8]== 4'h0 || int_data_d1[11:8]==4'h2)) |
// ptp_message_id == sync || delay_req |
ptp_event <= 1'b1; |
else if (int_valid_d1 && int_cnt==10'd4 && bypass_udp_cnt==10'd1 && ptp_l4 && (int_data_d1[11: 8]== 4'h0 || int_data_d1[11:8]==4'h2)) |
// ptp_message_id == sync || delay_req |
ptp_event <= 1'b1; |
end |
end |
|
always @(posedge rst or posedge clk) begin |
if (rst) begin |
ptp_msgid <= 4'd0; |
ptp_seqid <= 16'd0; |
end |
else if (ptp_valid_d1 && ptp_sop_d1) begin |
ptp_vlan <= 1'b0; |
ptp_ip <= 1'b0; |
ptp_udp <= 1'b0; |
ptp_port <= 1'b0; |
ptp_event <= 1'b0; |
else if (int_valid_d1 && int_sop_d1) begin |
ptp_msgid <= 4'd0; |
ptp_seqid <= 16'd0; |
end |
else begin |
if (ptp_valid_d1 && ptp_cnt==10'd4) // ether_type == vlan |
ptp_vlan <= ( ptp_data_d1[31:16]==16'h8100); |
else |
ptp_vlan <= 1'b0; |
if (ptp_valid_d1 && ptp_cnt==10'd4) // ether_type == ip |
ptp_ip <= ( ptp_data_d1[31:16]==16'h0800); |
if (ptp_valid_d1 && ptp_cnt==10'd6) // ip_type == udp |
ptp_udp <= ( ptp_data_d1[ 7: 0]== 8'h11 && ptp_ip); |
if (ptp_valid_d1 && ptp_cnt==10'd10) // udp_dest_port == ptp_event |
ptp_port <= ( ptp_data_d1[31:16]==16'h013f && ptp_udp); |
if (ptp_valid_d1 && ptp_cnt==10'd11) // ptp_message_id == sync || delay_req |
ptp_event <= ((ptp_data_d1[11: 8]== 4'h0 || ptp_data_d1[11:8]==4'h2) && ptp_port); |
|
if (ptp_valid_d1 && ptp_cnt==10'd11) // ptp_sequence_id |
ptp_msgid <= ptp_data_d1[11: 8]; |
if (ptp_valid_d1 && ptp_cnt==10'd19) // ptp_sequence_id |
ptp_seqid <= ptp_data_d1[31:16]; |
// get PTP identification information as additional information to Timestamp |
// message id |
if (int_valid_d1 && int_cnt==10'd3 && int_data_d1[31:16]==16'h88F7) |
ptp_msgid <= int_data_d1[11: 8]; |
else if (int_valid_d1 && int_cnt==10'd4 && bypass_udp_cnt==10'd1 && ptp_l4) |
ptp_msgid <= int_data_d1[11: 8]; |
// sequence id |
if (int_valid_d1 && int_cnt==10'd11 && ptp_l2) |
ptp_seqid <= int_data_d1[31:16]; |
else if (int_valid_d1 && int_cnt==10'd10 && ptp_l4) |
ptp_seqid <= int_data_d1[31:16]; |
end |
end |
|
96,13 → 172,13
ptp_found <= 1'b0; |
ptp_infor <= 52'd0; |
end |
else if (ptp_valid_d1 && ptp_sop_d1) begin |
else if (int_valid_d1 && int_sop_d1) begin |
ptp_found <= 1'b0; |
ptp_infor <= 52'd0; |
end |
else if (ptp_valid_d1 && ptp_eop_d1) begin |
else if (int_valid_d1 && int_eop_d1) begin |
ptp_found <= ptp_event; |
ptp_infor <= {ptp_seqid, ptp_msgid, ptp_time}; // 16+4+32 |
ptp_infor <= {ptp_seqid, ptp_msgid, sop_time}; // 16+4+32 |
end |
else begin |
ptp_found <= 1'b0; |
/trunk/rtl/tsu/tsu_queue.v
166,12 → 166,12
ptp_parser parser( |
.clk(gmii_clk), |
.rst(rst), |
.ptp_data(int_data), |
.ptp_valid(int_valid), |
.ptp_sop(int_sop), |
.ptp_eop(int_eop), |
.ptp_mod(int_mod), |
.ptp_time(gmii_time_stamp), |
.int_data(int_data), |
.int_valid(int_valid), |
.int_sop(int_sop), |
.int_eop(int_eop), |
.int_mod(int_mod), |
.sop_time(gmii_time_stamp), |
.ptp_found(ptp_found), |
.ptp_infor(ptp_infor) |
); |
/trunk/doc/ptpv1.pcap
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
trunk/doc/ptpv1.pcap
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/doc/ptpv2.pcap
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/doc/ptpv2.pcap
===================================================================
--- trunk/doc/ptpv2.pcap (nonexistent)
+++ trunk/doc/ptpv2.pcap (revision 10)
trunk/doc/ptpv2.pcap
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/sim/tsu/wave.do
===================================================================
--- trunk/sim/tsu/wave.do (revision 9)
+++ trunk/sim/tsu/wave.do (revision 10)
@@ -20,18 +20,21 @@
add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/int_data
add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/int_mod
add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Literal -radix unsigned /tsu_queue_tb/DUT_RX/parser/ptp_cnt
+add wave -noupdate -format Literal -radix unsigned /tsu_queue_tb/DUT_RX/parser/int_cnt
+add wave -noupdate -format Literal -radix unsigned /tsu_queue_tb/DUT_RX/parser/bypass_ipv4_cnt
+add wave -noupdate -format Literal -radix unsigned /tsu_queue_tb/DUT_RX/parser/bypass_udp_cnt
add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_valid_d1
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_sop_d1
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_eop_d1
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/ptp_mod_d1
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/ptp_data_d1
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/int_valid_d1
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/int_sop_d1
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/int_eop_d1
+add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/int_mod_d1
+add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/int_data_d1
add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_vlan
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_ip
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_udp
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_port
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/bypass_vlan
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/bypass_ipv4
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/bypass_udp
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_l2
+add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_l4
add wave -noupdate -format Logic /tsu_queue_tb/DUT_RX/parser/ptp_event
add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/ptp_msgid
add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/ptp_seqid
@@ -40,28 +43,9 @@
add wave -noupdate -format Literal /tsu_queue_tb/DUT_RX/parser/ptp_infor
add wave -noupdate -divider {New Divider}
add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Literal -radix unsigned /tsu_queue_tb/DUT_TX/parser/ptp_cnt
-add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_valid_d1
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_sop_d1
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_eop_d1
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_TX/parser/ptp_mod_d1
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_TX/parser/ptp_data_d1
-add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_vlan
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_ip
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_udp
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_port
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_event
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_TX/parser/ptp_msgid
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_TX/parser/ptp_seqid
-add wave -noupdate -divider {New Divider}
-add wave -noupdate -format Logic /tsu_queue_tb/DUT_TX/parser/ptp_found
-add wave -noupdate -format Literal /tsu_queue_tb/DUT_TX/parser/ptp_infor
-add wave -noupdate -divider {New Divider}
TreeUpdate [SetDefaultTree]
-WaveRestoreCursors {{Cursor 1} {21230000 ps} 0}
-configure wave -namecolwidth 307
+WaveRestoreCursors {{Cursor 1} {629901 ps} 0}
+configure wave -namecolwidth 188
configure wave -valuecolwidth 165
configure wave -justifyvalue left
configure wave -signalnamewidth 0
@@ -75,4 +59,4 @@
configure wave -timeline 0
configure wave -timelineunits ns
update
-WaveRestoreZoom {16852432 ps} {30375568 ps}
+WaveRestoreZoom {169911 ps} {813489 ps}