# Creating SmartDesign "top"
set sd_name {top}
create_smartdesign -sd_name ${sd_name}

# Disable auto promotion of pins of type 'pad'
auto_promote_pad_pins -promote_all 0

# Create top level Scalar Ports
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_RX_CLK_N_0} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_RX_CLK_N} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_RX_CLK_P_0} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_RX_CLK_P} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CLK_IN} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {DI} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {FLASH} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {IFACE} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_RXD_N_0} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_RXD_N} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_RXD_P_0} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_RXD_P} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {REF_CLK_PAD_N} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {REF_CLK_PAD_P} -port_direction {IN} -port_is_pad {1}

sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_CLK} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_EN} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM2_CLK} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM2_EN} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {DO} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_TXD_N_0} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_TXD_N} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_TXD_P_0} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_TXD_P} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED1} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {RX_CLK_G_0} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {RX_CLK_G} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {TEN} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {c1_frame_valid_o} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {pps_stretch_o} -port_direction {OUT}

sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_SCL} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM1_SDA} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM2_SCL} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAM2_SDA} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CLK} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {EEPROM_SCL} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {EEPROM_SDA} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {SS} -port_direction {INOUT} -port_is_pad {1}

# Create top level Bus Ports
sd_create_bus_port -sd_name ${sd_name} -port_name {RXD_0} -port_direction {IN} -port_range {[3:0]} -port_is_pad {1}
sd_create_bus_port -sd_name ${sd_name} -port_name {RXD_N_0} -port_direction {IN} -port_range {[3:0]} -port_is_pad {1}
sd_create_bus_port -sd_name ${sd_name} -port_name {RXD_N} -port_direction {IN} -port_range {[3:0]} -port_is_pad {1}
sd_create_bus_port -sd_name ${sd_name} -port_name {RXD} -port_direction {IN} -port_range {[3:0]} -port_is_pad {1}

sd_create_bus_port -sd_name ${sd_name} -port_name {GPIO} -port_direction {INOUT} -port_range {[15:0]}

sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TEN} -value {GND}
# Add CORERESET_PF_C1_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {CORERESET_PF_C1} -instance_name {CORERESET_PF_C1_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:EXT_RST_N} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:BANK_x_VDDI_STATUS} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:BANK_y_VDDI_STATUS} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:FF_US_RESTORE} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:PLL_POWERDOWN_B}



# Add IMX477_IF_TOP_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {IMX477_IF_TOP} -instance_name {IMX477_IF_TOP_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {IMX477_IF_TOP_0:c1_frame_valid_o}



# Add IMX477_IF_TOP_1 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {IMX477_IF_TOP} -instance_name {IMX477_IF_TOP_1}



# Add MAC_Hololink_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {MAC_Hololink} -instance_name {MAC_Hololink_0}



# Add PF_INIT_MONITOR_C0_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PF_INIT_MONITOR_C0} -instance_name {PF_INIT_MONITOR_C0_0}
sd_create_pin_group -sd_name ${sd_name} -group_name {Group} -instance_name {PF_INIT_MONITOR_C0_0} -pin_names {"SRAM_INIT_FROM_SPI_DONE" "PCIE_INIT_DONE" "USRAM_INIT_DONE" "SRAM_INIT_DONE" "XCVR_INIT_DONE" "USRAM_INIT_FROM_SNVM_DONE" "USRAM_INIT_FROM_UPROM_DONE" "USRAM_INIT_FROM_SPI_DONE" "SRAM_INIT_FROM_SNVM_DONE" "SRAM_INIT_FROM_UPROM_DONE" }
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:PCIE_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:USRAM_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:SRAM_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:XCVR_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:USRAM_INIT_FROM_SNVM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:USRAM_INIT_FROM_UPROM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:USRAM_INIT_FROM_SPI_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:SRAM_INIT_FROM_SNVM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:SRAM_INIT_FROM_UPROM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_INIT_MONITOR_C0_0:SRAM_INIT_FROM_SPI_DONE}



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_CLK" "CAM2_CLK" "MAC_Hololink_0:OUT3_FABCLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_EN" "MAC_Hololink_0:CAM1_EN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RX_CLK_N" "IMX477_IF_TOP_0:CAM1_RX_CLK_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RX_CLK_N_0" "IMX477_IF_TOP_1:CAM1_RX_CLK_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RX_CLK_P" "IMX477_IF_TOP_0:CAM1_RX_CLK_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RX_CLK_P_0" "IMX477_IF_TOP_1:CAM1_RX_CLK_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_SCL" "MAC_Hololink_0:CAM1_SCL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_SDA" "MAC_Hololink_0:CAM1_SDA" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM2_EN" "MAC_Hololink_0:CAM2_EN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM2_SCL" "MAC_Hololink_0:CAM2_SCL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM2_SDA" "MAC_Hololink_0:CAM2_SDA" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CLK" "MAC_Hololink_0:CLK" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CLK_IN" "MAC_Hololink_0:REF_CLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:CLK" "IMX477_IF_TOP_0:sif_clk" "IMX477_IF_TOP_1:sif_clk" "MAC_Hololink_0:OUT2_FABCLK_0" "MAC_Hololink_0:i_sif_clk" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:FABRIC_RESET_N" "IMX477_IF_TOP_0:RESET_N" "IMX477_IF_TOP_1:RESET_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:FPGA_POR_N" "IMX477_IF_TOP_0:FPGA_POR_N" "IMX477_IF_TOP_1:FPGA_POR_N" "PF_INIT_MONITOR_C0_0:FABRIC_POR_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:INIT_DONE" "IMX477_IF_TOP_0:INIT_DONE" "IMX477_IF_TOP_1:INIT_DONE" "MAC_Hololink_0:Device_Init_Done" "PF_INIT_MONITOR_C0_0:DEVICE_INIT_DONE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:PLL_LOCK" "MAC_Hololink_0:PLL_LOCK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DI" "MAC_Hololink_0:DI" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DO" "MAC_Hololink_0:DO" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"EEPROM_SCL" "MAC_Hololink_0:EEPROM_SCL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"EEPROM_SDA" "MAC_Hololink_0:EEPROM_SDA" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"FLASH" "MAC_Hololink_0:FLASH" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IFACE" "MAC_Hololink_0:IFACE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_0:ARST_N" "IMX477_IF_TOP_1:ARST_N" "PF_INIT_MONITOR_C0_0:AUTOCALIB_DONE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_0:RX_CLK_G" "RX_CLK_G" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_0:TRNG_RST_N" "MAC_Hololink_0:CAM1_TRNG_RSTN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_1:RX_CLK_G" "RX_CLK_G_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_1:TRNG_RST_N" "MAC_Hololink_0:CAM2_TRNG_RSTN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_1:c1_frame_valid_o" "c1_frame_valid_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_N" "MAC_Hololink_0:LANE0_RXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_N_0" "MAC_Hololink_0:LANE0_RXD_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_P" "MAC_Hololink_0:LANE0_RXD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_P_0" "MAC_Hololink_0:LANE0_RXD_P_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_N" "MAC_Hololink_0:LANE0_TXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_N_0" "MAC_Hololink_0:LANE0_TXD_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_P" "MAC_Hololink_0:LANE0_TXD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_P_0" "MAC_Hololink_0:LANE0_TXD_P_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED1" "MAC_Hololink_0:LED1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"MAC_Hololink_0:REF_CLK_PAD_N" "REF_CLK_PAD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"MAC_Hololink_0:REF_CLK_PAD_P" "REF_CLK_PAD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"MAC_Hololink_0:SS" "SS" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"MAC_Hololink_0:pps_stretch_o" "pps_stretch_o" }

# Add bus net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"GPIO" "MAC_Hololink_0:GPIO" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_0:RXD" "RXD" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_0:RXD_N" "RXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_1:RXD" "RXD_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_1:RXD_N" "RXD_N_0" }

# Add bus interface net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_0:BIF_1" "MAC_Hololink_0:SIF_TARGET_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IMX477_IF_TOP_1:BIF_1" "MAC_Hololink_0:SIF_TARGET_1" }

# Re-enable auto promotion of pins of type 'pad'
auto_promote_pad_pins -promote_all 1
# Save the SmartDesign 
save_smartdesign -sd_name ${sd_name}
# Generate SmartDesign "top"
generate_component -component_name ${sd_name}
