| |
| |
| |
|
|
| module marble_base ( |
| |
| input vgmii_tx_clk, |
| output [7:0] vgmii_txd, |
| output vgmii_tx_en, |
| output vgmii_tx_er, |
|
|
| |
| input vgmii_rx_clk, |
| input [7:0] vgmii_rxd, |
| input vgmii_rx_er, |
| input vgmii_rx_dv, |
|
|
| |
| input aux_clk, |
| input clk62, |
| input cfg_clk, |
| output phy_rstn, |
| input clk_locked, |
| input si570, |
|
|
| |
| input SCLK, |
| input CSB, |
| input MOSI, |
| output MISO, |
| output mmc_int, |
|
|
| |
| output boot_clk, |
| output boot_cs, |
| output boot_mosi, |
| input boot_miso, |
| output cfg_d02, |
|
|
| |
| inout [3:0] twi_scl, |
| inout [3:0] twi_sda, |
| inout TWI_RST, |
| input TWI_INT, |
|
|
| |
| output WR_DAC_SCLK, |
| output WR_DAC_DIN, |
| output WR_DAC1_SYNC, |
| output WR_DAC2_SYNC, |
|
|
| |
| |
| |
| |
| |
| |
| output FPGA_RxD, |
| input FPGA_TxD, |
|
|
| |
| input [3:0] GPS, |
|
|
| |
| output [3:0] ext_config, |
|
|
| |
| output in_use, |
|
|
| |
| |
| output lb_clk, |
| output [23:0] lb_addr, |
| output lb_strobe, |
| output lb_rd, |
| output lb_write, |
| output lb_rd_valid, |
| |
| output [31:0] lb_data_out, |
| input [31:0] lb_data_in, |
|
|
| |
| inout [191:0] fmc_test, |
| output ZEST_PWR_EN, |
| output [2:0] ps_sync, |
| output [7:0] LED |
| ); |
|
|
| parameter USE_I2CBRIDGE = 1; |
| parameter MMC_CTRACE = 1; |
| parameter GPS_CTRACE = 0; |
| parameter use_ddr_pps = 0; |
| parameter misc_config_default = 0; |
| parameter default_enable_rx = 1; |
|
|
| `ifdef VERILATOR |
| parameter [31:0] ip = {8'd192, 8'd168, 8'd7, 8'd4}; |
| parameter [47:0] mac = 48'h12555500012d; |
| `else |
| `ifdef YOSYS |
| parameter [31:0] ip = {8'd192, 8'd168, 8'd19, 8'd9}; |
| parameter [47:0] mac = 48'h12555500022d; |
| `else |
| parameter [31:0] ip = {8'd192, 8'd168, 8'd19, 8'd10}; |
| parameter [47:0] mac = 48'h12555500032d; |
| `endif |
| `endif |
|
|
| |
| wire tx_clk = vgmii_tx_clk; |
| wire rx_clk = vgmii_rx_clk; |
|
|
| |
| wire lb_control_strobe, lb_control_rd, lb_control_rd_valid; |
| assign lb_clk = tx_clk; |
| assign lb_strobe = lb_control_strobe; |
| wire config_clk = tx_clk; |
| assign lb_write = lb_control_strobe & ~lb_control_rd; |
| assign lb_rd_valid = lb_control_rd_valid; |
| assign lb_rd = lb_control_rd; |
|
|
| |
| wire [3:0] spi_pins_debug; |
| wire enable_rx; |
| wire [7:0] mbox_out2; |
| wire config_s, config_p; |
| wire [7:0] config_a, config_d; |
|
|
| |
| mmc_mailbox #( |
| .DEFAULT_ENABLE_RX(default_enable_rx) |
| ) mailbox_i ( |
| .clk(config_clk), |
| |
| .lb_addr(lb_addr[10:0]), |
| .lb_din(lb_data_out[7:0]), |
| .lb_dout(mbox_out2), |
| .lb_write(lb_write), |
| .lb_control_strobe(lb_control_strobe), |
| |
| .sck(SCLK), |
| .ncs(CSB), |
| .pico(MOSI), |
| .poci(MISO), |
| |
| .config_s(config_s), |
| .config_p(config_p), |
| .config_a(config_a), |
| .config_d(config_d), |
| |
| .enable_rx(enable_rx), |
| .spi_pins_debug(spi_pins_debug) |
| ); |
|
|
| |
| wire ibadge_stb, obadge_stb; |
| wire [7:0] ibadge_data, obadge_data; |
| wire xdomain_fault; |
| wire tx_mac_done; |
| wire [15:0] rx_mac_data; |
| wire rx_mac_hbank; |
| wire [1:0] rx_mac_buf_status; |
| wire allow_mmc_eth_config; |
| wire [31:0] lb_slave_data_read; |
|
|
| |
| wire [27:0] frequency_si570; |
| freq_count freq_cnt_si570(.f_in(si570), .sysclk(lb_clk), .frequency(frequency_si570)); |
|
|
| |
| wire [3:0] rx_category_rx, rx_category; |
| wire rx_category_s_rx, rx_category_s; |
|
|
| |
| wire [1:0] led_user_mode; |
| wire l1, l2; |
| wire [4:0] ps_sync_config; |
|
|
| |
| lb_marble_slave #( |
| .USE_I2CBRIDGE(USE_I2CBRIDGE), |
| .MMC_CTRACE(MMC_CTRACE), |
| .GPS_CTRACE(GPS_CTRACE), |
| .use_ddr_pps(use_ddr_pps), |
| .misc_config_default(misc_config_default) |
| ) slave( |
| .clk(lb_clk), .addr(lb_addr), |
| .control_strobe(lb_control_strobe), .control_rd(lb_control_rd), |
| .data_out(lb_data_out), .data_in(lb_slave_data_read), |
| .aux_clk(aux_clk), .clk62(clk62), |
| .ibadge_clk(rx_clk), |
| .ibadge_stb(ibadge_stb), .ibadge_data(ibadge_data), |
| .obadge_stb(obadge_stb), .obadge_data(obadge_data), |
| .xdomain_fault(xdomain_fault), |
| .mmc_pins(spi_pins_debug), |
| .rx_category_s(rx_category_s), .rx_category(rx_category), |
| .tx_mac_done(tx_mac_done), .rx_mac_data(rx_mac_data), |
| .rx_mac_buf_status(rx_mac_buf_status), .rx_mac_hbank(rx_mac_hbank), |
| .twi_scl(twi_scl), .twi_sda(twi_sda), |
| .twi_int(TWI_INT), .twi_rst(TWI_RST), |
| .wr_dac_sclk(WR_DAC_SCLK), .wr_dac_sdo(WR_DAC_DIN), |
| .wr_dac_sync({WR_DAC2_SYNC, WR_DAC1_SYNC}), |
| .cfg_d02(cfg_d02), |
| .mmc_int(mmc_int), |
| .zest_pwr_en(ZEST_PWR_EN), |
| .allow_mmc_eth_config(allow_mmc_eth_config), |
| .fmc_test(fmc_test), |
| .gps(GPS), .ext_config(ext_config), .frequency_si570(frequency_si570), |
| .ps_sync_config(ps_sync_config), |
| .led_user_mode(led_user_mode), .led1(l1), .led2(l2) |
| ); |
|
|
| |
| reg [23:0] p3_lb_addr_d; |
| reg p3_use_app_rd=0, p3_use_mbox_rd=0; |
| always @(posedge lb_clk) begin |
| p3_lb_addr_d <= lb_addr; |
| p3_use_app_rd <= p3_lb_addr_d[23:20] == 1; |
| p3_use_mbox_rd <= p3_lb_addr_d[23:20] == 2; |
| end |
| wire [31:0] p3_lb_data_in = p3_use_mbox_rd ? mbox_out2 : p3_use_app_rd ? lb_data_in : lb_slave_data_read; |
|
|
| |
| |
| |
| |
| parameter tx_mac_aw=10; |
| wire host_clk = lb_clk; |
| wire host_write = lb_control_strobe & ~lb_control_rd & (lb_addr[23:20]==1); |
| wire [tx_mac_aw:0] host_waddr = lb_addr[tx_mac_aw:0]; |
| wire [15:0] host_wdata = lb_data_out[15:0]; |
| wire [10:0] host_raddr = lb_addr[10:0]; |
|
|
| |
| wire [7:0] rx_mac_d; |
| wire [11:0] rx_mac_a; |
| wire rx_mac_wen; |
| wire rx_mac_accept, rx_mac_status_s; |
| wire [7:0] rx_mac_status_d; |
| base_rx_mac rx_mac( |
| |
| .host_clk(host_clk), .host_raddr(host_raddr), |
| .host_rdata(rx_mac_data), |
| |
| .rx_clk(vgmii_rx_clk), |
| .rx_mac_d(rx_mac_d), .rx_mac_a(rx_mac_a), .rx_mac_wen(rx_mac_wen), |
| .rx_mac_accept(rx_mac_accept), |
| .rx_mac_status_d(rx_mac_status_d), .rx_mac_status_s(rx_mac_status_s) |
| ); |
|
|
| |
| |
| |
| wire [tx_mac_aw-1:0] host_tx_raddr; |
| wire [15:0] host_tx_rdata; |
| wire [tx_mac_aw-1:0] buf_start_addr; |
| wire tx_mac_start; |
| mac_compat_dpram #( |
| .mac_aw(tx_mac_aw) |
| ) mac_compat_dpram_inst ( |
| .host_clk(host_clk), |
| .host_waddr(host_waddr), |
| .host_write(host_write), |
| .host_wdata(host_wdata), |
| |
| .tx_clk(tx_clk), |
| .host_raddr(host_tx_raddr), |
| .host_rdata(host_tx_rdata), |
| .buf_start_addr(buf_start_addr), |
| .tx_mac_start(tx_mac_start) |
| ); |
|
|
| |
| |
| reg enable_rx_r=0; always @(posedge tx_clk) enable_rx_r <= enable_rx | ~allow_mmc_eth_config; |
|
|
| |
| parameter enable_bursts=1; |
|
|
| wire [3:0] scanner_debug; |
| wire rx_mon, tx_mon; |
| wire boot_busy, blob_in_use; |
| rtefi_blob #(.ip(ip), .mac(mac), .mac_aw(tx_mac_aw), .p3_enable_bursts(enable_bursts)) rtefi( |
| .rx_clk(vgmii_rx_clk), .rxd(vgmii_rxd), |
| .rx_dv(vgmii_rx_dv), .rx_er(vgmii_rx_er), |
| .tx_clk(tx_clk) , .txd(vgmii_txd), |
| .tx_en(vgmii_tx_en), |
|
|
| |
| |
| |
| |
| |
| |
|
|
| .enable_rx(enable_rx_r), |
| .config_clk(config_clk), |
| .config_s(config_s & allow_mmc_eth_config), |
| .config_p(config_p & allow_mmc_eth_config), |
| .config_a(config_a[3:0]), .config_d(config_d), |
|
|
| |
| |
| .host_raddr(host_tx_raddr), |
| .host_rdata(host_tx_rdata), |
| .buf_start_addr(buf_start_addr), |
| .tx_mac_start(tx_mac_start), |
|
|
| .tx_mac_done(tx_mac_done), |
| .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), |
| .rx_mac_status_d(rx_mac_status_d), .rx_mac_status_s(rx_mac_status_s), |
| .scanner_debug(scanner_debug), |
| .ibadge_stb(ibadge_stb), .ibadge_data(ibadge_data), |
| .obadge_stb(obadge_stb), .obadge_data(obadge_data), |
| .xdomain_fault(xdomain_fault), |
| .p2_nomangle(1'b0), |
| .p3_addr(lb_addr), .p3_control_strobe(lb_control_strobe), |
| .p3_control_rd(lb_control_rd), .p3_control_rd_valid(lb_control_rd_valid), |
| .p3_data_out(lb_data_out), .p3_data_in(p3_lb_data_in), |
| .p4_spi_clk(boot_clk), .p4_spi_cs(boot_cs), |
| .p4_spi_mosi(boot_mosi), .p4_spi_miso(boot_miso), |
| .p4_busy(boot_busy), |
| .rx_mon(rx_mon), .tx_mon(tx_mon), .in_use(blob_in_use) |
| ); |
| assign vgmii_tx_er=1'b0; |
| assign in_use = blob_in_use | boot_busy; |
|
|
| |
| wire [3:0] unk_clk = {cfg_clk, si570, aux_clk, rx_clk}; |
| freq_demo freq_demo( |
| .refclk(tx_clk), .unk_clk(unk_clk), |
| .uart_tx(FPGA_RxD), .uart_rx(FPGA_TxD) |
| ); |
|
|
| |
| packet_categorize i_categorize(.clk(vgmii_rx_clk), |
| .strobe(rx_mac_status_s), .status(rx_mac_status_d), |
| .strobe_o(rx_category_s_rx), .category(rx_category_rx) |
| ); |
| data_xdomain #(.size(4)) x_category( |
| .clk_in(vgmii_rx_clk), .gate_in(rx_category_s_rx), .data_in(rx_category_rx), |
| .clk_out(lb_clk), .gate_out(rx_category_s), .data_out(rx_category) |
| ); |
|
|
| |
| reg [26:0] rx_heartbeat=0, tx_heartbeat=0; |
| always @(posedge rx_clk) rx_heartbeat <= rx_heartbeat+1; |
| always @(posedge tx_clk) tx_heartbeat <= tx_heartbeat+1; |
| wire led0 = led_user_mode ? l1 : rx_heartbeat[26]; |
| wire led1 = led_user_mode ? l2 : tx_heartbeat[26]; |
| wire rx_led, tx_led; |
| activity rx_act(.clk(rx_clk), .trigger(rx_mon), .led(rx_led)); |
| activity tx_act(.clk(tx_clk), .trigger(tx_mon), .led(tx_led)); |
| wire rx_h = rx_heartbeat[26]; |
| wire tx_h = tx_heartbeat[26]; |
| reg mod=0, reset=0; |
| reg [31:0] cnt=0; |
| always @(posedge rx_clk) begin |
| cnt <= reset ? 32'h0 : cnt + 1'b1; |
| mod <= cnt[0]; |
| end |
| assign LED = (led_user_mode==2) ? cnt[30:23] & {8{mod}} : {~tx_h, tx_h, ~rx_h, rx_h, tx_led, rx_led, led1, led0}; |
|
|
| |
| reg phy_rb=0; |
| always @(posedge tx_clk) begin |
| if (tx_heartbeat[21]) phy_rb <= 1; |
| if (~clk_locked) phy_rb <= 0; |
| end |
| assign phy_rstn = phy_rb; |
|
|
| ltm_sync ltm_sync_i(.clk(tx_clk), |
| .ps_config(ps_sync_config), .ps_sync(ps_sync)); |
|
|
| |
| `ifndef YOSYS |
| always @(posedge tx_clk) begin |
| if (slave.stop_sim & ~in_use) begin |
| $display("marble_base: stopping based on localbus request"); |
| $finish(0); |
| end |
| end |
| `endif |
|
|
| endmodule |
|
|