/// <summary> /// Inputs used by the device in the active instruction /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <param name="stagePortAOut_Stat"></param> /// <param name="stagePortBOut_Stat"></param> /// <param name="muxStagePortAIn_Stat"></param> /// <param name="muxStagePortBIn_Stat"></param> private static void InputsUsed( int cycle, out PortStatus stagePortAOut_Stat, out PortStatus stagePortBOut_Stat, out PortStatus muxStagePortAIn_Stat, out PortStatus muxStagePortBIn_Stat) { stagePortAOut_Stat = PortStatus.Inactive; stagePortBOut_Stat = PortStatus.Inactive; muxStagePortAIn_Stat = PortStatus.Inactive; muxStagePortBIn_Stat = PortStatus.Inactive; bool busRead_A; bool busRead_B; BusInModel.BusRead(cycle, out busRead_A, out busRead_B); if (busRead_A) { stagePortAOut_Stat = PortStatus.Active; muxStagePortAIn_Stat = PortStatus.Active; } if (busRead_B) { stagePortBOut_Stat = PortStatus.Active; muxStagePortBIn_Stat = PortStatus.Active; } }
/// <summary> /// Active deviceport for cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> private static DevicePort ActiveInputPort(int cycle) { var muxInstrWord = ActiveInstrWord(cycle - PIPELINE_DELAY); if (muxInstrWord == null) { return(DevicePort.Default); } bool busRead_A; bool busRead_B; BusInModel.BusRead(cycle, out busRead_A, out busRead_B); if (busRead_A) { return(DevicePort.Stage_A); } else if (busRead_B) { return(DevicePort.Stage_B); } else { return(DevicePort.Default); } }
/// <summary> /// Input connections to device /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> private static List <Connection> Connections(int cycle) { var conns = new List <Connection>(); DevicePort stagePortAOut = DevicePort.Stage_A; DevicePort stagePortBOut = DevicePort.Stage_B; DevicePort muxStagePortAIn = DevicePort.Mux_0; DevicePort muxStagePortBIn = DevicePort.Mux_0; PortStatus stagePortAOut_Stat; PortStatus stagePortBOut_Stat; PortStatus muxStagePortAIn_Stat; PortStatus muxStagePortBIn_Stat; InputsUsed(cycle, out stagePortAOut_Stat, out stagePortBOut_Stat, out muxStagePortAIn_Stat, out muxStagePortBIn_Stat); bool busRead_A; bool busRead_B; BusInModel.BusRead(cycle, out busRead_A, out busRead_B); var bankID = busRead_A ? Bank.Bank_A : Bank.Bank_B; var outputCalc = BusInModel.OutputCalc(bankID, cycle); var activeLabel = outputCalc.FormattedValue; conns.Add(new Connection( BusType.Data, stagePortAOut, stagePortAOut_Stat, activeLabel, null, muxStagePortAIn, muxStagePortAIn_Stat)); conns.Add(new Connection( BusType.Data, stagePortBOut, stagePortBOut_Stat, activeLabel, null, muxStagePortBIn, muxStagePortBIn_Stat)); return(conns); }
/// <summary> /// Build a list of jump conditions /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <param name="instructions"></param> /// <returns></returns> private List <JumpConditionItem> BuildJumpConditionItems(int cycle, List <string> instructions) { var jumpConditionItems = new List <JumpConditionItem>(); var item = new JumpConditionItem(); item.Name = "eob"; item.PipelineDelay = 0; item.T_2Value = true; item.T_1Value = true; item.T_0Value = true; jumpConditionItems.Add(item); Eob = true; item = new JumpConditionItem(); item.Name = "dpsign"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 2, "dpsign")); item.T_1Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 1, "dpsign")); item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "dpsign")); jumpConditionItems.Add(item); DpSign = item.T_0Value; item = new JumpConditionItem(); item.Name = "dpthresh"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 2, "tflag")); item.T_1Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 1, "tflag")); item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "tflag")); jumpConditionItems.Add(item); DpThresh = item.T_0Value; item = new JumpConditionItem(); item.Name = "dpeq"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 2, "eqflag")); item.T_1Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 1, "eqflag")); item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "eqflag")); jumpConditionItems.Add(item); DpEQ = item.T_0Value; item = new JumpConditionItem(); item.Name = "acuaeq"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 1, "aacueq")); item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "aacueq")); jumpConditionItems.Add(item); AcuAEQ = item.T_0Value; item = new JumpConditionItem(); item.Name = "acubeq"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 1, "bacueq")); item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "bacueq")); jumpConditionItems.Add(item); AcuBEQ = item.T_0Value; bool busRead_A_1; bool busRead_B_1; bool busRead_A_0; bool busRead_B_0; BusInModel.BusRead(cycle, out busRead_A_1, out busRead_B_1); BusInModel.BusRead(cycle - 1, out busRead_A_0, out busRead_B_0); item = new JumpConditionItem(); item.Name = "in1"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = busRead_A_1; item.T_0Value = busRead_A_0; jumpConditionItems.Add(item); In1 = item.T_0Value; item = new JumpConditionItem(); item.Name = "in2"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = busRead_B_1; item.T_0Value = busRead_B_0; jumpConditionItems.Add(item); In2 = item.T_0Value; var semT_0 = DFBState.GetCySimulatorPrivateField <int[]>(cycle, "sem"); var sem_enT_2 = DFBState.GetCySimulatorPrivateField <int[]>(cycle + 2, "sem_en"); var sem_enT_1 = DFBState.GetCySimulatorPrivateField <int[]>(cycle + 1, "sem_en"); var sem_enT_0 = DFBState.GetCySimulatorPrivateField <int[]>(cycle + 0, "sem_en"); item = new JumpConditionItem(); item.Name = "sem_0"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = null; item.T_0Value = Convert.ToBoolean(semT_0 == null ? 0 : semT_0[0]); jumpConditionItems.Add(item); Sem0 = item.T_0Value; item = new JumpConditionItem(); item.Name = "sem_en0"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(sem_enT_2 == null ? 0 : sem_enT_2[0]); item.T_1Value = Convert.ToBoolean(sem_enT_1 == null ? 0 : sem_enT_1[0]); item.T_0Value = Convert.ToBoolean(sem_enT_0 == null ? 0 : sem_enT_0[0]); jumpConditionItems.Add(item); item = new JumpConditionItem(); item.Name = "sem_1"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = null; item.T_0Value = Convert.ToBoolean(semT_0 == null ? 0 : semT_0[1]); jumpConditionItems.Add(item); Sem1 = item.T_0Value; item = new JumpConditionItem(); item.Name = "sem_en1"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(sem_enT_2 == null ? 0 : sem_enT_2[1]); item.T_1Value = Convert.ToBoolean(sem_enT_1 == null ? 0 : sem_enT_1[1]); item.T_0Value = Convert.ToBoolean(sem_enT_0 == null ? 0 : sem_enT_0[1]); jumpConditionItems.Add(item); item = new JumpConditionItem(); item.Name = "sem_2"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = null; item.T_0Value = Convert.ToBoolean(semT_0 == null ? 0 : semT_0[2]); jumpConditionItems.Add(item); Sem2 = item.T_0Value; item = new JumpConditionItem(); item.Name = "sem_en2"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(sem_enT_2 == null ? 0 : sem_enT_2[2]); item.T_1Value = Convert.ToBoolean(sem_enT_1 == null ? 0 : sem_enT_1[2]); item.T_0Value = Convert.ToBoolean(sem_enT_0 == null ? 0 : sem_enT_0[2]); jumpConditionItems.Add(item); var global_enT_2 = DFBState.GetCySimulatorPrivateField <int[]>(cycle + 2, "global_en"); var global_enT_1 = DFBState.GetCySimulatorPrivateField <int[]>(cycle + 1, "global_en"); var global_enT_0 = DFBState.GetCySimulatorPrivateField <int[]>(cycle, "global_en"); item = new JumpConditionItem(); item.Name = "glob_in1"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = null; item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "g1")); jumpConditionItems.Add(item); Glob_Int1 = item.T_0Value; item = new JumpConditionItem(); item.Name = "glob_en1"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(global_enT_2 == null ? 0 : global_enT_2[0]); item.T_1Value = Convert.ToBoolean(global_enT_1 == null ? 0 : global_enT_1[0]); item.T_0Value = Convert.ToBoolean(global_enT_0 == null ? 0 : global_enT_0[0]); jumpConditionItems.Add(item); item = new JumpConditionItem(); item.Name = "glob_in2"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = null; item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "g2")); jumpConditionItems.Add(item); Glob_Int2 = item.T_0Value; item = new JumpConditionItem(); item.Name = "glob_en2"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(global_enT_2 == null ? 0 : global_enT_2[1]); item.T_1Value = Convert.ToBoolean(global_enT_1 == null ? 0 : global_enT_1[1]); item.T_0Value = Convert.ToBoolean(global_enT_0 == null ? 0 : global_enT_0[1]); jumpConditionItems.Add(item); item = new JumpConditionItem(); item.Name = "sat"; item.PipelineDelay = 1; item.T_2Value = null; item.T_1Value = null; item.T_0Value = Convert.ToBoolean(DFBState.GetCySimulatorPrivateField <int?>(cycle + 0, "satflag")); jumpConditionItems.Add(item); Sat = item.T_0Value; item = new JumpConditionItem(); item.Name = "sat_en"; item.PipelineDelay = 2; item.T_2Value = Convert.ToBoolean(global_enT_2 == null ? 0 : global_enT_2[2]); item.T_1Value = Convert.ToBoolean(global_enT_1 == null ? 0 : global_enT_1[2]); item.T_0Value = Convert.ToBoolean(global_enT_0 == null ? 0 : global_enT_0[2]); jumpConditionItems.Add(item); return(jumpConditionItems); }