Esempio n. 1
0
        private async void Computation()
        {
            await Tick;

            Rdy.Next = '0';
            while (true)
            {
                ProgramFlow.DoNotUnroll();
                int a    = A.Cur.IntValue;
                int b    = B.Cur.IntValue;
                int sum  = a + b;
                int diff = a - b;
                int prod = a * b;
                int quot = a / b;
                ProgramFlow.IOBarrier();
                Rdy.Next  = '1';
                Sum.Next  = StdLogicVector.FromInt(sum, 32);
                Diff.Next = StdLogicVector.FromInt(diff, 32);
                Prod.Next = StdLogicVector.FromInt(prod, 32);
                Quot.Next = StdLogicVector.FromInt(quot, 32);
                await Tick;
                ProgramFlow.IOBarrier();
                Rdy.Next = '0';
                await Tick;
            }
        }
Esempio n. 2
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.DoNotUnroll();
                ProgramFlow.IOBarrier();
                Rdy.Next = '0';
                int i = 0;
                int j = 0;
                while (i++ < 10)
                {
                    ProgramFlow.DoNotUnroll();
                    j += i;
                    if (j < 8)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                Z.Next = StdLogicVector.FromInt(j, 32);
                await 63.Ticks();
                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                ProgramFlow.IOBarrier();
                await Tick;
            }
        }
Esempio n. 3
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.DoNotUnroll();

                Rdy.Next = '0';
                ProgramFlow.IOBarrier();

                // y^('')-mu(1-y^2)y^'+y=0.
                double dt = Dt.Cur.ToDouble();
                double mu = Mu.Cur.ToDouble();
                _y[2]  = mu * (1 - _y[0] * _y[0]) * _y[1] - _y[0];
                _y[0] += _y[1] * dt;
                _y[1] += _y[2] * dt;
                await 39.Ticks();
                Y.Next       = _y[0].ToSLV();
                Ydot.Next    = _y[1].ToSLV();
                Ydotdot.Next = _y[2].ToSLV();
                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                await Tick;
                ProgramFlow.IOBarrier();
            }
        }
Esempio n. 4
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.DoNotUnroll();
                ProgramFlow.IOBarrier();
                Rdy.Next = '0';
                Sin.Next = (Math.Sin(X.Cur.ToDouble())).ToSLV();
                Cos.Next = (Math.Cos(X.Cur.ToDouble())).ToSLV();
                await 63.Ticks();
                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                ProgramFlow.IOBarrier();
                await Tick;
            }
        }
Esempio n. 5
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.DoNotUnroll();
                ProgramFlow.IOBarrier();
                Rdy.Next   = '0';
                Sqrt1.Next = MathExt.Sqrt(UFix.FromUnsigned(X1.Cur.UnsignedValue, _fracWidth)).SLVValue;
                Sqrt2.Next = MathExt.Sqrt(UFix.FromUnsigned(X2.Cur.UnsignedValue, _fracWidth)).SLVValue;
                await NTicks(63);

                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                ProgramFlow.IOBarrier();
                await Tick;
            }
        }
Esempio n. 6
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.DoNotUnroll();
                ProgramFlow.IOBarrier();
                Rdy.Next = '0';
                var sincos = MathExt.ScSinCos(SFix.FromSigned(X.Cur.SignedValue, _xFracWidth), _yFracWidth);
                Cos.Next = sincos.Item1.SLVValue;
                Sin.Next = sincos.Item2.SLVValue;
                await 12.Ticks();
                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                ProgramFlow.IOBarrier();
                await Tick;
            }
        }
Esempio n. 7
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.DoNotUnroll();
                ProgramFlow.IOBarrier();
                Rdy.Next = '0';
                int x = X.Cur.IntValue;
                int y = Y.Cur.IntValue;
                int z;
                if (x == 0)
                {
                    z = y;
                }
                else
                {
                    while (y != 0)
                    {
                        ProgramFlow.DoNotUnroll();

                        if (x > y)
                        {
                            x -= y;
                        }
                        else
                        {
                            y -= x;
                        }
                    }
                    z = x;
                }
                Z.Next = StdLogicVector.FromInt(z, 32);
                await 63.Ticks();
                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                ProgramFlow.IOBarrier();
                await Tick;
            }
        }
Esempio n. 8
0
        private async void Computation()
        {
            await Tick;

            while (true)
            {
                ProgramFlow.IOBarrier();
                Rdy.Next  = '0';
                Sum.Next  = StdLogicVector.FromInt(A.Cur.IntValue + B.Cur.IntValue, 32);
                Diff.Next = StdLogicVector.FromInt(A.Cur.IntValue - B.Cur.IntValue, 32);
                Prod.Next = StdLogicVector.FromInt(A.Cur.IntValue * B.Cur.IntValue, 32);
                Quot.Next = StdLogicVector.FromInt(B.Cur.IntValue / A.Cur.IntValue, 32);
                Neg.Next  = StdLogicVector.FromInt(-A.Cur.IntValue, 32);
                Abs.Next  = StdLogicVector.FromInt(Math.Abs(A.Cur.IntValue), 32);
                //await 9.Ticks();
                await NTicks(9);

                ProgramFlow.IOBarrier();
                Rdy.Next = '1';
                ProgramFlow.IOBarrier();
                await Tick;
            }
        }
Esempio n. 9
0
        protected async void MasterWrite(StdLogicVector addr, StdLogicVector data)
        {
            ip2bus_mstrd_req.Next       = '0';
            ip2bus_mstwr_req.Next       = '1';
            ip2bus_mst_type.Next        = '0';
            ip2bus_mst_addr.Next        = addr;
            ip2bus_mst_be.Next          = StdLogicVector._1s(NativeDataWidth / 8);
            ip2bus_mst_length.Next      = StdLogicVector._0s(LengthWidth);
            ip2bus_mst_lock.Next        = '0';
            ip2bus_mst_reset.Next       = '0';
            ip2bus_mstwr_d.Next         = data;
            ip2bus_mstwr_rem.Next       = StdLogicVector._0s(NativeDataWidth / 8);
            ip2bus_mstwr_sof_n.Next     = '0';
            ip2bus_mstwr_eof_n.Next     = '0';
            ip2bus_mstwr_src_rdy_n.Next = '0';
            ip2bus_mstwr_src_dsc_n.Next = '1';
            do
            {
                await Tick;
            } while (bus2ip_mst_cmdack.Cur != '1');
            do
            {
                ip2bus_mstwr_req.Next = '0';
                if (bus2ip_mstwr_dst_rdy_n.Cur == '0')
                {
                    break;
                }
                await Tick;
            } while (true);
            ip2bus_mstwr_src_rdy_n.Next = '1';
            ip2bus_mstwr_sof_n.Next     = '1';
            ip2bus_mstwr_eof_n.Next     = '1';
            await Tick;

            ProgramFlow.IOBarrier();
        }