# 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 Ports
sd_create_scalar_port -sd_name ${sd_name} -port_name {TX} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {RX} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {REF_CLK_0} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {EXT_RST_N} -port_direction {IN}


# Add clock_gen_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {clock_gen} -instance_name {clock_gen_0}



# Add Core_UART_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {Core_UART} -instance_name {Core_UART_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {Core_UART_0:BIT8} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {Core_UART_0:CSN} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {Core_UART_0:ODD_N_EVEN} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {Core_UART_0:OVERFLOW}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {Core_UART_0:PARITY_EN} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {Core_UART_0:PARITY_ERR}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {Core_UART_0:FRAMING_ERR}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {Core_UART_0:BAUD_VAL} -value {0000000110101}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {Core_UART_0:DATA_OUT}


# 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:XCVR_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 PF_RESET_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PF_RESET} -instance_name {PF_RESET_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {PF_RESET_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {PF_RESET_0:FF_US_RESTORE} -value {GND}



# Add TVS_IP_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {TVS_IP} -instance_name {TVS_IP_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TVS_IP_0:TEMP_HIGH_CLEAR} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TVS_IP_0:TEMP_LOW_CLEAR} -value {VCC}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {TVS_IP_0:TEMP_HIGH}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {TVS_IP_0:TEMP_LOW}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {TVS_IP_0:ACTIVE}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TVS_IP_0:ENABLE_1V} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TVS_IP_0:ENABLE_18V} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TVS_IP_0:ENABLE_25V} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {TVS_IP_0:ENABLE_TEMP} -value {VCC}



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



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:clk_i" "Core_UART_0:CLK" "PF_RESET_0:CLK" "clock_gen_0:OUT0_FABCLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_RESET_0:PLL_LOCK" "clock_gen_0:PLL_LOCK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:rxrdy_i" "Core_UART_0:RXRDY" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:txrdy_i" "Core_UART_0:TXRDY" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"EXT_RST_N" "PF_RESET_0:EXT_RST_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_RESET_0:BANK_x_VDDI_STATUS" "PF_RESET_0:BANK_y_VDDI_STATUS" "INIT_MONITOR_0:BANK_6_VDDI_STATUS" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_RESET_0:INIT_DONE" "INIT_MONITOR_0:DEVICE_INIT_DONE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_RESET_0:FPGA_POR_N" "INIT_MONITOR_0:FABRIC_POR_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:resetn_i" "Core_UART_0:RESET_N" "PF_RESET_0:FABRIC_RESET_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_RESET_0:PLL_POWERDOWN_B" "clock_gen_0:PLL_POWERDOWN_N_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"REF_CLK_0" "clock_gen_0:REF_CLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Core_UART_0:RX" "RX" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_IP_0:VALID" "TVS_to_UART_0:valid_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:oen_o" "Core_UART_0:OEN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:wen_o" "Core_UART_0:WEN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Core_UART_0:TX" "TX" }

# Add bus net connections
#sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:data_out_i" "Core_UART_0:DATA_OUT" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_to_UART_0:channel_i" "TVS_IP_0:CHANNEL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"TVS_IP_0:VALUE" "TVS_to_UART_0:value_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Core_UART_0:DATA_IN" "TVS_to_UART_0:data_in_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}
