Commit f94f8ea5 authored by Renaud Pacalet's avatar Renaud Pacalet
Browse files

reorg., add VHDL code

parent 85b254f9
.DEFAULT_GOAL := help
NULL :=
SPACE := $(NULL) $(NULL)
DEVNULL := $(if $(V),,&> /dev/null)
# silence all recipes if V undefined or equal to empty string
$(V).SILENT:
###############
# Compilation #
###############
BUILD := build
$(shell mkdir -p $(BUILD) >/dev/null)
SRC := src
INCLUDE := include
......@@ -15,29 +21,32 @@ ifneq ($(DEBUG),)
CFLAGS += -DDEBUG
endif
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD)/$*.Td
COMPILE = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
POSTCOMPILE = mv -f $(BUILD)/$*.Td $(BUILD)/$*.d && touch $@
LD := gcc
LDFLAGS :=
LDLIBS := -lm
EXEC := make-pchk alist-to-pchk pchk-to-alist make-ldpc print-pchk make-gen print-gen rand-src encode transmit decode extract verify mod2dense-test mod2sparse-test mod2convert-test rand-test qc-to-pchk make-standard-qc-matrix stats
COMPILE = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
POSTCOMPILE = mv -f $(BUILD)/$*.Td $(BUILD)/$*.d && touch $@
EXEC := make-pchk alist-to-pchk pchk-to-alist make-ldpc print-pchk make-gen print-gen rand-src encode \
transmit decode extract verify mod2dense-test mod2sparse-test mod2convert-test rand-test qc-to-pchk make-standard-qc-matrix stats
.PHONY: help all clean
help::
@grep -v -e '^```' -e '^<!--' README.md
grep -v -e '^```' -e '^<!--' README.md
all: $(EXEC)
$(BUILD)/rand.o: CFLAGS += -DRAND_FILE=\"`pwd`/randfile\"
%.o: %.c
$(BUILD)/%.o: $(SRC)/%.c $(BUILD)/%.d
$(BUILD)/%.o: $(SRC)/%.c $(BUILD)/%.d | $(BUILD)
$(COMPILE) -o $@ $<
$(POSTCOMPILE)
$(BUILD):
mkdir -p $@
make-pchk: $(addprefix $(BUILD)/,make-pchk.o mod2sparse.o mod2dense.o mod2convert.o rcode.o alloc.o intio.o open.o)
alist-to-pchk: $(addprefix $(BUILD)/,alist-to-pchk.o mod2sparse.o mod2dense.o mod2convert.o rcode.o alloc.o intio.o open.o)
pchk-to-alist: $(addprefix $(BUILD)/,pchk-to-alist.o mod2sparse.o mod2dense.o mod2convert.o rcode.o alloc.o intio.o open.o)
......@@ -76,10 +85,4 @@ include $(wildcard $(patsubst %,$(BUILD)/%.d,$(basename $(wildcard $(SRC)/*.c)))
include Tests.mk
#################
# Documentation #
#################
include Doc.mk
# vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab textwidth=0:
......@@ -18,10 +18,11 @@ Goals:
all Compile C sources
test Run test for one code
test-all Run tests for all supported standard codes
test-clean Delete all files generated by tests
list List supported standard codes
stat Print statistics about row degrees of supported standard parity check matrices
doc Compile SCMS documentation (`scms.pdf`)
clean Delete all generated files
clean Delete all executables and object files
Variables (default value):
DEBUG If set, compile decode with -DDEBUG ()
......@@ -85,13 +86,14 @@ $ make test [VARIABLE=VALUE...]
The test:
* generates the parity check matrix of the code in text format (`build/STANDARD_Z_M_N.qc`, e.g. `build/80211n_27_12_24.qc`),
* converts the text format to `pchk` format (`build/STANDARD_Z_M_N.pchk`, e.g. `build/80211n_27_12_24.pchk`),
* generates the code's generator matrix (`build/STANDARD_Z_M_N.gen`, e.g. `build/80211n_27_12_24.gen`),
* randomly generates source frames (`build/SEED_T_D.src` where `D=(N-M)*Z`, e.g. `build/19_100_324.src`),
* encodes them (`build/STANDARD_Z_M_N_SEED_T_D.enc`, e.g. `build/80211n_27_12_24_19_100_324.enc`),
* adds noise to emulate a real transmission channel (`build/STANDARD_Z_M_N_channel_SEED_T_D.enc` where `channel` is `CHANNEL` with spaces substituted by `_`, e.g. `build/80211n_27_12_24_awgn_0.5_19_100_324.rec`),
* decodes the "_received_" frames (`build/STANDARD_Z_M_N_channel_decmethod_SEED_T_D.dec` where `decmethod` is `DECMETHOD` with spaces substituted by `_`, e.g. `build/80211n_27_12_24_awgn_0.5_scms_com_16_6_4_19_100_324.dec`).
* generates the parity check matrix of the code in text format: `build/STANDARD_Z_M_N.qc`
* converts the text format to `pchk` format: `build/STANDARD_Z_M_N.pchk`
* generates the code's generator matrix: `build/STANDARD_Z_M_N.gen`
* randomly generates source frames: `build/SEED_T_D.src` where `D=(N-M)*Z`
* encodes them: `build/STANDARD_Z_M_N_SEED_T_D.enc`
* adds noise to emulate a real transmission channel: `build/STANDARD_Z_M_N_channel_SEED_T_D.enc`
* decodes the "_received_" frames: `build/STANDARD_Z_M_N_channel_decmethod_SEED_T_D.dec`
* print a summary of the decoding result and also stored it in a log file: `build/STANDARD_Z_M_N_channel_decmethod_SEED_T_D.log`
To run a test for one specific standard code, type:
......
......@@ -2,22 +2,13 @@
# Testing #
###########
NULL :=
SPACE := $(NULL) $(NULL)
export V := 0
ifeq ($(V),0)
DEVNULL := &> /dev/null
AT := @
endif
DECODE := ./decode
ENCODE := ./encode
MAKEGEN := ./make-gen
MAKEQC := ./make-standard-qc-matrix
QCTOPCHK := ./qc-to-pchk
RANDSRC := ./rand-src
TRANSMIT := ./transmit
DECODE := decode
ENCODE := encode
MAKEGEN := make-gen
MAKEQC := make-standard-qc-matrix
QCTOPCHK := qc-to-pchk
RANDSRC := rand-src
TRANSMIT := transmit
# Defaults
export T := 100
......@@ -47,8 +38,8 @@ M := $(word 2,$(ZMN))
N := $(word 3,$(ZMN))
CODE := $(shell printf '%s_%03d_%02d_%02d' "$(STANDARD)" "$(Z)" "$(M)" "$(N)")
CODES += $(CODE)
$(BUILD)/$(CODES).gc: $(QCMATRIX)
$(AT)cp -f $< $@
$(BUILD)/$(CODE).qc: $(QCMATRIX)
cp -f $< $@
endif
# single test
......@@ -74,43 +65,40 @@ $(1)-SOURCE := $$(BUILD)/$$(SEED)_$$(T)_$$($(1)-D).src
$(1)-ENC := $$(BUILD)/$(1)_$$(SEED)_$$(T)_$$($(1)-D).enc
$(1)-REC := $$(BUILD)/$(1)_$$(CHANNEL_NAME)_$$(SEED)_$$(T)_$$($(1)-D).rec
$(1)-DEC := $$(BUILD)/$(1)_$$(CHANNEL_NAME)_$$(DECMETHOD_NAME)_$$(SEED)_$$(T)_$$($(1)-D).dec
$(1)-DONE := $$(BUILD)/$(1)_$$(CHANNEL_NAME)_$$(DECMETHOD_NAME)_$$(SEED)_$$(T)_$$($(1)-D).done
.PRECIOUS: $$($(1)-QC) $$($(1)-PCHK) $$($(1)-GEN) $$($(1)-SOURCE) $$($(1)-ENC) $$($(1)-REC) $$($(1)-DEC) $$($(1)-DONE)
.PRECIOUS: $$($(1)-QC) $$($(1)-PCHK) $$($(1)-GEN) $$($(1)-SOURCE) $$($(1)-ENC) $$($(1)-REC) $$($(1)-DEC)
$(1): $$($(1)-DONE)
@cat $$<
$(1): $$($(1)-DEC)
$$($(1)-QC): | $$(MAKEQC)
$$(AT)$$(MAKEQC) --standard="$$($(1)-STANDARD)" --lifting=$$($(1)-Z) --brows=$$($(1)-M) --bcols=$$($(1)-N) $$@
./$$(MAKEQC) --standard="$$($(1)-STANDARD)" --lifting=$$($(1)-Z) --brows=$$($(1)-M) --bcols=$$($(1)-N) $$@
$$($(1)-PCHK): $$($(1)-QC) | $$(QCTOPCHK)
$$(AT)$$(QCTOPCHK) $$< $$@
./$$(QCTOPCHK) $$< $$@
$$($(1)-GEN): $$($(1)-PCHK) | $$(MAKEGEN)
$$(AT)$$(MAKEGEN) $$< $$@ $$(GENMETHOD) $$(DEVNULL)
./$$(MAKEGEN) $$< $$@ $$(GENMETHOD) $$(DEVNULL)
$$($(1)-REC): $$($(1)-ENC) | $$(TRANSMIT)
$$(AT)$$(TRANSMIT) $$< $$@ $$(SEED) $$(CHANNEL) $$(DEVNULL)
./$$(TRANSMIT) $$< $$@ $$(SEED) $$(CHANNEL) $$(DEVNULL)
$$($(1)-ENC): $$($(1)-PCHK) $$($(1)-GEN) $$($(1)-SOURCE) | $$(ENCODE)
$$(AT)$$(ENCODE) $$^ $$@ $$(DEVNULL)
./$$(ENCODE) $$^ $$@ $$(DEVNULL)
$$($(1)-DEC) $$($(1)-DONE)&: $$($(1)-PCHK) $$($(1)-REC) | $$(DECODE)
$$(AT)result=$$$$($$(DECODE) $$^ $$(basename $$@).dec $$(CHANNEL) $$(decmethod) 2>&1) && \
printf '$$(basename $$(notdir $$@)): %s\n' "$$$$result" > $$(basename $$@).done
$$($(1)-DEC): $$($(1)-PCHK) $$($(1)-REC) | $$(DECODE)
./$$(DECODE) $$^ $$(basename $$@).dec $$(CHANNEL) $$(decmethod)
test-all: $(1)
endef
$(foreach code,$(CODES),$(eval $(call TEST_rule,$(code))))
$(BUILD)/$(SEED)_$(T)_%.src: | $(RANDSRC)
$(AT)$(RANDSRC) $@ $(SEED) $*x$(T)
./$(RANDSRC) $@ $(SEED) $*x$(T)
.PHONY: test-clean
test-clean::
rm -f $(addprefix $(BUILD)/,*.qc *.pchk *.gen *.src *.dec *.enc *.rec *.done)
rm -f $(addprefix $(BUILD)/,*.qc *.pchk *.gen *.src *.dec *.enc *.rec)
#################################
# List supported standard codes #
......@@ -119,7 +107,7 @@ test-clean::
.PHONY: list
list: $(MAKEQC)
@./$< --list
./$< --list
###################################################
# Print statistics about supported standard codes #
......@@ -130,6 +118,6 @@ STATS := stats
.PHONY: stat
stat: $(STATS)
@./$<
./$<
# vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab textwidth=0:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment