Initial commit of AESA implementation.
authorFarzad <farzad@sraa.de>
Tue, 3 Sep 2013 03:17:49 +0000 (23:17 -0400)
committerFarzad <farzad@sraa.de>
Tue, 3 Sep 2013 03:17:49 +0000 (23:17 -0400)
This version will pass vectors.
The makefile is not used to build, it will replace the make file
generated by DOL.

20 files changed:
aesa/AESA.xml [new file with mode: 0644]
aesa/Makefile [new file with mode: 0644]
aesa/dol.sh [new file with mode: 0755]
aesa/src/Beam_Former.c [new file with mode: 0644]
aesa/src/Beam_Former.h [new file with mode: 0644]
aesa/src/Consumer.c [new file with mode: 0644]
aesa/src/Consumer.h [new file with mode: 0644]
aesa/src/Corner_Turn.c [new file with mode: 0644]
aesa/src/Corner_Turn.h [new file with mode: 0644]
aesa/src/Corner_Turn_OL.c [new file with mode: 0644]
aesa/src/Corner_Turn_OL.h [new file with mode: 0644]
aesa/src/Data_Generator.c [new file with mode: 0644]
aesa/src/Data_Generator.h [new file with mode: 0644]
aesa/src/FFT_Radix2_DIF.c [new file with mode: 0644]
aesa/src/FFT_Radix2_DIF.h [new file with mode: 0644]
aesa/src/FIR.c [new file with mode: 0644]
aesa/src/FIR.h [new file with mode: 0644]
aesa/src/Weight_Generator.c [new file with mode: 0644]
aesa/src/Weight_Generator.h [new file with mode: 0644]
aesa/src/global.h [new file with mode: 0644]

diff --git a/aesa/AESA.xml b/aesa/AESA.xml
new file mode 100644 (file)
index 0000000..913132f
--- /dev/null
@@ -0,0 +1,437 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<processnetwork 
+xmlns="http://www.tik.ee.ethz.ch/~shapes/schema/PROCESSNETWORK" 
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+xsi:schemaLocation="http://www.tik.ee.ethz.ch/~shapes/schema/PROCESSNETWORK
+    http://www.tik.ee.ethz.ch/~shapes/schema/processnetwork.xsd" name="AESA_DBF"> 
+
+  <variable value="8" name="N_BEAMS"/>
+  <variable value="16" name="N_ANTENNA_ELEMENTS"/>
+  <variable value="16" name="N_OVERLAPPED_BEAMS"/>
+  <variable value="16" name="N_DOPPLER_CHANNELS"/>
+  
+  <variable value="8" name="SIZE_COMPLEX_NUM"/>
+  <variable value="64" name="N_FACTOR"/>
+  <variable value="4" name="N_RANGE_BINS"/>
+  <variable value="32" name="N_FFT"/>
+        
+  <!-- ********************************************************** -->
+  <!--                instantiate processes                       -->
+  <!-- ********************************************************** -->
+
+  <!-- Data generator process with N_BEAMS outputs -->
+       <process name="Data_Generator">
+         <iterator variable="i" range="N_BEAMS">
+           <port type="output" name="out">
+      <append function="i"/>
+      </port>
+    </iterator>
+         <source type="c" location="Data_Generator.c"/>
+       </process>
+
+  <!-- Weights generator process with N_BEAMS outputs -->      
+       <process name="Weight_Generator">
+         <iterator variable="i" range="N_BEAMS">
+           <port type="output" name="out">
+                 <append function="i"/>
+           </port>
+         </iterator>
+         <source type="c" location="Weight_Generator.c"/>
+       </process>
+
+  <!-- N_BEAMS processes to compute result -->
+  <iterator variable="i" range="N_BEAMS">
+    <process name="Beam_Former">
+      <append function="i"/>
+      <port type="input" name="data_input"/>
+      <port type="input" name="weight_input"/>
+      <port type="output" name="data_output"/>         
+      <source type="c" location="Beam_Former.c"/>
+    </process>
+  </iterator>
+       
+  <!-- Corner Turn With Overlap processes -->  
+  <iterator variable="i" range="N_BEAMS">
+    <process name="Corner_Turn_OL">
+      <append function="i"/>
+        <port type="input" name="data_input"/>
+        <port type="output" name="data_output"/>
+        <port type="output" name="data2_output_ol"/>
+      <source type="c" location="Corner_Turn_OL.c"/>
+    </process>
+  </iterator>
+
+  <!-- FFT processes to compute doppler channels -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <process name="FFT_Radix2_DIF">
+      <append function="i"/>
+        <port type="input" name="data_input"/>
+        <port type="output" name="data_output"/>               
+      <source type="c" location="FFT_Radix2_DIF.c"/>
+    </process>
+       </iterator>
+
+  <!-- Corner Turn processes  -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <process name="Corner_Turn">
+      <append function="i"/>      
+        <port type="input" name="data_input"/>
+        <port type="output" name="data_output"/>
+      <source type="c" location="Corner_Turn.c"/>
+    </process>
+       </iterator>
+       
+  <!-- FIR processes -->
+  <iterator variable="i" range="2 * N_BEAMS">
+     <process name="FIR">
+        <append function="i"/>
+        <port type="input" name="data_input"/>
+        <port type="output" name="data_output"/>
+        <source type="c" location="FIR.c"/>
+     </process>
+  </iterator>
+
+  <!-- Consumer process to collect data -->
+  <process name="Consumer">
+    <iterator variable="i" range=" N_BEAMS">
+      <port type="input" name="data_input">
+        <append function="i"/>
+      </port>
+      <port type="input" name="data2_input_delayed">
+        <append function="i"/>
+      </port>
+    </iterator>
+               <source type="c" location="Consumer.c"/>
+       </process>
+
+  <!-- ********************************************************** -->
+  <!--                instantiate channels                        -->
+  <!-- ********************************************************** -->
+
+  <!-- sw_channels from data generator to dbf -->
+  <iterator variable="i" range="N_BEAMS">
+         <sw_channel type="fifo" size="N_ANTENNA_ELEMENTS * SIZE_COMPLEX_NUM * N_FACTOR" name="data_to_dbf_chan">
+                 <append function="i"/>
+                 <port type="input" name="in"/>
+                 <port type="output" name="out"/>
+         </sw_channel>
+  </iterator>
+
+  <!-- sw_channels from weight generator to dbf --> 
+  <iterator variable="i" range="N_BEAMS"> 
+    <sw_channel type="fifo" size="N_ANTENNA_ELEMENTS * SIZE_COMPLEX_NUM * N_FACTOR" name="weight_to_dbf_chan">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+    </sw_channel>
+  </iterator>
+  
+  <!-- sw_channels from dbf to corner turn with overlap -->
+  <iterator variable="i" range="N_BEAMS">
+    <sw_channel type="fifo" size="N_RANGE_BINS * SIZE_COMPLEX_NUM * N_FACTOR" name="dbf_to_ct_ol">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+    </sw_channel>
+  </iterator>
+
+  <!-- sw_channels from corner turn to fft -->
+  <iterator variable="i" range="N_BEAMS"> 
+    <sw_channel type="fifo" size="N_FFT * SIZE_COMPLEX_NUM * N_FACTOR" name="ct_ol_to_fft">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+    </sw_channel>
+  </iterator>
+
+  <!-- sw_channels from corner turn delayed to fft -->
+  <iterator variable="i" range="N_BEAMS"> 
+    <sw_channel type="fifo" size="N_FFT * SIZE_COMPLEX_NUM * N_FACTOR" name="ct_ol_delayed_to_fft">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+    </sw_channel>
+  </iterator>
+
+  <!-- sw_channels from fft to corner turn -->
+  <iterator variable="i" range="2 * N_BEAMS"> 
+    <sw_channel type="fifo" size="N_FFT * SIZE_COMPLEX_NUM * N_FACTOR" name="fft_to_corner_turn">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+    </sw_channel>
+  </iterator>
+
+  <!-- sw channels from corner turn to fir -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <sw_channel type="fifo" size="N_RANGE_BINS * SIZE_COMPLEX_NUM * N_FACTOR" name="corner_turn_to_fir">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+     </sw_channel>
+  </iterator>
+
+  <!-- sw_channels from fir to consumer-->
+  <iterator variable="i" range="2 * N_BEAMS"> 
+    <sw_channel type="fifo" size="N_RANGE_BINS * SIZE_COMPLEX_NUM * N_FACTOR" name="fir_to_consumer">
+      <append function="i"/>
+      <port type="input" name="in"/>
+      <port type="output" name="out"/>
+    </sw_channel>
+  </iterator>
+  
+  <!-- ********************************************************** -->
+  <!--                instantiate connections                     -->
+  <!-- ********************************************************** -->
+
+  <!-- connections from data generator to channels -->
+  <iterator variable="i" range="N_BEAMS">
+         <connection name="Ant_To_Dbf_Chan_Data">
+      <append function="i"/>
+                 <origin name="Data_Generator">
+        <port name="out">
+        <append function="i"/>
+        </port>
+      </origin>
+                 <target name="data_to_dbf_chan">
+        <append function="i"/>
+        <port name="in"/>
+      </target>
+    </connection>
+  </iterator>
+
+  <!-- connections from weight generator to channels -->
+  <iterator variable="i" range="N_BEAMS">      
+    <connection name="Weight_To_Dbf_Chan_Weight">
+      <append function="i"/>
+      <origin name="Weight_Generator">
+        <port name="out">
+        <append function="i"/>
+        </port>
+      </origin>
+      <target name="weight_to_dbf_chan">
+             <append function="i"/>
+             <port name="in">
+        </port>
+      </target>
+    </connection>
+  </iterator>
+
+  <!-- connections from data channels to DBF processes -->  
+  <iterator variable="i" range="N_BEAMS">
+    <connection name="Dbf_Chan_Data_To_Dbf">
+      <append function="i"/>
+      <origin name="data_to_dbf_chan">
+      <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="Beam_Former">
+      <append function="i"/>
+        <port name="data_input"/>
+      </target>
+    </connection>
+  </iterator>
+
+  <!-- connections from weight channels to DBF processes -->
+  <iterator variable="i" range="N_BEAMS">
+    <connection name="Dbf_Chan_Weight_To_Dbf">
+      <append function="i"/>
+      <origin name="weight_to_dbf_chan">
+      <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="Beam_Former">
+        <append function="i"/>
+        <port name="weight_input"/>
+      </target>
+    </connection>
+  </iterator>
+  
+  <!-- connections from dbf to corner turn with overlap channels -->
+       <iterator variable="i" range="N_BEAMS">
+    <connection name="Dbf_To_Corner_Turn_Overlap_Chan">
+      <append function="i"/>
+      <origin name="Beam_Former">
+         <append function="i"/>
+        <port name="data_output">
+        </port>
+      </origin>
+      <target name="dbf_to_ct_ol">
+        <append function="i"/>
+        <port name="in"/>
+      </target>
+    </connection>
+  </iterator>
+
+  <!-- connections from dbf channels to CT processes -->  
+  <iterator variable="i" range="N_BEAMS">
+    <connection name="Chan1_To_Ct_Ol">
+      <append function="i"/>
+      <origin name="dbf_to_ct_ol">
+        <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="Corner_Turn_OL">
+        <append function="i"/>
+        <port name="data_input"/>
+      </target>
+    </connection>
+  </iterator>
+
+  <!-- connections from corner turn to FFT channels -->
+  <iterator variable="i" range="N_BEAMS">
+    <connection name="Ct_Ol_To_Chan2">
+      <append function="i"/>
+      <origin name="Corner_Turn_OL">
+        <append function="i"/>
+        <port name="data_output"/>
+      </origin>
+      <target name="ct_ol_to_fft">
+        <append function="i"/>
+        <port name="in"/>
+      </target>
+    </connection>
+    <connection name="Ct_Ol_Delay_To_Chan2">
+      <append function="i"/>
+      <origin name="Corner_Turn_OL">
+        <append function="i"/>
+        <port name="data2_output_ol"/>
+      </origin>
+      <target name="ct_ol_delayed_to_fft">
+        <append function="i"/>
+        <port name="in"/>
+      </target>
+    </connection>
+       </iterator>
+
+  <!-- connections from FFT channels to FFT-->
+  <iterator variable="i" range="N_BEAMS">
+    <connection name="Chan2_To_FFT">
+      <append function="i"/>
+      <origin name="ct_ol_to_fft">
+        <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="FFT_Radix2_DIF">
+        <append function="i"/>
+        <port name="data_input"/>
+      </target>
+    </connection>
+    <connection name="Chan2_Delay_To_FFT">
+      <append function="i"/>
+      <origin name="ct_ol_delayed_to_fft">
+        <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="FFT_Radix2_DIF">
+        <append function="i + N_BEAMS"/>
+        <port name="data_input"/>
+      </target>
+    </connection>
+       </iterator>
+
+  <!-- connections from FFT to Corner Turn channels -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <connection name="FFT_To_Chan3">
+      <append function="i"/>
+      <origin name="FFT_Radix2_DIF">
+        <append function="i"/>
+        <port name="data_output"/>
+      </origin>
+      <target name="fft_to_corner_turn">
+        <append function="i"/>
+        <port name="in"/>
+      </target>
+    </connection>
+       </iterator>
+
+  <!-- connections from Corner Turn channels to Corner Turn -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <connection name="Chan3_To_Corner_Turn">
+      <append function="i"/>
+      <origin name="fft_to_corner_turn">
+        <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="Corner_Turn">
+        <append function="i"/>
+        <port name="data_input"/>
+      </target>
+    </connection>
+       </iterator>
+
+
+  <!-- connections from Corner Turn to FIR Channels -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <connection name="Corner_Turn_To_Chan4">
+      <append function="i"/>
+      <origin name="Corner_Turn">
+        <append function="i"/>
+        <port name="data_output"/>
+      </origin>
+      <target name="corner_turn_to_fir">
+        <append function="i"/>
+        <port name="in"/>
+      </target>
+    </connection>
+       </iterator>
+
+
+  <!-- connections from FIR channels to FIR -->
+  <iterator variable="i" range="2 * N_BEAMS">
+    <connection name="Chan4_To_FIR">
+      <append function="i"/>
+      <origin name="corner_turn_to_fir">
+         <append function="i"/>
+         <port name="out"/>
+      </origin>
+      <target name="FIR">
+        <append function="i"/>
+        <port name="data_input"/>
+      </target>
+    </connection>
+  </iterator>
+
+  <!-- connection from FIR to FIR channels -->
+  <iterator variable="i" range="2 * N_BEAMS">
+     <connection name="FIR_to_Chan5">
+       <append function="i"/>
+       <origin name="FIR">
+          <append function="i"/>
+          <port name="data_output"/>
+       </origin>
+       <target name="fir_to_consumer">
+          <append function="i"/>
+          <port name="in"/>
+       </target>
+     </connection>
+  </iterator>
+
+   <!-- connections from FIR to Consumer Channels -->
+  <iterator variable="i" range="N_BEAMS">
+    <connection name="Chan5_To_Consumer">
+      <append function="i"/>
+      <origin name="fir_to_consumer">
+        <append function="i"/>
+        <port name="out"/>
+      </origin>
+      <target name="Consumer">
+        <port name="data_input">
+          <append function="i"/>
+        </port>
+      </target>
+    </connection>
+    <connection name="Chan5_To_Consumer_Delayed">
+      <append function="i"/>
+      <origin name="fir_to_consumer">
+        <append function="i + N_BEAMS"/>
+        <port name="out"/>
+      </origin>
+      <target name="Consumer">
+        <port name="data2_input_delayed">
+          <append function="i"/>
+        </port>
+      </target>
+    </connection>
+       </iterator>
+</processnetwork>
diff --git a/aesa/Makefile b/aesa/Makefile
new file mode 100644 (file)
index 0000000..9f97967
--- /dev/null
@@ -0,0 +1,21 @@
+CXX = g++
+CC = g++
+
+PREPROC_MACROS = -D__DOL_ETHZ_GEN__  -DINCLUDE_PROFILER #-DINCLUDE_PERFORMANCE #-DINCLUDE_TRACE
+
+SYSTEMC_INC = -I/usr/local/systemc/include
+SYSTEMC_LIB = /usr/local/systemc/lib-linux/libsystemc.a
+MY_LIB_INC = -Ilib -Isc_wrappers -Iprocesses
+VPATH = lib:sc_wrappers:processes
+
+CXXFLAGS = -g -O0 -Wall $(PREPROC_MACROS) $(SYSTEMC_INC) $(MY_LIB_INC)
+CFLAGS = $(CXXFLAGS)
+
+PROCESS_OBJS = dolSupport.o ProcessWrapper.o Fifo.o WindowedFifo.o Data_Generator_wrapper.o Weight_Generator_wrapper.o Beam_Former_wrapper.o Corner_Turn_OL_wrapper.o FFT_Radix2_DIF_wrapper.o Corner_Turn_wrapper.o FIR_wrapper.o Consumer_wrapper.o #xmlParser.o Performance_Extraction.o functional_trace.o
+
+all:sc_application
+
+sc_application: sc_application.o $(PROCESS_OBJS)
+       $(CXX) $(CXXFLAGS) -o $@ $^ $(SYSTEMC_LIB)  -lpthread -lX11 -lrt
+clean:
+       -rm -f *.o core core.* *.core *.tga static_characterization.xml sc_application
diff --git a/aesa/dol.sh b/aesa/dol.sh
new file mode 100755 (executable)
index 0000000..cba5140
--- /dev/null
@@ -0,0 +1,29 @@
+#clean up the old files
+rm -rf systemc
+rm aesa.dot
+rm aesa_flattened.xml
+rm Generator.class
+rm Generator.java
+
+#flattening
+java -cp ..:../../bin/jdom.jar:../../bin/xercesImpl.jar:../../bin/dol.jar  dol/helper/flattener/XMLFlattener AESA.xml Generator
+javac Generator.java
+java Generator > aesa_flattened.xml
+
+#creating dot file
+java -cp ..:../../bin/jdom.jar:../../bin/xercesImpl.jar:../../bin/dol.jar dol.main.Main -c -P aesa_flattened.xml -D aesa.dot -c
+
+#creating cpp
+java -cp ..:../../bin/jdom.jar:../../bin/xercesImpl.jar:../../bin/dol.jar dol.main.Main -P aesa_flattened.xml -H systemc -c
+
+#deleting the wrong make file and copying the corrected one in place
+rm systemc/src/Makefile
+cp Makefile systemc/src
+
+#compiling
+cd ./systemc/src
+
+make  
+
+#run the generated exe file
+./sc_application
\ No newline at end of file
diff --git a/aesa/src/Beam_Former.c b/aesa/src/Beam_Former.c
new file mode 100644 (file)
index 0000000..54ca81b
--- /dev/null
@@ -0,0 +1,98 @@
+#include "Beam_Former.h"
+
+/************************************************************************************/
+
+void Beam_Former_init(DOLProcess * p)
+{      
+       int i;
+       for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
+       {
+       p->local->Vector_Product[i].real = 0.0;
+       p->local->Vector_Product[i].imag = 0.0;
+       }
+       // p->local->sample_counter = 0;
+       p->local->pulse_counter = 0;
+       p->local->n_iterations = 0;
+       // New!
+       p->local->range_counter=0;
+
+       p->local->excount = 0;
+
+}
+
+/************************************************************************************/
+
+int Beam_Former_fire(DOLProcess * p)
+{
+       p->local->excount++;
+
+       ComplexNumber samples[NUMBER_OF_ANTENNA_ELEMENTS];
+       ComplexNumber weights[NUMBER_OF_ANTENNA_ELEMENTS];
+
+       // Read arrays from ports
+       DOL_read((void*)PORT_DATA_IN, &samples, NUMBER_OF_ANTENNA_ELEMENTS*sizeof(ComplexNumber), p);
+       DOL_read((void*)PORT_WEIGHT_IN, &weights, NUMBER_OF_ANTENNA_ELEMENTS*sizeof(ComplexNumber), p);
+
+       // Multiply and accumulate elementwise
+       int i;
+       for (i=0; i<NUMBER_OF_ANTENNA_ELEMENTS; i++)
+       {
+               /*  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  */
+       multiply_and_accumulate(&samples[i], &weights[i], p);
+       }
+
+       // This is not needed anymore
+       //p->local->sample_counter = p->local->sample_counter + 1;
+       p->local->range_counter = p->local->range_counter+1;
+       
+       if (p->local->range_counter == NUMBER_OF_RANGE_BINS)  // When we have enought data
+       {
+               DOL_write((void*)PORT_DATA_OUT, &(p->local->Vector_Product[0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p); // Send the data
+
+               // Reset the Vector Product vector
+               int i;
+               for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
+               {
+        p->local->Vector_Product[i].real = 0.0;
+        p->local->Vector_Product[i].imag = 0.0;
+       }
+
+       // This is not necessary anymore
+               // p->local->sample_counter = 0;
+
+               // Reset the range_counter
+               p->local->range_counter=0;
+
+               p->local->pulse_counter = p->local->pulse_counter + 1;
+
+               
+               if (p->local->pulse_counter ==  NUMBER_OF_PULSES)
+       {
+                       p->local->n_iterations = p->local->n_iterations + 1;
+                       p->local->pulse_counter = 0;
+               }               
+       }
+
+       if (p->local->n_iterations == NUMBER_OF_ITERATIONS) 
+  {
+               printf("\n\n:: Beam_former process finished ::\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+               
+               DOL_detach(p);
+       }
+       
+       return 0;
+}
+
+/************************************************************************************/
+
+void multiply_and_accumulate(ComplexNumber * next_sample, ComplexNumber * next_weight, DOLProcess * p)
+{
+       ComplexNumber temp;
+
+       temp.real = (next_sample->real * next_weight->real - next_sample->imag * next_weight->imag);
+       temp.imag = (next_sample->real * next_weight->imag + next_sample->imag * next_weight->real);
+       // Notice the change! every time we save into next range element of Vector_Product
+       p->local->Vector_Product[p->local->range_counter].real = p->local->Vector_Product[p->local->range_counter].real + temp.real;
+       p->local->Vector_Product[p->local->range_counter].imag = p->local->Vector_Product[p->local->range_counter].imag + temp.imag;
+}
diff --git a/aesa/src/Beam_Former.h b/aesa/src/Beam_Former.h
new file mode 100644 (file)
index 0000000..9b69a3d
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef BEAM_FORMER_H
+#define BEAM_FORMER_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_DATA_IN "data_input"
+#define PORT_WEIGHT_IN "weight_input"
+#define PORT_DATA_OUT "data_output"
+
+typedef struct _local_states
+{
+  ComplexNumber Vector_Product[NUMBER_OF_RANGE_BINS];
+    // int sample_counter;
+       int pulse_counter;
+       int n_iterations;
+    // New!
+       int range_counter;
+
+       int excount;
+       
+
+} Beam_Former_State;
+
+void Beam_Former_init(DOLProcess *);
+int Beam_Former_fire(DOLProcess *);
+void multiply_and_accumulate(ComplexNumber *, ComplexNumber *, DOLProcess * p);
+
+#endif
diff --git a/aesa/src/Consumer.c b/aesa/src/Consumer.c
new file mode 100644 (file)
index 0000000..78c42e4
--- /dev/null
@@ -0,0 +1,116 @@
+#include "Consumer.h"
+
+/************************************************************************************/
+
+void Consumer_init(DOLProcess * p)
+{
+       int i,j,k;
+
+       p->local->channel_cntr = 0;
+       p->local->pulse_cntr = 0;
+       p->local->bin_cntr = 0;
+       p->local->n_iterations = 0;
+
+       p->local->excount = 0;
+
+       
+       for (i=0; i<NUMBER_OF_DOPPLER_CHANNELS; i++) 
+       {
+               for (j=0; j<NUMBER_OF_PULSES; j++) 
+               {
+                       for (k=0; k<NUMBER_OF_RANGE_BINS; k++) 
+                       {
+                               (p->local->Channels[i][j][k]).real = 0.0;
+                               (p->local->Channels[i][j][k]).imag = 0.0;
+                               (p->local->Channels_Delayed[i][j][k]).real = 0.0;
+                               (p->local->Channels_Delayed[i][j][k]).imag = 0.0;
+                       }
+               }
+       }
+#ifdef PRINT_CONSUMER
+  p->local->out = fopen( "output.txt", "w" );
+#endif
+}
+
+/************************************************************************************/
+
+int Consumer_fire(DOLProcess * p)
+{
+       CREATEPORTVAR(input_port);
+       CREATEPORTVAR(input_port_delayed);
+       int chan_index;
+
+       p->local->excount++;
+
+
+       for (chan_index = 0; chan_index < NUMBER_OF_DOPPLER_CHANNELS; chan_index++) 
+       {
+
+
+               CREATEPORT(input_port, PORT_IN, 1, chan_index, NUMBER_OF_BEAMS);
+               // DOL_read((void*)input_port, &(p->local->Channels[chan_index][p->local->pulse_cntr][p->local->bin_cntr]), sizeof(ComplexNumber), p);
+               DOL_read((void*)input_port, &(p->local->Channels[chan_index][p->local->pulse_cntr][0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
+
+               CREATEPORT(input_port_delayed, PORT_IN_DELAYED, 1, chan_index, NUMBER_OF_BEAMS);
+               // DOL_read((void*)input_port_delayed, &(p->local->Channels_Delayed[chan_index][p->local->pulse_cntr][p->local->bin_cntr]), sizeof(ComplexNumber), p);
+               DOL_read((void*)input_port_delayed, &(p->local->Channels_Delayed[chan_index][p->local->pulse_cntr][0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
+       }
+       
+       // p->local->bin_cntr = p->local->bin_cntr + 1;
+       // if (p->local->bin_cntr == NUMBER_OF_RANGE_BINS) 
+       // {
+       //      p->local->bin_cntr = 0;
+               p->local->pulse_cntr = p->local->pulse_cntr + 1;
+               if (p->local->pulse_cntr == NUMBER_OF_PULSES)
+               {
+                       p->local->pulse_cntr = 0;
+                       p->local->n_iterations = p->local->n_iterations + 1;
+               }
+       // }
+       
+       if (p->local->n_iterations == NUMBER_OF_ITERATIONS) {
+    int i,j,k;
+    char c;            
+    printf("\n\n:: Consumer process finished :\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+    
+
+#ifdef PRINT_CONSUMER  
+         for (i=0; i<NUMBER_OF_DOPPLER_CHANNELS; i++) 
+         {
+      fprintf(p->local->out, "\n------------------------\n", i);
+      fprintf(p->local->out, ":: Doppler channel %d ::\n", i);
+      fprintf(p->local->out, "------------------------\n", i);
+                 for (j=0; j<NUMBER_OF_PULSES; j++) 
+                 {
+        fprintf(p->local->out, "\n:: Pulse %d, Range Bin 1 to %d ::\n", j, NUMBER_OF_RANGE_BINS);
+                         for (k=0; k<NUMBER_OF_RANGE_BINS; k++) 
+                         {
+          fprintf(p->local->out, "[%f, %f] ", p->local->Channels[i][j][k].real, p->local->Channels[i][j][k].imag);
+                         }
+        fprintf(p->local->out, "\n");
+                 }
+         }
+    
+    for (i=0; i<NUMBER_OF_DOPPLER_CHANNELS; i++) 
+         {
+      fprintf(p->local->out, "\n--------------------------------\n", i);
+      fprintf(p->local->out, ":: Doppler channel delayed %d ::\n", i);
+      fprintf(p->local->out, "--------------------------------\n", i);
+                 for (j=0; j<NUMBER_OF_PULSES; j++) 
+                 {
+        fprintf(p->local->out, "\n:: Pulse slot%d, Range Bin 0 to %d ::\n", j, NUMBER_OF_RANGE_BINS);
+                         for (k=0; k<NUMBER_OF_RANGE_BINS; k++) 
+                         {
+          fprintf(p->local->out, "[%f, %f] ", p->local->Channels_Delayed[i][j][k].real, p->local->Channels_Delayed[i][j][k].imag);
+                         }
+        fprintf(p->local->out, "\n");
+                 }
+    }
+#endif  
+
+               DOL_detach(p);
+       }
+       
+       return 0;
+}
diff --git a/aesa/src/Consumer.h b/aesa/src/Consumer.h
new file mode 100644 (file)
index 0000000..d10e070
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef CONSUMER_H
+#define CONSUMER_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_IN "data_input"
+#define PORT_IN_DELAYED "data2_input_delayed"
+
+typedef struct _local_states
+{
+  ComplexNumber Channels[NUMBER_OF_DOPPLER_CHANNELS][NUMBER_OF_PULSES][NUMBER_OF_RANGE_BINS];
+  ComplexNumber Channels_Delayed[NUMBER_OF_DOPPLER_CHANNELS][NUMBER_OF_PULSES][NUMBER_OF_RANGE_BINS];
+  int channel_cntr;
+       int pulse_cntr;
+       int bin_cntr;
+       int n_iterations;
+
+       int excount;
+#ifdef PRINT_CONSUMER
+  FILE *out;
+#endif
+} Consumer_State;
+
+void Consumer_init(DOLProcess *);
+int Consumer_fire(DOLProcess *);
+
+#endif
diff --git a/aesa/src/Corner_Turn.c b/aesa/src/Corner_Turn.c
new file mode 100644 (file)
index 0000000..3994caf
--- /dev/null
@@ -0,0 +1,213 @@
+#include "Corner_Turn.h"
+
+/************************************************************************************/
+
+void Corner_Turn_init(DOLProcess * p)
+{      
+       int i,j;
+       
+       for (i=0; i<NUMBER_OF_RANGE_BINS; i=i+1) 
+       {
+               for (j=0; j<NFFT; j=j+1) 
+               {
+                       p->local->Channels_A[i][j].real = 0.0;  
+                       p->local->Channels_A[i][j].imag = 0.0;
+                       p->local->Channels_B[i][j].real = 0.0;
+                       p->local->Channels_B[i][j].imag = 0.0;
+               }
+       }
+       
+       p->local->buffer_mode = 0;
+       // p->local->pulse_counter_in = 0;
+       p->local->pulse_counter_out = 0;
+       p->local->bin_counter_in = 0;
+       // p->local->bin_counter_out = 0;
+    p->local->n_batches = 0;
+       p->local->n_iterations = 0;
+
+       p->local->hold_input = 0;
+       p->local->hold_output = 0;
+
+       p->local->excount = 0;
+
+}
+
+/************************************************************************************/
+
+int Corner_Turn_fire(DOLProcess * p)
+{
+       // ComplexNumber next_sample;
+       ComplexNumber samples_in[NFFT];
+       ComplexNumber samples_out[NUMBER_OF_RANGE_BINS];
+       p->local->excount++;
+
+       if(!p->local->hold_input){
+       DOL_read((void*)PORT_DATA_IN, &samples_in, NFFT*sizeof(ComplexNumber), p);
+       }
+
+       if (p->local->buffer_mode == 0)  // if buffer_mode = 0: input buffer is A, output buffer is B
+       {
+
+               //  !!!!!!!!!!!!!!!!!!   Not sure about syntax. check the dest adrs and &
+               // p->local->Channels_A[p->local->bin_counter_in][p->local->pulse_counter_in] = next_sample;
+               if(!p->local->hold_input){
+               memcpy(&(p->local->Channels_A[p->local->bin_counter_in][0]) , &samples_in, NFFT*sizeof(int));
+               }
+
+               // next_sample = p->local->Channels_B[p->local->bin_counter_out][p->local->pulse_counter_out];
+               if(!p->local->hold_output){
+               int i;
+               for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
+               {
+                       samples_out[i]=p->local->Channels_B[i][p->local->pulse_counter_out];
+               }
+               // DOL_write((void*)PORT_DATA_OUT, &(next_sample), sizeof(ComplexNumber), p);
+               
+               DOL_write((void*)PORT_DATA_OUT, &(samples_out[0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
+               }
+       }
+
+       else  // if buffer_mode = 1: input buffer is B, output buffer is A
+       {
+               // p->local->Channels_B[p->local->bin_counter_in][p->local->pulse_counter_in] = next_sample;
+               if(!p->local->hold_input){
+               memcpy(&(p->local->Channels_B[p->local->bin_counter_in][0]) , &samples_in, NFFT*sizeof(int));
+               }
+               // next_sample = p->local->Channels_A[p->local->bin_counter_out][p->local->pulse_counter_out];
+               if(!p->local->hold_output){
+               int i;
+               for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
+               {
+                       samples_out[i]=p->local->Channels_A[i][p->local->pulse_counter_out];
+               }
+
+               // DOL_write((void*)PORT_DATA_OUT, &(next_sample), sizeof(ComplexNumber), p);
+               DOL_write((void*)PORT_DATA_OUT, &(samples_out[0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
+               }
+       }
+
+       // // p->local->pulse_counter_in = p->local->pulse_counter_in + 1;
+
+       // // if (p->local->pulse_counter_in == NFFT) 
+       // // {
+ //    // p->local->pulse_counter_in = 0;
+
+       //      p->local->bin_counter_in = p->local->bin_counter_in + 1;
+       //      if (p->local->bin_counter_in == NUMBER_OF_RANGE_BINS) 
+       //      {
+       //              p->local->bin_counter_in = 0;
+       //      }
+       // // }
+
+       // // p->local->bin_counter_out = p->local->bin_counter_out + 1;
+       // // if (p->local->bin_counter_out == NUMBER_OF_RANGE_BINS)  
+       // // {
+ // //    p->local->bin_counter_out = 0;
+
+       //      p->local->pulse_counter_out = p->local->pulse_counter_out + 1;
+       //      if (p->local->pulse_counter_out == NFFT) 
+       //      {
+ //                    p->local->pulse_counter_out = 0;
+       //              p->local->buffer_mode = p->local->buffer_mode ^ 0x01;     // Switch buffer mode
+
+       //         p->local->n_batches = p->local->n_batches + 1;
+               
+       //         //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+       //         // Probably this shouldn't be changed, but not sure. check it late!
+       //         if (p->local->n_batches == (NUMBER_OF_PULSES/NFFT))
+       //         {
+       //           p->local->n_batches = 0;
+       //                        p->local->n_iterations = p->local->n_iterations + 1;  
+       //         }
+       //      }
+       // // }
+
+               #if NUMBER_OF_RANGE_BINS > NFFT  // this is the case that we have to hold the output
+
+
+                       if(!p->local->hold_output)
+                       {
+                       p->local->pulse_counter_out = p->local->pulse_counter_out + 1;
+                       }
+
+                       p->local->bin_counter_in = p->local->bin_counter_in + 1;
+
+
+                       if (p->local->pulse_counter_out >= NFFT)
+                       {
+                               if   (p->local->bin_counter_in < NUMBER_OF_RANGE_BINS )   // -1
+                               {
+                               p->local->hold_output = 1 ;
+                               }
+                               else
+                               {
+                                       p->local->bin_counter_in = 0;
+                                       p->local->pulse_counter_out = 0;
+                                       p->local->hold_output = 0;
+                                       p->local->n_batches = p->local->n_batches + 1;
+                                       
+
+                                       p->local->buffer_mode = p->local->buffer_mode ^ 0x01;
+                                       
+                               }
+                       }
+
+
+               #elif NUMBER_OF_RANGE_BINS < NFFT  // this is the case that we have to hold the input
+
+                       if (!p->local->hold_input)
+                       {
+                       p->local->bin_counter_in = p->local->bin_counter_in + 1;
+                       }
+
+                       p->local->pulse_counter_out = p->local->pulse_counter_out + 1;
+                       
+                       if (p->local->bin_counter_in == NUMBER_OF_RANGE_BINS)
+                       {
+                               if(p->local->pulse_counter_out < NFFT)
+                               {
+                                       p->local->hold_input = 1;
+                               }
+                               else  // pulse_counter_out == NUMBER OF RANGE BINS
+                               {
+                                       p->local->bin_counter_in = 0;
+                                       p->local->pulse_counter_out = 0;
+                                       p->local->hold_input = 0;
+                                       p->local->n_batches = p->local->n_batches + 1;
+
+                                       p->local->buffer_mode = p->local->buffer_mode ^ 0x01;
+                                       
+                               }
+                       }
+
+
+               #else // in this case we have equal number of iterations over input and output
+                       p->local->bin_counter_in = p->local->bin_counter_in + 1;
+                       p->local->pulse_counter_out = p->local->pulse_counter_out + 1;
+                       
+                       if (p->local->bin_counter_in == NFFT - 1) // not sure about the -1!! do test
+                       {
+                               p->local->bin_counter_in = 0;
+                               p->local->pulse_counter_out = 0;
+                               p->local->n_batches = p->local->n_batches + 1;
+
+                               p->local->buffer_mode = p->local->buffer_mode ^ 0x01;
+                       }
+
+               #endif
+               
+       if (p->local->n_batches == (NUMBER_OF_PULSES/NFFT))
+    {
+          p->local->n_batches = 0;
+                         p->local->n_iterations = p->local->n_iterations + 1;  
+    }
+       if (p->local->n_iterations == NUMBER_OF_ITERATIONS) 
+       {
+               printf("\n\n:: Corner Turn process finished ::\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+               
+               DOL_detach(p);
+       }
+       
+       return 0;
+}
diff --git a/aesa/src/Corner_Turn.h b/aesa/src/Corner_Turn.h
new file mode 100644 (file)
index 0000000..f0aa261
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef CORNER_TURN_H
+#define CORNER_TURN_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_DATA_IN "data_input"
+#define PORT_DATA_OUT "data_output"
+
+typedef struct _local_states
+{
+  ComplexNumber Channels_A[NUMBER_OF_RANGE_BINS][NFFT];
+       ComplexNumber Channels_B[NUMBER_OF_RANGE_BINS][NFFT];
+       int buffer_mode;
+       // int pulse_counter_in;
+       int pulse_counter_out;
+       int bin_counter_in;
+       // int bin_counter_out;
+    int n_batches;
+       int n_iterations;
+       int hold_input;
+       int hold_output;
+
+               int excount;
+
+} Corner_Turn_State;
+
+void Corner_Turn_init(DOLProcess *);
+int Corner_Turn_fire(DOLProcess *);
+
+#endif
diff --git a/aesa/src/Corner_Turn_OL.c b/aesa/src/Corner_Turn_OL.c
new file mode 100644 (file)
index 0000000..5ce3f12
--- /dev/null
@@ -0,0 +1,307 @@
+#include "Corner_Turn_OL.h"
+
+/************************************************************************************/
+
+void Corner_Turn_OL_init(DOLProcess * p)
+{      
+       int i,j;
+
+       p->local->excount = 0;
+
+       
+       for (i=0; i<NUMBER_OF_RANGE_BINS; i=i+1) 
+       {
+               for (j=0; j<NFFT; j=j+1) 
+               {
+                       p->local->Main_A[i][j].real = 0.0;      // Buffer for N_Range_Bins * NFFT complex samples
+                       p->local->Main_A[i][j].imag = 0.0;
+                       p->local->Main_B[i][j].real = 0.0;
+                       p->local->Main_B[i][j].imag = 0.0;
+                       p->local->Delayed_C[i][j].real = 0.0;   // Buffer for N_Range_Bins * NFFT complex samples
+                       p->local->Delayed_C[i][j].imag = 0.0;
+                       p->local->Delayed_D[i][j].real = 0.0;
+                       p->local->Delayed_D[i][j].imag = 0.0;
+               }
+         
+         // for (j=0; j<(NFFT/2); j=j+1) 
+         // {
+                //  p->local->Delayed_Output[i][j].real = 0.0;  // Buffer to create out delay of NFFT/2 
+         //    p->local->Delayed_Output[i][j].imag = 0.0; 
+         // }
+       }
+
+       p->local->Zero.real = 0.0;
+    p->local->Zero.imag = 0.0;
+
+       // p->local->buffer_mode = 0;
+       p->local->state = 0;
+       p->local->input_pointer = 0;
+       p->local->output_pointer = 0;
+       p->local->hold_input=0;
+       p->local->hold_output=0;
+
+       p->local->pulse_counter_in = 0;
+       p->local->pulse_counter_out = 0;
+       p->local->bin_counter_in = 0;
+       p->local->bin_counter_out = 0;
+       // p->local->output_index = 0;
+    p->local->n_batches = 0;
+       p->local->n_iterations = 0;
+
+
+}
+
+/************************************************************************************/
+
+int Corner_Turn_OL_fire(DOLProcess * p)
+{
+       ComplexNumber samples_in[NUMBER_OF_RANGE_BINS];
+       p->local->excount++;
+
+       // This block will input in RANGE dimension and output in NFFT dimension.
+       if(!p->local->hold_input){
+       DOL_read((void*)PORT_DATA_IN, &samples_in, NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);  // Read a vector of input samples.
+       }
+       // if (p->local->buffer_mode == 0) // if buffer_mode = 0: input buffer is A, output buffer is B
+       // {
+       //      p->local->Beams_A[p->local->bin_counter_in][p->local->pulse_counter_in] = next_sample;
+       //      next_sample = p->local->Beams_B[p->local->bin_counter_out][p->local->pulse_counter_out];
+       //      DOL_write((void*)PORT_DATA_OUT, &next_sample, sizeof(ComplexNumber), p);
+       //      DOL_write((void*)PORT_DATA_OUT_OL, &(p->local->Delayed_Output[p->local->bin_counter_out][p->local->output_index]), sizeof(ComplexNumber), p);
+ //        p->local->Delayed_Output[p->local->bin_counter_out][p->local->output_index] = next_sample;     // Fill delay buffer with input
+       // }
+       // else  // if buffer_mode = 1: input buffer is B, output buffer is A
+       // {
+       //      p->local->Beams_B[p->local->bin_counter_in][p->local->pulse_counter_in] = next_sample;
+       //      next_sample = p->local->Beams_A[p->local->bin_counter_out][p->local->pulse_counter_out];
+       //      DOL_write((void*)PORT_DATA_OUT, &next_sample, sizeof(ComplexNumber), p);
+       //      DOL_write((void*)PORT_DATA_OUT_OL, &(p->local->Delayed_Output[p->local->bin_counter_out][p->local->output_index]), sizeof(ComplexNumber), p);
+ //        p->local->Delayed_Output[p->local->bin_counter_out][p->local->output_index] = next_sample;     // Fill delay buffer with input
+ //    }
+       int i;
+       switch (p->local->state)
+       {
+
+               case 0:
+                       // put the input vector in buffers (check documentation for details)
+                       if(!p->local->hold_input){
+                               for (i=0; i<NUMBER_OF_RANGE_BINS; i++){
+                               p->local->Main_B[i][p->local->input_pointer]=samples_in[i];                                     //input B1
+                               p->local->Delayed_C[i][p->local->input_pointer + (NFFT/2)]=samples_in[i];       //input C2
+                               }       
+                   }
+
+                   if(!p->local->hold_output){
+                   DOL_write((void*)PORT_DATA_OUT, &(p->local->Main_A[p->local->output_pointer][0]),NFFT*sizeof(ComplexNumber), p);                    //output A
+                   DOL_write((void*)PORT_DATA_OUT_OL, &(p->local->Delayed_D[p->local->output_pointer][0]), NFFT*sizeof(ComplexNumber), p);     //output D
+                       }
+               break;
+
+
+               case 1:
+                       // put the input vector in buffers (check documentation for details)
+                       if(!p->local->hold_input){
+                               for (i=0; i<NUMBER_OF_RANGE_BINS; i++){
+                               p->local->Main_B[i][p->local->input_pointer + (NFFT/2)]=samples_in[i];          //input B2
+                               p->local->Delayed_D[i][p->local->input_pointer ]=samples_in[i];                         //input D1
+                           }
+                   }
+                   if(!p->local->hold_output){
+                   DOL_write((void*)PORT_DATA_OUT, &(p->local->Main_A[p->local->output_pointer][0]),NFFT*sizeof(ComplexNumber), p);                    //output A
+                   DOL_write((void*)PORT_DATA_OUT_OL, &(p->local->Delayed_C[p->local->output_pointer][0]), NFFT*sizeof(ComplexNumber), p);     //output D
+                       }
+               break;
+
+
+               case 2:
+                       // put the input vector in buffers (check documentation for details)
+                       if(!p->local->hold_input){
+                               for (i=0; i<NUMBER_OF_RANGE_BINS; i++){
+                               p->local->Main_A[i][p->local->input_pointer]=samples_in[i];                                     //input A1
+                               p->local->Delayed_D[i][p->local->input_pointer + (NFFT/2)]=samples_in[i];       //input D2
+                           }
+                       }
+                   if(!p->local->hold_output){
+                   DOL_write((void*)PORT_DATA_OUT, &(p->local->Main_B[p->local->output_pointer][0]),NFFT*sizeof(ComplexNumber), p);                    //output A
+                   DOL_write((void*)PORT_DATA_OUT_OL, &(p->local->Delayed_C[p->local->output_pointer][0]), NFFT*sizeof(ComplexNumber), p);     //output D
+                       }
+               break;
+
+
+               case 3:
+                       // put the input vector in buffers (check documentation for details)
+                       if(!p->local->hold_input){
+                               for (i=0; i<NUMBER_OF_RANGE_BINS; i++){
+                               p->local->Main_A[i][p->local->input_pointer + (NFFT/2)]=samples_in[i];          //input A2
+                               p->local->Delayed_C[i][p->local->input_pointer ]=samples_in[i];                         //input C1
+                           }
+                       }
+                   if(!p->local->hold_output){
+                   DOL_write((void*)PORT_DATA_OUT, &(p->local->Main_B[p->local->output_pointer][0]),NFFT*sizeof(ComplexNumber), p);                    //output A
+                   DOL_write((void*)PORT_DATA_OUT_OL, &(p->local->Delayed_D[p->local->output_pointer][0]), NFFT*sizeof(ComplexNumber), p);     //output D
+                       }
+               break;
+       }
+
+
+       // state switching every NFFT/2
+
+       // !!!!!!!!!!!!!1111
+       //something is wrong with the logic! proceed to debug for now!
+       #if NUMBER_OF_RANGE_BINS > NFFT // This case, hold input till all output is sent (applies to all state switches)
+               
+               if (!p->local->hold_input)
+               {
+               p->local->input_pointer = p->local->input_pointer + 1;
+               }
+
+               p->local->output_pointer = p->local->output_pointer + 1;
+               
+               if (p->local->input_pointer == NFFT/2 - 1)
+               {
+                       if(p->local->output_pointer < NUMBER_OF_RANGE_BINS)
+                       {
+                               p->local->hold_input = 1;
+                       }
+                       else  // output_pointer == NUMBER OF RANGE BINS
+                       {
+                               p->local->input_pointer = 0;
+                               p->local->output_pointer = 0;
+                               p->local->hold_input = 0;
+                               p->local->n_batches = p->local->n_batches + 1;
+                               p->local->state = p->local->state + 1;
+                               if (p->local->state > 3)
+                               {
+                                       p->local->state = 1;
+                               }
+                       }
+               }
+
+
+       #elif NUMBER_OF_RANGE_BINS < NFFT //This is the case that we have to hold the output until we receive
+
+               p->local->input_pointer = p->local->input_pointer + 1;
+
+               if(!p->local->hold_output)
+               {
+               p->local->output_pointer = p->local->output_pointer + 1;
+               }
+
+               if (p->local->output_pointer >= NUMBER_OF_RANGE_BINS)
+               {
+                       if   (p->local->input_pointer < (NFFT/2 ) )   // ???  -1   ??
+                       {
+                       p->local->hold_output = 1 ;
+                       }
+                       else
+                       {
+                               p->local->input_pointer = 0;
+                               p->local->output_pointer = 0;
+                               p->local->hold_output = 0;
+
+                               p->local->state = p->local->state + 1;
+                               p->local->n_batches = p->local->n_batches + 1;
+                               if (p->local->state > 3)
+                               {
+                                       p->local->state = 1;
+                               }
+                       }
+               }
+
+
+
+       #else // This is the case that we have equal number of input and output iterations
+               p->local->input_pointer = p->local->input_pointer + 1;
+               p->local->output_pointer = p->local->output_pointer + 1;
+               
+               if (p->local->input_pointer == NFFT/2 - 1)
+               {
+                       p->local->input_pointer = 0;
+                       p->local->n_batches = p->local->n_batches + 1;
+                       p->local->state = p->local->state + 1;
+                       if (p->local->state > 3)
+                       {
+                               p->local->state = 1;
+                       }
+               }
+
+               if (p->local->output_pointer == NUMBER_OF_RANGE_BINS)
+               {
+                       p->local->output_pointer = 0;
+               }
+
+
+
+       #endif
+
+
+
+           // !!!!!!!!!!!!!!!!1  check numbers! number of batches! I'm not sure!
+    if (p->local->n_batches == 2 * (NUMBER_OF_PULSES/NFFT))          // Check if all batches completed
+    {
+      p->local->n_batches = 0;
+         p->local->n_iterations = p->local->n_iterations + 1;                  
+    }
+
+
+
+       if (p->local->n_iterations == NUMBER_OF_ITERATIONS)             
+       {
+               printf("\n\n:: Corner Turn with overlap process finished ::\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+               
+               DOL_detach(p);
+       }
+       
+       return 0;
+}
+
+
+
+
+
+
+
+       /////
+       // p->local->pulse_counter_in = p->local->pulse_counter_in + 1;
+       
+
+
+       // if (p->local->pulse_counter_in == NFFT) 
+       // {
+               
+
+       //      p->local->pulse_counter_in = 0;
+       //      p->local->bin_counter_in = p->local->bin_counter_in + 1;  
+
+       //      if (p->local->bin_counter_in == NUMBER_OF_RANGE_BINS) 
+       //      {
+       //              p->local->bin_counter_in = 0;  // One batch (N Range bins * NFFT pulses) ready      
+       //      }
+       // }
+       
+       // p->local->bin_counter_out = p->local->bin_counter_out + 1;
+       // if (p->local->bin_counter_out == NUMBER_OF_RANGE_BINS) 
+       // {
+       //      p->local->bin_counter_out = 0;                              
+       //      p->local->pulse_counter_out = p->local->pulse_counter_out + 1;    
+       //      if (p->local->pulse_counter_out == NFFT)        
+       //      {
+       //              p->local->pulse_counter_out = 0;
+       //              p->local->buffer_mode = p->local->buffer_mode ^ 0x01;         // Switch buffer mode
+
+       //          p->local->n_batches = p->local->n_batches + 1;
+       //          if (p->local->n_batches == (NUMBER_OF_PULSES/NFFT))          // Check if all batches completed
+       //          {
+       //            p->local->n_batches = 0;
+       //                p->local->n_iterations = p->local->n_iterations + 1;                  
+       //          }
+       //      }
+       // }
+       
+       // p->local->output_index = p->local->output_index + 1;            
+       // if (p->local->output_index == NFFT/2)                           
+       // {
+       //      p->local->output_index = 0;
+       // }
+       
diff --git a/aesa/src/Corner_Turn_OL.h b/aesa/src/Corner_Turn_OL.h
new file mode 100644 (file)
index 0000000..4bdf14f
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef CORNER_TURN_OL_H
+#define CORNER_TURN_OL_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_DATA_IN "data_input"
+#define PORT_DATA_OUT "data_output"
+#define PORT_DATA_OUT_OL "data2_output_ol"
+
+typedef struct _local_states
+{
+  // ComplexNumber Beams_A[NUMBER_OF_RANGE_BINS][NFFT];          // [Range][Pulses]
+  // ComplexNumber Beams_B[NUMBER_OF_RANGE_BINS][NFFT];          // [Range][Pulses]
+  // ComplexNumber Delayed_Output[NUMBER_OF_RANGE_BINS][NFFT/2]; // [Range][Pulses]
+
+  // Main buffers are A and B
+  // Delayed buffers are C and D
+
+  ComplexNumber Main_A[NUMBER_OF_RANGE_BINS][NFFT];
+  ComplexNumber Main_B[NUMBER_OF_RANGE_BINS][NFFT];
+  ComplexNumber Delayed_C[NUMBER_OF_RANGE_BINS][NFFT];
+  ComplexNumber Delayed_D[NUMBER_OF_RANGE_BINS][NFFT];
+  
+  ComplexNumber Zero;
+  // int buffer_mode;
+       int state;
+  int input_pointer;
+  int output_pointer;
+  int hold_input;
+  int hold_output;
+       int pulse_counter_in;
+       int pulse_counter_out;
+       int bin_counter_in;
+       int bin_counter_out;
+       // int output_index;
+  int nfft;
+  int n_batches;
+       int n_iterations;
+
+  int excount;
+  
+} Corner_Turn_OL_State;
+
+void Corner_Turn_OL_init(DOLProcess *);
+int Corner_Turn_OL_fire(DOLProcess *);
+
+#endif
diff --git a/aesa/src/Data_Generator.c b/aesa/src/Data_Generator.c
new file mode 100644 (file)
index 0000000..8d42a70
--- /dev/null
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include "Data_Generator.h"
+
+/************************************************************************************/
+
+void Data_Generator_init(DOLProcess * p)
+{
+       int i,j,k;
+       
+       // p->local->antenna_cntr = 0;                  
+       p->local->pulse_cntr = 0;
+       p->local->bin_cntr = 0;
+       p->local->n_firings = 0;
+
+       p->local->excount = 0;
+       
+       for (i=0; i<NUMBER_OF_PULSES; i++)  
+       {
+               for (j=0; j<NUMBER_OF_RANGE_BINS; j++) 
+               {
+                       for (k=0; k<NUMBER_OF_ANTENNA_ELEMENTS; k++) 
+                       {
+                               (p->local->Samples[i][j][k]).real = 1.0;
+                               (p->local->Samples[i][j][k]).imag = 0.0;
+                       }
+               }
+       }
+}
+
+/************************************************************************************/
+
+int Data_Generator_fire(DOLProcess * p)
+{      
+       int beam_index;
+       p->local->excount++;
+    // printf("\tgenerator  executions:  %d\n",p->local->excount);     
+
+
+       // printf("\n Data Gen \n \t range: %d \n\t pulse: %d", p->local->bin_cntr, p->local->pulse_cntr);
+       
+       CREATEPORTVAR(output_port);  
+       for (beam_index = 0; beam_index < NUMBER_OF_BEAMS; beam_index++) 
+       {
+               CREATEPORT(output_port, PORT_OUT, 1, beam_index, NUMBER_OF_BEAMS);
+               DOL_write((void*)output_port, &(p->local->Samples[p->local->pulse_cntr][p->local->bin_cntr][0])
+                                                                       , NUMBER_OF_ANTENNA_ELEMENTS*sizeof(ComplexNumber), p);
+       }
+       
+       //p->local->antenna_cntr = p->local->antenna_cntr + 1;
+       
+       // if (p->local->antenna_cntr == NUMBER_OF_ANTENNA_ELEMENTS) 
+       // {
+   //  p->local->antenna_cntr = 0;
+               
+               p->local->bin_cntr = p->local->bin_cntr + 1;        
+               if (p->local->bin_cntr == NUMBER_OF_RANGE_BINS)     
+               {
+                       p->local->bin_cntr = 0;
+                       // Increase pulse index
+                       p->local->pulse_cntr =  p->local->pulse_cntr + 1; 
+                       if (p->local->pulse_cntr == NUMBER_OF_PULSES)     
+                       {
+                               p->local->pulse_cntr = 0; 
+                               p->local->n_firings = p->local->n_firings + 1; 
+                       }
+               }
+       // }
+       
+       if (p->local->n_firings == NUMBER_OF_ITERATIONS)      
+    {
+    printf("\n\n:: Data generator process finished ::\n\n");   
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+    DOL_detach(p);
+       }
+       return 0;
+}
diff --git a/aesa/src/Data_Generator.h b/aesa/src/Data_Generator.h
new file mode 100644 (file)
index 0000000..766ff86
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef DATA_GENERATOR_H
+#define DATA_GENERATOR_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_OUT "out"
+
+typedef struct _local_states
+{
+    // ComplexNumber Samples[NUMBER_OF_ANTENNA_ELEMENTS][NUMBER_OF_PULSES][NUMBER_OF_RANGE_BINS];
+
+       // this "Samples" arrays definition is changed! it will be faster in array passing and more rational this way.
+       
+       ComplexNumber Samples[NUMBER_OF_PULSES][NUMBER_OF_RANGE_BINS][NUMBER_OF_ANTENNA_ELEMENTS];
+
+    //int antenna_cntr;
+       int pulse_cntr;
+       int bin_cntr;
+       int n_firings;
+
+       int excount;
+} Data_Generator_State;
+
+void Data_Generator_init(DOLProcess *);
+int Data_Generator_fire(DOLProcess *);
+#endif
diff --git a/aesa/src/FFT_Radix2_DIF.c b/aesa/src/FFT_Radix2_DIF.c
new file mode 100644 (file)
index 0000000..2e14788
--- /dev/null
@@ -0,0 +1,169 @@
+#include "FFT_Radix2_DIF.h"
+
+/************************************************************************************/
+
+void FFT_Radix2_DIF_init(DOLProcess * p)
+{      
+       // int i,j;
+       
+       // for (i=0; i<NFFT; i=i+1) 
+       // {
+       //      p->local->Samples_Inp[i].real = 0.0;    // Buffer A of NFFT size
+       //      p->local->Samples_Inp[i].imag = 0.0;
+       //      p->local->Samples_Out[i].real = 0.0;    // Buffer B of NFFT size
+       //      p->local->Samples_Out[i].imag = 0.0;
+       // }
+       
+       p->local->pow_2[0]=1;
+       int i;
+       for (i=1; i < MAX_POW; i++)
+       {
+               p->local->pow_2[i] = p->local->pow_2[i-1]*2;
+       }
+
+       // p->local->sample_counter = 0;
+       p->local->n_ffts = 0;
+       p->local->n_fft_batches = 0;
+       p->local->n_iterations = 0;
+       p->local->excount = 0;
+
+}
+
+/************************************************************************************/
+
+int FFT_Radix2_DIF_fire(DOLProcess * p)
+{
+       // ComplexNumber next_sample;
+       ComplexNumber samples_in[NFFT];
+       // ComplexNumber samples_out[NFFT];
+       p->local->excount++;
+
+
+    int N1,N2, k1, c;
+
+       DOL_read((void*)PORT_DATA_IN, &samples_in, NFFT*sizeof(ComplexNumber), p);              
+       
+       // p->local->Samples_Inp[p->local->sample_counter] = next_sample;                                               
+       // next_sample = p->local->Samples_Out[p->local->sample_counter];
+
+       // The value is calculated, the Dol write is placed as the bottom of the fire function
+
+       // p->local->sample_counter = p->local->sample_counter + 1;
+       // if (p->local->sample_counter == NFFT) 
+       // {
+    N1 = 2;
+    N2 = NFFT/2;
+
+    // FFT_Radix2(&(p->local->Samples_Inp[0]), NFFT);  // Compute first stage
+    FFT_Radix2(&(samples_in[0]), NFFT);  // Compute first stage
+
+
+    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    // I don't really understand what's happening here! \/ 
+       while (N2 != 1)  // Compute log NFFT stages
+       {
+                 for (k1 = 0; k1 < N1; k1++)
+               {
+           FFT_Radix2(&(samples_in[N2*k1]), N2);
+               }
+      N2 = N2/2;
+       }
+
+         // Bit_Reverse_Reorder(&(p->local->Samples_Inp[0]), &(p->local->Samples_Out[0]), NFFT, p);  // Reorder data for output
+               
+               // p->local->sample_counter = 0;
+               p->local->n_ffts = p->local->n_ffts + 1;
+               if (p->local->n_ffts == NOF_FFT_PER_RANGE_BIN)                                                  
+               {
+                       p->local->n_ffts = 0;
+                       p->local->n_fft_batches = p->local->n_fft_batches + 1;
+                       if (p->local->n_fft_batches == NOF_FFT_BATCHES)                         
+                       {                               
+                               p->local->n_fft_batches = 0;
+                               p->local->n_iterations = p->local->n_iterations + 1; 
+                       }
+               }
+       // }
+               // printf("\n FFT batches : %d\n",p->local->n_fft_batches);
+                       
+       DOL_write((void*)PORT_DATA_OUT, &samples_in, NFFT*sizeof(ComplexNumber), p);    
+
+       // what i think is happening: is that the output is placed in sample in, but in reverse reorder,
+       // it looks at how many inputs we have got, and it switches them. not necessary anymore!
+
+       if (p->local->n_iterations == NUMBER_OF_ITERATIONS) 
+       {
+               printf("\n\n:: FFT_Radix2_DIF process finished ::\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+               
+               DOL_detach(p);
+       }
+       
+       return 0;
+}
+
+/************************************************************************************/
+
+void FFT_Radix2(ComplexNumber * data, int N)
+{
+       int n2, k1, N1, N2;
+       ComplexNumber W, butterfly[2];
+       
+       N1=2;
+       N2=N/2;
+       
+       /** Do 2 Point DFTs */
+       for (n2 = 0; n2 < N2; n2++)
+       {
+         W.real=cos(n2*2.0*PI/(double)N);
+         W.imag=-sin(n2*2.0*PI/(double)N);
+
+               /** Compute one butterfly **/
+               butterfly[0].real = (data[n2].real + data[N2 + n2].real);
+               butterfly[0].imag = (data[n2].imag + data[N2 + n2].imag);
+               butterfly[1].real = (data[n2].real - data[N2 + n2].real) * W.real - ((data[n2].imag - data[N2 + n2].imag) * W.imag); 
+               butterfly[1].imag = (data[n2].imag - data[N2 + n2].imag) * W.real + ((data[n2].real - data[N2 + n2].real) * W.imag);
+               
+               /** In-place results */
+               for (k1 = 0; k1 < N1; k1++)
+               {
+           data[n2 + N2*k1].real = butterfly[k1].real;
+           data[n2 + N2*k1].imag = butterfly[k1].imag;
+               }
+       }
+}
+
+/************************************************************************************/
+
+void Bit_Reverse_Reorder(ComplexNumber * input, ComplexNumber * output, int N, DOLProcess * p)
+{
+       int bits, i, j, k;
+       bits = 0;
+
+       for (i=0; i<MAX_POW; i++)
+       {
+               if (p->local->pow_2[i] == N)
+               {
+                       bits=i;
+               }
+       }
+       
+       for (i=0; i<N; i++)
+       {
+               j=0;
+               for (k=0; k<bits; k++)
+               {
+           if (i & p->local->pow_2[k])
+                       {
+                               j += p->local->pow_2[bits-k-1];
+                       }
+               }
+               if (j>=i)  
+               {
+      output[i].real = input[j].real;
+      output[i].imag = input[j].imag;
+      output[j].real = input[i].real;
+      output[j].imag = input[i].imag;
+               }
+       }
+}
diff --git a/aesa/src/FFT_Radix2_DIF.h b/aesa/src/FFT_Radix2_DIF.h
new file mode 100644 (file)
index 0000000..6a99b0d
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef FFT_RADIX2_DIF_H
+#define FFT_RADIX2_DIF_H
+
+#include <stdlib.h>
+#include <math.h>
+#include <dol.h>
+#include "global.h"
+
+#define NOF_FFT_PER_RANGE_BIN NUMBER_OF_PULSES/NFFT
+#define NOF_FFT_BATCHES NOF_FFT_PER_RANGE_BIN//*NUMBER_OF_RANGE_BINS
+#define PI 3.14159265359
+#define MAX_POW 10             // Maximum 1024 point FFT 
+
+#define PORT_DATA_IN "data_input"
+#define PORT_DATA_OUT "data_output"
+
+typedef struct _local_states
+{
+       // These are not needed anymore, since we are reading a vector, we don't have to save the values for till next firing.
+    // ComplexNumber Samples_Inp[NFFT];
+       // ComplexNumber Samples_Out[NFFT];
+       // int sample_counter;
+       int n_ffts;
+       int n_fft_batches;
+       int n_iterations;
+  int pow_2[MAX_POW];
+
+       int excount;
+  
+} FFT_Radix2_DIF_State;
+
+void FFT_Radix2_DIF_init(DOLProcess * p);
+int FFT_Radix2_DIF_fire(DOLProcess * p);
+void Bit_Reverse_Reorder(ComplexNumber * input, ComplexNumber * output, int N, DOLProcess * p);
+void FFT_Radix2(ComplexNumber * data, int N);
+
+#endif
diff --git a/aesa/src/FIR.c b/aesa/src/FIR.c
new file mode 100644 (file)
index 0000000..57f7235
--- /dev/null
@@ -0,0 +1,108 @@
+#include "FIR.h"
+
+void FIR_init(DOLProcess* p) {
+  int i;
+
+  // initialize coefficients : to be changed
+  for(i = 0; i < FIR_LENGTH; i++) {
+    p->local->Coeffs[i].real = 1.0;
+    p->local->Coeffs[i].imag = 0.0;
+  }
+  
+  // initialize samples with zeros
+  FIR_reset_samples(p);
+  
+  // initialize counters
+  // p->local->bin_counter = 0;
+  p->local->pulse_counter = 0;
+  p->local->n_iterations = 0;
+
+  p->local->excount = 0;
+
+}
+
+int FIR_fire(DOLProcess* p) {
+
+  // ComplexNumber next_sample;
+  ComplexNumber samples_in[NUMBER_OF_RANGE_BINS];
+  ComplexNumber samples_out[NUMBER_OF_RANGE_BINS];
+
+  p->local->excount++;
+
+  // read next input sample
+  DOL_read((void*) PORT_DATA_IN, &samples_in, NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
+
+  int i;
+
+  // Previously the following 2 lines took "range" number of firings to complete. Now they are finnished 
+  // in a for loop
+  // FIR_insert_sample(p, next_sample);
+  
+  // compute next output sample using currently stored samples
+  // FIR_compute(p, &next_sample);
+  for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
+  {
+    FIR_insert_sample(p, samples_in[i]);
+    FIR_compute(p, &samples_out[i]); // second argument is the outputof function
+  }
+
+
+  DOL_write((void*) PORT_DATA_OUT, &samples_out, NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p);
+  
+  
+
+  // advance counters
+  // p->local->bin_counter = p->local->bin_counter + 1;
+  // if (p->local->bin_counter == NUMBER_OF_RANGE_BINS) {
+    
+    // one pulse has been completed, reset samples...
+    FIR_reset_samples(p);
+    
+    // p->local->bin_counter = 0;
+    p->local->pulse_counter = p->local->pulse_counter + 1;
+    
+    if (p->local->pulse_counter == NUMBER_OF_PULSES) {
+      p->local->pulse_counter = 0;
+      p->local->n_iterations = p->local->n_iterations + 1;
+    }   
+  // }
+
+  if (p->local->n_iterations == NUMBER_OF_ITERATIONS) {
+    printf("\n\n:: FIR process finished ::\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+    
+    DOL_detach(p);
+  }
+
+  return 0;
+}
+
+void FIR_reset_samples(DOLProcess* p) {
+  int i;
+  for(i = 0; i < FIR_LENGTH; i++) {
+    p->local->Samples[i].real = 0.0;
+    p->local->Samples[i].imag = 0.0;
+  }
+}
+
+void FIR_insert_sample(DOLProcess* p, ComplexNumber next_sample) {
+  // shift, then insert
+  int i;
+  for(i = FIR_LENGTH - 1; i > 0; i--)
+    p->local->Samples[i] = p->local->Samples[i-1];
+  p->local->Samples[0] = next_sample;
+}
+  
+
+void FIR_compute(DOLProcess* p, ComplexNumber* result) {
+  int i;
+  result->real = 0.0;
+  result->imag = 0.0;
+  for(i = 0; i < FIR_LENGTH; i++) {
+    result->real += (p->local->Samples[i].real * p->local->Coeffs[i].real - 
+                    p->local->Samples[i].imag * p->local->Coeffs[i].imag) ;
+    result->imag += (p->local->Samples[i].real * p->local->Coeffs[i].imag + 
+                    p->local->Samples[i].imag * p->local->Coeffs[i].real) ;
+  }
+}
+
diff --git a/aesa/src/FIR.h b/aesa/src/FIR.h
new file mode 100644 (file)
index 0000000..12ea765
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef FIR_H
+#define FIR_H
+
+#include <stdlib.h>
+#include <math.h>
+#include <dol.h>
+#include "global.h"
+
+#define FIR_LENGTH 4 // to be changed, as needed
+
+#define PORT_DATA_IN "data_input"
+#define PORT_DATA_OUT "data_output"
+
+typedef struct _local_states 
+{
+  ComplexNumber Coeffs[FIR_LENGTH];
+  ComplexNumber Samples[FIR_LENGTH];
+  // int bin_counter;
+  int pulse_counter;
+  int n_iterations;
+
+       int excount;
+  
+} FIR_State;
+
+void FIR_init(DOLProcess*);
+int FIR_fire(DOLProcess*);
+
+void FIR_reset_samples(DOLProcess*);
+void FIR_insert_sample(DOLProcess*, ComplexNumber);
+void FIR_compute(DOLProcess*, ComplexNumber*);
+  
+#endif
diff --git a/aesa/src/Weight_Generator.c b/aesa/src/Weight_Generator.c
new file mode 100644 (file)
index 0000000..73d16ad
--- /dev/null
@@ -0,0 +1,66 @@
+#include "Weight_Generator.h"
+
+/************************************************************************************/
+
+void Weight_Generator_init(DOLProcess * p)
+{
+       int i,j;
+
+       //p->local->weight_counter = 0;             
+       p->local->pulse_counter = 0;
+       p->local->n_firings = 0;
+       
+       
+       
+       for (i=0; i<NUMBER_OF_BEAMS; i++) 
+  {
+               for (j=0; j<NUMBER_OF_ANTENNA_ELEMENTS; j++) 
+    {
+                       (p->local->Weights[i][j]).real = 1.0;
+                       (p->local->Weights[i][j]).imag = 0.0;
+               }
+       }
+
+       p->local->excount = 0;
+
+}
+
+/************************************************************************************/
+
+int Weight_Generator_fire(DOLProcess * p)
+{
+  int beam_index;
+       p->local->excount++;
+  
+  // printf("\n  \t\t weight gen \t %d \n",   p->local->pulse_counter);
+       
+       CREATEPORTVAR(output_port);
+       for (beam_index = 0; beam_index < NUMBER_OF_BEAMS; beam_index++) 
+    {
+               CREATEPORT(output_port, PORT_OUT, 1, beam_index, NUMBER_OF_BEAMS);
+               DOL_write((void*)output_port, &(p->local->Weights[beam_index][0]), NUMBER_OF_ANTENNA_ELEMENTS*sizeof(ComplexNumber), p);
+       }
+
+       //p->local->weight_counter = p->local->weight_counter + 1; 
+
+       // if (p->local->weight_counter == NUMBER_OF_ANTENNA_ELEMENTS)
+       // {
+       //      p->local->weight_counter = 0;
+               p->local->pulse_counter = p->local->pulse_counter + 1;
+               if (p->local->pulse_counter == (NUMBER_OF_RANGE_BINS * NUMBER_OF_PULSES)) 
+        {
+                       p->local->pulse_counter = 0;
+                       p->local->n_firings = p->local->n_firings + 1;
+               }
+       //}
+       
+       if (p->local->n_firings == NUMBER_OF_ITERATIONS) 
+    {
+    printf("\n\n:: Weight generator finished ::\n\n");
+    // printf("\ttotal number of executions:  %d",p->local->excount);  
+    
+               DOL_detach(p);
+       }
+       
+       return 0;
+}
\ No newline at end of file
diff --git a/aesa/src/Weight_Generator.h b/aesa/src/Weight_Generator.h
new file mode 100644 (file)
index 0000000..75dbdb4
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef WEIGHT_GENERATOR_H
+#define WEIGHT_GENERATOR_H
+
+#include <dol.h>
+#include "global.h"
+
+#define PORT_OUT "out"
+
+typedef struct _local_states
+{
+  ComplexNumber Weights[NUMBER_OF_BEAMS][NUMBER_OF_ANTENNA_ELEMENTS];
+  //int weight_counter;
+       int pulse_counter;
+       int n_firings;
+
+       int excount;
+       
+
+       
+} Weight_Generator_State;
+
+void Weight_Generator_init(DOLProcess *);
+int Weight_Generator_fire(DOLProcess *);
+
+#endif
\ No newline at end of file
diff --git a/aesa/src/global.h b/aesa/src/global.h
new file mode 100644 (file)
index 0000000..a7e2fa2
--- /dev/null
@@ -0,0 +1,27 @@
+#include <string.h>
+
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#define NFFT 32
+#define NUMBER_OF_ANTENNA_ELEMENTS 16
+#define NUMBER_OF_BEAMS 8
+#define NUMBER_OF_PULSES 128
+#define NUMBER_OF_RANGE_BINS 4
+#define NUMBER_OF_DOPPLER_CHANNELS NUMBER_OF_BEAMS
+#define NUMBER_OF_ITERATIONS 4  
+
+#define PRINT_CONSUMER
+
+#include "stdio.h"
+
+//structure for holding complex numbers
+typedef struct complex_number
+{
+  float real;
+  float imag;
+} ComplexNumber;
+
+#endif
+
+