Пример #1
0
        //      ALTERADA - equivalent to "DeclareEntity()" and "GenerateArchitecture()" in VHDLGen.cs
        private void DeclareAndGenerateModule(IComponentDescriptor cd, IndentedTextWriter tw)
        {
            string name = GetComponentName(cd);

            //      Module Declaration
            tw.WriteLine("SC_MODULE(" + name + ")");
            tw.WriteLine("{");
            tw.Indent++;

            tw.WriteLine();
            tw.WriteLine("// Port List" );
            //      Port Declarations
            DeclarePortList(cd, tw, false);
            tw.WriteLine();

            tw.WriteLine("// Sub-Components");
            //      Sub-Components Declaration
            var components = cd.GetChildComponents();
            //    .Cast<ComponentDescriptor>()
            //    .Select(c => c.Instance.Representant)
            //    .Distinct()
            //    .Select(c => c.Descriptor);

            foreach (IComponentDescriptor scd in components)
            {
                DeclareComponent(scd, tw);
            }
            if (cd.GetChildComponents().Count() > 0)
                tw.WriteLine();

            tw.WriteLine("// Local Channels");
            //      Local Channel Declaration
            foreach (ISignalOrPortDescriptor sd in cd.GetSignals())
            {
                //object initVal = sd.InitialValue;
                //string initSuffix = "";
                //if (initVal != null)
                //    initSuffix = ".write( " + GetValueID(initVal);
                string sname = MakeIDName(sd.Name, sd);

                if (sd.ElementType.CILType.IsEnum)
                {
                    tw.WriteLine("sc_signal<int> " + sname + ";");
                }
                else if (sd.ElementType.CILType.IsArray)
                {
                    tw.WriteLine("sc_vector< sc_signal<" + GetTypeDescriptorCompletedName(sd.ElementType.Element0Type)
                        + "> > " + sname + ";");
                }
                else
                {
                    tw.WriteLine("sc_signal<" + GetTypeDescriptorCompletedName(sd.ElementType) + "> " + sname + ";");

                }

            }
            if (cd.GetSignals().Count() > 0)
                tw.WriteLine();

            tw.WriteLine("// Constants");
            //      Constant Declarations
            foreach (FieldDescriptor field in cd.GetConstants())
            {
                DeclareField(field, tw);
            }
            if (cd.GetConstants().Count() > 0)
                tw.WriteLine();

            tw.WriteLine("// Variables");
            //      Variables Declaration
            foreach (FieldDescriptor field in cd.GetVariables())
            {

                DeclareField(field, tw);
            }
            if (cd.GetVariables().Count() > 0)
                tw.WriteLine();

            tw.WriteLine("// Processes");
            //      Process Declaration
            foreach (ProcessDescriptor pd in cd.GetProcesses())
            {
                DeclareProcess(pd, tw);
                tw.WriteLine();
            }

            //      Other Methods Declaration
            //tw.WriteLine("// Funcoes/Procedimentos: ");
            //foreach (MethodDescriptor md in cd.GetMethods())
            //{
            //    GenerateMethodImpl(md, tw);
            //    tw.WriteLine();
            //}
            //if (cd.GetMethods().Count() > 0)
            //    tw.WriteLine();

            tw.WriteLine("// Active functions/methods ");
            foreach (MethodDescriptor md in cd.GetActiveMethods())
            {
                GenerateMethodImpl(md, tw);
                tw.WriteLine();
            }
            if (cd.GetMethods().Count() > 0)
                tw.WriteLine();           


            //      Constructors
            tw.WriteLine("// Constructor");
            GenerateCtor(cd, tw);

            tw.Indent--;
            tw.WriteLine("};");
            tw.WriteLine("#endif");
        }