mirror of
https://github.com/Lukas0025/POC1-SIMD-DNA.git
synced 2025-04-05 07:11:32 +01:00
Shift register first implementation
This commit is contained in:
parent
e17800f1d4
commit
c7b7b48896
@ -6,8 +6,8 @@
|
||||
|
||||
define:
|
||||
# BIT NOT selector
|
||||
0 [ABC][DE][NSE]
|
||||
1 [ABCD]{E}[NSE]
|
||||
0 [ABC][DE][NSE].<U*>
|
||||
1 [ABCD]{E}[NSE].<U*>
|
||||
NO [ABC][DE]{NSE}
|
||||
Nl [ABCD]{E}{NSE}
|
||||
|
||||
@ -26,4 +26,4 @@ instructions: # O(12)
|
||||
{CDEN} # remove write 0 mark
|
||||
{NSEG} # remove unwraper
|
||||
{A*B*C*} {D*E*} # write 0
|
||||
{N*S*E*} # lock all NOT selectors
|
||||
{N*S*E*U*} # lock all NOT selectors
|
@ -1,18 +1,57 @@
|
||||
#
|
||||
# RULE 110 cellular automaton implementation in DNA|SIMD
|
||||
# Selected NOT in DNA|SIMD
|
||||
# @autor Lukáš Plevač <xpleva07@vutbr.cz>
|
||||
# @date 11.21.2023
|
||||
# @date 11.27.2023
|
||||
#
|
||||
|
||||
define:
|
||||
0 {A}[BCD][EF]
|
||||
1 {A}{BCD}[EF]
|
||||
# BIT NOT selector
|
||||
0 [ABC][DE][NSE].<U*>
|
||||
1 [ABCD]{E}[NSE].<U*>
|
||||
|
||||
data:
|
||||
01
|
||||
# Implicit zero
|
||||
00110[ABC][DE][NSE]
|
||||
#01100[ABC][DE][NSE]
|
||||
#11000[ABC][DE][NSE]
|
||||
00000[ABC][DE][NSE]
|
||||
11111[ABC][DE][NSE]
|
||||
|
||||
instructions:
|
||||
# need mark for 10 and 01
|
||||
{G*E*F*A*} # mark 01
|
||||
#{GEFA} # remove mark 01
|
||||
#{B*C*D*E*} # write 1
|
||||
instructions: # O(34)
|
||||
{NSEU} # remove all notselectors selector
|
||||
{D*E*N*}
|
||||
{DEN}
|
||||
{E*N*S*E*A*}
|
||||
{D*E*N*S*E*G*}
|
||||
{ENSEA}
|
||||
{E*N*S*E*A*B*}
|
||||
{ENSEAB}
|
||||
{E*N*S*E*I*} # bind not selector for 11
|
||||
{N*S*E*A*B*C*F*}
|
||||
{DENSEG}
|
||||
{NSEABCF}
|
||||
{D*E*N*S*E*A*B*}
|
||||
{DENSEAB}
|
||||
{E*N*S*E*Y*}
|
||||
{B*C*D*}
|
||||
{DENSEAB}
|
||||
{ENSEI} # remove temp not selector for 11
|
||||
{N*S*E*U*} # bind not selector for 00
|
||||
{ENSEY}
|
||||
{A*B*C*} # write zero back
|
||||
{D*E*} # second zero part
|
||||
# selected not subprogram
|
||||
{G*D*E*N*} # mark NOT 0 and NOT 1
|
||||
{ABCD} # remove unwraped 1
|
||||
{GDEN} # remove mark
|
||||
{C*D*E*N*} # mark write 0
|
||||
{CDEN} # remowe mark write 0 (is only posible when is unvraped for second part of zero)
|
||||
{A*B*C*D*} # write 1
|
||||
{ABCD} # remove not writed 1 (is unwraped by mark write 0)
|
||||
{N*S*E*G*} # unwrap write 0 mark
|
||||
{CDEN} # remove write 0 mark
|
||||
{NSEG} # remove unwraper
|
||||
{A*B*C*} {D*E*} # write 0
|
||||
{N*S*E*U*} # lock all NOT selectors
|
||||
|
||||
|
@ -74,6 +74,10 @@ class Assembly:
|
||||
gins = []
|
||||
for ins in asm:
|
||||
ins = re.sub("\s+" , " ", ins.strip()) # remove whitespaces
|
||||
com = ""
|
||||
if len(ins.split("#")) > 1:
|
||||
com = ins.split("#")[1]
|
||||
|
||||
ins = ins.split("#")[0] # remove comments
|
||||
|
||||
if "instructions:" in ins:
|
||||
@ -89,9 +93,12 @@ class Assembly:
|
||||
DNAInsArray.append(molecule.parse(self.useMacros(DNAin)))
|
||||
|
||||
if len(DNAInsArray) > 0:
|
||||
gins.append(DNAInsArray)
|
||||
gins.append({
|
||||
"ins": DNAInsArray,
|
||||
"comment": com
|
||||
})
|
||||
|
||||
return gins
|
||||
return gins
|
||||
|
||||
def decode(self, reg):
|
||||
mol = molecule.encode(reg.mol)
|
||||
|
@ -10,6 +10,7 @@ parser.add_argument('assembly')
|
||||
parser.add_argument('-s', '--spaceing', default=" ", help='space sentense between ascii char of DNA strands')
|
||||
parser.add_argument('-v', '--verbose', help='show simulation step by step not only final', action='store_true', default=False)
|
||||
parser.add_argument('-d', '--decode', help='use macros to decode final result', action='store_true', default=False)
|
||||
parser.add_argument('-c', '--comments', help='show comments for instructions', action='store_true', default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -43,7 +44,11 @@ for ins in asm.getInstructions():
|
||||
print("=================================")
|
||||
print()
|
||||
|
||||
for insc in ins:
|
||||
if args.comments:
|
||||
print("#%s" % ins["comment"])
|
||||
print("")
|
||||
|
||||
for insc in ins["ins"]:
|
||||
insc.rawPrint()
|
||||
|
||||
print()
|
||||
@ -52,7 +57,7 @@ for ins in asm.getInstructions():
|
||||
print()
|
||||
|
||||
for reg in regs:
|
||||
reg.instruction(ins)
|
||||
reg.instruction(ins["ins"])
|
||||
|
||||
if args.verbose:
|
||||
reg.asciiShow(spaceing = args.spaceing)
|
||||
|
Loading…
x
Reference in New Issue
Block a user