# 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 {IO_IN_0} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {IO_IN_1} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {IO_IN_2} -port_direction {IN}
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_P_0} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE1_RXD_N_0} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE1_RXD_P_0} -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 {RESETN} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {gate_en_in} -port_direction {IN}

sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE0_RX_VAL} -port_direction {OUT}
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_P_0} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE1_TXD_N_0} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LANE1_TXD_P_0} -port_direction {OUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_1} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_2} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_3} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_4} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_5} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_6} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_7} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {LED_8} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {OUT0_FABCLK_GATED_0} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {dout_or} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {error_o} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {lock_o} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {rx_val_o} -port_direction {OUT}



# Add PolarFire_Fabric_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PolarFire_Fabric} -instance_name {PolarFire_Fabric_0}



# Add XCVR_Top_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {XCVR_Top} -instance_name {XCVR_Top_0}
sd_create_pin_group -sd_name ${sd_name} -group_name {PADs_IN_0} -instance_name {XCVR_Top_0} -pin_names {"LANE0_RXD_P_0" "LANE0_RXD_N_0" "LANE1_RXD_P_0" "LANE1_RXD_N_0" }
sd_create_pin_group -sd_name ${sd_name} -group_name {PADs_OUT_0} -instance_name {XCVR_Top_0} -pin_names {"LANE0_TXD_P_0" "LANE0_TXD_N_0" "LANE1_TXD_P_0" "LANE1_TXD_N_0" }
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {XCVR_Top_0:error_o_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {XCVR_Top_0:lock_o_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {XCVR_Top_0:rx_val_o_0}



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"IO_IN_0" "XCVR_Top_0:IO_IN_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IO_IN_1" "XCVR_Top_0:IO_IN_1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"IO_IN_2" "XCVR_Top_0:IO_IN_2" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_N_0" "XCVR_Top_0:LANE0_RXD_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_P_0" "XCVR_Top_0:LANE0_RXD_P_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RX_VAL" "XCVR_Top_0:LANE0_RX_VAL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_N_0" "XCVR_Top_0:LANE0_TXD_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_P_0" "XCVR_Top_0:LANE0_TXD_P_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE1_RXD_N_0" "XCVR_Top_0:LANE1_RXD_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE1_RXD_P_0" "XCVR_Top_0:LANE1_RXD_P_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE1_TXD_N_0" "XCVR_Top_0:LANE1_TXD_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE1_TXD_P_0" "XCVR_Top_0:LANE1_TXD_P_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_1" "PolarFire_Fabric_0:LED_1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_2" "PolarFire_Fabric_0:LED_2" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_3" "PolarFire_Fabric_0:LED_3" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_4" "PolarFire_Fabric_0:LED_4" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_5" "PolarFire_Fabric_0:LED_5" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_6" "PolarFire_Fabric_0:LED_6" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_7" "PolarFire_Fabric_0:LED_7" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_8" "PolarFire_Fabric_0:LED_8" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"OUT0_FABCLK_GATED_0" "PolarFire_Fabric_0:OUT0_FABCLK_GATED_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:BANK_6_VDDI_STATUS" "XCVR_Top_0:BANK_x_VDDI_STATUS" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:FABRIC_POR_N" "XCVR_Top_0:FPGA_POR_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:RCOSC_160MHZ_GL" "XCVR_Top_0:REF_CLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:RESETN" "RESETN" "XCVR_Top_0:Reset_In" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:Reset_out" "XCVR_Top_0:INIT_DONE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:XCVR_INIT_DONE" "XCVR_Top_0:PCS_ARST_N" "XCVR_Top_0:PMA_ARST_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:dout_or" "dout_or" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PolarFire_Fabric_0:gate_en_in" "gate_en_in" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"REF_CLK_PAD_N" "XCVR_Top_0:REF_CLK_PAD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"REF_CLK_PAD_P" "XCVR_Top_0:REF_CLK_PAD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"XCVR_Top_0:error_o" "error_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"XCVR_Top_0:lock_o" "lock_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"XCVR_Top_0:rx_val_o" "rx_val_o" }



# 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}
