) + 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 #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") #Write data and answer arrays to files #This is done seperatly in order to write all the values sequentially despite them being generated out of order (one in the lower half of memory and one in the upper half for each instruction row) for i in range(0, gf.DROWS): zD[t][s].write(d_wordH[i] + "\n") zA[t][s].write(a_wordH[i] + "\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) i_wordH = "Address %d:" %(r)+i_wordH zI[t][s].write(i_wordH+"\n") print "Completed all generation succesfully"
#Generate instruction addr0 = gf.int_to_bin(r,gf.DADDR_BITS) #Operand0 addr1 = gf.int_to_bin(r+(gf.DROWS/2),gf.DADDR_BITS) #Operand1 if op == 2: #I'm implimenting OP==2 as a TRUE_NOP, op==12 is a HALF_NOP addr2 = gf.int_to_bin(r,gf.DADDR_BITS) #Secondary address same as row so NOTHING will be written else: 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 ########### if op == 3: #TRUE_NOP print "HEEEEEEEEERRRRR: TRUE_NOP: ", i_wordH ########### 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 zI[t][s].write(word+"\n") #Write data and answer arrays to files #This is done seperatly in order to write all the values sequentially despite them being generated out of order (one in the lower half of memory and one in the upper half for each instruction row) for i in range(0,gf.DROWS):
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"
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 else: #If it happens to fit within one packet executing this is shorter start = gf.int_to_bin(0, gf.DADDR_BITS + 6) count = gf.int_to_bin(count, gf.SC_len - gf.DADDR_BITS - 9) #How many words to load command = count + start + cmd print "LDcommand1: ", command commandH = gf.bin_to_hex(command) print "LDcommand2: ", commandH commandH = gf.formatH_for_roach(commandH) print "LDcommand3: ", commandH LDprogram = commandH + string + ZERO_WORD_RH + ZERO_WORD_RH
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 else: #If it happens to fit within one packet executing this is shorter start= gf.int_to_bin(0,gf.DADDR_BITS+6) count= gf.int_to_bin(count,gf.SC_len-gf.DADDR_BITS-9) #How many words to load command=count+start+cmd print "LDcommand1: ", command commandH = gf.bin_to_hex(command) print "LDcommand2: ", commandH commandH = gf.formatH_for_roach(commandH) print "LDcommand3: ", commandH LDprogram=commandH+string+ZERO_WORD_RH+ZERO_WORD_RH
t = int(tile.getAttribute("id")) # print " Tile: ",t, "t_index", t_index #Check that the tile value currently being read is the next one in numerical order #If it's not the tiles and strips with in them must have a TRUE_NOP inserted #Create inputs for a T_NOP operation //For where the xml supplies nothing for certain locations in hydra while t_index < t: #Creat this T_NOP for every strip in the tile for k in range(0, STRIPS): count_nops = count_nops + 1 data = FP.fp_infinity( gf.D_wf, gf.D_we, 1 ) #Set NULLs to negative infinity in the current format as a recognisable default H_data = gf.bin_to_hex(data) H_data = gf.formatH_for_roach(H_data) Dword = "Address %d:" % (ir_index) + H_data zD[t_index][k].write(Dword + "\n") #Write the word to file count = count + 1 opcode = opcode_dict["NOP_I4"] #Set sel's to it's local strip/tile value as a matter of default which is the purpose of the index parameters sel0 = gf.sel_string(-1, k) sel1 = gf.sel_string(-1, k) #Set addresses to the same as the implied address (the row number) #In the case of addr2, this will mean addr2 is NOT written to making it a TRUE_NOP addr0 = gf.addr_string(-1, ir_index) addr1 = gf.addr_string(-1, ir_index)
t_index=0 for tile in row.getElementsByTagName("tile"): t=int(tile.getAttribute("id")) # print " Tile: ",t, "t_index", t_index #Check that the tile value currently being read is the next one in numerical order #If it's not the tiles and strips with in them must have a TRUE_NOP inserted #Create inputs for a T_NOP operation //For where the xml supplies nothing for certain locations in hydra while t_index < t: #Create this T_NOP for every strip in the tile for k in range(0,STRIPS): count_nops = count_nops+1 data=FP.fp_infinity(gf.D_wf,gf.D_we,1) #Set NULLs to negative infinity in the current format as a recognisable default H_data=gf.bin_to_hex(data) H_data=gf.formatH_for_roach(H_data) Dword="Address %d:"%(ir_index) + H_data zD[t_index][k].write(Dword+"\n") #Write the word to file count = count+1 opcode=opcode_dict["NOP_I4"] #Set sel's to it's local strip/tile value as a matter of default which is the purpose of the index parameters sel0=gf.selS_string(-1, k) sel1=gf.selS_string(-1, k) #Set addresses to the same as the implied address (the row number) #In the case of addr2, this will mean addr2 is NOT written to making it a TRUE_NOP addr0=gf.addr_string(-1,ir_index) addr1=gf.addr_string(-1,ir_index)
print "Rounded: ",significand #Format into one floating-point representation string: fp_value=str(sign)+bin_exp+significand return fp_value ######### Main ########## wf = int(sys.argv[1])##Number of fraction bits, width of the fraction we = int(sys.argv[2])##Number of exponent bits, width of the exponent bias=pow(2,we-1)-1 print "All conversions will be carried out assuming a fraction/mantissa width of %dbits, an exponent width of %dbits and a bias of %d"%(wf,we,bias) print("Enter a floating point value or 'q' to quit") while (1): a=raw_input("Enter a floating point value: ") if str(a)=='q': sys.exit() print "HERE1: ", a a=float(a) print "HERE2: ", a result = custom_floating_point_creator (a,wf,we) print result print gf.bin_to_hex(result)
buff = wf - len(significand) significand = significand + zeros[0:buff] print "Rounded: ", significand #Format into one floating-point representation string: fp_value = str(sign) + bin_exp + significand return fp_value ######### Main ########## wf = int(sys.argv[1]) ##Number of fraction bits, width of the fraction we = int(sys.argv[2]) ##Number of exponent bits, width of the exponent bias = pow(2, we - 1) - 1 print "All conversions will be carried out assuming a fraction/mantissa width of %dbits, an exponent width of %dbits and a bias of %d" % ( wf, we, bias) print("Enter a floating point value or 'q' to quit") while (1): a = raw_input("Enter a floating point value: ") if str(a) == 'q': sys.exit() print "HERE1: ", a a = float(a) print "HERE2: ", a result = custom_floating_point_creator(a, wf, we) print result print gf.bin_to_hex(result)