Beispiel #1
0
        /// <summary>
        /// 通过一FPGA实例来初始化FPGAInitForm,一般用于属性修改;
        /// </summary>
        /// <param name="fpga"></param>
        public FPGAInitForm(FPGA fpga)
        {
            SetFatherComponents();
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterParent;

            _nameTB.Text  = fpga.Name;
            _typeCB.Text  = fpga.Type;
            _adCB.Text    = fpga.AD;
            _clockTB.Text = fpga.Clock.ToString();
            //logic
            _slicesTB.Text   = fpga.Slices.ToString();
            _glbTB.Text      = fpga.GLB.ToString();
            _logicCells.Text = fpga.LogicCells.ToString();
            _lutTB.Text      = fpga.LUT.ToString();
            //IO
            _difIOTB.Text    = fpga.DifferentialIO.ToString();
            _singalIOTB.Text = fpga.SingalIO.ToString();
            //memory
            _totalBlockTB.Text = fpga.TotalBlock.ToString();
            _blockTB.Text      = fpga.Block.ToString();
            _maxDstTB.Text     = fpga.MaxDistributed.ToString();
            //speedLevel
            _indTempTB.Text     = fpga.IndustrialTemp.ToString();
            _extenedTempTB.Text = fpga.ExtenedTemp.ToString();
            _commercialTB.Text  = fpga.Commercial.ToString();
            //IPResource
            _gtpTB.Text  = fpga.GTP.ToString();
            _aesTB.Text  = fpga.AES.ToString();
            _amsTB.Text  = fpga.AMS.ToString();
            _pcieTB.Text = fpga.PCIE.ToString();
            _dspTB.Text  = fpga.DSP;
        }
Beispiel #2
0
        protected virtual void yesBtn_Click(object sender, EventArgs e)
        {
            if (false == CompleteJudgment())
            {
                return;
            }
            FPGA fpga = new FPGA();

            RefreshFPGA(fpga);
            //XMLManager.HandleType.SaveXML_FPGA(fpga);
            fpga.SaveXmlByName();

            this.DialogResult = DialogResult.Yes;
        }
Beispiel #3
0
 //实现一个ModelBaseCore到BaseDrawerCore的转换方法
 protected BaseDrawerCore GetBaseDrawerCore(ModelBaseCore obj, Rectangle rect)
 {
     if (NodeType == EndType.PPC)
     {
         PPC ppc = obj as PPC;
         return(new PPCViewModel(ppc, rect));
     }
     else if (NodeType == EndType.FPGA)
     {
         FPGA fpga = obj as FPGA;
         return(new FPGAViewModel(fpga, rect));
     }
     else //NodeType == EndType.ZYNQ
     {
         ZYNQ zynq = obj as ZYNQ;
         return(new ZYNQViewModel(zynq, rect));
     }
 }
Beispiel #4
0
 protected void RefreshFPGA(FPGA fpga)
 {
     try
     {
         fpga.Name  = _nameTB.Text;
         fpga.Type  = _typeCB.Text;
         fpga.AD    = _adCB.Text;
         fpga.Clock = int.Parse(_clockTB.Text);
         //logic
         fpga.Slices     = int.Parse(_slicesTB.Text);
         fpga.GLB        = int.Parse(_glbTB.Text);
         fpga.LogicCells = int.Parse(_logicCells.Text);
         fpga.LUT        = int.Parse(_lutTB.Text);
         //IO
         fpga.DifferentialIO = int.Parse(_difIOTB.Text);
         fpga.SingalIO       = int.Parse(_singalIOTB.Text);
         //memory
         fpga.TotalBlock     = int.Parse(_totalBlockTB.Text);
         fpga.Block          = int.Parse(_blockTB.Text);
         fpga.MaxDistributed = int.Parse(_maxDstTB.Text);
         //speedLevel
         fpga.IndustrialTemp = int.Parse(_indTempTB.Text);
         fpga.ExtenedTemp    = int.Parse(_extenedTempTB.Text);
         fpga.Commercial     = int.Parse(_commercialTB.Text);
         //IPResource
         fpga.GTP  = int.Parse(_gtpTB.Text);
         fpga.AES  = int.Parse(_aesTB.Text);
         fpga.AMS  = int.Parse(_amsTB.Text);
         fpga.PCIE = int.Parse(_pcieTB.Text);
         fpga.DSP  = _dspTB.Text;
     }
     catch (Exception e)
     {
         MessageBox.Show("填入值异常", e.Message);
     }
 }
        private void ShowNodeInitialForm(CmpNode node)
        {
            switch (node.NodeType)
            {
            case EndType.PPC:
                PPC ppc = node.Obj as PPC;
                Component_PPCInitForm ppcForm = new Component_PPCInitForm(ppc);
                ppcForm.ShowDialog();
                if (ppcForm.DialogResult == DialogResult.Yes)
                {
                    node.Obj = ppcForm._ppc;
                }
                break;

            case EndType.FPGA:
                FPGA fpga = node.Obj as FPGA;
                Component_FPGAInitForm fpgaForm = new Component_FPGAInitForm(fpga);
                fpgaForm.ShowDialog();
                if (fpgaForm.DialogResult == DialogResult.Yes)
                {
                    node.Obj = fpgaForm._fpga;
                }
                break;

            default:    //ComputeNodeType.ZYNQ
                ZYNQ zynq = node.Obj as ZYNQ;
                Component_ZYNQInitForm zynqForm = new Component_ZYNQInitForm(zynq);
                zynqForm.ShowDialog();
                if (zynqForm.DialogResult == DialogResult.Yes)
                {
                    node.Obj = zynqForm._zynq;
                }
                break;
            }
            return;
        }
Beispiel #6
0
 public FPGAViewModel(FPGA fpga)
 {
     _fpga = fpga;
 }
Beispiel #7
0
 public FPGAViewModel(FPGA fpga, Rectangle rect)
     : base(rect)
 {
     _fpga = fpga;
 }
        /*组件修改*/
        private void ContextMSModify_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = _eqTreeView.SelectedNode;
            string   oldNodeName  = selectedNode.Text;

            switch (selectedNode.Parent.Text)
            {
            case "PPCs":
                //通过读取XML文件初始化PPC,然后用一个PPC实例初始化PPCInitForm
                PPC ppc = ModelFactory <PPC> .CreateByName(selectedNode.Text);

                PPCInitForm ppcInitForm = new PPCInitForm(ppc);
                ppcInitForm.ShowDialog();

                if (ppcInitForm.DialogResult == DialogResult.Yes)
                {
                    if (ppcInitForm.GetObjectName() != oldNodeName)
                    {    //改了名字的话,要删除老文件
                        selectedNode.Text = ppcInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetPPCPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                ppcInitForm.Dispose();
                break;

            case "FPGAs":
                FPGA fpga = ModelFactory <FPGA> .CreateByName(selectedNode.Text);

                FPGAInitForm fpgaInitForm = new FPGAInitForm(fpga);
                fpgaInitForm.ShowDialog();

                if (fpgaInitForm.DialogResult == DialogResult.Yes)
                {
                    if (fpgaInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = fpgaInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetFPGAPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                fpgaInitForm.Dispose();
                break;

            case "ZYNQs":
                ZYNQ zynq = ModelFactory <ZYNQ> .CreateByName(selectedNode.Text);

                ZYNQInitForm zynqInitForm = new ZYNQInitForm(zynq);
                zynqInitForm.ShowDialog();

                if (zynqInitForm.DialogResult == DialogResult.Yes)
                {
                    if (zynqInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = zynqInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetZYNQPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                zynqInitForm.Dispose();
                break;

            case "板卡库":
                Board board = ModelFactory <Board> .CreateByName(selectedNode.Text);

                BoardInitForm boardInitForm = new BoardInitForm(board);
                boardInitForm.ShowDialog();

                if (boardInitForm.DialogResult == DialogResult.Yes)
                {
                    if (boardInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = boardInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetBoardPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                boardInitForm.Dispose();
                break;

            case "背板库":
                BackPlane bp = ModelFactory <BackPlane> .CreateByName(selectedNode.Text);

                BackPlaneInitForm bpInitForm = new BackPlaneInitForm(bp);
                bpInitForm.ShowDialog();

                if (bpInitForm.DialogResult == DialogResult.Yes)
                {
                    if (bpInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = bpInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetBackPlanePath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                bpInitForm.Dispose();
                break;

            case "机箱库":
                Models.Container  ctnView     = ModelFactory <Models.Container> .CreateByName(selectedNode.Text);;
                ContainerInitForm ctnInitForm = new ContainerInitForm(ctnView);
                ctnInitForm.ShowDialog();

                if (ctnInitForm.DialogResult == DialogResult.Yes)
                {
                    if (ctnInitForm.GetObjectName() != oldNodeName)
                    {
                        selectedNode.Text = ctnInitForm.GetObjectName();
                        var filePath = string.Format(@"{0}\{1}.xml", XMLManager.PathManager.GetContainerPath(), oldNodeName);
                        File.Delete(filePath);
                    }
                }
                ctnInitForm.Dispose();
                break;

            default:
                break;
            }
            //无论有无文件内容更改都把TreeView的内容读入对应xml文件内
            XMLManager.HandleTreeView.ReadTreeViewToXML(_eqTreeView, XMLManager.PathManager.GetEqLibFilePath());
        }
Beispiel #9
0
        static unsafe void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var dense_path = "matrix_data/wide.csv";
            var csr_path   = "matrix_data/wide_csr.csv";
            var cisr_path  = "matrix_data/wide_cisr.csv";

            // Obtain Matrix Dimensions
            var          n  = File.ReadAllLines(dense_path).Length;
            StreamReader sr = new StreamReader(dense_path);
            var          m  = sr.ReadLine().Split(',').Length;

            sr.Close();

            var matrix = Matrix.CreateSparse <double>(n, m);


            // Load Dense Matrix Representation
            using (TextFieldParser csv_parser = new TextFieldParser(dense_path))
            {
                csv_parser.CommentTokens = new string[] { "#" };
                csv_parser.SetDelimiters(new string[] { "," });
                for (int i = 0; i < n; i++)
                {
                    string[] row_data = csv_parser.ReadFields();
                    for (int j = 0; j < m; j++)
                    {
                        matrix[i, j] = Convert.ToDouble(row_data[j]);
                    }
                }
            }


            // Load CISR Matrix Representation
            UInt32[] cisr_values;
            UInt32[] cisr_column_indices;
            UInt32[] cisr_row_lengths;
            using (TextFieldParser csv_parser = new TextFieldParser(cisr_path))
            {
                csv_parser.CommentTokens = new string[] { "#" };
                csv_parser.SetDelimiters(new string[] { "," });

                string[] cisr_values_line = csv_parser.ReadFields();
                cisr_values = cisr_values_line.Select(UInt32.Parse).ToArray();

                string[] cisr_column_indices_line = csv_parser.ReadFields();
                cisr_column_indices = cisr_column_indices_line.Select(UInt32.Parse).ToArray();

                string[] cisr_row_lengths_line = csv_parser.ReadFields();
                cisr_row_lengths = cisr_row_lengths_line.Select(UInt32.Parse).ToArray();
            }


            // Display Loaded Matrix
            Console.WriteLine("Dense Matrix Representation:");
            Console.WriteLine(matrix);
            Console.WriteLine("CISR Values:         " + String.Join(", ", cisr_values));
            Console.WriteLine("CISR Column Indices: " + String.Join(", ", cisr_column_indices));
            Console.WriteLine("CISR Row Lengths:    " + String.Join(", ", cisr_row_lengths));


            // Generate and Time Reference Solution
            var vector = Matrix.CreateSparse <double>(m, 1);

            for (int i = 0; i < m; i++)
            {
                vector[i, 0] = i % 1024;
            }
            Matrix <double> result;

            var ref_watch = new System.Diagnostics.Stopwatch();

            ref_watch.Start();
            result = matrix * vector;
            ref_watch.Stop();
            Console.WriteLine("Result:");
            Console.WriteLine(result);
            Console.WriteLine("Extreme Library Multiplication Time: {0} us", (double)ref_watch.ElapsedTicks / Stopwatch.Frequency * 1000000);


            // Interleave CISR Value and Column Indices into single array
            int num_nonzeros = cisr_values.Length;

            uint[] cisr_data = new uint[2 * num_nonzeros];
            for (int i = 0; i < num_nonzeros; i++)
            {
                cisr_data[2 * i]     = cisr_values[i];
                cisr_data[2 * i + 1] = cisr_column_indices[i];
            }

            // Connect to FPGA
            FPGA.UpdateDeviceList();
            FPGA.OpenDevice(0);
            FPGA.watch.Start();

            // Transfer Row Lengths
            fixed(uint *data = cisr_row_lengths)
            {
                FPGA.BlockArrayWrite(1, data, (uint)cisr_row_lengths.Length);
            }

            FPGA.SendRowDoneTrigger();

            // Transfer Interleaved CISR Data
            fixed(uint *data = cisr_data)
            {
                FPGA.BlockArrayWrite(2, data, (uint)cisr_data.Length);
            }

            while (true)
            {
                ;
            }
        }
Beispiel #10
0
        public const int ViewMargin = 100;//边距100

        public ShowViewPanel(TreeNode node)
        {
            //初始化成员变量
            this.DoubleBuffered = true;//重绘双缓冲开启,防止界面闪烁
            base.AutoScroll     = true;
            _treeNode           = node;
            NodeInfo info = (NodeInfo)node.Tag;

            FormType    = info._formType;
            ZoomFactor  = 1;
            _viewOffset = new PointF();

            switch (FormType)
            {
            case Princeple.FormType.PPC:
                PPC ppc = ModelFactory <PPC> .CreateByName(node.Text);

                ShowView = new PPCViewModel(ppc);
                break;

            case Princeple.FormType.FPGA:
                FPGA fpga = ModelFactory <FPGA> .CreateByName(node.Text);

                ShowView = new FPGAViewModel(fpga);
                break;

            case Princeple.FormType.ZYNQ:
                ZYNQ zynq = ModelFactory <ZYNQ> .CreateByName(node.Text);

                ShowView = new ZYNQViewModel(zynq);
                break;

            case Princeple.FormType.BOARD:
                Board board = ModelFactory <Board> .CreateByName(node.Text);

                ShowView = new BoardViewModel(board);
                break;

            case Princeple.FormType.BACKPLANE:
                BackPlane bp = ModelFactory <BackPlane> .CreateByName(node.Text);

                ShowView = new BackPlaneViewModel(bp);
                break;

            case Princeple.FormType.CONTIANER:
                Container ctn = ModelFactory <Container> .CreateByName(node.Text);

                ShowView = new ContainerViewModel(ctn);
                break;

            case Princeple.FormType.COMPONENT:
                Component cmp = ModelFactory <Component> .CreateByName(node.Text);

                ShowView = new ComponentViewModel(cmp);
                break;

            case Princeple.FormType.SYSTEM:
                SystemStru sys = ModelFactory <SystemStru> .CreateByName(node.Text);

                ShowView = new SystemStruViewModel(sys);
                break;

            case Princeple.FormType.TOPO:
                var        sysName = node.Text.Substring(node.Text.IndexOf(':') + 1);
                SystemStru sys2    = ModelFactory <SystemStru> .CreateByName(sysName);

                ShowView = new StaticTopo(sys2);
                break;

            case Princeple.FormType.APP:
                var        sysNode  = node.Parent.Nodes[0];
                var        sysSName = sysNode.Text.Substring(sysNode.Text.IndexOf(':') + 1);
                SystemStru sys3     = ModelFactory <SystemStru> .CreateByName(sysSName);

                var sysStatic = new StaticTopo(sys3);

                ShowView = new DynamicTopo(sysStatic);
                ((DynamicTopo)ShowView).Components = (GetNodeCmps(node));
                break;

            case Princeple.FormType.STATUS:
                ShowView = new Status();
                break;

            default:    //无对应界面类型退出
                return;
            }
            SetViewSize();

            //绑定界面点击事件的处理
            if (ShowView as IDrawerChoosed != null)
            {
                this.MouseClick += new MouseEventHandler(((IDrawerChoosed)ShowView).MouseEventHandler);
            }
            if (ShowView as IDrawerNotify != null)
            {
                info.NodeInfoChanged += new Action <TargetNode>(((IDrawerNotify)ShowView).OnNodeInfoChanged);
            }
            ShowView.RedrawRequst += new Action(OnShowViewRedrawRequst);
            this.Scroll           += new ScrollEventHandler(ShowViewPanel_Scroll);
            this.MouseWheel       += new MouseEventHandler(ShowViewPanel_MouseWheel);
        }
 public Component_FPGAInitForm(FPGA fpga)
     : base(fpga)
 {
     base.Text = fpga.Name;
 }