summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorsave2008-05-14 09:51:39 +0000
committersave2008-05-14 09:51:39 +0000
commit45a3fb0e4223afb131b697c93601d6f553922586 (patch)
tree4831ae43c3420204bca979b2908af46930d66c42 /cleopatre
parent25367d10327a14e6cc29d167bad53803283cb088 (diff)
Triplicate and vote for each reading with the Gidel access
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1978 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/hal/gidel/AHBMemory.tpp14
-rw-r--r--cleopatre/hal/gidel/AHBRegister.cpp44
-rw-r--r--cleopatre/hal/gidel/test/Makefile14
-rw-r--r--cleopatre/hal/gidel/test/src/start2.cpp194
4 files changed, 253 insertions, 13 deletions
diff --git a/cleopatre/hal/gidel/AHBMemory.tpp b/cleopatre/hal/gidel/AHBMemory.tpp
index 5a1bda15bd..c164f81e66 100644
--- a/cleopatre/hal/gidel/AHBMemory.tpp
+++ b/cleopatre/hal/gidel/AHBMemory.tpp
@@ -329,7 +329,19 @@ template <typename T> AHBMemoryRef<T>::operator unsigned int ()
if(addr <= size)
{
//Get the value at the current address
- return ahb.GetAt(addr);
+ T one, two, three, result;
+ one = ahb.GetAt(addr);
+ two = ahb.GetAt(addr);
+ three = ahb.GetAt(addr);
+
+ if((one == two) || (one == three))
+ result = one;
+ else if(two == three)
+ result = two;
+ else
+ result = three;
+
+ return result;
}
else
{
diff --git a/cleopatre/hal/gidel/AHBRegister.cpp b/cleopatre/hal/gidel/AHBRegister.cpp
index 1bdc3e8b3d..469ed25c6a 100644
--- a/cleopatre/hal/gidel/AHBRegister.cpp
+++ b/cleopatre/hal/gidel/AHBRegister.cpp
@@ -17,6 +17,23 @@
#include <unistd.h>
#include "AHBRegister.h"
+static unsigned int getAHBRegister(ReadWriteRegister reg)
+{
+ unsigned int one, two, three, result;
+ one = reg;
+ two = reg;
+ three = reg;
+
+ if((one == two) || (one == three))
+ result = one;
+ else if(two == three)
+ result = two;
+ else
+ result = three;
+ return result;
+}
+
+
/**
* Class AHBRegister
*/
@@ -43,38 +60,53 @@ AHBRegister& AHBRegister::operator= (const unsigned int val)
}
AHBRegister& AHBRegister::operator|= (const unsigned int val)
{
+ unsigned int tmp;
page = page_value;
- reg |= val;
+ tmp = getAHBRegister(reg);
+ tmp |= val;
+ reg = tmp;
return *this;
}
AHBRegister& AHBRegister::operator&= (const unsigned int val)
{
+ unsigned int tmp;
page = page_value;
- reg &= val;
+ tmp = getAHBRegister(reg);
+ tmp &= val;
+ reg = tmp;
return *this;
}
AHBRegister& AHBRegister::operator^= (const unsigned int val)
{
+ unsigned int tmp;
page = page_value;
- reg ^= val;
+ tmp = getAHBRegister(reg);
+ tmp ^= val;
+ reg = tmp;
return *this;
}
AHBRegister& AHBRegister::operator+= (const unsigned int val)
{
+ unsigned int tmp;
page = page_value;
- reg = reg + val;
+ tmp = getAHBRegister(reg);
+ tmp += val;
+ reg = tmp;
return *this;
}
AHBRegister& AHBRegister::operator-= (const unsigned int val)
{
+ unsigned int tmp;
page = page_value;
- reg = reg - val;
+ tmp = getAHBRegister(reg);
+ tmp -= val;
+ reg = tmp;
return *this;
}
AHBRegister::operator unsigned int ()
{
page = page_value;
- return reg;
+ return getAHBRegister(reg);
}
diff --git a/cleopatre/hal/gidel/test/Makefile b/cleopatre/hal/gidel/test/Makefile
index 06ec282801..c3e8cb7529 100644
--- a/cleopatre/hal/gidel/test/Makefile
+++ b/cleopatre/hal/gidel/test/Makefile
@@ -1,5 +1,5 @@
-OBJECTS := start
+BINS := start start2
OBJPATH := obj
LIBPATH := ../obj
DRVPATH := /usr/local/gidel/gidel82lnx/lib
@@ -8,9 +8,8 @@ INCDRVPATH := $(DRVPATH)
###################################################
# Files
-THE_SRC := $(NAME).cpp
-THE_OBJ := $(foreach objects, $(OBJECTS), $(OBJPATH)/$(objects).o)
-THE_BIN := $(OBJPATH)/test
+THE_OBJ := $(foreach objects, $(BINS), $(OBJPATH)/$(objects).o)
+THE_BIN := $(foreach bins, $(BINS), $(OBJPATH)/$(bins))
# Common stuff
CC := g++
@@ -27,10 +26,13 @@ all:
make compile ; \
fi
-compile: $(THE_BIN) $(THE_LIB)
+compile: $(THE_BIN)
-$(THE_BIN) : $(THE_OBJ)
+$(OBJPATH)/start2: $(OBJPATH)/start2.o
+ $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+
+$(OBJPATH)/start: $(OBJPATH)/start.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
$(OBJPATH)/%.o : src/%.cpp
diff --git a/cleopatre/hal/gidel/test/src/start2.cpp b/cleopatre/hal/gidel/test/src/start2.cpp
new file mode 100644
index 0000000000..84c644a3c7
--- /dev/null
+++ b/cleopatre/hal/gidel/test/src/start2.cpp
@@ -0,0 +1,194 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test.cpp
+ * \brief simple loader and basic test program
+ * \ingroup
+ *
+ * this program load an rbf file into the gidel's FPGA
+ * and start some tests
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#include "AHBMemory.h"
+#include "AHBRegister.h"
+#include "Gidel.h"
+
+#define FPGA_NUM 1
+#define RBF "/home/spidcom/Maria_proto/projects/Maria_Proto_11/modules/maria_proto/board/hardware/proto_maria_ddr/fpga.rbf"
+
+CGidel *m_gidel = NULL;
+char rbf[_MAX_PATH];
+
+static void catch_sigint(int sig)
+{
+ if(m_gidel != NULL)
+ {
+ printf("freeing memory...\n");
+ delete m_gidel;
+ }
+ exit(0);
+}
+
+void test_irq(LPVOID pData)
+{
+ printf("Oh What a pretty IRQ !\n");
+}
+
+int main(int argc, char* argv[])
+{
+ signal(SIGINT, catch_sigint);
+
+ memset(rbf, 0, sizeof(rbf));
+ strcpy(rbf, RBF);
+
+ //download .rbf into the FPGA
+ printf("\nLoading FPGA under GIDEL..........");
+ try
+ {
+ m_gidel = new CGidel(rbf, FPGA_NUM);
+ }
+ catch(const ProcException& e)
+ {
+ e.ErrorMsg();
+ exit(-1);
+ }
+ catch(...)
+ {
+ printf("failed\nUnable to Load FPGA under Gidel\n");
+ exit(-1);
+ }
+ //print rbf version
+ printf("done (V%d)\n", m_gidel->GetRBFVersion());
+ //start processor and ahb
+ printf("Starting processor and AHB........");
+ m_gidel->f_rst_ahb = 0;
+ m_gidel->f_rst_proc = 0;
+
+ if(!m_gidel->f_rst_ahb && !m_gidel->f_rst_proc)
+ printf("done\n");
+ else
+ printf("failed\nUnable to UnReset processor and AHB\n");
+
+ //set interrupt handler (interrupt from LEON)
+ m_gidel->SetUserInterruptHandler(&test_irq);
+ m_gidel->EnableInterrupt(true);
+
+ AHBRegister L2A_head(m_gidel, 0xB500001C);
+
+ unsigned int error = 0;
+ unsigned int result;
+ printf("Read/Write test starting... ");
+
+ for(unsigned int i=0;;i++)
+ {
+ L2A_head = i;
+ for(int j=0;j<1;j++)
+ {
+ result = L2A_head;
+ if(L2A_head != i)
+ {
+ printf("i=0x%08x ; result=0x%08x\n",i,result);
+ error++;
+ }
+ }
+ if(!(i%100000))
+ {
+ if(error)
+ {
+ printf("%d on %d Errors\n",error, i);
+ i = 0;
+ error = 0;
+ }
+ else
+ printf("No Errors\n");
+ }
+ }
+
+/*
+ unsigned int one;
+ unsigned int two;
+ unsigned int three;
+ unsigned int four;
+
+ for(unsigned int i=0;;i++)
+ {
+ L2A_head = i;
+ one = L2A_head;
+ two = L2A_head;
+ three = L2A_head;
+ // four = L2A_head;
+
+ if((one != i) || (two != i) || (three != i) || (four != i))
+ {
+ printf("one=0x%08x ; two=0x%08x ; three=0x%08x ; four=0x%08x\n",one,two,three,four);
+ error++;
+ }
+
+ if(!(i%100000))
+ {
+ if(error)
+ {
+ printf("%d on %d Errors\n",error, i);
+ i = 0;
+ error = 0;
+ }
+ else
+ printf("No Errors\n");
+ }
+ }
+*/
+/*
+ unsigned int one;
+ unsigned int two;
+ unsigned int three;
+
+ for(unsigned int i=0;;i++)
+ {
+ L2A_head = i;
+ one = L2A_head;
+ two = L2A_head;
+ three = L2A_head;
+ unsigned int result;
+
+ if((one == two) || (one == three))
+ {
+ result = one;
+ }
+ else if(two == three)
+ {
+ result = two;
+ }
+ else
+ result = three;
+
+ if(result != i)
+ {
+ printf("i=0x%08x ; one=0x%08x ; two=0x%08x ; three=0x%08x ; result=0x%08x\n",i,one,two,three,result);
+ error++;
+ }
+
+ if(!(i%100000))
+ {
+ if(error)
+ {
+ printf("%d on %d Errors\n",error, i);
+ i = 0;
+ error = 0;
+ }
+ else
+ printf("No Errors\n");
+ }
+ }
+*/
+
+ return 0;
+}
+