# Creating SmartDesign DATA_GENERATOR
set sd_name {DATA_GENERATOR}
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 {clk} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {reset_n} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {err_en} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {prbs_wave_sel} -port_direction {IN}

sd_create_bus_port -sd_name ${sd_name} -port_name {wave_sel} -port_direction {IN} -port_range {[1:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {prbs_sel} -port_direction {IN} -port_range {[1:0]}
sd_create_bus_port -sd_name ${sd_name} -port_name {data_out} -port_direction {OUT} -port_range {[31:0]}

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



# Add prbs_wav_sel_0 instance
sd_instantiate_hdl_module -sd_name ${sd_name} -hdl_module_name {prbs_wav_sel} -hdl_file {hdl\prbs_wav_sel.v} -instance_name {prbs_wav_sel_0}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {prbs_wav_sel_0:data_out} -pin_slices {[31:0]}
sd_create_pin_slices -sd_name ${sd_name} -pin_name {prbs_wav_sel_0:data_out} -pin_slices {[63:32]}
sd_mark_pins_unused -sd_name ${sd_name} -pin_names {prbs_wav_sel_0:data_out[63:32]}



# Add wave_gen16bit_0 instance
sd_instantiate_hdl_module -sd_name ${sd_name} -hdl_module_name {wave_gen16bit} -hdl_file {hdl\wav_gen_16bit.v} -instance_name {wave_gen16bit_0}



# Add scalar net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"wave_gen16bit_0:clk" "clk" "prbs_generator_0:clk" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"err_en" "prbs_generator_0:err_en" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"prbs_wave_sel" "prbs_wav_sel_0:prbs_wav_sel" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"wave_gen16bit_0:reset_n" "reset_n" "prbs_generator_0:reset_n" }

# Add bus net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"prbs_wav_sel_0:data_out[31:0]" "data_out" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"prbs_generator_0:prbs_out" "prbs_wav_sel_0:prbs_in" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"prbs_sel" "prbs_generator_0:prbs_sel" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"wave_gen16bit_0:data_out" "prbs_wav_sel_0:wave_in" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"wave_gen16bit_0:wave_sel" "wave_sel" }


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