# Creating SmartDesign IMX334_IF_TOP
set sd_name {IMX334_IF_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 {ARST_N} -port_direction {IN}
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} -port_direction {IN} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {INIT_DONE} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {TRNG_RST_N} -port_direction {IN}

sd_create_scalar_port -sd_name ${sd_name} -port_name {CAMCLK_RESET_N} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {CAMERA_CLK} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {PARALLEL_CLOCK} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {frame_start_o} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {frame_valid_o} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {line_valid_o} -port_direction {OUT}


# Create top level Bus Ports
sd_create_bus_port -sd_name ${sd_name} -port_name {CAM1_RXD} -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 {c1_data_out_o} -port_direction {OUT} -port_range {[31:0]}


sd_create_pin_slices -sd_name ${sd_name} -pin_name {c1_data_out_o} -pin_slices {[15:8]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {c1_data_out_o} -pin_slices {[23:16]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {c1_data_out_o} -pin_slices {[31:24]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {c1_data_out_o} -pin_slices {[7:0]}
# Add AND2_0 instance
sd_instantiate_macro -sd_name ${sd_name} -macro_name {AND2} -instance_name {AND2_0}



# Add CAM_IOD_TIP_TOP_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {CAM_IOD_TIP_TOP} -instance_name {CAM_IOD_TIP_TOP_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CAM_IOD_TIP_TOP_0:RESTART_TRNG} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CAM_IOD_TIP_TOP_0:HS_SEL} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CAM_IOD_TIP_TOP_0:SKIP_TRNG} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CAM_IOD_TIP_TOP_0:HS_IO_CLK_PAUSE} -value {GND}



# Add CORERESET_PF_C3_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {CORERESET_PF_C3} -instance_name {CORERESET_PF_C3_0}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C3_0:BANK_x_VDDI_STATUS} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C3_0:BANK_y_VDDI_STATUS} -value {VCC}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C3_0:SS_BUSY} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C3_0:FF_US_RESTORE} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {CORERESET_PF_C3_0:FPGA_POR_N} -value {GND}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {CORERESET_PF_C3_0:PLL_POWERDOWN_B}



# Add mipicsi2rxdecoderPF_C0_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {mipicsi2rxdecoderPF_C1} -instance_name {mipicsi2rxdecoderPF_C0_0}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {mipicsi2rxdecoderPF_C0_0:DATA_O} -pin_slices {[19:12]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {mipicsi2rxdecoderPF_C0_0:DATA_O} -pin_slices {[29:22]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {mipicsi2rxdecoderPF_C0_0:DATA_O} -pin_slices {[39:32]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {mipicsi2rxdecoderPF_C0_0:DATA_O} -pin_slices {[9:2]}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:FRAME_END_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:LINE_START_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:LINE_END_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:ECC_ERROR_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:CRC_ERROR_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:EBD_VALID_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:VIRTUAL_CHANNEL_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:DATA_TYPE_O}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {mipicsi2rxdecoderPF_C0_0:WORD_COUNT_O}



# Add PF_CCC_C2_0 instance
sd_instantiate_component -sd_name ${sd_name} -component_name {PF_CCC_C2} -instance_name {PF_CCC_C2_0}



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:A" "TRNG_RST_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:B" "CORERESET_PF_C3_0:PLL_LOCK" "PF_CCC_C2_0:PLL_LOCK_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:Y" "CAM_IOD_TIP_TOP_0:TRAINING_RESETN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"ARST_N" "CAM_IOD_TIP_TOP_0:ARST_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RX_CLK_N" "CAM_IOD_TIP_TOP_0:RX_CLK_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RX_CLK_P" "CAM_IOD_TIP_TOP_0:RX_CLK_P" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAMCLK_RESET_N" "CORERESET_PF_C3_0:FABRIC_RESET_N" "mipicsi2rxdecoderPF_C0_0:RESET_N_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAMERA_CLK" "CAM_IOD_TIP_TOP_0:RX_CLK_G" "PF_CCC_C2_0:REF_CLK_0" "mipicsi2rxdecoderPF_C0_0:CAM_CLOCK_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L0_LP_DATA" "mipicsi2rxdecoderPF_C0_0:L0_LP_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L0_LP_DATA_N" "mipicsi2rxdecoderPF_C0_0:L0_LP_DATA_N_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L1_LP_DATA" "mipicsi2rxdecoderPF_C0_0:L1_LP_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L1_LP_DATA_N" "mipicsi2rxdecoderPF_C0_0:L1_LP_DATA_N_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L2_LP_DATA" "mipicsi2rxdecoderPF_C0_0:L2_LP_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L2_LP_DATA_N" "mipicsi2rxdecoderPF_C0_0:L2_LP_DATA_N_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L3_LP_DATA" "mipicsi2rxdecoderPF_C0_0:L3_LP_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L3_LP_DATA_N" "mipicsi2rxdecoderPF_C0_0:L3_LP_DATA_N_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:training_done_o" "CORERESET_PF_C3_0:EXT_RST_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C3_0:CLK" "PARALLEL_CLOCK" "PF_CCC_C2_0:OUT0_FABCLK_0" "mipicsi2rxdecoderPF_C0_0:PARALLEL_CLOCK_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CORERESET_PF_C3_0:INIT_DONE" "INIT_DONE" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"frame_start_o" "mipicsi2rxdecoderPF_C0_0:FRAME_START_O" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"frame_valid_o" "mipicsi2rxdecoderPF_C0_0:FRAME_VALID_O" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"line_valid_o" "mipicsi2rxdecoderPF_C0_0:LINE_VALID_O" }

# Add bus net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM1_RXD" "CAM_IOD_TIP_TOP_0:RXD" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L0_RXD_DATA" "mipicsi2rxdecoderPF_C0_0:L0_HS_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L1_RXD_DATA" "mipicsi2rxdecoderPF_C0_0:L1_HS_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L2_RXD_DATA" "mipicsi2rxdecoderPF_C0_0:L2_HS_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:L3_RXD_DATA" "mipicsi2rxdecoderPF_C0_0:L3_HS_DATA_I" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAM_IOD_TIP_TOP_0:RXD_N" "RXD_N" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"c1_data_out_o[15:8]" "mipicsi2rxdecoderPF_C0_0:DATA_O[19:12]" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"c1_data_out_o[23:16]" "mipicsi2rxdecoderPF_C0_0:DATA_O[29:22]" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"c1_data_out_o[31:24]" "mipicsi2rxdecoderPF_C0_0:DATA_O[39:32]" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"c1_data_out_o[7:0]" "mipicsi2rxdecoderPF_C0_0:DATA_O[9:2]" }


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