Skip to content
Snippets Groups Projects
Commit 14307dab authored by bbartels's avatar bbartels Committed by dawehr
Browse files

wip: moved files to new structure

parent 61c8292c
No related branches found
No related tags found
1 merge request!9Abstract the hardware layer
Showing
with 56 additions and 54 deletions
# Declaration of variables
# Generic Variables
GCC=gcc
CFLAGS= -Wall
HEADERS = $(shell find src -name "*.h")
INCLUDES = $(foreach dir, $(INCDIR), -I$(dir))
INCDIR=inc
LIBS=
OBJDIR=obj
# Test library specific variables
TESTSRCDIR=src/test
TESTSOURCES := $(wildcard $(TESTSRCDIR)/*.c )
TESTOBJECTS = $(TESTCSOURCES:$(TESTSRCDIR)/%.c=$(OBJDIR)/%.o)
# Queue library specific variables
QUEUESRCDIR=src/queue
QUEUESOURCES := $(wildcard $(QUEUESRCDIR)/*.c)
QUEUEOBJECTS = $(QUEUESOURCES:$(QUEUESRCDIR)/%.c=$(OBJDIR)/%.o)
# Computation graph library specific variables
COMPGRAPHSRCDIR=src/computation_graph
COMPGRAPHSOURCES := $(wildcard $(COMPGRAPHSRCDIR)/*.c)
COMPGRAPHOBJECTS = $(COMPGRAPHSOURCES:$(COMPGRAPHSRCDIR)/%.c=$(OBJDIR)/%.o)
# Quad app library specific variables
QUADAPPSRCDIR=src/quad_app
QUADAPPSOURCES := $(wildcard $(QUADAPPSRCDIR)/*.c)
QUADAPPOBJECTS = $(QUADAPPSOURCES:$(QUADAPPSRCDIR)/%.c=$(OBJDIR)/%.o)
# Default target
all: $(INCDIR) $(OBJDIR) $(TESTOBJECTS) $(QUEUEOBJECTS) $(COMPGRAPHOBJECTS) $(QUADAPPOBJECTS)
$(TESTOBJECTS) : $(OBJDIR)/%.o : $(TESTSRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES)
$(QUEUEOBJECTS) : $(OBJDIR)/%.o : $(QUEUESRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES)
$(COMPGRAPHOBJECTS) : $(OBJDIR)/%.o : $(COMPGRAPHSRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES)
$(QUADAPPOBJECTS) : $(OBJDIR)/%.o : $(QUADAPPSRCDIR)/%.c
$(GCC) $(CFLAGS) -c $^ -o $@ $(INCLUDES)
$(INCDIR): $(HEADERS)
[ -d $(INCDIR) ] || mkdir $(INCDIR)
cp $^ $(INCDIR)
$(OBJDIR):
[ -d $(OBJDIR) ] || mkdir $(OBJDIR)
clean:
rm -rf $(OBJDIR)/
#include <stdio.h>
#include "computation_graph.h"
#include "graph_blocks/node_add.h"
#include "graph_blocks/node_mult.h"
#include "graph_blocks/node_constant.h"
#include "graph_blocks/node_gain.h"
#include "tests.h"
int main() {
// struct computation_graph *graph = create_graph();
//
// int const1 = graph_add_node_const(graph, "Const 2");
// graph_set_param_val(graph, const1, CONST_SET, 2);
// int const2 = graph_add_node_const(graph, "Const 1");
// graph_set_param_val(graph, const2, CONST_SET, 3);
//
// int add1_id = graph_add_node_add(graph, "Add");
// graph_set_source(graph, add1_id, ADD_SUMMAND1, const1, CONST_VAL);
// graph_set_source(graph, add1_id, ADD_SUMMAND2, const2, CONST_VAL);
//
// int gain1_id = graph_add_node_gain(graph, "Gain");
// graph_set_param_val(graph, gain1_id, GAIN_GAIN, 3);
// graph_set_source(graph, gain1_id, GAIN_INPUT, add1_id, ADD_SUM);
//
// int mult1_id = graph_add_node_mult(graph, "Mult");
// graph_set_source(graph, mult1_id, MULT_MULTIPLICAND2, gain1_id, GAIN_RESULT);
// graph_set_source(graph, mult1_id, MULT_MULTIPLICAND1, const1, CONST_VAL);
//
// graph_compute_node(graph, mult1_id);
// FILE* dot_fp;
// dot_fp = fopen("..\\comp_graph.dot", "w");
// export_dot(graph, dot_fp);
// fclose(dot_fp);
// printf("Sum is %f\n", graph_get_output(graph, mult1_id, GAIN_RESULT));
int success = graph_run_tests();
printf("Success: %s\n", success == 0 ? "Yes" : "No");
fflush(stdout);
return 0;
}
# QUAD_ROOT is obtained from environment
SRC = $(QUAD_ROOT)/computation_graph/src/graph_blocks/*.c $(QUAD_ROOT)/computation_graph/src/computation_graph.c
INC = $(QUAD_ROOT)/computation_graph/src
BLOCKS_INC = $(QUAD_ROOT)/computation_graph/src/graph_blocks
LIB = $(QUAD_ROOT)/lib/test
test_computation_graph: test_computation_graph.c $(SRC)
gcc -o test_computation_graph -I. -I$(INC) -I$(BLOCKS_INC) -I$(LIB) $(LIB)/test.o test_computation_graph.c $(SRC) -lm
.PHONY: clean
clean:
rm test_computation_graph
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment