# Creating SmartDesign DDR_Read_FHD_RX_0
set sd_name {DDR_Read_FHD_RX_0}
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 {ddr_data_valid_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {disp_clk_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {frame_end_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {read_ack_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {read_done_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {read_en_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {resetn_i} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {sys_clk_i} -port_direction {IN}

sd_create_scalar_port -sd_name ${sd_name} -port_name {data_valid_o} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {read_req_o} -port_direction {OUT}


# Create top level Bus Ports
sd_create_bus_port -sd_name ${sd_name} -port_name {frame_start_addr_i} -port_direction {IN} -port_range {[7:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {h_pan_i} -port_direction {IN} -port_range {[11:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {horz_resl_i} -port_direction {IN} -port_range {[15:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {v_pan_i} -port_direction {IN} -port_range {[11:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {wdata_i} -port_direction {IN} -port_range {[511:0]}

sd_create_bus_port -sd_name ${sd_name} -port_name {beats_to_read_0} -port_direction {OUT} -port_range {[15:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {data_o} -port_direction {OUT} -port_range {[15:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {read_start_addr_o} -port_direction {OUT} -port_range {[31:0]}


# Add AND2_0 instance
sd_instantiate_macro -sd_name ${sd_name} -macro_name {AND2} -instance_name {AND2_0}
sd_invert_pins -sd_name ${sd_name} -pin_names {AND2_0:B}



# Add data_unpacker_FHD_RX_0 instance
sd_instantiate_hdl_module -sd_name ${sd_name} -hdl_module_name {data_unpacker_FHD_RX} -hdl_file {hdl\data_unpacker_FHD_RX_0.vhd} -instance_name {data_unpacker_FHD_RX_0}



# Add DDR_read_controller_HDMI_RX_0 instance
sd_instantiate_hdl_module -sd_name ${sd_name} -hdl_module_name {DDR_read_controller_HDMI_RX} -hdl_file {hdl\DDR_read_controller_HDMI_RX.vhd} -instance_name {DDR_read_controller_HDMI_RX_0}



# Add Register_Config_1 instance
sd_instantiate_hdl_core -sd_name ${sd_name} -hdl_core_name {Register_Config} -instance_name {Register_Config_1}
# Exporting Parameters of instance Register_Config_1
sd_configure_core_instance -sd_name ${sd_name} -instance_name {Register_Config_1} -params {\
"G_REGISTER_WIDTH:513" }\
-validate_rules 0
sd_save_core_instance_config -sd_name ${sd_name} -instance_name {Register_Config_1}
sd_update_instance -sd_name ${sd_name} -instance_name {Register_Config_1}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {Register_Config_1:Data_I} -pin_slices {[511:0]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {Register_Config_1:Data_I} -pin_slices {[512:512]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {Register_Config_1:Data_O} -pin_slices {[511:0]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {Register_Config_1:Data_O} -pin_slices {[512:512]}



# Add video_fifo_0 instance
sd_instantiate_hdl_core -sd_name ${sd_name} -hdl_core_name {video_fifo} -instance_name {video_fifo_0}
# Exporting Parameters of instance video_fifo_0
sd_configure_core_instance -sd_name ${sd_name} -instance_name {video_fifo_0} -params {\
"g_HALF_EMPTY_THRESHOLD:1048" \
"g_INPUT_VIDEO_DATA_BIT_WIDTH:512" \
"g_VIDEO_FIFO_AWIDTH:12" }\
-validate_rules 0
sd_save_core_instance_config -sd_name ${sd_name} -instance_name {video_fifo_0}
sd_update_instance -sd_name ${sd_name} -instance_name {video_fifo_0}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:wfull_o}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:wafull_o}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:rempty_o}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:raempty_o}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:rhempty_o}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:wdata_count_o}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {video_fifo_0:rdata_count_o}



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:A" "DDR_read_controller_HDMI_RX_0:reset_i" "Register_Config_1:RESETN_I" "data_unpacker_FHD_RX_0:reset_i" "resetn_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:B" "DDR_read_controller_HDMI_RX_0:frame_end_i" "frame_end_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"AND2_0:Y" "video_fifo_0:rresetn_i" "video_fifo_0:wresetn_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:read_ackn_i" "read_ack_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:read_done_i" "read_done_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:read_en_i" "data_unpacker_FHD_RX_0:read_en_i" "read_en_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:read_req_o" "read_req_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:sys_clk_i" "Register_Config_1:SYS_CLK_I" "sys_clk_i" "video_fifo_0:wclock_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Register_Config_1:Data_I[512:512]" "ddr_data_valid_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Register_Config_1:Data_O[512:512]" "video_fifo_0:wen_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_unpacker_FHD_RX_0:data_valid_o" "data_valid_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_unpacker_FHD_RX_0:disp_clk_i" "disp_clk_i" "video_fifo_0:rclock_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_unpacker_FHD_RX_0:fifo_data_valid_i" "video_fifo_0:rdata_rdy_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_unpacker_FHD_RX_0:fifo_read_o" "video_fifo_0:ren_i" }

# Add bus net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:frame_start_addr_i" "frame_start_addr_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:h_pan_i" "h_pan_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:read_start_addr_o" "read_start_addr_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"DDR_read_controller_HDMI_RX_0:v_pan_i" "v_pan_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Register_Config_1:Data_I[511:0]" "wdata_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"Register_Config_1:Data_O[511:0]" "video_fifo_0:wdata_i" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"beats_to_read_0" "data_unpacker_FHD_RX_0:beats_to_read_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_o" "data_unpacker_FHD_RX_0:data_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_unpacker_FHD_RX_0:data_i" "video_fifo_0:rdata_o" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"data_unpacker_FHD_RX_0:horz_resl_i" "horz_resl_i" }


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