Esempio n. 1
0
            public static string ComponentEventOutputs(IEnumerable <Connection> connections, bool useProcesses)
            {
                string outputsString = "-- ComponentEventOutputs\n";

                if (useProcesses)
                {
                    foreach (string output in _getInternalEventOutputStrings(connections))
                    {
                        outputsString += String.Format(Smv.NextVarAssignment, output, Smv.False);
                    }
                }
                else
                {
                    foreach (string output in _getInternalEventOutputs(connections))
                    {
                        string[] outpSplit = Smv.SplitConnectionVariableName(output);
                        bool     alreadyChecked;
                        string   varName = Smv.ConvertConnectionVariableName(output, Smv.ModuleParameters.Event, out alreadyChecked);

                        string setRule   = String.Format("\t{0}.{1}_set : {2};\n", outpSplit[0], Smv.ModuleParameters.Event(outpSplit[1]), Smv.True);
                        string resetRule = String.Format("\t{0} : {1};\n", Smv.True, Smv.False);
                        outputsString += String.Format(Smv.EmptyNextCaseBlock, varName, setRule + resetRule);
                    }
                }
                return(outputsString);
            }
Esempio n. 2
0
            public static string InternalEventConnections(IEnumerable <Connection> internalBuffers, bool useProcesses)
            {
                string            eventConnections    = "-- _internalEventConnections\n";
                MultiMap <string> eventConnectionsMap = _getEventConnectionsMap(internalBuffers);
                List <string>     definesList         = new List <string>();

                foreach (string dst in eventConnectionsMap.Keys)
                {
                    bool   dstComponent;
                    string dstSmvVar = Smv.ConvertConnectionVariableName(dst, Smv.ModuleParameters.Event, out dstComponent);

                    string srcString = "\t("; //+ srcSmvVar + " : " + Smv.True + ";\n";
                    foreach (string src in eventConnectionsMap[dst])
                    {
                        bool   srcComponent;
                        string srcSmvVar = Smv.ConvertConnectionVariableName(src, Smv.ModuleParameters.Event, out srcComponent);
                        if (srcComponent)
                        {
                            srcString += srcSmvVar + " | ";
                        }
                        else
                        {
                            srcString += String.Format("({0} & {1}) | ", srcSmvVar, Smv.Alpha);
                        }
                    }

                    srcString = srcString.TrimEnd(Smv.OrTrimChars) + ")";
                    if (useProcesses)
                    {
                        srcString        += " : " + Smv.True + ";\n";
                        eventConnections += String.Format(Smv.NextCaseBlock + "\n", dstSmvVar, srcString);
                    }
                    else
                    {
                        string reset_string;
                        if (dstComponent)
                        {
                            string[] connectionDst = Smv.SplitConnectionVariableName(dst);
                            reset_string      = String.Format("\t({0}.{1}_reset) : {2};\n", connectionDst[0], Smv.ModuleParameters.Event(connectionDst[1]), Smv.False);
                            srcString        += " : " + Smv.True + ";\n";
                            eventConnections += String.Format(Smv.NextCaseBlock + "\n", dstSmvVar, srcString + reset_string);
                        }
                        else
                        {
                            //reset_string = String.Format("\t{0} : {1};\n", Smv.True, Smv.False);
                            //srcString = srcString.TrimEnd(Smv.OrTrimChars) + ") : " + Smv.True + ";\n";
                            //eventConnections += String.Format(Smv.EmptyNextCaseBlock + "\n", dstSmvVar, srcString + reset_string);
                            dstSmvVar += "_set";
                            definesList.Add(String.Format(Smv.DefineBlock, dstSmvVar, srcString));
                        }
                    }
                }

                foreach (string def in definesList)
                {
                    eventConnections += def;
                }
                return(eventConnections);
            }
Esempio n. 3
0
            private static bool _isInputFromComponent(FBInterface instanceParameter, IEnumerable <Connection> connections, string instanceName, out Connection inputConnection)
            {
                inputConnection = null;
                bool srcComponent = false;

                if (instanceParameter.Direction == Direction.Input)
                {
                    inputConnection = connections.FirstOrDefault(conn => conn.Destination == instanceName + "." + instanceParameter.Name);
                    if (inputConnection != null)
                    {
                        Smv.ConvertConnectionVariableName(inputConnection.Source, Smv.ModuleParameters.Event, out srcComponent);
                    }
                }

                return(srcComponent);
            }
Esempio n. 4
0
            private static IEnumerable <string> _getInternalEventOutputs(IEnumerable <Connection> internalBuffers)
            {
                HashSet <string> internalEventOutputs = new HashSet <string>();

                foreach (Connection connection in internalBuffers.Where(conn => conn.Type == ConnectionType.Event))
                {
                    bool srcComponent;
                    Smv.ConvertConnectionVariableName(connection.Source, Smv.ModuleParameters.Event, out srcComponent);
                    if (!internalEventOutputs.Contains(connection.Source))
                    {
                        if (srcComponent)
                        {
                            internalEventOutputs.Add(connection.Source);
                        }
                    }
                }
                return(internalEventOutputs);
            }
Esempio n. 5
0
            public static string InternalDataConnections(IEnumerable <Connection> internalBuffers, IEnumerable <WithConnection> withConnections, IEnumerable <Variable> allVariables, IEnumerable <FBInstance> instances)
            {
                string dataConnections = "-- _internalDataConnections\n";

                foreach (Connection connection in internalBuffers.Where(conn => conn.Type == ConnectionType.Data))
                {
                    bool   srcComponent;
                    bool   dstComponent;
                    string dstSmvVar = Smv.ConvertConnectionVariableName(connection.Destination, Smv.ModuleParameters.Variable, out dstComponent);
                    string srcSmvVar = Smv.ConvertConnectionVariableName(connection.Source, Smv.ModuleParameters.Variable, out srcComponent);
                    string srcString = "";

                    /*if (srcComponent && dstComponent)
                     * {
                     *  //srcString = "\t" + srcSmvVar + " : " + Smv.True + ";\n"; //TODO: make direct connections without double-buffering
                     *  var srcVar = _findVariable(connection.Source, allVariables, instances);
                     *
                     *  if (srcVar.ArraySize == 0)
                     *      dataConnections += String.Format(Smv.NextVarAssignment + "\n", dstSmvVar, srcSmvVar);
                     *  else
                     *  {
                     *      for (int i = 0; i < srcVar.ArraySize; i++)
                     *      {
                     *          dataConnections += String.Format(Smv.NextVarAssignment + "\n", dstSmvVar + Smv.ArrayIndex(i), srcSmvVar + Smv.ArrayIndex(i));
                     *      }
                     *  }
                     * }
                     * else */
                    if (!srcComponent && dstComponent)
                    {
                        var dstVar = _findVariable(connection.Destination, allVariables, instances);
                        if (dstVar.ArraySize == 0)
                        {
                            srcString        = FbSmvCommon.VarSamplingRule(connection.Source, withConnections, false);
                            dataConnections += String.Format(Smv.NextCaseBlock + "\n", dstSmvVar, srcString);
                        }
                        else
                        {
                            for (int i = 0; i < dstVar.ArraySize; i++)
                            {
                                srcString        = FbSmvCommon.VarSamplingRule(connection.Source, withConnections, false, i);
                                dataConnections += String.Format(Smv.NextCaseBlock + "\n", dstSmvVar + Smv.ArrayIndex(i), srcString);
                            }
                        }
                    }
                    else if (srcComponent && !dstComponent)
                    {
                        IEnumerable <string> samplingEvents      = _getSamplingEventNamesForVariable(connection.Destination, withConnections);
                        MultiMap <string>    eventConnectionsMap = _getEventConnectionsMap(internalBuffers);

                        string eventSeed = "";
                        foreach (string ev in samplingEvents)
                        {
                            string src = "";
                            foreach (string parentEvent in eventConnectionsMap[ev])
                            {
                                bool dontCare;
                                src += Smv.ConvertConnectionVariableName(parentEvent, Smv.ModuleParameters.Event, out dontCare) + Smv.Or;
                            }
                            eventSeed += String.Format("({0}){1}", src.TrimEnd(Smv.OrTrimChars), Smv.Or);
                        }

                        var srcVar = _findVariable(connection.Source, allVariables, instances);
                        if (srcVar.ArraySize == 0)
                        {
                            srcString        = String.Format("\t{0} : {1};\n", eventSeed.TrimEnd(Smv.OrTrimChars), srcSmvVar);
                            dataConnections += String.Format(Smv.NextCaseBlock + "\n", dstSmvVar, srcString);
                        }
                        else
                        {
                            for (int i = 0; i < srcVar.ArraySize; i++)
                            {
                                srcString        = String.Format("\t{0} : {1};\n", eventSeed.TrimEnd(Smv.OrTrimChars), srcSmvVar + Smv.ArrayIndex(i));
                                dataConnections += String.Format(Smv.NextCaseBlock + "\n", dstSmvVar + Smv.ArrayIndex(i), srcString);
                            }
                        }
                    }
                }
                return(dataConnections);
            }