📄 gigabitber_rx.v
字号:
/////////////////////////////////////////////////////////////////////////////////// File Name: GigabitBER_RX.v// Version: 2.2// Date: 05/14/03// Model: Reciever Core for the Bit Error Rate Tester.// GigabitBER_RX recieves a bit stream sent by a GigabitBER_TX,// analyzing the stream for errors. The reciever attempts to// synchronize the pattern generator in the transmitter with// its own pattern generator.// The reciever has two resets. The first is generated from the// reset_in port. This reset clears the counters and resets the// state machine that looks for long strings of commas from the// transmitter. The second reset is generated when a long string// of commas is detected. This reset is used to synchronize the// pattern generators in the reciever and the transmitter.//// Company: Xilinx, Inc.// Contributor: Mike Matera//// Disclaimer: XILINX IS PROVIDING THIS DESIGN, CODE, OR// INFORMATION "AS IS" SOLELY FOR USE IN DEVELOPING// PROGRAMS AND SOLUTIONS FOR XILINX DEVICES. BY// PROVIDING THIS DESIGN, CODE, OR INFORMATION AS// ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,// APPLICATION OR STANDARD, XILINX IS MAKING NO// REPRESENTATION THAT THIS IMPLEMENTATION IS FREE// FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE// RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY// REQUIRE FOR YOUR IMPLEMENTATION. XILINX// EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH// RESPECT TO THE ADEQUACY OF THE IMPLEMENTATION,// INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR// REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR// PURPOSE.//// (c) Copyright 2003 Xilinx, Inc.// All rights reserved./////////////////////////////////////////////////////////////////////////////////`ifdef GIGABITBER_RX `else `define GIGABITBER_RX`timescale 100ps/10ps //-------------------------------------------------------------// // Constant Summary://// SCIENTIFIC: // Defined enables logic to measure the error figure.//// RX_INIT_COUNTER_MSB: // Number of bits in the comma stream counter. This controls// the number of cycles that comma is received before// resetting the pattern follower.//// TOTAL_FRAMES_MSB: // Number of bits in the total frames counter. Larger values// allow for greater test times. //// DROPPED_FRAMES_MSB: // Number of bits in the total frames counter. Larger values// allow for measurement of higher bit error rates. ////-------------------------------------------------------------module GigabitBER_RX( data_in, comma_detect_in, en_comma_align_out, total_frames_out, dropped_frames_out, error_figure_out, search_out, link_out, error_out, abort_out, bec_count_out, overflow_flag, pattern_select_in, reset_in, clock_in, data_to_chipscope); //------------------------------------------------------------- // // Port Summary: // // data_in[19:00] (synchronous: clock_in) // Data from the MGT. // // comma_detect_in (synchronous: clock_in) // Connected to the RXCOMMADET port of the MGT. This signal // is used to identify commas in the bit stream. It is // generated correctly wether or not the stream is properly // aligned. // // en_comma_align_out (synchronous: clock_in) // Connected to the ENPCOMMAALIGN port of the MGT. This // signal is high during the initialization phase of the // reciever. Otherwise it is low so that random data does // not cause realignment. // // total_frames_out[`TOTAL_FRAMES_MSB:00] (synchronous: clock_in) // Total frames received. // // dropped_frames_out[`DROPPED_FRAMES_MSB:00] (synchronous: clock_in) // Total frames received with error. // // error_figure_out[`TOTAL_FRAMES_MSB:00] (synchronous: clock_in) // Shortest interval between consecutive errors. This // number is important for good calculation of a bit // error rate. // // search_out (synchronous: clock_in) // High indicating the receiver is waiting to establish link. // // link_out (synchronous: clock_in) // High indicating the receiver has established a link. // // error_out (synchronous: clock_in) // High indicating a bit error has caused dropped_frames_out // to increment. // // abort_out (synchronous: clock_in) // High when the reciever has abandoned the test due to bit // errors. This condition can only be cleared by the // receipt of a comma stream. (reset_in won't do it). // // bec_count_out (synchronous: clock_in) // Total number of bit errors. // // overflow_flag (synchronous: clock_in) // Overflow flag indicating the overflow of bit error counter. // // pattern_select_in[03:00] (synchronous: clock_in) // Selects which PRBS Pattern to use. // // reset_in (synchronous: clock_in) // Reset for the counters and the comma detect logic. // // clock_in (clock: buffered) // Reciever clock. This clock must also be connected to // RXUSRCLK on the MGT. // //------------------------------------------------------------- output [`DROPPED_FRAMES_MSB:00] dropped_frames_out; output [`TOTAL_FRAMES_MSB:00] total_frames_out, error_figure_out; output search_out, link_out, error_out, abort_out, en_comma_align_out; output overflow_flag; output [31:00] bec_count_out; output [40:00] data_to_chipscope; input [19:00] data_in; input [03:00] pattern_select_in; input reset_in, clock_in, comma_detect_in; reg [`TOTAL_FRAMES_MSB:00] total_frames_out; reg [`DROPPED_FRAMES_MSB:00] dropped_frames_out; reg [31:00] bec_count; reg [31:00] bec_count_out_del; reg overflow_flag; wire [31:00] bec_count_out; wire Armed, Locked, Distress, Abort, FoundCommaStream, CommaStrobe, frame_advance, error_advance; wire [31:00] errored_bits; assign search_out = Armed; assign link_out = Locked | Distress; assign error_out = Distress; assign abort_out = Abort; assign en_comma_align_out = FoundCommaStream; assign frame_advance = link_out | error_out; CommaStream comma_comp ( .remote_reset_out(FoundCommaStream), .comma_detect_in(comma_detect_in), .reset_in(link_out), .clock_in(clock_in) ); RisingEdgeDetect strobe_comp ( .rising_edge_out(CommaStrobe), .sig_in(FoundCommaStream), .clock_in(clock_in) ); PatternFollower expected_comp ( .data_in(data_in), .armed_out(Armed), .errored_bits(errored_bits), .locked_out(Locked), .distress_out(Distress), .abort_out(Abort), .bit_error_out(error_advance), .pattern_select_in(pattern_select_in), .data_to_chipscope(data_to_chipscope), .reset_in(CommaStrobe), .clock_in(clock_in) ); // Total Frames always @ (posedge clock_in) begin if (reset_in) total_frames_out <= 0; else if (frame_advance) total_frames_out <= total_frames_out + 1; end // Errors always @ (posedge clock_in) begin if (reset_in) dropped_frames_out <= 0; else if (error_advance) dropped_frames_out <= dropped_frames_out + 1; end // Bit Error Count always @ (posedge clock_in) begin if (reset_in) begin bec_count <= 32'd0; overflow_flag <= 1'b0; end else begin if (bec_count_out_del > bec_count) overflow_flag <= 1'b1; if (error_advance == 1'b1) begin bec_count <= bec_count + errored_bits; end end end always @ (posedge clock_in) begin if (reset_in) begin bec_count_out_del <= 32'd0; end else begin bec_count_out_del <= bec_count; end end assign bec_count_out = bec_count;`ifdef SCIENTIFIC reg [`TOTAL_FRAMES_MSB:00] error_figure_out, last_error_interval, last_error_interval_d1; reg update_figure; // Update Figure always @ (posedge clock_in) begin update_figure <= error_advance & (last_error_interval < error_figure_out); end // Error Interval always @ (posedge clock_in) begin if (error_advance) last_error_interval <= 0; else last_error_interval <= last_error_interval + 1; last_error_interval_d1 <= last_error_interval; end // Error Figure always @ (posedge clock_in) begin if (reset_in) error_figure_out <= 40'hFFFFFFFFFF; else if (update_figure) error_figure_out <= last_error_interval_d1; end`else assign error_figure_out = 0;`endif endmodulemodule CommaStream ( remote_reset_out, comma_detect_in, reset_in, clock_in ); output remote_reset_out; input comma_detect_in; input reset_in, clock_in; parameter ARMED_STATE = 3'b10, COMMA_STATE = 3'b01; reg [`RX_INIT_COUNTER_MSB:00] CommaCounter, CommaCounter__next; reg [01:00] MachineState, MachineState__next; wire armed_bit, comma_bit; assign {armed_bit, comma_bit} = MachineState; assign remote_reset_out = comma_bit; always @ (comma_detect_in or MachineState or CommaCounter) begin MachineState__next <= MachineState; CommaCounter__next <= CommaCounter; case (MachineState) ARMED_STATE: begin if (comma_detect_in) begin CommaCounter__next <= CommaCounter + 1; if (CommaCounter[`RX_INIT_COUNTER_MSB]) MachineState__next <= COMMA_STATE; end else CommaCounter__next <= 0; end COMMA_STATE: begin if (~comma_detect_in) begin CommaCounter__next <= CommaCounter + 1; if (~CommaCounter[`RX_INIT_COUNTER_MSB]) MachineState__next <= ARMED_STATE; end else begin CommaCounter__next <= {1'b1,`RX_INIT_COUNTER_MSB-1'b0,1'b1}; MachineState__next <= COMMA_STATE; end end default: begin MachineState__next <= ARMED_STATE; CommaCounter__next <= 0; end endcase end always @ (posedge clock_in) begin if (reset_in) begin MachineState <= ARMED_STATE; CommaCounter <= 0; end else begin MachineState <= MachineState__next; CommaCounter <= CommaCounter__next; end endendmodule`endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -