/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(Bank bankID, int cycle) { var label = "Out:"; int?val = null; bool busRead_A; bool busRead_B; BusRead(cycle, out busRead_A, out busRead_B); if (bankID == Bank.Bank_A && !busRead_A) { return(NullLabeledValue <long?>(label)); } else if (bankID == Bank.Bank_B && !busRead_B) { return(NullLabeledValue <long?>(label)); } val = DFBState.GetCySimulatorPrivateField <int?>(cycle, "p3bus"); if (val == null || !val.HasValue) { return(NullLabeledValue <long?>(label)); } var r = new LabeledValue <long?>("Out:"); r.Value = Convert.ToInt32(val.Value); r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, (int)r.Value) : ""; return(r); }
/// <summary> /// Bus that was read /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <param name="busA"></param> /// <param name="busB"></param> public static void BusRead(int cycle, out bool busA, out bool busB) { busA = false; busB = false; bool busRead = false; var val = DFBState.GetCySimulatorPrivateField <int?>(cycle, "p3busflag"); if (val != null) { busRead = Convert.ToBoolean(val.Value); } if (!busRead) { return; } int acuaddr1 = 0; val = DFBState.GetCySimulatorPrivateField <int?>(cycle, "acuaddr1"); if (val == null || !val.HasValue) { return; } acuaddr1 = Convert.ToInt32(val.Value); if ((acuaddr1 & 1) != 0) { busA = true; } else { busB = true; } }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(Bank bankID, int cycle) { var label = "Out:"; var busWritten = BusWritten(cycle); if (busWritten == null) { return(NullLabeledValue <long?>(label)); } if (bankID == Bank.Bank_A && busWritten.Equals("A") || bankID == Bank.Bank_B && busWritten.Equals("B")) { // Value var shift = DFBState.GetCySimulatorPrivateField <long>(cycle, "shift"); var r = new LabeledValue <long?>("Out:"); r.Value = shift; r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, (int)r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Retrieves the simulator object for a given cycle back from the current cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static CyControlWord Instruction(int cycle) { // Note: m_commandIndex in the simulator object is the next instruction // so retrieve the prior simulator var simulation = DFBState.GetCySimulator(cycle - 1); //int instrIndex; if (simulation == null) { return(instructionList[0]); } else if (simulation.RamSel.Equals("A")) { if (simulation.m_commandIndexA > instructionAList.Count - 1) { return(instructionAList[0]); } else { return(instructionAList[simulation.m_commandIndexA]); } } else if (simulation.RamSel.Equals("B")) { if (simulation.m_commandIndexB > instructionBList.Count - 1) { return(instructionBList[0]); } else { return(instructionBList[simulation.m_commandIndexB]); } } else { return(null); } /* * if (simulation == null || simulation.RamSel.Equals("A")) * { * instrIndex = simulation == null ? 0 : simulation.m_commandIndexA; * } * else * { * instrIndex = simulation.m_commandIndexB; * } * * if (instrIndex >= 0 && instrIndex < instructionList.Count) * { * return instructionList[instrIndex]; * } * else * { * //return new CyControlWord(instrIndex); * return null; * } */ }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(Bank bankID, int cycle) { var label = "Out:"; // ram var field = bankID == Bank.Bank_A ? "DAram" : "DBram"; var ram = DFBState.GetCySimulatorPrivateField <long[]>(cycle, field); // address field = bankID == Bank.Bank_A ? "Aaddrnext" : "Baddrnext"; var address = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); // ramVal / output if (address != null && address.HasValue && ram != null) { var r = new LabeledValue <long?>(label); r.Value = (int?)ram[address.Value]; r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Bus that was written: "A" | "B" | null /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> private static string BusWritten(int cycle) { // Was bus written? int cword; bool busWasWritten; bool busAWritten; bool busBWritten; cword = DFBState.GetCySimulatorPrivateField <int>(cycle, "cword"); busWasWritten = (cword >> 13 & 1) == 1 ? true : false; if (!busWasWritten) { return(null); } // Bus A or B? var busAddr = DFBState.GetCySimulatorPrivateField <int>(cycle, "acuaddr"); // 1 = A, 2 = B busAWritten = busAddr.Equals(1); busBWritten = busAddr.Equals(0); if (busAWritten) { return("A"); } else if (busBWritten) { return("B"); } else { return(null); } }
/// <summary> /// Create a new instance of this device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <param name="code">Data area section string from the assembly code file</param> public DataRamModel(Bank bankID, int cycle, string code) : base(bankID, cycle, VALUE_WIDTH, ADDR_WIDTH, PIPELINE_DELAY) { // name name = bankID == Bank.Bank_A ? DevicePort.DataRam_A.ToString() : DevicePort.DataRam_B.ToString(); // instructions var instr = ActiveInstr(bankID, cycle); instructions.Add(instr); // connectionInputs connectionInputs = Connections(bankID, cycle); // output output = OutputCalc(bankID, cycle); // ram var field = bankID == Bank.Bank_A ? "DAram" : "DBram"; ram = DFBState.GetCySimulatorPrivateField <long[]>(cycle, field); // address / addressPrev field = bankID == Bank.Bank_A ? "Aaddrnext" : "Baddrnext"; address = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); addressPrev = DFBState.GetCySimulatorPrivateField <int?>(cycle - 1, field); // valuePrev valuePrev = OutputCalc(bankID, cycle - 1).Value; // valueWritten var writeInstr = instructions[0].Equals("write(db)") || instructions[0].Equals("write(da)"); if (writeInstr) { var mux1_Output = Mux1Model.OutputCalc(bankID, cycle); if (mux1_Output.Value.HasValue) { valueWritten = mux1_Output.Value; } } ramItems = BuildRamItems(bankID, this.ram, code); var sb = new StringBuilder(); foreach (var ramItem in RamItems) { sb.AppendFormat("{0,6} {1,8} {2,10} {3,11} {4}\n", "[" + ramItem.Address + "]", ramItem.ValHex, ramItem.ValDfb, ramItem.ValInt, ramItem.Comment); } ramString = sb.ToString().TrimEnd('\n'); }
/// <summary> /// Swimlane style - vertical lane per label, ACU A/B values with label /// </summary> /// <param name="dfbState"></param> /// <returns></returns> public byte[] Generate( DFBState dfbState) { // Graph GraphViz.Graph graph = CreateGraph("dfb_call"); const double labelColWidth = 2.25f; const double rowHeight = 1.5f; double currCol_x = 0; double currRow_y = 0; // Subgraphs var labels = dfbState.StateFrames .Where(x => x.CodeStateCycle.IsJumpInstruction == true) .Select(x => x.CodeStateCycle.Label) .Distinct() .ToList(); labels.ForEach(x => CreateSubgraph(graph, x)); // Cycle through all of the jump instructions and build call sequence var jumpStateFrames = dfbState.StateFrames .Where(x => x.CodeStateCycle.IsJumpInstruction == true) .OrderBy(x => x.Cycle); foreach (var stateFrame in jumpStateFrames) { // Place all nodes for same label in one column var xPos = (currCol_x + (labelColWidth * stateFrame.CodeStateCycle.CodeState.State.StateNumber)); // Place every node in an exclusive row var yPos = currRow_y; currRow_y -= rowHeight; AddSubgraphNode( graph, dfbState, stateFrame, xPos, yPos); } var text = graph.ToString(); wrapper.RenderingEngine = Enums.RenderingEngine.Neato; //wrapper.RenderingEngine = Enums.RenderingEngine.Dot; // doesn't do absolute pos return(wrapper.GenerateGraph(text, Enums.GraphReturnType.Svg)); }
/// <summary> /// Create a new instance of this device for the given cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> public GlobalModel(int cycle) : base(Bank.NotApplicable, cycle, VALUE_WIDTH, ADDR_WIDTH, PIPELINE_DELAY) { // name name = DevicePort.Global.ToString(); // instructions instructions.Add(ActiveInstr(cycle - ALUModel.PIPELINE_DELAY)); // connectionInputs connectionInputs = Connections(cycle); // output output = OutputCalc(cycle); // global_en var global_en = DFBState.GetCySimulatorPrivateField <int[]>(cycle, "global_en"); if (global_en != null) { global_en0 = global_en[0]; global_en1 = global_en[1]; global_en2 = global_en[2]; } satEn = DFBState.GetCySimulatorPrivateField <int?>(cycle, "satEn"); sqcnt = DFBState.GetCySimulatorPrivateField <int?>(cycle, "sqcnt"); sqcval = DFBState.GetCySimulatorPrivateField <int?>(cycle, "sqcval"); satflag = DFBState.GetCySimulatorPrivateField <int?>(cycle, "satflag"); rflag = DFBState.GetCySimulatorPrivateField <int?>(cycle, "rflag"); tflag = DFBState.GetCySimulatorPrivateField <int?>(cycle, "tflag"); tsign = DFBState.GetCySimulatorPrivateField <int?>(cycle, "tsign"); dpsign = DFBState.GetCySimulatorPrivateField <int?>(cycle, "dpsign"); dpeq = DFBState.GetCySimulatorPrivateField <int?>(cycle, "eqflag"); // sem_en0/1/2 var sem_en = DFBState.GetCySimulatorPrivateField <int[]>(cycle, "sem_en"); if (sem_en != null) { sem_en0 = sem_en[0]; sem_en1 = sem_en[1]; sem_en2 = sem_en[2]; } }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(int cycle) { var label = "Out:"; var aluout = DFBState.GetCySimulatorPrivateField <long?>(cycle, "aluout"); if (aluout != null) { var r = new LabeledValue <long?>(label); r.Value = aluout; r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, (int)r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(int cycle) { var label = "Out:"; var macacc = DFBState.GetCySimulatorPrivateField <long?>(cycle, "MACacc"); if (macacc != null) { int maclower = Convert.ToInt32(macacc >> 23); var r = new LabeledValue <long?>("Out:"); r.Value = maclower; r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(Bank bankID, int cycle) { var label = "Out:"; // reg var field = bankID == Bank.Bank_A ? "Aacc" : "Bacc"; var reg_reg = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); if (reg_reg != null) { var r = new LabeledValue <long?>(label); r.Value = reg_reg.Value; r.FormattedValue = r.Value.HasValue ? FormatHex(VALUE_WIDTH, r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(Bank bankID, int cycle) { var label = "Out:"; var field = bankID == DFBStateModel.Bank.Bank_A ? "a1mux" : "b1mux"; var val = DFBState.GetCySimulatorPrivateField <long?>(cycle, field); if (val != null && val.HasValue) { var r = new LabeledValue <long?>(label); r.Value = val.Value; r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Generates a node for the state label /// </summary> /// <param name="label"></param> /// <param name="pos_X"></param> /// <param name="pos_Y"></param> /// <returns></returns> public void AddSubgraphNode( GraphViz.Graph graph, DFBState dfbState, DFBStateFrame dfbStateFrame, double?pos_X, double?pos_Y) { // State prior to current frame gives the beginning values for ACU when label was entered DFBStateFrame dfbStateFrameBegValues = dfbState.StatePrior(dfbStateFrame.Cycle); var shapeName = dfbStateFrame.CodeStateCycle.UniqueName; var node = CreateNode(dfbStateFrame, pos_X, pos_Y, dfbStateFrameBegValues, shapeName); graph.Subgraphs .Where(x => x.Tag.ToString() == dfbStateFrame.CodeStateCycle.Label) .FirstOrDefault() .Nodes.Add(node); // Add edge for ACU change from one label call to the next AddEdges(graph, dfbState, dfbStateFrame, dfbStateFrameBegValues, shapeName); }
/// <summary> /// Output value of the device for the given cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> /// <returns></returns> public static LabeledValue <long?> OutputCalc(int cycle) { var label = "Out:"; if (cycle - PIPELINE_DELAY < 0) { return(NullLabeledValue <long?>(label)); } var val = DFBState.GetCySimulatorPrivateField <long?>(cycle, "shift"); if (val != null && val.HasValue) { var r = new LabeledValue <long?>(label); r.Value = val.Value; r.FormattedValue = r.Value.HasValue ? FormatValue(VALUE_WIDTH, r.Value) : ""; return(r); } else { return(NullLabeledValue <long?>(label)); } }
/// <summary> /// Adds edge connections between labels, and for the change in ACU address between calls to the same label /// </summary> /// <param name="graph"></param> /// <param name="dfbState"></param> /// <param name="dfbStateFrame"></param> /// <param name="dfbStateFrameBegValues"></param> /// <param name="shapeName"></param> private void AddEdges( GraphViz.Graph graph, DFBState dfbState, DFBStateFrame dfbStateFrame, DFBStateFrame dfbStateFrameBegValues, string shapeName) { // State prior to this label's last execution gives the prior beginning values for ACU when label was entered DFBStateFrame dfbStateFramePriorBegValues = null; var statePriorSameLabel = dfbState.StatePriorSameLabel(dfbStateFrame.Cycle); if (statePriorSameLabel != null) { var sameLabelPriorCycleNbr = statePriorSameLabel.Cycle; dfbStateFramePriorBegValues = dfbState.StatePrior(sameLabelPriorCycleNbr); } // State following current frame gives connection target var dfbStateFrameNext = dfbState.StateNext(dfbStateFrame.Cycle); if (dfbStateFrameNext == null) { return; } var shapeNameNext = dfbStateFrameNext.CodeStateCycle.UniqueName; // label var labels = new List <string>(); var state = dfbStateFrame.CodeStateCycle.CodeState.State; var fallThrough = true; if (state.AcuAEQ == 1 && dfbStateFrame.JumpConditions.AcuAEQ) { labels.Add("AcuAEQ"); fallThrough = false; } if (state.AcuBEQ == 1 && dfbStateFrame.JumpConditions.AcuBEQ) { labels.Add("AcuBEQ"); fallThrough = false; } if (state.DpEQ == 1 && dfbStateFrame.JumpConditions.DpEQ) { labels.Add("DpEQ"); fallThrough = false; } if (state.DpSign == 1 && dfbStateFrame.JumpConditions.DpSign) { labels.Add("DpSign"); fallThrough = false; } if (state.DpThresh == 1 && dfbStateFrame.JumpConditions.DpThresh) { labels.Add("DpThresh"); fallThrough = false; } if (state.In1 == 1 && dfbStateFrame.JumpConditions.In1) { labels.Add("In1"); fallThrough = false; } if (state.In2 == 1 && dfbStateFrame.JumpConditions.In2) { labels.Add("In2"); fallThrough = false; } if (state.Sat == 1 && dfbStateFrame.JumpConditions.Sat) { labels.Add("Sat"); fallThrough = false; } if (fallThrough) { labels.Add("false"); } var edge = new GraphViz.Edge(); graph.Edges.Add(edge); edge.Connections.AddRange(new string[] { shapeName, shapeNameNext }); edge.EdgeAttributes.style = GraphViz.Style.Edge.solid; edge.EdgeAttributes.color = KnownColor.ForestGreen; edge.EdgeAttributes.arrowhead = GraphViz.ArrowType.normal; edge.EdgeAttributes.arrowtail = GraphViz.ArrowType.inv; edge.EdgeAttributes.label = new GraphViz.escString(String.Join(" ", labels)); // Add connection for ACU delta from prior call of same label if (dfbStateFramePriorBegValues != null && statePriorSameLabel != null) { // Determine ACU reg address changes from last time this label was executed var shapeNamePriorCall = statePriorSameLabel.CodeStateCycle.UniqueName; Func <int, int, string> sign = delegate(int curr, int prior) { if (prior < curr) { return("+"); } else { return(""); } }; var sb = new StringBuilder(); var acuABeg = (int)dfbStateFrameBegValues.ACU_A.Reg_reg.Value; var acuABegPrior = (int)dfbStateFramePriorBegValues.ACU_A.Reg_reg.Value; var acuABegChange = acuABeg - acuABegPrior; if (acuABegChange != 0) { sb.AppendFormat("\\nACU_A Chg: {0}{1}", sign(acuABeg, acuABegPrior), acuABegChange.ToString()); } var acuBBeg = (int)dfbStateFrameBegValues.ACU_B.Reg_reg.Value; var acuBBegPrior = (int)dfbStateFramePriorBegValues.ACU_B.Reg_reg.Value; var acuBBegChange = acuBBeg - acuBBegPrior; if (acuBBegChange != 0) { if (acuABegChange != 0) { sb.AppendLine(""); } sb.AppendFormat("\\nACU_B Chg: {0}{1}", sign(acuBBeg, acuBBegPrior), acuBBegChange.ToString()); } edge = new GraphViz.Edge(); graph.Edges.Add(edge); edge.Connections.AddRange(new string[] { shapeNamePriorCall, shapeName }); edge.EdgeAttributes.color = KnownColor.Gray; edge.EdgeAttributes.weight = 0.5f; edge.EdgeAttributes.style = GraphViz.Style.Edge.dashed; edge.EdgeAttributes.arrowhead = GraphViz.ArrowType.none; edge.EdgeAttributes.arrowtail = GraphViz.ArrowType.none; edge.EdgeAttributes.headlabel = new GraphViz.escString(sb.ToString()); edge.EdgeAttributes.labeldistance = 0.6f; } }
/// <summary> /// Create a new instance of this device for the given cycle /// </summary> /// <param name="cycle">Zero-based program cycle number</param> public MACModel(int cycle) : base(Bank.NotApplicable, cycle, VALUE_WIDTH, 0, PIPELINE_DELAY) { // name name = DevicePort.MAC.ToString(); // instructions instructions.Add(ActiveInstr(cycle)); // [t-2] instructions.Add(ActiveInstr(cycle - 1)); // [t-1] instructions.Add(ActiveInstr(cycle - 2)); // [now] // connectionInputs connectionInputs = Connections(cycle); // output output = OutputCalc(cycle); // pipelineItems pipelineItems = new List <PipelineItem>(); for (int i = 0; i < instructions.Count; i++) { var instr = instructions[i]; long? aluValue = null; long? a = null; long? b = null; string outputFormula = null; int? accum = null; switch (instr) { case "loadalu": if (i > 0) { // Adds the previous ALU output (from the shifter) to the product and starts a new accumulation. aluValue = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "aluout"); a = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "a2mux"); b = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "b2mux"); if (i == PIPELINE_DELAY) { outputFormula = "a * b + [Prev ALU]"; } } break; case "clra": if (i > 0) { // Clears the accumulator and stores the current product a = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "a2mux"); b = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "b2mux"); if (i == PIPELINE_DELAY) { accum = 0; outputFormula = "a * b"; } } break; case "hold": if (i > 0) { // Holds the value in the accumulator from the previous cycle. No multiply if (i == PIPELINE_DELAY) { accum = Convert.ToInt32(OutputCalc(cycle - i + 1).Value); outputFormula = "Accum"; } } break; case "macc": if (i > 0) { // Multiplies the values on mux2 of side A and side B. // Adds the product to the current value of the accumulator. a = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "a2mux"); b = DFBState.GetCySimulatorPrivateField <long?>(cycle - i + 1, "b2mux"); if (i == PIPELINE_DELAY) { accum = Convert.ToInt32(OutputCalc(cycle - i + 1).Value); outputFormula = "a * b + Accum"; } } break; } var pipelineItem = new PipelineItem(); var lvAluValue = new LabeledValue <long?>("Prev ALU:"); lvAluValue.Value = aluValue.HasValue ? aluValue.Value : (long?)null; lvAluValue.FormattedValue = FormatValue(VALUE_WIDTH, lvAluValue.Value); pipelineItem.AluValue = lvAluValue; var lvA = new LabeledValue <long?>("a:"); lvA.Value = a.HasValue ? a.Value : (long?)null; lvA.FormattedValue = FormatValue(VALUE_WIDTH, lvA.Value); pipelineItem.A = lvA; var lvB = new LabeledValue <long?>("b:"); lvB.Value = b.HasValue ? b.Value : (long?)null; lvB.FormattedValue = FormatValue(VALUE_WIDTH, lvB.Value); pipelineItem.B = lvB; var lvOutputFormula = new LabeledValue <string>("Formula:"); lvOutputFormula.Value = outputFormula; lvOutputFormula.FormattedValue = outputFormula; pipelineItem.OutputFormula = lvOutputFormula; var lvAccum = new LabeledValue <int?>("Accum:"); lvAccum.Value = accum.HasValue ? accum.Value : (int?)null; lvAccum.FormattedValue = FormatValue(VALUE_WIDTH, lvAccum.Value); pipelineItem.Accumulator = lvAccum; pipelineItems.Add(pipelineItem); } }
/// <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); }
/// <summary> /// Create a new instance of this device for the given cycle /// </summary> /// <param name="bankID">BankID of the device</param> /// <param name="cycle">Zero-based program cycle number</param> /// <param name="code">Data area section string from the assembly code file</param> public ACUModel(Bank bankID, int cycle, string code) : base(bankID, cycle, VALUE_WIDTH, ADDR_WIDTH, PIPELINE_DELAY) { // ACU values update during simulator makestep(), so properties must be read from previous cycle //cycle -= 1; if (cycle < 0) { return; } // name name = bankID == Bank.Bank_A ? DevicePort.ACU_A.ToString() : DevicePort.ACU_B.ToString(); // instructions var instr = bankID == Bank.Bank_A ? CodeStoreModel.Instruction(cycle).AcuA : CodeStoreModel.Instruction(cycle).AcuB; instructions.Add(instr); // ACU has no connectionInputs // connectionInputs // output output = OutputCalc(bankID, cycle); // reg var field = bankID == Bank.Bank_A ? "Aacc" : "Bacc"; reg_reg = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); // freg field = bankID == Bank.Bank_A ? "Afreg" : "Bfreg"; reg_freg = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); // mreg field = bankID == Bank.Bank_A ? "Amreg" : "Bmreg"; reg_mreg = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); // lreg field = bankID == Bank.Bank_A ? "Alreg" : "Blreg"; reg_lreg = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); // flag_mod field = bankID == Bank.Bank_A ? "Amodflag" : "Bmodflag"; reg_flag_mod = DFBState.GetCySimulatorPrivateField <int?>(cycle, field); // ram field = bankID == Bank.Bank_A ? "aacuram" : "bacuram"; ram = DFBState.GetCySimulatorPrivateField <int[]>(cycle, field); // address field = "acuaddr"; address = DFBState.GetCySimulatorPrivateField <int?>(cycle - 0, field); // addressPrev field = "acuaddr"; addressPrev = DFBState.GetCySimulatorPrivateField <int?>(cycle - 1, field); ramItems = BuildRamItems(bankID, this.ram, code); var sb = new StringBuilder(); foreach (var ramItem in RamItems) { sb.AppendFormat("{0,4} {1,4} {2,3} {3}\n", "[" + ramItem.Address + "]", ramItem.ValHex, ramItem.ValInt, ramItem.Comment); } ramString = sb.ToString().TrimEnd('\n'); }