def OUTA(): """ The OUTA Operation """ control_signal = gen_control_signal_dict() opcode_addr = gen_opcode_addr_component_dict() mc_step_addr = gen_microcode_step_addr_component_dict() input_sig_addr = gen_input_signal_addr_component_dict() templates = [] # Step 2 - A -> OUT addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["OUTA"]]) data = rom_programmer.combine_data_components( [control_signal["A_OUT"], control_signal["OUT_IN"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 3: Reset microcode step addresses = rom_programmer.combine_address_components( [mc_step_addr[3], opcode_addr["OUTA"]]) data = rom_programmer.combine_data_components( [control_signal["STEP_COUNTER_RESET"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) return templates
def AADD(): """ """ control_signal = gen_control_signal_dict() opcode_addr = gen_opcode_addr_component_dict() mc_step_addr = gen_microcode_step_addr_component_dict() templates = [] # Step 2: ALU -> A addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["AADD"]]) data = rom_programmer.combine_data_components( [control_signal["ALU_OUT"], control_signal["A_IN"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 3: Reset microcode step addresses = rom_programmer.combine_address_components( [mc_step_addr[3], opcode_addr["AADD"]]) data = rom_programmer.combine_data_components( [control_signal["STEP_COUNTER_RESET"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) return templates
def JIC(): """ """ control_signal = gen_control_signal_dict() opcode_addr = gen_opcode_addr_component_dict() mc_step_addr = gen_microcode_step_addr_component_dict() input_signals = gen_input_signal_addr_component_dict() templates = [] ############ # IF CARRY # ############ # Step 2: PC -> RAM Addr addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["JIC"], input_signals["CARRY"]]) data = rom_programmer.combine_data_components( [control_signal["PROGRAM_COUNTER_OUT"], control_signal["RAM_ADDR_IN"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 3: RAM -> PC addresses = rom_programmer.combine_address_components( [mc_step_addr[3], opcode_addr["JIC"], input_signals["CARRY"]]) data = rom_programmer.combine_data_components([ control_signal["RAM_OUT"], control_signal["PROGRAM_COUNTER_IN"], ]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 4: Reset microcode step counter addresses = rom_programmer.combine_address_components( [mc_step_addr[4], opcode_addr["JIC"], input_signals["CARRY"]]) data = rom_programmer.combine_data_components( [control_signal["STEP_COUNTER_RESET"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) ################ # IF NOT CARRY # ################ # Step 2: PC increment (Skip past the address we would have jumped # to) addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["JIC"], input_signals["NOT_CARRY"]]) data = rom_programmer.combine_data_components([ control_signal["PROGRAM_COUNTER_INCREMENT"], ]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 3: Reset microcode step counter addresses = rom_programmer.combine_address_components( [mc_step_addr[3], opcode_addr["JIC"], input_signals["NOT_CARRY"]]) data = rom_programmer.combine_data_components( [control_signal["STEP_COUNTER_RESET"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) return templates
def fetch(): """ """ control_signal = gen_control_signal_dict() mc_step_addr = gen_microcode_step_addr_component_dict() opcode_addr = gen_opcode_addr_component_dict() templates = [] opcodes = opcode_addr.values() # opcodes = [ # opcode_addr["LDA"], # opcode_addr["LDB"], # opcode_addr["AADD"], # opcode_addr["OUTA"], # opcode_addr["HALT"], # opcode_addr["NOOP"], # opcode_addr["JIC"] # ] for opcode in opcodes: # Step 0: PC -> RAM Addr addresses = rom_programmer.combine_address_components( [opcode, mc_step_addr[0]]) data = rom_programmer.combine_data_components([ control_signal["PROGRAM_COUNTER_OUT"], control_signal["RAM_ADDR_IN"] ]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 1: RAM -> instruction register and program counter count addresses = rom_programmer.combine_address_components( [opcode, mc_step_addr[1]]) data = rom_programmer.combine_data_components([ control_signal["PROGRAM_COUNTER_INCREMENT"], control_signal["RAM_OUT"], control_signal["INSTRUCTION_REGISTER_IN"] ]) templates.append(rom_programmer.DataTemplate(addresses, data)) return templates
def LDB(): """ """ control_signal = gen_control_signal_dict() opcode_addr = gen_opcode_addr_component_dict() mc_step_addr = gen_microcode_step_addr_component_dict() templates = [] # Step 2: PC -> RAM Addr addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["LDB"]]) data = rom_programmer.combine_data_components( [control_signal["PROGRAM_COUNTER_OUT"], control_signal["RAM_ADDR_IN"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 3: RAM -> RAM Addr and PC Incr addresses = rom_programmer.combine_address_components( [mc_step_addr[3], opcode_addr["LDB"]]) data = rom_programmer.combine_data_components([ control_signal["RAM_OUT"], control_signal["RAM_ADDR_IN"], control_signal["PROGRAM_COUNTER_INCREMENT"] ]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 3: RAM -> B addresses = rom_programmer.combine_address_components( [mc_step_addr[4], opcode_addr["LDB"]]) data = rom_programmer.combine_data_components( [control_signal["RAM_OUT"], control_signal["B_IN"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) # Step 5: Reset microcode step counter addresses = rom_programmer.combine_address_components( [mc_step_addr[5], opcode_addr["LDB"]]) data = rom_programmer.combine_data_components( [control_signal["STEP_COUNTER_RESET"]]) templates.append(rom_programmer.DataTemplate(addresses, data)) return templates
def NOOP(): """ The NOOP Operation """ opcode_addr = gen_opcode_addr_component_dict() mc_step_addr = gen_microcode_step_addr_component_dict() control_signal = gen_control_signal_dict() # Step 2: Reset microcode step addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["NOOP"]]) data = rom_programmer.combine_data_components( [control_signal["STEP_COUNTER_RESET"]]) return [rom_programmer.DataTemplate(addresses, data)]
def HALT(): """ """ control_signal = gen_control_signal_dict() opcode_addr = gen_opcode_addr_component_dict() mc_step_addr = gen_microcode_step_addr_component_dict() templates = [] # Step 2: Set halt flag addresses = rom_programmer.combine_address_components( [mc_step_addr[2], opcode_addr["HALT"]]) data = rom_programmer.combine_data_components([control_signal["HALT"]]) return [rom_programmer.DataTemplate(addresses, data)]