| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| module rtefi_center #( |
| parameter paw = 11, |
| parameter n_lat = 3, |
| parameter mac_aw = 10, |
| parameter handle_arp = 1, |
| parameter handle_icmp = 1, |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| parameter [31:0] ip = {8'd192, 8'd168, 8'd7, 8'd4}, |
| parameter [47:0] mac = 48'h12555500012d, |
| parameter udp_port0 = 7, |
| parameter udp_port1 = 801, |
| parameter udp_port2 = 802, |
| parameter udp_port3 = 803, |
| parameter udp_port4 = 0, |
| parameter udp_port5 = 0, |
| parameter udp_port6 = 0, |
| parameter udp_port7 = 0 |
| ) ( |
| |
| input rx_clk, |
| input [7:0] rxd, |
| input rx_dv, |
| input rx_er, |
| |
| input tx_clk, |
| output [7:0] txd, |
| output tx_en, |
| |
| |
| |
| input enable_rx, |
| input config_clk, |
| input [3:0] config_a, |
| input [7:0] config_d, |
| input config_s, |
| input config_p, |
| |
| |
| output [mac_aw - 1: 0] host_raddr, |
| input [15:0] host_rdata, |
| |
| input [mac_aw - 1: 0] buf_start_addr, |
| |
| input tx_mac_start, |
| output tx_mac_done, |
| |
| output [10:0] len_c, |
| output [6:0] raw_l, |
| output [6:0] raw_s, |
| output [7:0] idata, |
| input [7*8-1:0] mux_data_in, |
| |
| output [7:0] rx_mac_d, |
| output [11:0] rx_mac_a, |
| output rx_mac_wen, |
| |
| input rx_mac_hbank, |
| output [1:0] rx_mac_buf_status, |
| |
| input rx_mac_accept, |
| output [7:0] rx_mac_status_d, |
| output rx_mac_status_s, |
| |
| output ibadge_stb, |
| output [7:0] ibadge_data, |
| output obadge_stb, |
| output [7:0] obadge_data, |
| output xdomain_fault, |
| |
| output [3:0] scanner_debug, |
| output rx_mon, |
| output tx_mon, |
| |
| output in_use |
| ); |
|
|
| |
| reg [7:0] eth_in_r=0; |
| reg eth_in_s_r=0, eth_in_e_r=0; |
| always @(posedge rx_clk) begin |
| eth_in_r <= rxd; |
| eth_in_s_r <= rx_dv; |
| eth_in_e_r <= rx_er; |
| end |
|
|
| |
| wire [3:0] ip_a; reg [7:0] ip_d=0; |
| wire [3:0] pno_a; reg [7:0] pno_d=0; |
| wire [7:0] sdata; |
| wire scanner_busy; |
| wire sdata_s, sdata_l; |
| wire [10:0] pack_len; |
| wire [7:0] status_vec; wire status_valid; |
| scanner #(.handle_arp(handle_arp), .handle_icmp(handle_icmp)) a_scan( |
| .clk(rx_clk), |
| .eth_in(eth_in_r), .eth_in_s(eth_in_s_r), .eth_in_e(eth_in_e_r), |
| .enable_rx(enable_rx), |
| .ip_a(ip_a), .ip_d(ip_d), |
| .pno_a(pno_a), .pno_d(pno_d), |
| .busy(scanner_busy), .debug(scanner_debug), |
| .odata(sdata), .odata_s(sdata_s), .odata_f(sdata_l), |
| .pack_len(pack_len), .status_vec(status_vec), .status_valid(status_valid) |
| ); |
| assign rx_mac_status_d = status_vec; |
| assign rx_mac_status_s = status_valid; |
| `ifdef SIMULATE |
| |
| `endif |
|
|
| |
| wire [paw-1:0] pbuf_a_rx, gray_state; |
| wire [8:0] pbuf_din; |
| pbuf_writer #(.paw(paw)) b_write(.clk(rx_clk), |
| .data_in(sdata), .data_s(sdata_s), .data_f(sdata_l), |
| .pack_len(pack_len), .status_vec(status_vec), .status_valid(status_valid), |
| .mem_a(pbuf_a_rx), .mem_d(pbuf_din), |
| .rx_mac_d(rx_mac_d), .rx_mac_a(rx_mac_a), .rx_mac_wen(rx_mac_wen), |
| .rx_mac_hbank(rx_mac_hbank), .rx_mac_buf_status(rx_mac_buf_status), |
| .rx_mac_accept(rx_mac_accept), |
| .gray_state(gray_state), |
| .badge_stb(ibadge_stb) |
| ); |
| assign ibadge_data = pbuf_din[7:0]; |
|
|
| |
| |
| |
| reg [8:0] pbuf[0:(1<<paw)-1]; |
| reg [8:0] pbuf_out=0; |
| wire [paw-1:0] mem_a2; |
| always @(posedge rx_clk) pbuf[pbuf_a_rx] <= pbuf_din; |
| always @(posedge tx_clk) pbuf_out <= pbuf[mem_a2]; |
| integer jx; |
| initial for (jx=0; jx<(1<<paw); jx=jx+1) pbuf[jx]=0; |
|
|
| |
| |
| wire [3:0] ip_mem_a_tx; reg[7:0] ip_mem_d_tx=0; |
| |
| wire [5:0] pc; |
| wire [1:0] category; |
| wire [2:0] udp_sel; |
| wire [7:0] eth_data_out; |
| wire eth_strobe_short, eth_strobe_long; |
| localparam p_offset=480; |
| construct #(.paw(paw), .p_offset(p_offset)) c_construct(.clk(tx_clk), |
| .gray_state(gray_state), |
| .ip_a(ip_mem_a_tx), .ip_d(ip_mem_d_tx), |
| .addr(mem_a2), .pbuf_out(pbuf_out), |
| .pc(pc), .category(category), .udp_sel(udp_sel), |
| .badge_stb(obadge_stb), .badge_data(obadge_data), |
| .xdomain_fault(xdomain_fault), |
| .eth_data_out(eth_data_out), .eth_strobe_short(eth_strobe_short), .eth_strobe_long(eth_strobe_long) |
| ); |
|
|
| |
| wire xraw_s, xraw_l; wire [7:0] raw_d; |
| xformer #(.n_lat(n_lat), .handle_icmp(handle_icmp)) d_xform(.clk(tx_clk), |
| .pc(pc), .category(category), .udp_sel(udp_sel), |
| .idata(eth_data_out), .eth_strobe_short(eth_strobe_short), .eth_strobe_long(eth_strobe_long), |
| .len_c(len_c), |
| .raw_l(raw_l), .raw_s(raw_s), |
| .mux_data_in(mux_data_in), |
| .odata(raw_d), .ostrobe_s(xraw_s), .ostrobe_l(xraw_l) |
| ); |
| assign idata = eth_data_out; |
|
|
| |
| |
| |
| |
| localparam precog_latency = (1<<paw) - p_offset + 4 + n_lat; |
| wire [7:0] tx_mac_data; |
| wire tx_mac_strobe_s, tx_mac_strobe_l; |
| generate if (mac_aw > 1) begin : mac_b |
| mac_subset #( |
| .mac_aw(mac_aw), |
| .latency(precog_latency) |
| ) txmac ( |
| .host_raddr(host_raddr), |
| .host_rdata(host_rdata), |
| .buf_start_addr(buf_start_addr), |
| .tx_mac_start(tx_mac_start), |
| .tx_mac_done(tx_mac_done), |
| .scanner_busy(scanner_busy), |
| .tx_clk(tx_clk), |
| .mac_data(tx_mac_data), |
| .strobe_s(tx_mac_strobe_s), |
| .strobe_l(tx_mac_strobe_l) |
| ); |
| end else begin : no_mac_b |
| assign host_raddr = 0; |
| assign tx_mac_strobe_s = 0; |
| assign tx_mac_strobe_l = 0; |
| assign tx_mac_data = 0; |
| assign tx_mac_done = 0; |
| end endgenerate |
|
|
| |
| |
| |
| wire xraw2_s = xraw_s | tx_mac_strobe_s; |
| wire xraw2_l = xraw_l | tx_mac_strobe_l; |
| wire [7:0] raw2_d = tx_mac_strobe_s ? tx_mac_data : raw_d; |
|
|
| |
| wire opack_s; wire [7:0] opack_d; |
| ethernet_crc_add e_crc(.clk(tx_clk), |
| .raw_s(xraw2_s), .raw_l(xraw2_l), .raw_d(raw2_d), |
| .opack_s(opack_s), .opack_d(opack_d) |
| ); |
|
|
| |
| reg [7:0] eth_out_r=0; |
| reg eth_out_s_r=0; |
| always @(posedge tx_clk) begin |
| eth_out_r <= opack_d; |
| eth_out_s_r <= opack_s; |
| end |
| assign txd = eth_out_r; |
| assign tx_en = eth_out_s_r; |
|
|
| |
| assign rx_mon = eth_in_s_r; |
| assign tx_mon = opack_s; |
|
|
| |
| reg [paw-1:0] in_use_timer=0; |
| assign in_use = |in_use_timer; |
| always @(posedge rx_clk) begin |
| if (in_use) in_use_timer <= in_use_timer - 1; |
| if (rx_mon) in_use_timer <= {paw{1'b1}}; |
| end |
|
|
| |
| reg [7:0] ip_mem[0:15]; |
| always @(posedge config_clk) if (config_s) ip_mem[config_a] <= config_d; |
| always @(posedge rx_clk) ip_d <= ip_mem[ip_a]; |
| always @(posedge tx_clk) ip_mem_d_tx <= ip_mem[ip_mem_a_tx]; |
| initial begin |
| |
| ip_mem[0] = mac[47:40]; |
| ip_mem[1] = mac[39:32]; |
| ip_mem[2] = mac[31:24]; |
| ip_mem[3] = mac[23:16]; |
| ip_mem[4] = mac[15:8]; |
| ip_mem[5] = mac[7:0]; |
| ip_mem[6] = ip[31:24]; |
| ip_mem[7] = ip[23:16]; |
| ip_mem[8] = ip[15:8]; |
| ip_mem[9] = ip[7:0]; |
| end |
|
|
| |
| reg [7:0] pno_mem[0:15]; |
| always @(posedge config_clk) if (config_p) pno_mem[config_a] <= config_d; |
| always @(posedge rx_clk) pno_d <= pno_mem[pno_a]; |
| initial begin |
| pno_mem[0] = udp_port0[15:8]; |
| pno_mem[1] = udp_port0[7:0]; |
| pno_mem[2] = udp_port1[15:8]; |
| pno_mem[3] = udp_port1[7:0]; |
| pno_mem[4] = udp_port2[15:8]; |
| pno_mem[5] = udp_port2[7:0]; |
| pno_mem[6] = udp_port3[15:8]; |
| pno_mem[7] = udp_port3[7:0]; |
| pno_mem[8] = udp_port4[15:8]; |
| pno_mem[9] = udp_port4[7:0]; |
| pno_mem[10] = udp_port5[15:8]; |
| pno_mem[11] = udp_port5[7:0]; |
| pno_mem[12] = udp_port6[15:8]; |
| pno_mem[13] = udp_port6[7:0]; |
| pno_mem[14] = udp_port7[15:8]; |
| pno_mem[15] = udp_port7[7:0]; |
| end |
|
|
| endmodule |
|
|