[Avida-SVN] r1549 - in development: source/cpu support/config
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Mon May 14 07:34:28 PDT 2007
Author: dknoester
Date: 2007-05-14 10:34:28 -0400 (Mon, 14 May 2007)
New Revision: 1549
Modified:
development/source/cpu/cHardwareGX.cc
development/source/cpu/cHardwareGX.h
development/support/config/default-gx.org
development/support/config/instset-gx.cfg
Log:
More fixes to cHardwareGX, if-bind2 instruction.
Modified: development/source/cpu/cHardwareGX.cc
===================================================================
--- development/source/cpu/cHardwareGX.cc 2007-05-14 01:28:06 UTC (rev 1548)
+++ development/source/cpu/cHardwareGX.cc 2007-05-14 14:34:28 UTC (rev 1549)
@@ -255,6 +255,7 @@
tInstLibEntry<tMethod>("bind", &cHardwareGX::Inst_Bind),
tInstLibEntry<tMethod>("bind2", &cHardwareGX::Inst_Bind2),
tInstLibEntry<tMethod>("if-bind", &cHardwareGX::Inst_IfBind),
+ tInstLibEntry<tMethod>("if-bind2", &cHardwareGX::Inst_IfBind2),
tInstLibEntry<tMethod>("num-sites", &cHardwareGX::Inst_NumSites),
// These are dummy instructions used for making mutiple programids
@@ -385,6 +386,10 @@
if (m_tracer != NULL) m_tracer->TraceHardware(*this);
if(m_current->GetExecute()) {
+ // In case the IP is modified by this instruction, make sure that it wraps
+ // around to the beginning of the genome.
+ IP().Adjust();
+
// Find the instruction to be executed.
const cInstruction& cur_inst = IP().GetInst();
@@ -2959,12 +2964,14 @@
// Binding fails if we are already bound!
cHeadProgramid& read = GetHead(nHardware::HEAD_READ);
if(read.GetMemSpace() != m_current->GetID()) return false;
+ cHeadProgramid& write = GetHead(nHardware::HEAD_WRITE);
// Now, select another programid to match against.
// Go through all *other* programids looking for matches
std::vector<cMatchSite> all_matches;
for(programid_list::iterator i=m_programids.begin(); i!=m_programids.end(); ++i) {
- if(*i != m_current) {
+ // Don't bind to ourself, or to whatever programid our write head is attached to.
+ if((*i != m_current) && ((*i)->GetID() != write.GetMemSpace())) {
std::vector<cMatchSite> matches = (*i)->Sites(GetLabel());
all_matches.insert(all_matches.end(), matches.begin(), matches.end());
}
@@ -2976,7 +2983,7 @@
// Otherwise set the read head to a random match
unsigned int c = ctx.GetRandom().GetUInt(all_matches.size());
- // Ok, it matched. Bind the current programid to the matched site.
+ // Ok, it matched. Bind the current programid's read head to the matched site.
m_current->Bind(nHardware::HEAD_READ, all_matches[c]);
// And we're done.
@@ -3054,6 +3061,19 @@
return ret;
}
+
+bool cHardwareGX::Inst_IfBind2(cAvidaContext& ctx)
+{
+ // Normal Bind2
+ bool ret = Inst_Bind2(ctx);
+
+ //Skip the next instruction if binding was not successful
+ if (!ret) IP().Advance();
+
+ return ret;
+}
+
+
/*! This instruction puts the total number of binding sites found in BX
Currently it is used to keep track of whether genome division has completed.*/
bool cHardwareGX::Inst_NumSites(cAvidaContext& ctx)
@@ -3179,7 +3199,7 @@
if(write.GetMemSpace() == m_current->GetID()) return false;
// It should never be the case that the read and write heads are on the same programid.
- //assert(read.GetMemSpace() != write.GetMemSpace());
+ assert(read.GetMemSpace() != write.GetMemSpace());
// Actually, it can happen with bind2 @JEB
// If the read and write heads are on the same programid, then fail
Modified: development/source/cpu/cHardwareGX.h
===================================================================
--- development/source/cpu/cHardwareGX.h 2007-05-14 01:28:06 UTC (rev 1548)
+++ development/source/cpu/cHardwareGX.h 2007-05-14 14:34:28 UTC (rev 1549)
@@ -545,6 +545,7 @@
bool Inst_Bind(cAvidaContext& ctx); //!< Attempt to match the currently executing cProgramid against other cProgramids.
bool Inst_Bind2(cAvidaContext& ctx); //!< Attempt to locate two programids with the same site.
bool Inst_IfBind(cAvidaContext& ctx); //!< Attempt to match the currently executing cProgramid against other cProgramids. Execute next inst if successful.
+ bool Inst_IfBind2(cAvidaContext& ctx); //!< Attempt to match and bind two programids.
bool Inst_NumSites(cAvidaContext& ctx); //!< Count the number of corresponding binding sites
bool Inst_ProgramidCopy(cAvidaContext& ctx); //!< Like h-copy, but fails if read/write heads not on other programids and will not write over
bool Inst_ProgramidDivide(cAvidaContext& ctx); //!< Like h-divide,
Modified: development/support/config/default-gx.org
===================================================================
--- development/support/config/default-gx.org 2007-05-14 01:28:06 UTC (rev 1548)
+++ development/support/config/default-gx.org 2007-05-14 14:34:28 UTC (rev 1549)
@@ -55,14 +55,13 @@
nop-C
nop-C
site
-nop-B # P2? This programid is responsible for locating two genomes,
-bind2 # and then triggering the divide process.
-nop-B
-nop-C
-if-n-equ
+nop-B # Cell-cycle programid. This programid is responsible for
+if-bind2 # locating two genomes and then triggering the divide process.
+ nop-B
+ nop-C
p-divide
site
-nop-C # End of P2.
+nop-C # End of cell-cycle programid..
site # Site and empty space.
nop-C
nop-C
Modified: development/support/config/instset-gx.cfg
===================================================================
--- development/support/config/instset-gx.cfg 2007-05-14 01:28:06 UTC (rev 1548)
+++ development/support/config/instset-gx.cfg 2007-05-14 14:34:28 UTC (rev 1549)
@@ -14,46 +14,22 @@
add 1 # n
sub 1 # o
nand 1 # p
-IO 1 # q
+IO 1 # q Puts current contents of register and gets new.
site 1 # r
bind 1 # s
-bind2 1 # t
-if-bind 1 # u
-g-alloc 1 # v
-p-alloc 1 # w
-p-copy 1 # x
-p-divide 1 # y
-goto 1 # z
-label 1 # A
-
+bind2 1 # s
+if-bind 1 # t
+if-bind2 1 # u
+num-sites 1 # v
+g-alloc 1 # w
+p-alloc 1 # x
+p-copy 1 # y
+p-divide 1 # z
+goto 1 # A
+label 1 # B
-PROGRAMID 0 # B
-EXECUTABLE 0 # C
-BINDABLE 0 # D
-READABLE 0 # E
-
-#adv-head 1
-#jump-f 1
-#jump-b 1
-#call 1
-#return 1
-#if-bit-1 1
-#get 1
-#put 1
-#h-read 1
-#h-write 1
-#set-head 1
-#search-f 1
-#search-b 1
-
-
-# Works on multiple nops: pop push inc dec IO adv-head
-
-# What if we add a new head. Search will return the location of something,
-# and put the new head there. Then set-head will move another head to that
-# point. In the case of the copy loop, it only needs to be set once and
-# this will speed up the code quite a bit!
-
-# Search with no template returns current position (abs line number) in
-# genome.
+PROGRAMID 0 0 # C
+EXECUTABLE 0 0 # D
+BINDABLE 0 0 # E
+READABLE 0 0 # F
More information about the Avida-cvs
mailing list