Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
feCodeGen.pl 97.92 KiB
#!/usr/bin/perl

#//     \page feCodeGen feCodeGen.pl
#//     Documentation for feCodeGen.pl - Controls parsing of Matlab files and code generation.
#//

#// \n\n This script is invoked by the auto generated build/src/epics/util/Makefile. \n\n\n
use File::Path;
use Cwd;
require "lib/SUM.pm";
require "lib/AND.pm";
require "lib/MULTIPLY.pm";
require "lib/DIVIDE.pm";
require "lib/SATURATE.pm";
require "lib/MUX.pm";
require "lib/DEMUX.pm";
require "lib/RelationalOperator.pm";
require "lib/Switch.pm";
require "lib/Gain.pm";
require "lib/Abs.pm";
require "lib/MATH.pm";
require "lib/Dac20.pm";

#// \b REQUIRED \b ARGUMENTS: \n
#//	- Model file name with .mdl extension \n
#//	- Output file name (from Makefile, this is same name without .mdl extension.\n
#//	
#// Remaining arguments listed in code are optional and not normally used by RCG Makefile. \n\n

# Normal call from Makefile is just first two args.

#//	
#// \b PRODUCTS: \n
#//	- C code 
#//		- C source file <em> (build/src/fe/model_name/model_name.c)</em>, representing user model parts and processing sequence.\n
#//		- C code Makefile <em>(build/fe/model_name/Makefile)</em>. \n
#//	- Header file <em>(build/src/include/model_name/model_name.h)</em>, containing data passing structure between real-time code and EPICS sequencer code. \n
#//	- EPICS channel list <em>(build/src/epics/fmseq/model_name)</em>, to be used later by <em>fmseq.pl</em> to produce EPICS products. Included in this file: \n
#//		- List of all filter modules \n
#//		- List of all EPICS channel names and types. \n
#//		- List of extra test points ie those not associated with Filter modules. \n
#//	- EPICS state code Makefile <em>(build/config/Makefile.model_nameepics) </em>
#//	- File containing list of all code source files <em>(build/src/epics/util/sources.model_name)</em> \n
#//	- File containing list of all DAQ channels and rates <em>(build/src/epics/fmseq/model_name_daq)</em>.
#//		- NOTE: Opened here, but actually written to by <em>lib/Parser3.pm</em>
#//	- Foton IIR filter definition file <em>(build/build/model_nameepics/config/MODEL_NAME.txt)</em>
#//	- Various common MEDM screen files, including:
#//		- MODEL_NAME_GDS_TP.adl: Contains primary runtime diags, including timing, networks, DAQ. 
#//			- This code calls sub in <em>lib/medmGenGdsTp.pm</em> to actually produce the MEDM file.
#//		- MODEL_NAME_DAC_MONITOR_num.adl: Outputs from DAC modules, directly from the main sequencer code. 
#//			- This code calls sub in <em>lib/DAC.pm</em> or <em>lib/DAC18.pm</em> to actually produce the MEDM files.
#//		- MODEL_NAME_MONITOR_ADCnum.adl: Inputs to all ADC channels used by the model. 
#//			- This code calls sub in <em>lib/ADC.pm</em> to actually produce the MEDM files.
#//		- MODEL_NAME_MATRIXNAME.adl: Inputs from matrix elements.
#//			- This code calls sub in <em>mkmatrix.pl</em> to actually produce the MEDM files.
#//		- MODEL_NAME_FILTERNAME.adl: Interface for Filter modules.
#//			- This code calls sub in <em>/lib/Filt.pm</em> to actually produce the MEDM files.
#//	- Parser diagnostics file <em>(build/epics/util/diags.txt)</em>, which lists all parts and their connections after model parsing.

#	
#//	
#// <b>BASIC CODE SEQUENCE:</b>: \n
#//	

die "Usage: $PROGRAM_NAME <MDL file> <Output file name> [<DCUID number>] [<ifo>] [<speed>]\n\t" . "ifo is (e.g.) H1, M1; speed is 2K, 16K, 32K or 64K\n"
        if (@ARGV != 2 && @ARGV != 3 && @ARGV != 4 && @ARGV != 5);

#Setup current working directory and pointer to RCG source directory.
$currWorkDir = &Cwd::cwd();
$rcg_src_dir = $ENV{"RCG_SRC_DIR"};