VPATH=src/:build/ CONFIG_DIR = configurations_3tr SRC_DIR = src SRC_COMMON_DIR=$(SRC_DIR)/common BUILD_DIR ?= build TMP = tmp TCS2ASM_CONST=$(SRC_COMMON_DIR)/run_parameters TCS2ASM_PRE_CONST=$(SRC_COMMON_DIR)/run_pre_const TCS2ASM_POST_CONST=$(SRC_COMMON_DIR)/run_post_const INS_ERR=insert_error # Programs used TCC = trapcc PYTHON ?= python3 program=lb2tp program_rx_reset=lb2tp -s0 --reset_rx --status --SFPinfo program_rx_get=lb2tp -s0 --opt_out program_pre=pretrigger program_scsn_peek=scsn_peek config_of_rob3a=./cnf_rob simulation_of_rob3a=./sim_rob # 3 << 16 are the HCM and BM, bits 0..15 are the normal MCMs. # for only one column the mask is 0x3000F, for full ROB is 0x3FFFF MCM_PRESENT_MSK=0x3FFFF #MCM_PRESENT_MSK=0x3000F data_va=./data # option to write all registers: --wr_default # alternativ: skip writing the power up values: --skip_default SCSN_DAT_OPT=--wr_default # -Ve : overflow as error not as warning # -g : ignore all ORG directives (set the start address at some defined point in program) # ignoring the ORGs leads to better usage of the IMEM, but for simulation it is good to have some well recognized start addresses of the different program parts. ASM_OPTIONS=-Ve ASM_MAIN=fitred # default: rob_sim default: help help: ## Print this help text @perl -nle 'printf(" %-20s %s\n",$$1,$$2) if /^(\S+):.*##\s*(.*)/' Makefile .PHONY: build build: pip build.ninja ## Run ninja to build everything ninja pip: ## Install Python dependencies with pip $(PYTHON) -m pip install -r requirements.txt .PHONY: build.ninja build.ninja: ## Regenerate ninja config file $(PYTHON) scripts/cfginfo.py -o cfginfo.yaml jinja2 templates/ninja.j2 cfginfo.yaml > $@ # Venelin - test, can be deleted later # filter all scsn and extended commands to get only the configuration for one ROB3A $(CONFIG_DIR)/test.dat: $(TMP)/$(ASM_MAIN).dat $(SRC_COMMON_DIR)/reset.tcs $(SRC_DIR)/trg/ptrg.tcs $(SRC_COMMON_DIR)/main.tcs $(SRC_COMMON_DIR)/scsn_ids.tcs $(TCS2ASM_PRE_CONST).tcs $(TCS2ASM_CONST).tcs $(TCS2ASM_POST_CONST).tcs $(TCC) $(SRC_COMMON_DIR)/reset.tcs > $@ cat $(TMP)/$(ASM_MAIN).dat >> $@ $(TCC) $(SRC_DIR)/trg/ptrg.tcs >> $@ $(TMP)/$(ASM_MAIN).dat: $(TMP)/$(ASM_MAIN).cpu0.code $(TMP)/$(ASM_MAIN).cpu1.code $(TMP)/$(ASM_MAIN).cpu2.code $(TMP)/$(ASM_MAIN).cpu3.code codem -i0 $(TMP)/$(ASM_MAIN).cpu0.code \ -i1 $(TMP)/$(ASM_MAIN).cpu1.code \ -i2 $(TMP)/$(ASM_MAIN).cpu2.code \ -i3 $(TMP)/$(ASM_MAIN).cpu3.code \ -o $@ -3 -s127 -v $(TCS2ASM_CONST).asm: $(SRC_COMMON_DIR)/scsn_ids.tcs $(TCS2ASM_PRE_CONST).tcs $(TCS2ASM_CONST).tcs $(TCS2ASM_POST_CONST).tcs $(TCC) -s $(TCS2ASM_CONST).asm $(SRC_COMMON_DIR)/scsn_ids.tcs $(TCS2ASM_PRE_CONST).tcs $(TCS2ASM_CONST).tcs $(TCS2ASM_POST_CONST).tcs $(TMP)/$(ASM_MAIN).cpu0.code $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu0.labe0s.tcs: $(TCS2ASM_CONST).asm $(SRC_COMMON_DIR)/*.asm asm_mimd -i $(SRC_COMMON_DIR)/$(ASM_MAIN).asm -od $(TMP)/$(ASM_MAIN).cpu0.code -ol \ $(TMP)/$(ASM_MAIN).cpu0.log -oc $(TMP)/$(ASM_MAIN).cpu0c.log -dcpu0 \ -oa $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu0.labels.tcs -oh \ $(TMP)/$(ASM_MAIN).imem0.hex $(ASM_OPTIONS) @grep -i 'warning\|error' $(TMP)/$(ASM_MAIN).cpu0.log $(TMP)/$(ASM_MAIN).cpu1.code $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu1.labels.tcs: $(TCS2ASM_CONST).asm $(SRC_COMMON_DIR)/*.asm asm_mimd -i $(SRC_COMMON_DIR)/$(ASM_MAIN).asm -od $(TMP)/$(ASM_MAIN).cpu1.code -ol \ $(TMP)/$(ASM_MAIN).cpu1.log -oc $(TMP)/$(ASM_MAIN).cpu1c.log -dcpu1 \ -oa $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu1.labels.tcs -oh \ $(TMP)/$(ASM_MAIN).imem1.hex $(ASM_OPTIONS) @grep -i 'warning\|error' $(TMP)/$(ASM_MAIN).cpu1.log $(TMP)/$(ASM_MAIN).cpu2.code $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu2.labels.tcs: $(TCS2ASM_CONST).asm $(SRC_COMMON_DIR)/*.asm asm_mimd -i $(SRC_COMMON_DIR)/$(ASM_MAIN).asm -od $(TMP)/$(ASM_MAIN).cpu2.code -ol \ $(TMP)/$(ASM_MAIN).cpu2.log -oc $(TMP)/$(ASM_MAIN).cpu2c.log -dcpu2 \ -oa $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu2.labels.tcs -oh \ $(TMP)/$(ASM_MAIN).imem2.hex $(ASM_OPTIONS) @grep -i 'warning\|error' $(TMP)/$(ASM_MAIN).cpu2.log $(TMP)/$(ASM_MAIN).cpu3.code $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu3.labels.tcs: $(TCS2ASM_CONST).asm $(SRC_COMMON_DIR)/*.asm asm_mimd -i $(SRC_COMMON_DIR)/$(ASM_MAIN).asm -od $(TMP)/$(ASM_MAIN).cpu3.code -ol \ $(TMP)/$(ASM_MAIN).cpu3.log -oc $(TMP)/$(ASM_MAIN).cpu3c.log -dcpu3 \ -oa $(SRC_COMMON_DIR)/$(ASM_MAIN).cpu3.labels.tcs -oh \ $(TMP)/$(ASM_MAIN).imem3.hex $(ASM_OPTIONS) @grep -i 'warning\|error' $(TMP)/$(ASM_MAIN).cpu3.log rob_config: $(CONFIG_DIR)/test.dat $(TCC) ./src/common/patch_single_rob3a.tcs > ./src/common/patch_single_rob3a.dat topti_cnf -i $^ \ $(SCSN_DAT_OPT) \ -p ./src/common/patch_single_rob3a.dat \ -o $(config_of_rob3a)/sc_send_rob.dat --rob_pos 4 -d $(config_of_rob3a)/config_dump.txt scp $(config_of_rob3a)/sc_send_rob.dat angelov@va-tosh:TRD.svn/TRAPconfig.svn/cnf_rob rob_sim: $(CONFIG_DIR)/test.dat #./src/common/patch_single_rob3a_sim.tcs # $(TCC) ./src/common/patch_single_rob3a_sim.tcs > ./src/common/patch_single_rob3a_sim.dat topti_cnf -i $< \ -o $(simulation_of_rob3a)/sc_send.dat --rob_pos 4 \ --pmask $(MCM_PRESENT_MSK) --no_imem -d $(simulation_of_rob3a)/config_dump.txt cp $(TMP)/fitred.imem0.hex $(simulation_of_rob3a)/imem0.hex cp $(TMP)/fitred.imem1.hex $(simulation_of_rob3a)/imem1.hex cp $(TMP)/fitred.imem2.hex $(simulation_of_rob3a)/imem2.hex cp $(TMP)/fitred.imem3.hex $(simulation_of_rob3a)/imem3.hex @grep -i 'warning\|error' $(TMP)/fitred.cpu?.log # -p ./src/common/patch_single_rob3a_sim.dat init: ## init the ROB @echo "*** Send the scsn commands to the ROB3A via scsn" $(program) --rob_reset -i $(config_of_rob3a)/sc_send_rob.dat -o $(config_of_rob3a)/out @echo "*** Send one pretrigger 5 - go to acq mode" $(program_pre) 5 # switch to acq mode @echo "*** Clear the ORI receiver" $(program_rx_reset) -rm $(data_va)/* @echo "*** Send one pretrigger 1 - first event is configuration send!" $(program_pre) 1 # first event with configuration $(program_rx_get) $(data_va)/evn00000001.txt tdump_packed $(data_va)/evn00000001.txt > $(config_of_rob3a)/unpacked_cnf # unpack the configuration @echo "*** Dump only two registers from the unpacked received configuration" grep "SMMODE" $(config_of_rob3a)/unpacked_cnf grep "ADCMSK" $(config_of_rob3a)/unpacked_cnf @sleep 2 @echo "*** Dump the state of the TRAPs" @$(program_scsn_peek) smcmd @$(program_scsn_peek) all > rconf_ini.txt rob_reset: $(program) --rob_reset cmp_cnf: @$(program_scsn_peek) all > rconf_end.txt diff -y rconf_ini.txt rconf_end.txt |less ins_err: $(SRC_COMMON_DIR)/$(INS_ERR).tcs $(TCC) $(SRC_COMMON_DIR)/$(INS_ERR).tcs > $(config_of_rob3a)/$(INS_ERR).dat $(program) -i $(config_of_rob3a)/$(INS_ERR).dat pre1000: $(program_pre) 1 1000 300 sleep 1 pre: $(program_rx_reset) -rm $(data_va)/* $(program_pre) 1 $(program_rx_get) $(data_va)/evn00000001.txt read_raw -d 1 -i1 $(data_va)/evn00000001.txt -o1 data/ read_raw -d 2 -i1 $(data_va)/evn00000001.txt |less read_raw -d 1 -i1 $(data_va)/evn00000001.txt pre1001r: pre1000 pre pow_cyc: pow_off pow_on pow_off: @echo "*** Turn ROB power off" $(program) --rob_off sleep 2 pow_on: @echo "*** Turn ROB power on" $(program) --rob_on sleep 1 rob_all: rob_config pow_cyc init # --------------------------------------------------------------------------- # Tom's targets for building config bundles for the wingDB .PRECIOUS: upload/%.sqlldr upload/%.sqlldr: build.ninja ; ninja $@ define WINGDBCMD awk '/Wing_User/{u=$$3} /Wing_Password/{p=$$3} /Wing_Dbname/{d=$$3} END {print u"/"p"@"d}' endef VERSION = $(shell scripts/version.py --format name ) BUNDLES = $(patsubst cfgbundles/%.yaml, %, $(wildcard cfgbundles/*.yaml) ) SQLLDR_FILES = $(patsubst %, upload/%-$(VERSION).sqlldr, $(BUNDLES) ) .PHONY: web uct bundles bundles: $(patsubst %, upload/%-$(VERSION).sqlldr, $(BUNDLES) ) web: $(SQLLDR_FILES) ## Upload TRAPconfig to TRD web site scp $^ lxplus.cern.ch:/eos/project-a/alice-trd/www/download/trapconf/ uct_tests: upload/run3_tests-$(VERSION).sqlldr ## Upload to wingDB@UCT and update tags ssh alicetrd wing_tags update $$(seq 220 222) $(VERSION) ssh alicetrd wing_tags ls | grep $(VERSION) uct_kr: upload/run3_krypton-$(VERSION).sqlldr ## Upload to wingDB@UCT and update tags ssh alicetrd wing_tags update $$(seq 220 222) $(VERSION) ssh alicetrd wing_tags ls | grep $(VERSION) .PRECIOUS: upload/%.uct.log upload/%.uct.log: WINGDB=$(shell ssh alicetrd cat /etc/trd/wingdb.conf | $(WINGDBCMD)) upload/%.uct.log: upload/%.sqlldr scp $< alicetrd.phy.uct.ac.za: ssh alicetrd sqlldr $(WINGDB) control=$(notdir $<) scp alicetrd.phy.uct.ac.za:$*.log $@ graph: graph.pdf ## generate a ninja dependency graph open $< graph.pdf: build.ninja ninja -t graph | dot -Tpdf -ograph.pdf # --------------------------------------------------------------------------- # .PHONY: clean init pre pre1000 rob_config rob_sim pre1000r cmp_cnf ins_err rob_reset # .PHONY: clean clean: if [ -f build.ninja ] ; then ninja -t clean; fi rm -f $(TCS2ASM_CONST).asm find $(SRC_COMMON_DIR)/ -name '*.cpu?.labels.tcs' -exec rm -f '{}' ';' find $(TMP)/ -name '*.cpu?.code' -exec rm -f '{}' ';' find $(TMP)/ -name '*.cpu?.log' -exec rm -f '{}' ';' find $(TMP)/ -name '*.cpu?c.log' -exec rm -f '{}' ';' find $(TMP)/ -name '*.imem?.hex' -exec rm -f '{}' ';' find $(TMP)/ -name '*.dat' -exec rm -f '{}' ';' rm -rf build/ rm -f src/common/runpar_*.asm