Exemplo n.º 1
0
def custom_floating_point_creator (decX,wf,we):

		mx=fp_max(wf,we)
		if decX>=mx:
				print '\033[1;44The value returned is the representation of infinity\033[1;m'
		
		zeros="0000000000000000000000000000000000000000000000000000000000000000"#64 zeros
		bias=pow(2,we-1)-1

		#Get sign
		if decX < 0:
				sign=1
		else:
				sign=0

		#Create binary representation
		binary_string = dec_to_bin(decX)
		normalised_array = normalise(binary_string)

		#Create exponent and convert to binary
		exp = normalised_array[0]
		
		#Check exponent is within a valid range
		if exp > bias:
				print '\033[1;41mNumber is too large, requiring an exponent of %d where only vlaues up to %d are supported\033[1;m'%(exp,bias)
				sys.exit()

		if exp<(-1*(bias-1)):
				print '\033[1;41mNumber is too small, requiring an exponent of %d where only values down to %d are supported.  Denormalized numbers are not supported.\033[1;m'%(exp, bias-1)
				sys.exit()

		#Handle special case of exp = 0 (meaning either the value is zero or the value doesn't need to be shifted
		if exp == 0 and normalised_array[1][0]=='0':#Then the whole value is zero and so the exponent is set to all zeros
				bin_exp=gf.int_to_bin(exp,we)
		
		else:#Normal case so bias the exponent before converting to binary
				exp = exp+bias
				bin_exp=gf.int_to_bin(exp,we)

		#Round off mantissa if need be:
		significand=normalised_array[1][2:]	#Mantissa with the "1." cut off the front

		if len(significand)>wf:	#If the length of the significand is longer than wf then it needs to be rounded off.

				significand=sround(significand,wf)
				print '\033[1;42mNumber has been rounded\033[1;m'

		else: #Buffer with zeros to make up full mantissa

				buff = wf-len(significand)
				significand = significand+zeros[0:buff]

		#Format into one floating-point representation string:
		fp_value=str(sign)+bin_exp+significand

		return fp_value
Exemplo n.º 2
0
                #Writing the same answer to both operand addresses, this way reading from and writing to every address is tested
                a_wordH[r] = "Address %d:" % (r) + answerH

            elif op == 3:  #MUL
                answer = var1I * var1I
                answerFP = FP.custom_floating_point_creator(
                    answer, gf.D_wf, gf.D_we)
                answerH = gf.bin_to_hex_l(answerFP, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH

            print instruction_count, ":  ", "var1: ", var1I, "opcode: ", opcode, ":", opcode_names[
                op], "Ans: ", answer
            var1I = random.randrange(-100, 100)

            #Generate instruction
            addr0 = gf.int_to_bin(r, gf.DADDR_BITS)  #Operand0
            addr1 = gf.int_to_bin(r, gf.DADDR_BITS)  #Operand1
            addr2 = gf.int_to_bin(
                r, gf.DADDR_BITS
            )  #Secondary address same as row so NOTHING will be written to the specified address, in the case of NOPs (2 or 12) NOTHING will be written

            sel0 = gf.int_to_bin(
                s, gf.STRIP_Ad_bits
            )  #set sel's to the strip currently being written
            sel1 = gf.int_to_bin(s, gf.STRIP_Ad_bits)
            selq = gf.int_to_bin(
                t, gf.TILES_Ad_bits
            )  #Set the selq to the tile currently being written

            i_word = addr2 + selq + opcode + sel1 + sel0 + addr1 + addr0  #Complete instruction in binary
            i_wordH = gf.bin_to_hex(i_word)  #Complete instruction in hex
Exemplo n.º 3
0
						var1=FP.custom_floating_point_creator (var1,gf.D_wf,gf.D_we)
						var2=FP.custom_floating_point_creator (var2,gf.D_wf,gf.D_we)
						answer=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)

						var1H =gf.bin_to_hex_l(var1,64)
						var2H= gf.bin_to_hex_l(var2,64)
						answerH= gf.bin_to_hex_l(answer,64)
						d_wordH[r] = "Address %d:" %(r) + var1H
						d_wordH[r+(gf.DROWS/2)] = "Address %d:" %(r+(gf.DROWS/2)) + var2H
						
						a_wordH[r] = "Address %d:" %(r) + answerH+sign
						a_wordH[r+(gf.DROWS/2)] = "Address %d:" %(r+(gf.DROWS/2)) + answerH+sign  #Writing the same answer to both operand addresses, this way reading from and writing to every address are tested

						#Generate instruction
						opcode	= mul
						addr0	= gf.int_to_bin(r,gf.DADDR_BITS)			#Operand0
						addr1	= gf.int_to_bin(r+(gf.DROWS/2),gf.DADDR_BITS)		#Operand1
						addr2	= gf.int_to_bin(r+(gf.DROWS/2),gf.DADDR_BITS)		#Secondary address
						sel0	= gf.int_to_bin(s,3)	#set sel's to the strip currently being written
						sel1	= gf.int_to_bin(s,3)
						selq	= gf.int_to_bin(t,3)	#Set the selq to the tile currently being written    
						
						i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	#Complete instruction in binary
						i_wordH = gf.bin_to_hex(i_word) #Complete instruction in hex 
						i_wordH = gf.formatH_for_roach(i_wordH)	#Insert '\x' marks to indicate hex to python transmit script

						#Format final lines to be written to files
						word = i_word+":"+i_wordH				#Instruction line containing both the binary and roach formated instruction

						#Write instruction and data words to file
						zI[t][s].write(word+"\n")
Exemplo n.º 4
0
                             2)] = "Address %d:" % (r +
                                                    (gf.DROWS / 2)) + answerH

            elif op == 6:  #MIN
                answer = min(var1I, var2I)
                answerFP = FP.custom_floating_point_creator(
                    answer, gf.D_wf, gf.D_we)
                answerH = gf.bin_to_hex_l(answerFP, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH
                a_wordH[r + (gf.DROWS /
                             2)] = "Address %d:" % (r +
                                                    (gf.DROWS / 2)) + answerH

            elif op == 7:  # <
                if var1I < var2I:
                    answer = gf.int_to_bin(1, gf.D_len)
                else:
                    answer = gf.int_to_bin(0, gf.D_len)

                answerH = gf.bin_to_hex_l(answer, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH
                a_wordH[r + (gf.DROWS /
                             2)] = "Address %d:" % (r +
                                                    (gf.DROWS / 2)) + answerH

            elif op == 8:  # ==
                if var1I == var2I:
                    answer = gf.int_to_bin(1, gf.D_len)
                else:
                    answer = gf.int_to_bin(0, gf.D_len)
Exemplo n.º 5
0
								answerFP=FP.custom_floating_point_creator (answerI,gf.D_wf,gf.D_we)
								a_wordH = gf.bin_to_hex_l(answerFP,64)
								a_wordH = "Address %d:" %(r) + a_wordH
								zA[t][s].write(a_wordH+"\n")


						
print "Generating nop instruction words for a %dx%d with %d instructions per strip: total number of instructions being: "%(gf.STRIPS,gf.TILES,gf.IROWS),gf.IROWS*gf.STRIPS*gf.TILES
nop = "000010"
add = "000000"
for t in range(0, gf.TILES):
		for s in range(0,gf.STRIPS):
				for r in range(0,gf.IROWS):
						if t==0 and s==0 and r == 3 : #In Tile0Strip0Row 3, put an add instruction in to cause an overflow on addition of r3 to r4
								opcode	= add
								addr0	= gf.int_to_bin(r,gf.DADDR_BITS)
								addr1	= gf.int_to_bin(r+1,gf.DADDR_BITS)
								print "****************HERE TWO++++++++++++++"
						else:
								opcode	= add
								addr0	= gf.int_to_bin(r,gf.DADDR_BITS)
								addr1	= gf.int_to_bin(r,gf.DADDR_BITS)

						addr2	= gf.int_to_bin(r,gf.DADDR_BITS)
						sel0	= gf.int_to_bin(s,3)
						sel1	= gf.int_to_bin(s,3)
						selq	= gf.int_to_bin(t,3)
				
						i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	
						i_wordH = gf.bin_to_hex(i_word) 
						i_wordH = gf.formatH_for_roach(i_wordH)
Exemplo n.º 6
0
    if count % len_dchunk > 0:
        Nosys_commands = Nosys_commands + 1

    print("nosys_command2: ", Nosys_commands)
    for i in range(0, Nosys_commands):
        p = i * len_dchunk * 16

        if count > len_dchunk:
            new_count = len_dchunk
            count = count - len_dchunk
        else:
            new_count = count
        #new_count = len(string[p:p+(len_dchunk*16)])
        print("new_count1: ", new_count)
        new_count = gf.int_to_bin(
            new_count,
            (gf.SC_len - gf.DADDR_BITS - 9))  #How many words to load
        print("new_count2: ", new_count)

        start_add = gf.hydra_Daddr(i * len_dchunk)
        row = gf.int_to_bin(start_add[0], gf.DADDR_BITS)
        strip = gf.int_to_bin(start_add[1], 3)
        tile = gf.int_to_bin(start_add[2], 3)
        start = row + strip + tile

        command = new_count + start + cmd
        commandH = gf.bin_to_hex(command)
        commandH = gf.formatH_for_roach(commandH)
        LDprogram = LDprogram + commandH + string[p:p + (
            len_dchunk * 16)] + ZERO_WORD_RH + ZERO_WORD_RH
Exemplo n.º 7
0
                answer = max(var1I, var2I)
                answerFP = FP.custom_floating_point_creator(
                    answer, gf.D_wf, gf.D_we)
                answerH = gf.bin_to_hex_l(answerFP, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH

            elif op == 6:  #MIN
                answer = min(var1I, var2I)
                answerFP = FP.custom_floating_point_creator(
                    answer, gf.D_wf, gf.D_we)
                answerH = gf.bin_to_hex_l(answerFP, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH

            elif op == 7:  # <
                if var1I < var2I:
                    answer = gf.int_to_bin(1, gf.D_len)
                else:
                    answer = gf.int_to_bin(0, gf.D_len)

                answerH = gf.bin_to_hex_l(answer, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH

            elif op == 8:  # ==
                if var1I == var2I:
                    answer = gf.int_to_bin(1, gf.D_len)
                else:
                    answer = gf.int_to_bin(0, gf.D_len)

                answerH = gf.bin_to_hex_l(answer, 64)
                a_wordH[r] = "Address %d:" % (r) + answerH
                    (gf.DROWS / 2)] = "Address %d:" % (r +
                                                       (gf.DROWS / 2)) + var2H

            #Generate answers
            answer = str(hex(var1 - var2))
            answer = answer[2:]
            while len(answer) != 16:
                answer = '0' + answer
            a_wordH[r] = "Address %d:" % (r) + answer
            a_wordH[r + (gf.DROWS / 2)] = "Address %d:" % (
                r + (gf.DROWS / 2)
            ) + answer  #Writing the same answer to both operand addresses, this way reading form and writing to every address are tested

            #Generate instruction
            opcode = sub
            addr0 = gf.int_to_bin(r, gf.DADDR_BITS)  #Operand0
            addr1 = gf.int_to_bin(r + (gf.DROWS / 2), gf.DADDR_BITS)  #Operand1
            addr2 = gf.int_to_bin(r + (gf.DROWS / 2),
                                  gf.DADDR_BITS)  #Secondary address
            sel0 = gf.int_to_bin(
                s, 3)  #set sel's to the strip currently being written
            sel1 = gf.int_to_bin(s, 3)
            selq = gf.int_to_bin(
                t, 3)  #Set the selq to the tile currently being written

            i_word = addr2 + selq + opcode + sel1 + sel0 + addr1 + addr0  #Complete instruction in binary
            i_wordH = gf.bin_to_hex(i_word)  #Complete instruction in hex
            i_wordH = gf.formatH_for_roach(
                i_wordH
            )  #Insert '\x' marks to indicate hex to python transmit script
Exemplo n.º 9
0
		print("nosys_command1: ", Nosys_commands)
		if count%len_dchunk >0:
				Nosys_commands = Nosys_commands+1

		print("nosys_command2: ", Nosys_commands)
		for i in range (0,Nosys_commands):
				p=i*len_dchunk*16
				
				if count>len_dchunk:
						new_count = len_dchunk
						count = count-len_dchunk
				else:
						new_count = count
				#new_count = len(string[p:p+(len_dchunk*16)])
				print ("new_count1: ", new_count)
				new_count= gf.int_to_bin(new_count,(gf.SC_len-gf.DADDR_BITS-9))	#How many words to load
				print ("new_count2: ", new_count)

				start_add = gf.hydra_Daddr(i*len_dchunk)
				row= gf.int_to_bin(start_add[0],gf.DADDR_BITS)
				strip= gf.int_to_bin(start_add[1],3)
				tile= gf.int_to_bin(start_add[2],3)
				start=row+strip+tile

				command=new_count+start+cmd
				commandH = gf.bin_to_hex(command) 
				commandH = gf.formatH_for_roach(commandH)
				LDprogram=LDprogram+commandH+string[p:p+(len_dchunk*16)]+ZERO_WORD_RH+ZERO_WORD_RH


Exemplo n.º 10
0
							
						elif op== 5:#MAX
								answer = max(var1I,var2I)
								answerFP=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)
								answerH= gf.bin_to_hex_l(answerFP,64)
								a_wordH[r] = "Address %d:" %(r) + answerH

						elif op== 6:#MIN
								answer = min(var1I,var2I)
								answerFP=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)
								answerH= gf.bin_to_hex_l(answerFP,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
						
						elif op== 7:# <
								if var1I<var2I:
										answer=gf.int_to_bin(1,gf.D_len)
								else:
										answer=gf.int_to_bin(0,gf.D_len)

								answerH= gf.bin_to_hex_l(answer,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
						
						elif op== 8:# ==
								if var1I==var2I:
										answer=gf.int_to_bin(1,gf.D_len)
								else:
										answer=gf.int_to_bin(0,gf.D_len)

								answerH= gf.bin_to_hex_l(answer,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
						
Exemplo n.º 11
0
if count > len_dchunk:	#65536 = 2^16, 16 counter bits available in the LOAD_DATA command
		#For as many LD commands are needed to count each data word, insert the correct LD command and add to program string
		Nosys_commands = count/len_dchunk
		if count%len_dchunk >0:
				Nosys_commands = Nosys_commands+1

		for i in range (0,Nosys_commands):
				p=i*len_dchunk*16
				
				if count>len_dchunk:
						new_count = len_dchunk
						count = count-len_dchunk
				else:
						new_count = count

				new_count= gf.int_to_bin(new_count,(gf.SC_len-gf.INS_ADDR_CD-3))	#How many words to load

				start_add = gf.hydra_Daddr(i*len_dchunk)
				row= gf.int_to_bin(start_add[0],gf.DADDR_BITS)
				strip= gf.int_to_bin(start_add[1],gf.STRIP_Ad_bits)
				tile= gf.int_to_bin(start_add[2],gf.TILES_Ad_bits)
				start=row+strip+tile

				command=new_count+start+cmd
				commandH = gf.bin_to_hex(command) 
				commandH = gf.formatH_for_roach(commandH)
				LDprogram=ZERO_WORD_RH+LDprogram+commandH+string[p:p+(len_dchunk*16)]+ZERO_WORD_RH



else:	#If it happens to fit within one packet executing this is shorter
Exemplo n.º 12
0
zI =a[0] #Array of handles on instruction files: zI[tile][strip]
zD =a[1] #Array of handles on data files: zD[tile][strip]
zA =a[2] #Array of handles on answer files: zA[tile][strip]

######################################-TEST GENERATION-#######################################
#-----------------------------------------------------------------------------------------------------
#<<<<<<Test_branching: Uses rows 0-6 in strips 0_0 and 1_0, all other strips are loaded with TRUE_NOPS>>>>>
#-----------------------------------------------------------------------------------------------------
#Generate effectivly 2 while loops one after the other testing first branch if false (strip0) and second branch if true (strip1)

print "Generating branching tests"
r=0; s=0; t=0;
#----Row0----------------------------------#
#--Strip0-----------------#
opcode	= add
addr0	= gf.int_to_bin(0,gf.DADDR_BITS)
addr1	= gf.int_to_bin(2,gf.DADDR_BITS)
addr2	= gf.int_to_bin(r,gf.DADDR_BITS)
sel0	= gf.int_to_bin(s,3)
sel1	= gf.int_to_bin(s,3)
selq	= gf.int_to_bin(t,3)

i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	
i_wordH = gf.bin_to_hex(i_word) 
i_wordH = gf.formatH_for_roach(i_wordH)

varFP=FP.custom_floating_point_creator (0,gf.D_wf,gf.D_we)
d_wordH = gf.bin_to_hex_l(varFP,64)

ansFP=FP.custom_floating_point_creator (11,gf.D_wf,gf.D_we)
a_wordH = gf.bin_to_hex_l(ansFP,64)
Exemplo n.º 13
0
		for s in range(0,gf.STRIPS):
				for r in range(0,gf.DROWS):
						varI=random.randrange(0,100)
						varFP=FP.custom_floating_point_creator (varI,gf.D_wf,gf.D_we)
						d_wordH = gf.bin_to_hex_l(varFP,64)
						d_wordH = "Address %d:" %(r) + d_wordH
						zD[t][s].write(d_wordH+"\n")
						zA[t][s].write(d_wordH+"\n")
						
print "Generating nop instruction words for a %dx%d with %d instructions per strip: total number of instructions being: "%(gf.STRIPS,gf.TILES,gf.IROWS),gf.IROWS*gf.STRIPS*gf.TILES
nop = "000010"
for t in range(0, gf.TILES):
		for s in range(0,gf.STRIPS):
				for r in range(0,gf.IROWS):
						opcode	= nop
						addr0	= gf.int_to_bin(r,gf.DADDR_BITS)
						addr1	= gf.int_to_bin(r,gf.DADDR_BITS)
						addr2	= gf.int_to_bin(r,gf.DADDR_BITS)
						sel0	= gf.int_to_bin(s,gf.STRIP_Ad_bits)
						sel1	= gf.int_to_bin(s,gf.STRIP_Ad_bits)
						selq	= gf.int_to_bin(t,gf.TILES_Ad_bits)
				
						i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	
						i_wordH = gf.bin_to_hex(i_word) 
						i_wordH = gf.formatH_for_roach(i_wordH)
				
						i_wordH = "Address %d:" %(r)+i_wordH	
						zI[t][s].write(i_wordH+"\n")

print "Completed all generation succesfully"
Exemplo n.º 14
0
zA = a[2]  #Array of handles on answer files: zA[tile][strip]

######################################-TEST GENERATION-#######################################
#-----------------------------------------------------------------------------------------------------
#<<<<<<Test_branching: Uses rows 0-6 in strips 0_0 and 1_0, all other strips are loaded with TRUE_NOPS>>>>>
#-----------------------------------------------------------------------------------------------------
#Generate effectivly 2 while loops one after the other testing first branch if false (strip0) and second branch if true (strip1)

print "Generating branching tests"
r = 0
s = 0
t = 0
#----Row0----------------------------------#
#--Strip0-----------------#
opcode = add
addr0 = gf.int_to_bin(0, gf.DADDR_BITS)
addr1 = gf.int_to_bin(2, gf.DADDR_BITS)
addr2 = gf.int_to_bin(r, gf.DADDR_BITS)
sel0 = gf.int_to_bin(s, 3)
sel1 = gf.int_to_bin(s, 3)
selq = gf.int_to_bin(t, 3)

i_word = addr2 + selq + opcode + sel1 + sel0 + addr1 + addr0
i_wordH = gf.bin_to_hex(i_word)
i_wordH = gf.formatH_for_roach(i_wordH)

varFP = FP.custom_floating_point_creator(0, gf.D_wf, gf.D_we)
d_wordH = gf.bin_to_hex_l(varFP, 64)

ansFP = FP.custom_floating_point_creator(11, gf.D_wf, gf.D_we)
a_wordH = gf.bin_to_hex_l(ansFP, 64)
Exemplo n.º 15
0
				for s in range(0,gf.STRIPS):

						a_wordH = "Address %d:" %(r) + operands[s]
						zA[t][s].write(a_wordH+"\n")
						

				#Create and write instructions to file
				#Shift sel0_range along the correct number of times to select correct strips' operand to copy
				sel0_range=range(gf.STRIPS)
				for i in range(r+1):
						sel0_range=[sel0_range[-1]]+sel0_range[:-1]

				for s in range(0,gf.STRIPS):

						addr0	= gf.int_to_bin(r,gf.DADDR_BITS)				#Operand0
						addr1	= gf.int_to_bin(r,gf.DADDR_BITS)				#Operand1 (Is unused and meaningless for a copy
						addr2	= gf.int_to_bin(r,gf.DADDR_BITS)				#Specified address
						sel0	= gf.int_to_bin(sel0_range[s],3)				#Set to prearranged other strip
						sel1	= gf.int_to_bin(s,3)	#Operand1 set to local (it's meaningless)
						selq	= gf.int_to_bin(t,3)	#Set the selq to the tile currently being written    
						
						i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	#Complete instruction in binary
						i_wordH = gf.bin_to_hex(i_word) #Complete instruction in hex 
						i_wordH = gf.formatH_for_roach(i_wordH)	#Insert buffer zeros
						i_wordH = "Address %d:" %(r) + i_wordH 
						zI[t][s].write(i_wordH+"\n")
						
##Create a single row nop accross the whole system to give the data memory offset needed to save the inter-tile copied data
r= NO_inter_strip
opcode=nop
Exemplo n.º 16
0
								answer = max(var1I,var2I)
								answerFP=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)
								answerH= gf.bin_to_hex_l(answerFP,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
								a_wordH[r+(gf.DROWS/2)] = "Address %d:" %(r+(gf.DROWS/2)) + answerH

						elif op== 6:#MIN
								answer = min(var1I,var2I)
								answerFP=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)
								answerH= gf.bin_to_hex_l(answerFP,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
								a_wordH[r+(gf.DROWS/2)] = "Address %d:" %(r+(gf.DROWS/2)) + answerH
						
						elif op== 7:# <
								if var1I<var2I:
										answer=gf.int_to_bin(1,gf.D_len)
								else:
										answer=gf.int_to_bin(0,gf.D_len)

								answerH= gf.bin_to_hex_l(answer,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
								a_wordH[r+(gf.DROWS/2)] = "Address %d:" %(r+(gf.DROWS/2)) + answerH
						
						elif op== 8:# ==
								if var1I==var2I:
										answer=gf.int_to_bin(1,gf.D_len)
								else:
										answer=gf.int_to_bin(0,gf.D_len)

								answerH= gf.bin_to_hex_l(answer,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
Exemplo n.º 17
0
		for s in range(0,gf.STRIPS):
				for r in range(0,gf.DROWS):
						varI=random.randrange(0,100000)
						varFP=FP.custom_floating_point_creator (varI,gf.D_wf,gf.D_we)
						d_wordH = gf.bin_to_hex_l(varFP,64)
						d_wordH = "Address %d:" %(r) + d_wordH
						zD[t][s].write(d_wordH+"\n")
						zA[t][s].write(d_wordH+"\n")
						
print "Generating nop instruction words for a %dx%d with %d instructions per strip: total number of instructions being: "%(gf.STRIPS,gf.TILES,gf.IROWS),gf.IROWS*gf.STRIPS*gf.TILES
nop = "000010"
for t in range(0, gf.TILES):
		for s in range(0,gf.STRIPS):
				for r in range(0,gf.IROWS):
						opcode	= nop
						addr0	= gf.int_to_bin(r,gf.DADDR_BITS)
						addr1	= gf.int_to_bin(r,gf.DADDR_BITS)
						addr2	= gf.int_to_bin(r,gf.DADDR_BITS)
						sel0	= gf.int_to_bin(s,3)
						sel1	= gf.int_to_bin(s,3)
						selq	= gf.int_to_bin(t,3)
				
						i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	
						i_wordH = gf.bin_to_hex(i_word) 
						i_wordH = gf.formatH_for_roach(i_wordH)
				
						i_wordH = "Address %d:" %(r)+i_wordH	
						zI[t][s].write(i_wordH+"\n")

print "Completed all generation succesfully"
Exemplo n.º 18
0
							answerFP=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)
							answerH= gf.bin_to_hex_l(answerFP,64)
							#Writing the same answer to both operand addresses, this way reading from and writing to every address is tested
							a_wordH[r] = "Address %d:" %(r) + answerH

						elif op== 3:#MUL
								answer = var1I*var1I
								answerFP=FP.custom_floating_point_creator (answer,gf.D_wf,gf.D_we)
								answerH= gf.bin_to_hex_l(answerFP,64)
								a_wordH[r] = "Address %d:" %(r) + answerH
						
						print instruction_count,":  ", "var1: ", var1I, "opcode: ", opcode,":",opcode_names[op], "Ans: ", answer
						var1I=random.randrange(-100,100)

						#Generate instruction
						addr0	= gf.int_to_bin(r,gf.DADDR_BITS)		#Operand0
						addr1	= gf.int_to_bin(r,gf.DADDR_BITS)		#Operand1
						addr2	= gf.int_to_bin(r,gf.DADDR_BITS)		#Secondary address same as row so NOTHING will be written to the specified address, in the case of NOPs (2 or 12) NOTHING will be written

						sel0	= gf.int_to_bin(s,gf.STRIP_Ad_bits)	#set sel's to the strip currently being written
						sel1	= gf.int_to_bin(s,gf.STRIP_Ad_bits)
						selq	= gf.int_to_bin(t,gf.TILES_Ad_bits)	#Set the selq to the tile currently being written    
						
						i_word = addr2+selq+opcode+sel1+sel0+addr1+addr0	#Complete instruction in binary
						i_wordH = gf.bin_to_hex(i_word) #Complete instruction in hex 
						i_wordH = gf.formatH_for_roach(i_wordH)	#Insert '\x' marks to indicate hex to python transmit script

						#Format final lines to be written to files
						word = opcode_names[op]+i_word+":"+i_wordH				#Instruction line containing both the binary and roach formatted instruction

						#Write instruction and data words to file
Exemplo n.º 19
0
		print("nosys_command1: ", Nosys_commands)
		if count%len_dchunk >0:
				Nosys_commands = Nosys_commands+1

		print("nosys_command2: ", Nosys_commands)
		for i in range (0,Nosys_commands):
				p=i*len_dchunk*32
				
				if count>len_dchunk:
						new_count = len_dchunk
						count = count-len_dchunk
				else:
						new_count = count
				#new_count = len(string[p:p+(len_dchunk*32)])
				print ("new_count1: ", new_count)
				new_count= gf.int_to_bin(new_count,(gf.SC_len-gf.DADDR_BITS-9))	#How many words to load
				print ("new_count2: ", new_count)

				start_add = gf.hydra_Daddr(i*len_dchunk)
				row= gf.int_to_bin(start_add[0],gf.DADDR_BITS)
				strip= gf.int_to_bin(start_add[1],3)
				tile= gf.int_to_bin(start_add[2],3)
				start=row+strip+tile

				command=new_count+start+cmd
				commandH = gf.bin_to_hex(command) 
				commandH = gf.formatH_for_roach(commandH)
				LDprogram=LDprogram+commandH+string[p:p+(len_dchunk*32)]+ZERO_WORD_RH+ZERO_WORD_RH