function [inst_addr] = pb_inst_radio_shape_cyclops(freq, cos_phase, sin_phase, tx_phase, tx_enable, phase_reset, trigger_scan, useshape, amp, real_add_sub, imag_add_sub, channel_swap, flags, inst, inst_data, length)
% FUNCTION NAME:
%   pb_inst_radio_shape_cyclops
%   
% DESCRIPTION:
%   Write an instruction that makes use of the pulse shape feature of some 
%   RadioProcessor boards. This adds two new paramters, use_shape and amp, which 
%   control the shape feature. All other parameters are identical to the 
%   pb_inst_radio() function. If you do not wish to use the shape feature, the 
%   pb_inst_radio() function can be used instead.
%
% INPUTS:
%   freq - Selects which frequency register to use.
%
%   cos_phase - Selects which phase register to use for the cos (real) channel.
%
%   sin_phase - Selects which phase register to use for the sin (imaginary) channel.
%
%   tx_phase - Selects which phase register to use for the TX channel.
%
%   tx_enable - When this is 1, the TX channel will be output on the Analog Out 
%               connector. When this is 0, Analog Out channel will be turned off.
%
%   phase_reset - When this is 1, the phase of all DDS channels will be reset to 
%                 their time=0 phase. They will stay in this state until the value 
%                 of this bit returns to 0.
%
%   trigger_scan - When this is 1, a scan will be triggered. To start a second 
%                  scan, this bit must be set to 0 and then back to 1.
%
%   use_shape - Select whether or not to use shaped pulses. If this is 0, a 
%               regular non-shaped pulse (hard pulse) is output. If it is nonzero, 
%               the shaped pulse is used. The pulse shape waveform can be set 
%               using the pb_dds_load() function.
%
%   amp - Select which amplitude register to use. The values of the amplitude 
%         registers can be set with pb_set_amp().
%
%   real_add_sub - A '1' will add the incoming real signal with the real value 
%                  stored in memory. A '0' will subtract the incoming real 
%                  signal from the real value stored in memory.
%
%   imag_add_sub - A '1' will add the incoming imaginary signal with the 
%                  imaginary value stored in memory. A '0' will subtract the 
%                  incoming imaginary signal from the imaginary value stored 
%                  in memory.
%
%   channel_swap - A '0' will keep all real values in the real part of the signal 
%                  averager (and all imaginary values in the imaginary part of the 
%                  averager), while a '1' will cause the incoming real signal to be 
%                  added (or subtracted) from the imaginary value stored in memory, 
%                  and will cause that value to be stored in the imaginary section 
%                  of memory. A '1' will also cause the incoming imaginary signal 
%                  to be added (or subtracted) from the real value stored in memory,
%                  and will cause that value to be stored in the real section of memory.
%
%   flags - Controls the state of the user available digital out pins. Set every 
%           bit to one for each flag you want to set high
%
%   inst - Which instruction to use. See manual for details.
%
%   inst_data - Some instructions require additional data. This allows that data 
%               to be specified. See manual for details.
%
%   length - Time until the next instruction is executed in nanoseconds
%
% OUTPUTS:
%   inst_addr - The address of the instruction, can be used for branch 
%               instructions. Counts from 0.
%
% $Revision: R2017a$ 
% $Author: SpinCore Technologies, Inc.$
% $Date: November 17, 2023$
% ------------------------------------------------------------------------------

global SPINAPI_DLL_NAME;

if(isnumeric(flags))
    num_flags = flags;
else
    num_flags = hex2dec(flags);
end

if(isa(inst, 'char'))
    inst = upper(inst);
end

switch inst
	case {'CONTINUE', 0}
		op_code = 0;
	case {'STOP', 1}
		op_code = 1;
	case {'LOOP', 2}
		op_code = 2;
	case {'END_LOOP', 3}
		op_code = 3;
	case {'JSR', 4}
		op_code = 4;
	case {'RTS', 5}
		op_code = 5;
	case {'BRANCH', 6}
		op_code = 6;
	case {'LONG_DELAY', 7}
		op_code = 7;
	case {'WAIT', 8}
		op_code = 8;
end

inst_addr = calllib(SPINAPI_DLL_NAME, 'pb_inst_radio_shape_cyclops', freq,cos_phase, sin_phase, tx_phase, tx_enable, phase_reset, trigger_scan, useshape, amp, real_add_sub, imag_add_sub, channel_swap, num_flags, op_code, inst_data, length);

end