## check afterwards if everything is written out correctly import eeprom_pi as ep import inst ## for cmd line args access import sys ## checks the actual content of the EEPROM against the should have one def check_micro_inst(address, instruction): data = ep.read_data_at(address) ctl_word_half = 0x00 if eeprom_n == 1: ctl_word_half = instruction & 0xff elif eeprom_n == 2: ctl_word_half = (instruction >> 8) & 0xff print("data type: %s, content: %s" % (type(data), hex(data))) print("ctl_word_half type: %s, contet: %s" % (type(ctl_word_half), hex(ctl_word_half))) if(data != ctl_word_half): print("error at address %s: %s, should be: %s" % (hex(address), hex(data), hex(ctl_word_half))) ## look for cmd line parameter to known which EEPROM we write to currently if(len(sys.argv) != 2): print("usage: %s " % sys.argv[0]) print("please specify the eeprom you want to check.") exit() eeprom_n = int(sys.argv[1]) if not (eeprom_n == 1 or eeprom_n == 2): print("error: only two eeproms supported right now") exit() print("checking eeprom %s" % eeprom_n) ## setup board in read mode ep.init_board(False) raw_input("plug EEPROM in and continue with any key...") ## for every instruction nr_inst = 1 for instruction_data in inst.INST: print("checking instruction %s" % nr_inst) base_address = instruction_data[0] mops = instruction_data[1] n = 0 # write fetch instruction micro ops for every instruction for fi_mop in inst.INST_MICRO_OP_FETCH_INSTRUCTION: check_micro_inst(base_address+n, fi_mop) n += 1 for mop in mops: check_micro_inst(base_address+n, mop) n += 1 ## insert 0x00 for not used micro instuctions, so all control signals 0 ## and the pc is not doing some unwanted stuff while n < inst.MAX_MICRO_OPS: check_micro_inst(base_address+n, 0x0000) n += 1 print("------------") nr_inst += 1 ## write a fetch instruction at address 0x0, so that after a reset we are ## fetching the first instruction print("\n") print("writing inst fetch instruction at address 0x0, so we begin executing" "after reset:") n = 0 base_address = 0x0 for fi_mop in inst.INST_MICRO_OP_FETCH_INSTRUCTION: check_micro_inst(base_address+n, fi_mop) n += 1 ## write NULLs while n < inst.MAX_MICRO_OPS: check_micro_inst(base_address+n, 0x0000) n += 1 ## write HLT instruction aka, everything 0x00, no new instruction fetch cycle n = 0 base_address = inst.INST_HLT while n < inst.MAX_MICRO_OPS*2: check_micro_inst(base_address+n, 0x0000) n += 1 trash = raw_input("please unplug the power to the EEPORM now and press any key to continue") ep.cleanup()