1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-30 08:32:52 +08:00

Add QSPI flash access and IPROG for fb2CG

This commit is contained in:
Alex Forencich 2020-09-29 21:08:21 -07:00
parent 1806a464bb
commit 9c25a4523e
12 changed files with 526 additions and 12 deletions

View File

@ -0,0 +1,4 @@
# Timing constraints for FPGA boot logic
set_property ASYNC_REG TRUE [get_cells "fpga_boot_sync_reg_0_reg fpga_boot_sync_reg_1_reg"]
set_false_path -to [get_pins "fpga_boot_sync_reg_0_reg/D"]

View File

@ -55,6 +55,7 @@ SYN_FILES += lib/pcie/rtl/pulse_merge.v
# XDC files
XDC_FILES = fpga.xdc
XDC_FILES += boot.xdc
XDC_FILES += led.tcl
XDC_FILES += lib/axis/syn/axis_async_fifo.tcl
XDC_FILES += lib/axis/syn/sync_reset.tcl

View File

@ -306,6 +306,160 @@ led_sreg_driver_inst (
.sreg_clk(led_sreg_clk)
);
// Flash
wire qspi_clk_int;
wire [3:0] qspi_dq_int;
wire [3:0] qspi_dq_i_int;
wire [3:0] qspi_dq_o_int;
wire [3:0] qspi_dq_oe_int;
wire qspi_cs_int;
sync_signal #(
.WIDTH(4),
.N(2)
)
flash_sync_signal_inst (
.clk(pcie_user_clk),
.in({qspi_dq_int}),
.out({qspi_dq_i_int})
);
STARTUPE3
startupe3_inst (
.CFGCLK(),
.CFGMCLK(),
.DI(qspi_dq_int),
.DO(qspi_dq_o_int),
.DTS(~qspi_dq_oe_int),
.EOS(),
.FCSBO(qspi_cs_int),
.FCSBTS(1'b0),
.GSR(1'b0),
.GTS(1'b0),
.KEYCLEARB(1'b1),
.PACK(1'b0),
.PREQ(),
.USRCCLKO(qspi_clk_int),
.USRCCLKTS(1'b0),
.USRDONEO(1'b0),
.USRDONETS(1'b1)
);
// FPGA boot
wire fpga_boot;
reg fpga_boot_sync_reg_0 = 1'b0;
reg fpga_boot_sync_reg_1 = 1'b0;
reg fpga_boot_sync_reg_2 = 1'b0;
wire icap_avail;
reg [2:0] icap_state = 0;
reg icap_csib_reg = 1'b1;
reg icap_rdwrb_reg = 1'b0;
reg [31:0] icap_di_reg = 32'hffffffff;
wire [31:0] icap_di_rev;
assign icap_di_rev[ 7] = icap_di_reg[ 0];
assign icap_di_rev[ 6] = icap_di_reg[ 1];
assign icap_di_rev[ 5] = icap_di_reg[ 2];
assign icap_di_rev[ 4] = icap_di_reg[ 3];
assign icap_di_rev[ 3] = icap_di_reg[ 4];
assign icap_di_rev[ 2] = icap_di_reg[ 5];
assign icap_di_rev[ 1] = icap_di_reg[ 6];
assign icap_di_rev[ 0] = icap_di_reg[ 7];
assign icap_di_rev[15] = icap_di_reg[ 8];
assign icap_di_rev[14] = icap_di_reg[ 9];
assign icap_di_rev[13] = icap_di_reg[10];
assign icap_di_rev[12] = icap_di_reg[11];
assign icap_di_rev[11] = icap_di_reg[12];
assign icap_di_rev[10] = icap_di_reg[13];
assign icap_di_rev[ 9] = icap_di_reg[14];
assign icap_di_rev[ 8] = icap_di_reg[15];
assign icap_di_rev[23] = icap_di_reg[16];
assign icap_di_rev[22] = icap_di_reg[17];
assign icap_di_rev[21] = icap_di_reg[18];
assign icap_di_rev[20] = icap_di_reg[19];
assign icap_di_rev[19] = icap_di_reg[20];
assign icap_di_rev[18] = icap_di_reg[21];
assign icap_di_rev[17] = icap_di_reg[22];
assign icap_di_rev[16] = icap_di_reg[23];
assign icap_di_rev[31] = icap_di_reg[24];
assign icap_di_rev[30] = icap_di_reg[25];
assign icap_di_rev[29] = icap_di_reg[26];
assign icap_di_rev[28] = icap_di_reg[27];
assign icap_di_rev[27] = icap_di_reg[28];
assign icap_di_rev[26] = icap_di_reg[29];
assign icap_di_rev[25] = icap_di_reg[30];
assign icap_di_rev[24] = icap_di_reg[31];
always @(posedge clk_125mhz_int) begin
case (icap_state)
0: begin
icap_state <= 0;
icap_csib_reg <= 1'b1;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'hffffffff; // dummy word
if (fpga_boot_sync_reg_2 && icap_avail) begin
icap_state <= 1;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'hffffffff; // dummy word
end
end
1: begin
icap_state <= 2;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'hAA995566; // sync word
end
2: begin
icap_state <= 3;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h20000000; // type 1 noop
end
3: begin
icap_state <= 4;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h30008001; // write 1 word to CMD
end
4: begin
icap_state <= 5;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h0000000F; // IPROG
end
5: begin
icap_state <= 0;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h20000000; // type 1 noop
end
endcase
fpga_boot_sync_reg_0 <= fpga_boot;
fpga_boot_sync_reg_1 <= fpga_boot_sync_reg_0;
fpga_boot_sync_reg_2 <= fpga_boot_sync_reg_1;
end
ICAPE3
icape3_inst (
.AVAIL(icap_avail),
.CLK(clk_125mhz_int),
.CSIB(icap_csib_reg),
.I(icap_di_rev),
.O(),
.PRDONE(),
.PRERROR(),
.RDWRB(icap_rdwrb_reg)
);
// PCIe
wire pcie_sys_clk;
wire pcie_sys_clk_gt;
@ -1386,7 +1540,17 @@ core_inst (
.qsfp_1_i2c_scl_t(qsfp_1_i2c_scl_t),
.qsfp_1_i2c_sda_i(qsfp_1_i2c_sda_i),
.qsfp_1_i2c_sda_o(qsfp_1_i2c_sda_o),
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t)
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t),
/*
* QSPI flash
*/
.fpga_boot(fpga_boot),
.qspi_clk(qspi_clk_int),
.qspi_dq_i(qspi_dq_i_int),
.qspi_dq_o(qspi_dq_o_int),
.qspi_dq_oe(qspi_dq_oe_int),
.qspi_cs(qspi_cs_int)
);
endmodule

View File

@ -208,7 +208,17 @@ module fpga_core #
output wire qsfp_1_i2c_scl_t,
input wire qsfp_1_i2c_sda_i,
output wire qsfp_1_i2c_sda_o,
output wire qsfp_1_i2c_sda_t
output wire qsfp_1_i2c_sda_t,
/*
* QSPI flash
*/
output wire fpga_boot,
output wire qspi_clk,
input wire [3:0] qspi_dq_i,
output wire [3:0] qspi_dq_o,
output wire [3:0] qspi_dq_oe,
output wire qspi_cs
);
// PHC parameters
@ -424,6 +434,13 @@ reg qsfp_1_lp_mode_reg = 1'b0;
reg qsfp_1_i2c_scl_o_reg = 1'b1;
reg qsfp_1_i2c_sda_o_reg = 1'b1;
reg fpga_boot_reg = 1'b0;
reg qspi_clk_reg = 1'b0;
reg qspi_cs_reg = 1'b1;
reg [3:0] qspi_dq_o_reg = 4'd0;
reg [3:0] qspi_dq_oe_reg = 4'd0;
reg pcie_dma_enable_reg = 0;
reg [95:0] get_ptp_ts_96_reg = 0;
@ -461,6 +478,13 @@ assign qsfp_1_i2c_scl_t = qsfp_1_i2c_scl_o_reg;
assign qsfp_1_i2c_sda_o = qsfp_1_i2c_sda_o_reg;
assign qsfp_1_i2c_sda_t = qsfp_1_i2c_sda_o_reg;
assign fpga_boot = fpga_boot_reg;
assign qspi_clk = qspi_clk_reg;
assign qspi_cs = qspi_cs_reg;
assign qspi_dq_o = qspi_dq_o_reg;
assign qspi_dq_oe = qspi_dq_oe_reg;
//assign pcie_dma_enable = pcie_dma_enable_reg;
always @(posedge clk_250mhz) begin
@ -483,6 +507,10 @@ always @(posedge clk_250mhz) begin
axil_csr_bvalid_reg <= 1'b1;
case ({axil_csr_awaddr[15:2], 2'b00})
16'h0040: begin
// FPGA ID
fpga_boot_reg <= axil_csr_wdata == 32'hFEE1DEAD;
end
// GPIO
16'h0110: begin
// GPIO I2C 0
@ -513,6 +541,20 @@ always @(posedge clk_250mhz) begin
qsfp_1_lp_mode_reg <= axil_csr_wdata[13];
end
end
// Flash
16'h0144: begin
// QSPI control
if (axil_csr_wstrb[0]) begin
qspi_dq_o_reg <= axil_csr_wdata[3:0];
end
if (axil_csr_wstrb[1]) begin
qspi_dq_oe_reg <= axil_csr_wdata[11:8];
end
if (axil_csr_wstrb[2]) begin
qspi_clk_reg <= axil_csr_wdata[16];
qspi_cs_reg <= axil_csr_wdata[17];
end
end
// PHC
16'h0230: set_ptp_ts_96_reg[15:0] <= axil_csr_wdata; // PTP set fns
16'h0234: set_ptp_ts_96_reg[45:16] <= axil_csr_wdata; // PTP set ns
@ -582,6 +624,15 @@ always @(posedge clk_250mhz) begin
axil_csr_rdata_reg[12] <= qsfp_1_reset_reg;
axil_csr_rdata_reg[13] <= qsfp_1_lp_mode_reg;
end
// Flash
16'h0140: axil_csr_rdata_reg <= {8'd0, 8'd4, 8'd1, 8'd0}; // Flash ID
16'h0144: begin
// QSPI control
axil_csr_rdata_reg[3:0] <= qspi_dq_i;
axil_csr_rdata_reg[11:8] <= qspi_dq_oe;
axil_csr_rdata_reg[16] <= qspi_clk;
axil_csr_rdata_reg[17] <= qspi_cs;
end
// PHC
16'h0200: axil_csr_rdata_reg <= {8'd0, 8'd0, 8'd0, 8'd0}; // PHC features
16'h0210: axil_csr_rdata_reg <= ptp_ts_96[15:0]; // PTP cur fns
@ -628,6 +679,13 @@ always @(posedge clk_250mhz) begin
qsfp_1_i2c_scl_o_reg <= 1'b1;
qsfp_1_i2c_sda_o_reg <= 1'b1;
fpga_boot_reg <= 1'b0;
qspi_clk_reg <= 1'b0;
qspi_cs_reg <= 1'b1;
qspi_dq_o_reg <= 4'd0;
qspi_dq_oe_reg <= 4'd0;
pcie_dma_enable_reg <= 1'b0;
end
end

View File

@ -199,6 +199,7 @@ def bench():
qsfp_1_intr_n = Signal(bool(0))
qsfp_1_i2c_scl_i = Signal(bool(0))
qsfp_1_i2c_sda_i = Signal(bool(0))
qspi_dq_i = Signal(intbv(0)[4:])
# Outputs
led_red = Signal(intbv(0)[7:])
@ -258,6 +259,11 @@ def bench():
qsfp_1_i2c_scl_t = Signal(bool(1))
qsfp_1_i2c_sda_o = Signal(bool(1))
qsfp_1_i2c_sda_t = Signal(bool(1))
fpga_boot = Signal(bool(0))
qspi_clk = Signal(bool(0))
qspi_dq_o = Signal(intbv(0)[4:])
qspi_dq_oe = Signal(intbv(0)[4:])
qspi_cs = Signal(bool(0))
# sources and sinks
qsfp_0_source = axis_ep.AXIStreamSource()
@ -664,7 +670,13 @@ def bench():
qsfp_1_i2c_scl_t=qsfp_1_i2c_scl_t,
qsfp_1_i2c_sda_i=qsfp_1_i2c_sda_i,
qsfp_1_i2c_sda_o=qsfp_1_i2c_sda_o,
qsfp_1_i2c_sda_t=qsfp_1_i2c_sda_t
qsfp_1_i2c_sda_t=qsfp_1_i2c_sda_t,
fpga_boot=fpga_boot,
qspi_clk=qspi_clk,
qspi_dq_i=qspi_dq_i,
qspi_dq_o=qspi_dq_o,
qspi_dq_oe=qspi_dq_oe,
qspi_cs=qspi_cs
)
@always(delay(5))

View File

@ -121,6 +121,7 @@ reg qsfp_1_mod_prsnt_n = 0;
reg qsfp_1_intr_n = 0;
reg qsfp_1_i2c_scl_i = 1;
reg qsfp_1_i2c_sda_i = 1;
reg [3:0] qspi_dq_i = 0;
// Outputs
wire [7:0] led_red;
@ -180,6 +181,11 @@ wire qsfp_1_i2c_scl_o;
wire qsfp_1_i2c_scl_t;
wire qsfp_1_i2c_sda_o;
wire qsfp_1_i2c_sda_t;
wire fpga_boot;
wire qspi_clk;
wire [3:0] qspi_dq_o;
wire [3:0] qspi_dq_oe;
wire qspi_cs;
initial begin
// myhdl integration
@ -248,7 +254,8 @@ initial begin
qsfp_1_mod_prsnt_n,
qsfp_1_intr_n,
qsfp_1_i2c_scl_i,
qsfp_1_i2c_sda_i
qsfp_1_i2c_sda_i,
qspi_dq_i
);
$to_myhdl(
led_red,
@ -307,7 +314,12 @@ initial begin
qsfp_1_i2c_scl_o,
qsfp_1_i2c_scl_t,
qsfp_1_i2c_sda_o,
qsfp_1_i2c_sda_t
qsfp_1_i2c_sda_t,
fpga_boot,
qspi_clk,
qspi_dq_o,
qspi_dq_oe,
qspi_cs
);
// dump file
@ -448,7 +460,13 @@ UUT (
.qsfp_1_i2c_scl_t(qsfp_1_i2c_scl_t),
.qsfp_1_i2c_sda_i(qsfp_1_i2c_sda_i),
.qsfp_1_i2c_sda_o(qsfp_1_i2c_sda_o),
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t)
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t),
.fpga_boot(fpga_boot),
.qspi_clk(qspi_clk),
.qspi_dq_i(qspi_dq_i),
.qspi_dq_o(qspi_dq_o),
.qspi_dq_oe(qspi_dq_oe),
.qspi_cs(qspi_cs)
);
endmodule

View File

@ -0,0 +1,4 @@
# Timing constraints for FPGA boot logic
set_property ASYNC_REG TRUE [get_cells "fpga_boot_sync_reg_0_reg fpga_boot_sync_reg_1_reg"]
set_false_path -to [get_pins "fpga_boot_sync_reg_0_reg/D"]

View File

@ -72,6 +72,7 @@ SYN_FILES += lib/pcie/rtl/pulse_merge.v
# XDC files
XDC_FILES = fpga.xdc
XDC_FILES += boot.xdc
XDC_FILES += led.tcl
XDC_FILES += lib/axis/syn/axis_async_fifo.tcl
XDC_FILES += lib/axis/syn/sync_reset.tcl

View File

@ -303,6 +303,160 @@ led_sreg_driver_inst (
.sreg_clk(led_sreg_clk)
);
// Flash
wire qspi_clk_int;
wire [3:0] qspi_dq_int;
wire [3:0] qspi_dq_i_int;
wire [3:0] qspi_dq_o_int;
wire [3:0] qspi_dq_oe_int;
wire qspi_cs_int;
sync_signal #(
.WIDTH(4),
.N(2)
)
flash_sync_signal_inst (
.clk(pcie_user_clk),
.in({qspi_dq_int}),
.out({qspi_dq_i_int})
);
STARTUPE3
startupe3_inst (
.CFGCLK(),
.CFGMCLK(),
.DI(qspi_dq_int),
.DO(qspi_dq_o_int),
.DTS(~qspi_dq_oe_int),
.EOS(),
.FCSBO(qspi_cs_int),
.FCSBTS(1'b0),
.GSR(1'b0),
.GTS(1'b0),
.KEYCLEARB(1'b1),
.PACK(1'b0),
.PREQ(),
.USRCCLKO(qspi_clk_int),
.USRCCLKTS(1'b0),
.USRDONEO(1'b0),
.USRDONETS(1'b1)
);
// FPGA boot
wire fpga_boot;
reg fpga_boot_sync_reg_0 = 1'b0;
reg fpga_boot_sync_reg_1 = 1'b0;
reg fpga_boot_sync_reg_2 = 1'b0;
wire icap_avail;
reg [2:0] icap_state = 0;
reg icap_csib_reg = 1'b1;
reg icap_rdwrb_reg = 1'b0;
reg [31:0] icap_di_reg = 32'hffffffff;
wire [31:0] icap_di_rev;
assign icap_di_rev[ 7] = icap_di_reg[ 0];
assign icap_di_rev[ 6] = icap_di_reg[ 1];
assign icap_di_rev[ 5] = icap_di_reg[ 2];
assign icap_di_rev[ 4] = icap_di_reg[ 3];
assign icap_di_rev[ 3] = icap_di_reg[ 4];
assign icap_di_rev[ 2] = icap_di_reg[ 5];
assign icap_di_rev[ 1] = icap_di_reg[ 6];
assign icap_di_rev[ 0] = icap_di_reg[ 7];
assign icap_di_rev[15] = icap_di_reg[ 8];
assign icap_di_rev[14] = icap_di_reg[ 9];
assign icap_di_rev[13] = icap_di_reg[10];
assign icap_di_rev[12] = icap_di_reg[11];
assign icap_di_rev[11] = icap_di_reg[12];
assign icap_di_rev[10] = icap_di_reg[13];
assign icap_di_rev[ 9] = icap_di_reg[14];
assign icap_di_rev[ 8] = icap_di_reg[15];
assign icap_di_rev[23] = icap_di_reg[16];
assign icap_di_rev[22] = icap_di_reg[17];
assign icap_di_rev[21] = icap_di_reg[18];
assign icap_di_rev[20] = icap_di_reg[19];
assign icap_di_rev[19] = icap_di_reg[20];
assign icap_di_rev[18] = icap_di_reg[21];
assign icap_di_rev[17] = icap_di_reg[22];
assign icap_di_rev[16] = icap_di_reg[23];
assign icap_di_rev[31] = icap_di_reg[24];
assign icap_di_rev[30] = icap_di_reg[25];
assign icap_di_rev[29] = icap_di_reg[26];
assign icap_di_rev[28] = icap_di_reg[27];
assign icap_di_rev[27] = icap_di_reg[28];
assign icap_di_rev[26] = icap_di_reg[29];
assign icap_di_rev[25] = icap_di_reg[30];
assign icap_di_rev[24] = icap_di_reg[31];
always @(posedge clk_125mhz_int) begin
case (icap_state)
0: begin
icap_state <= 0;
icap_csib_reg <= 1'b1;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'hffffffff; // dummy word
if (fpga_boot_sync_reg_2 && icap_avail) begin
icap_state <= 1;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'hffffffff; // dummy word
end
end
1: begin
icap_state <= 2;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'hAA995566; // sync word
end
2: begin
icap_state <= 3;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h20000000; // type 1 noop
end
3: begin
icap_state <= 4;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h30008001; // write 1 word to CMD
end
4: begin
icap_state <= 5;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h0000000F; // IPROG
end
5: begin
icap_state <= 0;
icap_csib_reg <= 1'b0;
icap_rdwrb_reg <= 1'b0;
icap_di_reg <= 32'h20000000; // type 1 noop
end
endcase
fpga_boot_sync_reg_0 <= fpga_boot;
fpga_boot_sync_reg_1 <= fpga_boot_sync_reg_0;
fpga_boot_sync_reg_2 <= fpga_boot_sync_reg_1;
end
ICAPE3
icape3_inst (
.AVAIL(icap_avail),
.CLK(clk_125mhz_int),
.CSIB(icap_csib_reg),
.I(icap_di_rev),
.O(),
.PRDONE(),
.PRERROR(),
.RDWRB(icap_rdwrb_reg)
);
// PCIe
wire pcie_sys_clk;
wire pcie_sys_clk_gt;
@ -1441,7 +1595,17 @@ core_inst (
.qsfp_1_i2c_scl_t(qsfp_1_i2c_scl_t),
.qsfp_1_i2c_sda_i(qsfp_1_i2c_sda_i),
.qsfp_1_i2c_sda_o(qsfp_1_i2c_sda_o),
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t)
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t),
/*
* QSPI flash
*/
.fpga_boot(fpga_boot),
.qspi_clk(qspi_clk_int),
.qspi_dq_i(qspi_dq_i_int),
.qspi_dq_o(qspi_dq_o_int),
.qspi_dq_oe(qspi_dq_oe_int),
.qspi_cs(qspi_cs_int)
);
endmodule

View File

@ -258,7 +258,17 @@ module fpga_core #
output wire qsfp_1_i2c_scl_t,
input wire qsfp_1_i2c_sda_i,
output wire qsfp_1_i2c_sda_o,
output wire qsfp_1_i2c_sda_t
output wire qsfp_1_i2c_sda_t,
/*
* QSPI flash
*/
output wire fpga_boot,
output wire qspi_clk,
input wire [3:0] qspi_dq_i,
output wire [3:0] qspi_dq_o,
output wire [3:0] qspi_dq_oe,
output wire qspi_cs
);
// PHC parameters
@ -497,6 +507,13 @@ reg qsfp_1_lp_mode_reg = 1'b0;
reg qsfp_1_i2c_scl_o_reg = 1'b1;
reg qsfp_1_i2c_sda_o_reg = 1'b1;
reg fpga_boot_reg = 1'b0;
reg qspi_clk_reg = 1'b0;
reg qspi_cs_reg = 1'b1;
reg [3:0] qspi_dq_o_reg = 4'd0;
reg [3:0] qspi_dq_oe_reg = 4'd0;
reg pcie_dma_enable_reg = 0;
reg [95:0] get_ptp_ts_96_reg = 0;
@ -534,6 +551,13 @@ assign qsfp_1_i2c_scl_t = qsfp_1_i2c_scl_o_reg;
assign qsfp_1_i2c_sda_o = qsfp_1_i2c_sda_o_reg;
assign qsfp_1_i2c_sda_t = qsfp_1_i2c_sda_o_reg;
assign fpga_boot = fpga_boot_reg;
assign qspi_clk = qspi_clk_reg;
assign qspi_cs = qspi_cs_reg;
assign qspi_dq_o = qspi_dq_o_reg;
assign qspi_dq_oe = qspi_dq_oe_reg;
//assign pcie_dma_enable = pcie_dma_enable_reg;
always @(posedge clk_250mhz) begin
@ -556,6 +580,10 @@ always @(posedge clk_250mhz) begin
axil_csr_bvalid_reg <= 1'b1;
case ({axil_csr_awaddr[15:2], 2'b00})
16'h0040: begin
// FPGA ID
fpga_boot_reg <= axil_csr_wdata == 32'hFEE1DEAD;
end
// GPIO
16'h0110: begin
// GPIO I2C 0
@ -586,6 +614,20 @@ always @(posedge clk_250mhz) begin
qsfp_1_lp_mode_reg <= axil_csr_wdata[13];
end
end
// Flash
16'h0144: begin
// QSPI control
if (axil_csr_wstrb[0]) begin
qspi_dq_o_reg <= axil_csr_wdata[3:0];
end
if (axil_csr_wstrb[1]) begin
qspi_dq_oe_reg <= axil_csr_wdata[11:8];
end
if (axil_csr_wstrb[2]) begin
qspi_clk_reg <= axil_csr_wdata[16];
qspi_cs_reg <= axil_csr_wdata[17];
end
end
// PHC
16'h0230: set_ptp_ts_96_reg[15:0] <= axil_csr_wdata; // PTP set fns
16'h0234: set_ptp_ts_96_reg[45:16] <= axil_csr_wdata; // PTP set ns
@ -655,6 +697,15 @@ always @(posedge clk_250mhz) begin
axil_csr_rdata_reg[12] <= qsfp_1_reset_reg;
axil_csr_rdata_reg[13] <= qsfp_1_lp_mode_reg;
end
// Flash
16'h0140: axil_csr_rdata_reg <= {8'd0, 8'd4, 8'd1, 8'd0}; // Flash ID
16'h0144: begin
// QSPI control
axil_csr_rdata_reg[3:0] <= qspi_dq_i;
axil_csr_rdata_reg[11:8] <= qspi_dq_oe;
axil_csr_rdata_reg[16] <= qspi_clk;
axil_csr_rdata_reg[17] <= qspi_cs;
end
// PHC
16'h0200: axil_csr_rdata_reg <= {8'd0, 8'd0, 8'd0, 8'd0}; // PHC features
16'h0210: axil_csr_rdata_reg <= ptp_ts_96[15:0]; // PTP cur fns
@ -701,6 +752,13 @@ always @(posedge clk_250mhz) begin
qsfp_1_i2c_scl_o_reg <= 1'b1;
qsfp_1_i2c_sda_o_reg <= 1'b1;
fpga_boot_reg <= 1'b0;
qspi_clk_reg <= 1'b0;
qspi_cs_reg <= 1'b1;
qspi_dq_o_reg <= 4'd0;
qspi_dq_oe_reg <= 4'd0;
pcie_dma_enable_reg <= 1'b0;
end
end

View File

@ -235,6 +235,7 @@ def bench():
qsfp_1_intr_n = Signal(bool(0))
qsfp_1_i2c_scl_i = Signal(bool(0))
qsfp_1_i2c_sda_i = Signal(bool(0))
qspi_dq_i = Signal(intbv(0)[4:])
# Outputs
led_red = Signal(intbv(0)[7:])
@ -300,6 +301,11 @@ def bench():
qsfp_1_i2c_scl_t = Signal(bool(1))
qsfp_1_i2c_sda_o = Signal(bool(1))
qsfp_1_i2c_sda_t = Signal(bool(1))
fpga_boot = Signal(bool(0))
qspi_clk = Signal(bool(0))
qspi_dq_o = Signal(intbv(0)[4:])
qspi_dq_oe = Signal(intbv(0)[4:])
qspi_cs = Signal(bool(0))
# sources and sinks
qsfp_0_0_source = xgmii_ep.XGMIISource()
@ -726,7 +732,13 @@ def bench():
qsfp_1_i2c_scl_t=qsfp_1_i2c_scl_t,
qsfp_1_i2c_sda_i=qsfp_1_i2c_sda_i,
qsfp_1_i2c_sda_o=qsfp_1_i2c_sda_o,
qsfp_1_i2c_sda_t=qsfp_1_i2c_sda_t
qsfp_1_i2c_sda_t=qsfp_1_i2c_sda_t,
fpga_boot=fpga_boot,
qspi_clk=qspi_clk,
qspi_dq_i=qspi_dq_i,
qspi_dq_o=qspi_dq_o,
qspi_dq_oe=qspi_dq_oe,
qspi_cs=qspi_cs
)
@always(delay(5))

View File

@ -147,6 +147,7 @@ reg qsfp_1_mod_prsnt_n = 0;
reg qsfp_1_intr_n = 0;
reg qsfp_1_i2c_scl_i = 1;
reg qsfp_1_i2c_sda_i = 1;
reg [3:0] qspi_dq_i = 0;
// Outputs
wire [7:0] led_red;
@ -212,6 +213,11 @@ wire qsfp_1_i2c_scl_o;
wire qsfp_1_i2c_scl_t;
wire qsfp_1_i2c_sda_o;
wire qsfp_1_i2c_sda_t;
wire fpga_boot;
wire qspi_clk;
wire [3:0] qspi_dq_o;
wire [3:0] qspi_dq_oe;
wire qspi_cs;
initial begin
// myhdl integration
@ -308,7 +314,8 @@ initial begin
qsfp_1_mod_prsnt_n,
qsfp_1_intr_n,
qsfp_1_i2c_scl_i,
qsfp_1_i2c_sda_i
qsfp_1_i2c_sda_i,
qspi_dq_i
);
$to_myhdl(
led_red,
@ -373,7 +380,12 @@ initial begin
qsfp_1_i2c_scl_o,
qsfp_1_i2c_scl_t,
qsfp_1_i2c_sda_o,
qsfp_1_i2c_sda_t
qsfp_1_i2c_sda_t,
fpga_boot,
qspi_clk,
qspi_dq_o,
qspi_dq_oe,
qspi_cs
);
// dump file
@ -546,7 +558,13 @@ UUT (
.qsfp_1_i2c_scl_t(qsfp_1_i2c_scl_t),
.qsfp_1_i2c_sda_i(qsfp_1_i2c_sda_i),
.qsfp_1_i2c_sda_o(qsfp_1_i2c_sda_o),
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t)
.qsfp_1_i2c_sda_t(qsfp_1_i2c_sda_t),
.fpga_boot(fpga_boot),
.qspi_clk(qspi_clk),
.qspi_dq_i(qspi_dq_i),
.qspi_dq_o(qspi_dq_o),
.qspi_dq_oe(qspi_dq_oe),
.qspi_cs(qspi_cs)
);
endmodule