# Creating SmartDesign "MAC_Hololink"
set sd_name {MAC_Hololink}
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 {DI} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {Device_Init_Done} -port_direction {IN}
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_0} -port_direction {IN}
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 {SIF_TARGET_0_i_sif_axis_tlast_0} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {SIF_TARGET_0_i_sif_axis_tvalid_0} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {SIF_TARGET_1_i_sif_axis_tlast_1} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {SIF_TARGET_1_i_sif_axis_tvalid_1} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {i_sif_clk} -port_direction {IN}

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 {CAM1_TRNG_RSTN} -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 {CAM2_TRNG_RSTN} -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 {OUT2_FABCLK_0} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {OUT3_FABCLK_0} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {PLL_LOCK_0} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {SIF_TARGET_0_o_sif_axis_tready_0} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {SIF_TARGET_1_o_sif_axis_tready_1} -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 {SIF_TARGET_0_i_sif_axis_tdata_0} -port_direction {IN} -port_range {[63:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {SIF_TARGET_0_i_sif_axis_tkeep_0} -port_direction {IN} -port_range {[7:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {SIF_TARGET_0_i_sif_axis_tuser_0} -port_direction {IN} -port_range {[1:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {SIF_TARGET_1_i_sif_axis_tdata_1} -port_direction {IN} -port_range {[63:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {SIF_TARGET_1_i_sif_axis_tkeep_1} -port_direction {IN} -port_range {[7:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {SIF_TARGET_1_i_sif_axis_tuser_1} -port_direction {IN} -port_range {[1:0]}

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

# Create top level Bus interface Ports
sd_create_bif_port -sd_name ${sd_name} -port_name {SIF_TARGET_0} -port_bif_vlnv {AMBA:AMBA4:AXI4Stream:r0p0_1} -port_bif_role {slave} -port_bif_mapping {\
"TVALID:SIF_TARGET_0_i_sif_axis_tvalid_0" \
"TREADY:SIF_TARGET_0_o_sif_axis_tready_0" \
"TDATA:SIF_TARGET_0_i_sif_axis_tdata_0" \
"TKEEP:SIF_TARGET_0_i_sif_axis_tkeep_0" \
"TLAST:SIF_TARGET_0_i_sif_axis_tlast_0" \
"TUSER:SIF_TARGET_0_i_sif_axis_tuser_0" } 

sd_create_bif_port -sd_name ${sd_name} -port_name {SIF_TARGET_1} -port_bif_vlnv {AMBA:AMBA4:AXI4Stream:r0p0_1} -port_bif_role {slave} -port_bif_mapping {\
"TVALID:SIF_TARGET_1_i_sif_axis_tvalid_1" \
"TREADY:SIF_TARGET_1_o_sif_axis_tready_1" \
"TDATA:SIF_TARGET_1_i_sif_axis_tdata_1" \
"TKEEP:SIF_TARGET_1_i_sif_axis_tkeep_1" \
"TLAST:SIF_TARGET_1_i_sif_axis_tlast_1" \
"TUSER:SIF_TARGET_1_i_sif_axis_tuser_1" } 

# Add AND2_0 instance
sd_instantiate_macro -sd_name ${sd_name} -macro_name {AND2} -instance_name {AND2_0}



# Add AND2_1 instance
sd_instantiate_macro -sd_name ${sd_name} -macro_name {AND2} -instance_name {AND2_1}



# Add AND2_2 instance
sd_instantiate_macro -sd_name ${sd_name} -macro_name {AND2} -instance_name {AND2_2}



# Add AND2_3 instance
sd_instantiate_macro -sd_name ${sd_name} -macro_name {AND2} -instance_name {AND2_3}



# Add CoreAPB3_C1_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {CoreAPB3_C1} -instance_name {CoreAPB3_C1_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {CoreAPB3_C1_0:APBmslave0}



# 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_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:FPGA_POR_N} -value {VCC}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {CORERESET_PF_C1_0:PLL_POWERDOWN_B}



# Add HoloLink_SD_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {HoloLink_SD} -instance_name {HoloLink_SD_0}
sd_invert_pins -sd_name ${sd_name} -pin_names {HoloLink_SD_0:i_sys_rst}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {HoloLink_SD_0:o_ptp_rst}



# Add MAC_BaseR_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {MAC_BaseR} -instance_name {MAC_BaseR_0}



# Add MAC_BaseR_1 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {MAC_BaseR} -instance_name {MAC_BaseR_1}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {MAC_BaseR_1:LANE0_RX_CLK_R}



# Add PF_CCC_C1_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PF_CCC_C1} -instance_name {PF_CCC_C1_0}



# Add PF_SYSTEM_SERVICES_C0_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PF_SYSTEM_SERVICES_C0} -instance_name {PF_SYSTEM_SERVICES_C0_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_SYSTEM_SERVICES_C0_0:USR_CMD_ERROR}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_SYSTEM_SERVICES_C0_0:USR_BUSY}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_SYSTEM_SERVICES_C0_0:SS_BUSY}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_SYSTEM_SERVICES_C0_0:USR_RDVLD}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {PF_SYSTEM_SERVICES_C0_0:SYSSERV_INIT_REQ}



# Add PF_XCVR_REF_CLK_C0_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PF_XCVR_REF_CLK_C0} -instance_name {PF_XCVR_REF_CLK_C0_0}



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



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:A" "AND2_1:A" "AND2_2:A" "AND2_3:A" "CORERESET_PF_C1_0:FABRIC_RESET_N" "HoloLink_SD_0:i_sys_rst" "PF_SYSTEM_SERVICES_C0_0:RESETN" "pps_stretch_0:rstn_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:B" "MAC_BaseR_0:LANE0_TX_CLK_STABLE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:Y" "MAC_BaseR_0:I_SYS_TX_SRESETN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_1:B" "MAC_BaseR_0:LANE0_RX_VAL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_1:Y" "MAC_BaseR_0:I_SYS_RX_SRESETN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_2:B" "MAC_BaseR_1:LANE0_TX_CLK_STABLE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_2:Y" "MAC_BaseR_1:I_SYS_TX_SRESETN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_3:B" "MAC_BaseR_1:LANE0_RX_VAL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_3:Y" "MAC_BaseR_1:I_SYS_RX_SRESETN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_EN" "CAM1_TRNG_RSTN" "CAM2_EN" "CAM2_TRNG_RSTN" "HoloLink_SD_0:o_init_done" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_SCL" "HoloLink_SD_0:CAM1_SCL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_SDA" "HoloLink_SD_0:CAM1_SDA" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM2_SCL" "HoloLink_SD_0:CAM2_SCL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM2_SDA" "HoloLink_SD_0:CAM2_SDA" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CLK" "HoloLink_SD_0:CLK" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:CLK" "HoloLink_SD_0:i_hif_clk" "MAC_BaseR_0:I_SYS_CLK" "MAC_BaseR_1:I_SYS_CLK" "OUT2_FABCLK_0" "PF_CCC_C1_0:OUT0_FABCLK_0" "pps_stretch_0:hif_clk_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:INIT_DONE" "Device_Init_Done" "MAC_BaseR_0:Device_Init_Done" "MAC_BaseR_1:Device_Init_Done" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C1_0:PLL_LOCK" "PF_CCC_C1_0:PLL_LOCK_0" "PLL_LOCK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DI" "HoloLink_SD_0:DI" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DO" "HoloLink_SD_0:DO" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"EEPROM_SCL" "HoloLink_SD_0:EEPROM_SCL" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"EEPROM_SDA" "HoloLink_SD_0:EEPROM_SDA" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"FLASH" "HoloLink_SD_0:FLASH" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:IFACE" "IFACE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:SS" "SS" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:i_apb_clk" "MAC_BaseR_0:PCLK" "MAC_BaseR_1:PCLK" "PF_CCC_C1_0:OUT1_FABCLK_0" "PF_SYSTEM_SERVICES_C0_0:CLK" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:i_ptp_clk" "PF_CCC_C1_0:OUT2_FABCLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:i_sif_clk" "i_sif_clk" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:o_pps" "pps_stretch_0:pps_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_N" "MAC_BaseR_0:LANE0_RXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_N_0" "MAC_BaseR_1:LANE0_RXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_P" "MAC_BaseR_0:LANE0_RXD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_RXD_P_0" "MAC_BaseR_1:LANE0_RXD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_N" "MAC_BaseR_0:LANE0_TXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_N_0" "MAC_BaseR_1:LANE0_TXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_P" "MAC_BaseR_0:LANE0_TXD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LANE0_TXD_P_0" "MAC_BaseR_1:LANE0_TXD_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"LED1" "pps_stretch_0:pps_stretch_o" "pps_stretch_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"MAC_BaseR_0:LANE0_RX_CLK_R" "PF_CCC_C1_0:REF_CLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"MAC_BaseR_0:REF_CLK" "MAC_BaseR_1:REF_CLK" "PF_XCVR_REF_CLK_C0_0:REF_CLK" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"OUT3_FABCLK_0" "PF_CCC_C1_0:OUT3_FABCLK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_XCVR_REF_CLK_C0_0:REF_CLK_PAD_N" "REF_CLK_PAD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"PF_XCVR_REF_CLK_C0_0:REF_CLK_PAD_P" "REF_CLK_PAD_P" }

# Add bus net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"GPIO" "HoloLink_SD_0:GPIO" }

# Add bus interface net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"CoreAPB3_C1_0:APB3mmaster" "HoloLink_SD_0:APB_INITIATOR" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CoreAPB3_C1_0:APBmslave1" "PF_SYSTEM_SERVICES_C0_0:APBSlave" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:HIF_INITIATOR_0" "MAC_BaseR_0:AXI4S_TRGT" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:HIF_INITIATOR_1" "MAC_BaseR_1:AXI4S_TRGT" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:HIF_TARGET_0" "MAC_BaseR_0:AXI4S_INITR" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:HIF_TARGET_1" "MAC_BaseR_1:AXI4S_INITR" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:SIF_TARGET_0" "SIF_TARGET_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"HoloLink_SD_0:SIF_TARGET_1" "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 "MAC_Hololink"
generate_component -component_name ${sd_name}
