# Creating SmartDesign PolarFire_Fabric
set sd_name {PolarFire_Fabric}
create_smartdesign -sd_name ${sd_name}

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

# Create top level Ports
sd_create_scalar_port -sd_name ${sd_name} -port_name {Reset_out} -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 {dout_or} -port_direction {OUT}
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 {RESETN} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {XCVR_INIT_DONE} -port_direction {OUT}
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 {RCOSC_160MHZ_GL} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {FABRIC_POR_N} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {BANK_6_VDDI_STATUS} -port_direction {OUT}


# Add CCC_0_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {CCC_0} -instance_name {CCC_0_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CCC_0_0:OUT3_FABCLK_GATED_0_EN} -value {VCC}



# Add fabric_logic_0 instance
sd_instantiate_hdl_module -sd_name ${sd_name} -hdl_module_name {fabric_logic} -hdl_file {hdl\fabric_logic.v} -instance_name {fabric_logic_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {fabric_logic_0:LD} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {fabric_logic_0:DIN} -value {GND}



# Add Gate_control_0 instance
sd_instantiate_hdl_module -sd_name ${sd_name} -hdl_module_name {Gate_control} -hdl_file {hdl\Gate_control.v} -instance_name {Gate_control_0}



# Add INIT_MONITOR_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {INIT_MONITOR} -instance_name {INIT_MONITOR_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:PCIE_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:USRAM_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:SRAM_INIT_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:USRAM_INIT_FROM_SNVM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:USRAM_INIT_FROM_UPROM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:USRAM_INIT_FROM_SPI_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:SRAM_INIT_FROM_SNVM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:SRAM_INIT_FROM_UPROM_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:SRAM_INIT_FROM_SPI_DONE}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {INIT_MONITOR_0:AUTOCALIB_DONE}



# Add OSC_clock_source_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {OSC_clock_source} -instance_name {OSC_clock_source_0}



# Add reset_sync0_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {reset_sync0} -instance_name {reset_sync0_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync0_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync0_0:FF_US_RESTORE} -value {GND}



# Add reset_sync1_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {reset_sync1} -instance_name {reset_sync1_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync1_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync1_0:FF_US_RESTORE} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {reset_sync1_0:PLL_POWERDOWN_B}



# Add reset_sync2_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {reset_sync2} -instance_name {reset_sync2_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync2_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync2_0:FF_US_RESTORE} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {reset_sync2_0:PLL_POWERDOWN_B}



# Add reset_sync3_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {reset_sync3} -instance_name {reset_sync3_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync3_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {reset_sync3_0:FF_US_RESTORE} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {reset_sync3_0:PLL_POWERDOWN_B}



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync1_0:BANK_y_VDDI_STATUS" "reset_sync1_0:BANK_x_VDDI_STATUS" "reset_sync0_0:BANK_x_VDDI_STATUS" "reset_sync0_0:BANK_y_VDDI_STATUS" "INIT_MONITOR_0:BANK_6_VDDI_STATUS" "reset_sync2_0:BANK_x_VDDI_STATUS" "reset_sync2_0:BANK_y_VDDI_STATUS" "reset_sync3_0:BANK_x_VDDI_STATUS" "reset_sync3_0:BANK_y_VDDI_STATUS" "BANK_6_VDDI_STATUS" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync0_0:CLK" "CCC_0_0:OUT0_FABCLK_GATED_0" "fabric_logic_0:CLK" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync1_0:CLK" "CCC_0_0:OUT1_FABCLK_GATED_0" "fabric_logic_0:CLK1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync2_0:CLK" "CCC_0_0:OUT2_FABCLK_GATED_0" "fabric_logic_0:CLK2" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync3_0:CLK" "CCC_0_0:OUT3_FABCLK_GATED_0" "fabric_logic_0:CLK3" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync1_0:PLL_LOCK" "reset_sync0_0:PLL_LOCK" "reset_sync2_0:PLL_LOCK" "reset_sync3_0:PLL_LOCK" "CCC_0_0:PLL_LOCK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"dout_or" "fabric_logic_0:dout_or" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync1_0:FPGA_POR_N" "reset_sync0_0:FPGA_POR_N" "INIT_MONITOR_0:FABRIC_POR_N" "reset_sync2_0:FPGA_POR_N" "reset_sync3_0:FPGA_POR_N" "FABRIC_POR_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CCC_0_0:OUT0_FABCLK_GATED_0_EN" "CCC_0_0:OUT1_FABCLK_GATED_0_EN" "CCC_0_0:OUT2_FABCLK_GATED_0_EN" "Gate_control_0:gate_en_out" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"gate_en_in" "Gate_control_0:gate_en_in" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_1" "fabric_logic_0:LED_1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_2" "fabric_logic_0:LED_2" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_3" "fabric_logic_0:LED_3" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_4" "fabric_logic_0:LED_4" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_5" "fabric_logic_0:LED_5" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_6" "fabric_logic_0:LED_6" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_7" "fabric_logic_0:LED_7" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED_8" "fabric_logic_0:LED_8" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"RCOSC_160MHZ_GL" "OSC_clock_source_0:RCOSC_160MHZ_GL" "CCC_0_0:REF_CLK_0" "Gate_control_0:clk" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Reset_out" "reset_sync1_0:INIT_DONE" "reset_sync0_0:INIT_DONE" "INIT_MONITOR_0:DEVICE_INIT_DONE" "reset_sync2_0:INIT_DONE" "reset_sync3_0:INIT_DONE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync0_0:FABRIC_RESET_N" "fabric_logic_0:RST" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync0_0:PLL_POWERDOWN_B" "CCC_0_0:PLL_POWERDOWN_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync1_0:FABRIC_RESET_N" "fabric_logic_0:RST1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync2_0:FABRIC_RESET_N" "fabric_logic_0:RST2" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"reset_sync3_0:FABRIC_RESET_N" "fabric_logic_0:RST3" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"RESETN" "reset_sync1_0:EXT_RST_N" "reset_sync0_0:EXT_RST_N" "reset_sync2_0:EXT_RST_N" "reset_sync3_0:EXT_RST_N" "Gate_control_0:rstn" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"XCVR_INIT_DONE" "INIT_MONITOR_0:XCVR_INIT_DONE" }



# 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 PolarFire_Fabric
generate_component -component_name ${sd_name}
