public FPUWrapper(EISEVersion iseVer)
 {
     var a = new SLVSignal(32);
     var b = new SLVSignal(32);
     var r = new SLVSignal(32);
     var clk = new SLSignal();
     _fpu = new FloatingPointCore()
     {
         A = a,
         B = b,
         Clk = clk,
         Result = r,
         DSP48EUsage = FloatingPointCore.EDSP48EUsage.FullUsage,
         Function = FloatingPointCore.EFunction.AddSubtract,
         TargetDeviceFamily = SystemSharp.Interop.Xilinx.EDeviceFamily.Virtex6,
         UseMaximumLatency = true,
         Precision = FloatingPointCore.EPrecision.Single,
         ResultPrecision = FloatingPointCore.EPrecision.Single,
         AddSubSel = FloatingPointCore.EAddSub.Add,
         TargetISEVersion = iseVer
     };
     Clk = clk;
     A = a;
     B = b;
     R = r;
 }
Ejemplo n.º 2
0
        public FPUWrapper(EISEVersion iseVer)
        {
            var a   = new SLVSignal(32);
            var b   = new SLVSignal(32);
            var r   = new SLVSignal(32);
            var clk = new SLSignal();

            _fpu = new FloatingPointCore()
            {
                A                  = a,
                B                  = b,
                Clk                = clk,
                Result             = r,
                DSP48EUsage        = FloatingPointCore.EDSP48EUsage.FullUsage,
                Function           = FloatingPointCore.EFunction.AddSubtract,
                TargetDeviceFamily = SystemSharp.Interop.Xilinx.EDeviceFamily.Virtex6,
                UseMaximumLatency  = true,
                Precision          = FloatingPointCore.EPrecision.Single,
                ResultPrecision    = FloatingPointCore.EPrecision.Single,
                AddSubSel          = FloatingPointCore.EAddSub.Add,
                TargetISEVersion   = iseVer
            };
            Clk = clk;
            A   = a;
            B   = b;
            R   = r;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructs a new testbechn.
        /// </summary>
        /// <param name="userLogic">component under test</param>
        public AXILiteSlaveUserLogicTestbench(AXILiteSlaveUserLogic userLogic)
        {
            user_logic = userLogic;

            _sig_Bus2IP_Clk = new SLSignal();
            _sig_Bus2IP_Resetn = new SLSignal() { InitialValue = '0' };
            _sig_Bus2IP_Data = new SLVSignal(userLogic.SLVDWidth) { InitialValue = StdLogicVector.Xs(userLogic.SLVDWidth) };
            _sig_Bus2IP_BE = new SLVSignal(userLogic.SLVDWidth / 8) { InitialValue = StdLogicVector._0s(userLogic.SLVDWidth / 8) };
            _sig_Bus2IP_RdCE = new SLVSignal(userLogic.NumRegs) { InitialValue = StdLogicVector._0s(userLogic.NumRegs) };
            _sig_Bus2IP_WrCE = new SLVSignal(userLogic.NumRegs) { InitialValue = StdLogicVector._0s(userLogic.NumRegs) };
            _sig_IP2Bus_Data = new SLVSignal(userLogic.SLVDWidth) { InitialValue = StdLogicVector._0s(userLogic.SLVDWidth) };
            _sig_IP2Bus_RdAck = new SLSignal() { InitialValue = '0' };
            _sig_IP2Bus_WrAck = new SLSignal() { InitialValue = '0' };
            _sig_IP2Bus_Error = new SLSignal() { InitialValue = '0' };

            userLogic.Bus2IP_Clk = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_BE = _sig_Bus2IP_BE;
            userLogic.Bus2IP_Clk = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_Data = _sig_Bus2IP_Data;
            userLogic.Bus2IP_RdCE = _sig_Bus2IP_RdCE;
            userLogic.Bus2IP_Resetn = _sig_Bus2IP_Resetn;
            userLogic.Bus2IP_WrCE = _sig_Bus2IP_WrCE;
            userLogic.IP2Bus_Data = _sig_IP2Bus_Data;
            userLogic.IP2Bus_Error = _sig_IP2Bus_Error;
            userLogic.IP2Bus_RdAck = _sig_IP2Bus_RdAck;
            userLogic.IP2Bus_WrAck = _sig_IP2Bus_WrAck;

            _clockGen = new Clock(new Time(10.0, ETimeUnit.ns))
            {
                Clk = _sig_Bus2IP_Clk
            };
        }
Ejemplo n.º 4
0
            public override void Establish(IAutoBinder binder)
            {
                if (_realized)
                {
                    return;
                }

                _addrBits = MathExt.CeilLog2(_array.ArrayObj.Length);
                _dataBits = Marshal.SerializeForHW(_array.ElementType.GetSampleInstance()).Size;

                _clkI     = (SLSignal)binder.GetSignal(EPortUsage.Clock, "Clk", null, null);
                _dataOutI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "memIf_dataOut", null, StdLogicVector._0s(_dataBits));
                _addrI    = (SLVSignal)binder.GetSignal(EPortUsage.Default, "memIf_addr", null, StdLogicVector._0s(_addrBits));
                _clk      = _clkI.Descriptor;
                _addr     = _addrI.Descriptor;
                _dataOut  = _dataOutI.Descriptor;

                if (NeedWriteAccess)
                {
                    _wrEnI   = (SLSignal)binder.GetSignal(EPortUsage.Default, "memIf_wrEn", null, StdLogic._0);
                    _dataInI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "memIf_dataIn", null, StdLogicVector._0s(_dataBits));
                    _wrEn    = _wrEnI.Descriptor;
                    _dataIn  = _dataInI.Descriptor;
                }

                var memIfBuilder = new MemIfBuilder(this);
                var memIfAlg     = memIfBuilder.GetAlgorithm();

                memIfAlg.Name = "MemIf";
                binder.CreateProcess(Process.EProcessKind.Triggered, memIfAlg, _clk);

                _realized = true;
            }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructs a new testbechn.
        /// </summary>
        /// <param name="userLogic">component under test</param>
        public AXILiteSlaveUserLogicTestbench(AXILiteSlaveUserLogic userLogic)
        {
            user_logic = userLogic;

            _sig_Bus2IP_Clk    = new SLSignal();
            _sig_Bus2IP_Resetn = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_Bus2IP_Data = new SLVSignal(userLogic.SLVDWidth)
            {
                InitialValue = StdLogicVector.Xs(userLogic.SLVDWidth)
            };
            _sig_Bus2IP_BE = new SLVSignal(userLogic.SLVDWidth / 8)
            {
                InitialValue = StdLogicVector._0s(userLogic.SLVDWidth / 8)
            };
            _sig_Bus2IP_RdCE = new SLVSignal(userLogic.NumRegs)
            {
                InitialValue = StdLogicVector._0s(userLogic.NumRegs)
            };
            _sig_Bus2IP_WrCE = new SLVSignal(userLogic.NumRegs)
            {
                InitialValue = StdLogicVector._0s(userLogic.NumRegs)
            };
            _sig_IP2Bus_Data = new SLVSignal(userLogic.SLVDWidth)
            {
                InitialValue = StdLogicVector._0s(userLogic.SLVDWidth)
            };
            _sig_IP2Bus_RdAck = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_IP2Bus_WrAck = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_IP2Bus_Error = new SLSignal()
            {
                InitialValue = '0'
            };

            userLogic.Bus2IP_Clk    = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_BE     = _sig_Bus2IP_BE;
            userLogic.Bus2IP_Clk    = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_Data   = _sig_Bus2IP_Data;
            userLogic.Bus2IP_RdCE   = _sig_Bus2IP_RdCE;
            userLogic.Bus2IP_Resetn = _sig_Bus2IP_Resetn;
            userLogic.Bus2IP_WrCE   = _sig_Bus2IP_WrCE;
            userLogic.IP2Bus_Data   = _sig_IP2Bus_Data;
            userLogic.IP2Bus_Error  = _sig_IP2Bus_Error;
            userLogic.IP2Bus_RdAck  = _sig_IP2Bus_RdAck;
            userLogic.IP2Bus_WrAck  = _sig_IP2Bus_WrAck;

            _clockGen = new Clock(new Time(10.0, ETimeUnit.ns))
            {
                Clk = _sig_Bus2IP_Clk
            };
        }
Ejemplo n.º 6
0
        private void CreateState(int ncsteps)
        {
            int pcWidth = MathExt.CeilLog2(ncsteps);

            _pc      = (SLVSignal)_binder.GetSignal(EPortUsage.State, "State", null, StdLogicVector._0s(pcWidth));
            _altAddr = (SLVSignal)_binder.GetSignal(EPortUsage.Default, "BCU_AltAddr", null, StdLogicVector._0s(pcWidth));
            _rdEn    = (SLSignal)_binder.GetSignal(EPortUsage.Default, "ROM_RdEn", null, StdLogic._1);
            _brP     = (SLVSignal)_binder.GetSignal <StdLogicVector>(EPortUsage.Default, "BCU_BrP", null, "0");
            _brN     = (SLVSignal)_binder.GetSignal <StdLogicVector>(EPortUsage.Default, "BCU_BrN", null, "1");
            _rst     = (SLSignal)_binder.GetSignal(EPortUsage.Default, "BCU_Rst", null, StdLogic._1);
        }
Ejemplo n.º 7
0
        public void CreateStagedDecoder(IAutoBinder binder, SLVSignal cwSignal, SLSignal clkSignal, bool registered)
        {
            var       valWordInit   = StdLogicVector._0s(_vcf.ValueWordWidth);
            var       rcwSignal     = (SLVSignal)binder.GetSignal(EPortUsage.Default, "D1_CW", null, valWordInit);
            var       rcwSignalDesc = rcwSignal.Descriptor;
            SLVSignal rrcwSignal    = null;

            if (registered)
            {
                rrcwSignal = (SLVSignal)binder.GetSignal(EPortUsage.Default, "D2_CW", null, valWordInit);
            }

            var syncBuilder = new DefaultAlgorithmBuilder();

            syncBuilder.If(clkSignal.ToSignalRef(SignalRef.EReferencedProperty.RisingEdge));

            syncBuilder.Store(rcwSignal.ToSignalRef(SignalRef.EReferencedProperty.Next),
                              ((ISignal)cwSignal[_vcf.ValueWordWidth - 1, 0]).ToSignalRef(SignalRef.EReferencedProperty.Cur));
            if (registered)
            {
                syncBuilder.Store(rrcwSignal.ToSignalRef(SignalRef.EReferencedProperty.Next),
                                  rcwSignal.ToSignalRef(SignalRef.EReferencedProperty.Cur));
            }

            foreach (var ms in _strings)
            {
                ms.AssembleStagedDecoderSync(binder, syncBuilder, cwSignal, registered);
            }
            syncBuilder.EndIf();
            var syncFunc = syncBuilder.Complete();

            syncFunc.Name = "cwdecode_sync";
            binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, syncFunc, clkSignal.Descriptor);

            var combBuilder = new DefaultAlgorithmBuilder();
            var sensitivity = new HashSet <ISignalOrPortDescriptor>();

            sensitivity.Add(cwSignal.Descriptor);
            sensitivity.Add(rcwSignalDesc);
            if (registered)
            {
                sensitivity.Add(rrcwSignal.Descriptor);
            }
            foreach (var ms in _strings)
            {
                ms.AssembleStagedDecoderComb(combBuilder, registered ? rrcwSignal : rcwSignal, sensitivity, registered);
            }
            var combFunc = combBuilder.Complete();

            combFunc.Name = "cwdecode_comb";
            binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, combFunc, sensitivity.ToArray());
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Maps a signal to a register.
 /// </summary>
 /// <param name="sig">signal to map</param>
 /// <param name="mode">register access</param>
 /// <param name="reg">register idnex</param>
 /// <param name="startBit">bit offset in register</param>
 protected void MapSignal(SLSignal sig, EAccessMode mode, int reg, int startBit)
 {
     if (mode != EAccessMode.Read)
     {
         _writeBits[reg, startBit] = sig;
         _writeSignals.Add(sig);
     }
     if (mode != EAccessMode.Write)
     {
         _readBits[reg, startBit] = sig;
         _readSignals.Add(sig);
     }
 }
Ejemplo n.º 9
0
        public Mod2TestDesign(int inIntWidth, int fracWidth, int outIntWidth)
        {
            _clk = new SLSignal();
            _x = new SLVSignal(inIntWidth + fracWidth) { InitialValue = StdLogicVector._0s(inIntWidth + fracWidth) };
            _r = new SLVSignal(outIntWidth + fracWidth) { InitialValue = StdLogicVector._0s(outIntWidth + fracWidth) };

            _clkGen = new Clock(new Time(10.0, ETimeUnit.ns));
            Bind(() => _clkGen.Clk = _clk);

            _mod2 = new FixFPMod1(inIntWidth, fracWidth, outIntWidth)
            {
                X = _x,
                R = _r
            };
        }
        private void updateSignalInfo()
        {
            lvSignals.Items.Clear();
            SLTestCase testCase =
                outputsTestSuites[lvOutputs.SelectedItems[0].SubItems[2].Text][lvTestCases.SelectedIndices[0]];
            SLSignal signal = testCase.inputSignals[cmbInputVars.SelectedItem.ToString()];

            for (int i = 0; i < signal.signalStepTimes.Count - 1; ++i)
            {
                String[] items = new String[2];
                items[0] = signal.signalStepTimes[i].ToString();
                items[1] = signal.signalValues[i].ToString();
                ListViewItem listViewItem = new ListViewItem(items);
                lvSignals.Items.Add(listViewItem);
            }
        }
Ejemplo n.º 11
0
        public override void Establish(IAutoBinder binder)
        {
            if (_established)
            {
                return;
            }

            _clk        = binder.GetSignal(EPortUsage.Clock, null, null, null).Descriptor;
            _enI        = (SLSignal)binder.GetSignal(EPortUsage.Default, _port.Name + "_en", null, StdLogic._1);
            _en         = _enI.Descriptor;
            _slvSignalI = (SLVSignal)binder.GetSignal(EPortUsage.Default, _port.Name + "_in", null, StdLogicVector._0s(_dataWidth));
            _slvSignal  = _slvSignalI.Descriptor;
            var templ = new ConvProcessBuilder(this);
            var alg   = templ.GetAlgorithm();

            binder.CreateProcess(Process.EProcessKind.Triggered, alg, _clk, _en);

            _established = true;
        }
Ejemplo n.º 12
0
        public Mod2TestDesign(int inIntWidth, int fracWidth, int outIntWidth)
        {
            _clk = new SLSignal();
            _x   = new SLVSignal(inIntWidth + fracWidth)
            {
                InitialValue = StdLogicVector._0s(inIntWidth + fracWidth)
            };
            _r = new SLVSignal(outIntWidth + fracWidth)
            {
                InitialValue = StdLogicVector._0s(outIntWidth + fracWidth)
            };

            _clkGen = new Clock(new Time(10.0, ETimeUnit.ns));
            Bind(() => _clkGen.Clk = _clk);

            _mod2 = new FixFPMod1(inIntWidth, fracWidth, outIntWidth)
            {
                X = _x,
                R = _r
            };
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates a signal implementation for a given initial value.
        /// The factory method automatically selects the most suitable signal, i.e. an <c>SLSignal</c> if <paramref name="initialValue"/>
        /// is of type <c>StdLogic</c>, <c>SLVSignal</c> if <paramref name="initialValue"/> is of type <c>StdLogicVector</c>, <c>Signal1D</c>
        /// if <paramref name="initialValue"/> is an array or just <c>Signal</c> otherwise.
        /// </summary>
        /// <param name="initialValue">desired initial value for created signal</param>
        public static SignalBase CreateInstance(object initialValue)
        {
            TypeDescriptor elemType = TypeDescriptor.GetTypeOf(initialValue);
            SignalBase     sinst;

            if (elemType.CILType.Equals(typeof(StdLogic)))
            {
                sinst = new SLSignal();
                sinst.InitialValueObject = initialValue;
            }
            else if (elemType.CILType.Equals(typeof(StdLogicVector)))
            {
                sinst = new SLVSignal(((StdLogicVector)initialValue).Size);
                sinst.InitialValueObject = initialValue;
            }
            else if (elemType.CILType.IsArray && elemType.CILType.GetArrayRank() == 1)
            {
                Array array       = (Array)initialValue;
                Type  subElemType = elemType.CILType.GetElementType();
                int   length      = array.GetLength(0);
                Array signalArray = Array.CreateInstance(typeof(Signal <>).MakeGenericType(subElemType), length);
                for (int i = 0; i < length; i++)
                {
                    signalArray.SetValue(CreateInstance(array.GetValue(i)), i);
                }
                sinst = (SignalBase)Activator.CreateInstance(
                    typeof(VSignal <>).MakeGenericType(subElemType), signalArray);
            }
            else if (elemType.CILType.IsArray)
            {
                throw new NotSupportedException("Signals of multi-dimensional arrays not supported");
            }
            else
            {
                sinst = (SignalBase)Activator.CreateInstance(typeof(Signal <>).MakeGenericType(elemType.CILType));
                sinst.InitialValueObject = initialValue;
            }
            return(sinst);
        }
Ejemplo n.º 14
0
        public ALUTestDesign(int awidth, int bwidth, int pipelineDepth)
        {
            _clk = new SLSignal();
            _a = new SLVSignal(awidth) { InitialValue = StdLogicVector._0s(awidth) };
            _b = new SLVSignal(bwidth) { InitialValue = StdLogicVector._0s(bwidth) };
            _ba = new SLVSignal(awidth) { InitialValue = StdLogicVector._0s(awidth) };

            _clkGen = new Clock(new Time(10.0, ETimeUnit.ns));
            Bind(() => _clkGen.Clk = _clk);

            _add = new ALU(ALU.EFunction.Add, ALU.EArithMode.Signed, pipelineDepth,
                awidth, bwidth, Math.Max(awidth, bwidth) + 1);
            Bind(() =>
            {
                _add.Clk = _clk;
                _add.A = _a;
                _add.B = _b;
                _add.R = _rAdd;
            });
            _rAdd = new SLVSignal(_add.RWidth);

            _sub = new ALU(ALU.EFunction.Sub, ALU.EArithMode.Signed, pipelineDepth,
                awidth, bwidth, Math.Max(awidth, bwidth) + 1);
            Bind(() =>
            {
                _sub.Clk = _clk;
                _sub.A = _a;
                _sub.B = _b;
                _sub.R = _rSub;
            });
            _rSub = new SLVSignal(_sub.RWidth);

            _mul = new ALU(ALU.EFunction.Mul, ALU.EArithMode.Signed, pipelineDepth,
                awidth, bwidth, awidth + bwidth);
            Bind(() =>
            {
                _mul.Clk = _clk;
                _mul.A = _a;
                _mul.B = _b;
                _mul.R = _rMul;
            });
            _rMul = new SLVSignal(_mul.RWidth);

            _neg = new ALU(ALU.EFunction.Neg, ALU.EArithMode.Signed, pipelineDepth,
                awidth, 0, awidth + 1);
            Bind(() =>
            {
                _neg.Clk = _clk;
                _neg.A = _a;
                _neg.R = _rNeg;
            });
            _rNeg = new SLVSignal(_neg.RWidth);

            _not = new ALU(ALU.EFunction.Not, ALU.EArithMode.Signed, pipelineDepth,
                awidth, 0, awidth);
            Bind(() =>
            {
                _not.Clk = _clk;
                _not.A = _a;
                _not.R = _rNot;
            });
            _rNot = new SLVSignal(_not.RWidth);

            _and = new ALU(ALU.EFunction.And, ALU.EArithMode.Signed, pipelineDepth,
                awidth, awidth, awidth);
            Bind(() =>
            {
                _and.Clk = _clk;
                _and.A = _a;
                _and.B = _ba;
                _and.R = _rAnd;
            });
            _rAnd = new SLVSignal(_and.RWidth);

            _or = new ALU(ALU.EFunction.Or, ALU.EArithMode.Signed, pipelineDepth,
                awidth, awidth, awidth);
            Bind(() =>
            {
                _or.Clk = _clk;
                _or.A = _a;
                _or.B = _ba;
                _or.R = _rOr;
            });
            _rOr = new SLVSignal(_or.RWidth);
        }
Ejemplo n.º 15
0
            public override void Establish(IAutoBinder binder)
            {
                if (_realized)
                    return;

                object constValue;
                var literal = (Literal)_literal;
                if (literal.IsConst(out constValue))
                {
                    var slv = Marshal.SerializeForHW(constValue);
                    _dataOutI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "constSignal_" + constValue.ToString(), null, slv);
                    _dataOut = _dataOutI.Descriptor;
                }
                else
                {
                    bool needRead = true, needWrite = true;
                    var fref = _literal as FieldRef;
                    if (fref != null)
                    {
                        needRead = fref.FieldDesc.IsReadInCurrentContext(Host.Context);
                        needWrite = fref.FieldDesc.IsWrittenInCurrentContext(Host.Context);
                    }

                    var stlit = (IStorableLiteral)_literal;
                    string name = stlit.Name;
                    var valueSample = _literal.Type.GetSampleInstance();
                    _dataBits = Marshal.SerializeForHW(valueSample).Size;

                    _clkI = (SLSignal)binder.GetSignal(EPortUsage.Clock, null, null, null);
                    _clk = _clkI.Descriptor;
                    if (needWrite)
                    {
                        _wrEnI = (SLSignal)binder.GetSignal(EPortUsage.Default, name + "_wrEn", null, StdLogic._0);
                        _wrEn = _wrEnI.Descriptor;
                        _dataInI = (SLVSignal)binder.GetSignal(EPortUsage.Default, name + "_dataIn", null, StdLogicVector._0s(_dataBits));
                        _dataIn = _dataInI.Descriptor;
                    }
                    if (needRead)
                    {
                        _dataOutI = (SLVSignal)binder.GetSignal(EPortUsage.Default, name + "_dataOut", null, StdLogicVector._0s(_dataBits));
                        _dataOut = _dataOutI.Descriptor;
                    }

                    //var apb = new AccessProcessBuilder(this, needRead, needWrite);
                    //var alg = apb.GetAlgorithm();
                    //alg.Name = name + "_process";
                    //binder.CreateProcess(Process.EProcessKind.Triggered, alg, _clk);
                    CommonClockProcess ccp = null;
                    string algName = name + "_process";
                    if (Host.Descriptor.HasAttribute<CommonClockProcess>())
                    {
                        ccp = Host.Descriptor.QueryAttribute<CommonClockProcess>();
                        Host.Descriptor.RemoveChild(ccp.CCProc);
                    }
                    else
                    {
                        ccp = new CommonClockProcess(_clk);
                        Host.Descriptor.AddAttribute(ccp);
                    }
                    ccp.AddAccessor(this, needRead, needWrite);
                    var alg = ccp.FrameBuilder.Complete();
                    alg.Name = algName;
                    ccp.CCProc = binder.CreateProcess(Process.EProcessKind.Triggered, alg, _clk);
                }

                _realized = true;
            }
Ejemplo n.º 16
0
        public static void Run()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            GenTestData();

            Signal <float> in_real    = new Signal <float>();
            Signal <float> in_imag    = new Signal <float>();
            Signal <bool>  data_valid = new Signal <bool>();
            Signal <bool>  data_ack   = new Signal <bool>();
            Signal <float> out_real   = new Signal <float>();
            Signal <float> out_imag   = new Signal <float>();
            Signal <bool>  data_req   = new Signal <bool>();
            Signal <bool>  data_ready = new Signal <bool>();
            Signal <bool>  data_fin1  = new Signal <bool>();
            Signal <bool>  data_fin2  = new Signal <bool>();
            SLSignal       clk        = new SLSignal();

            Clock cgen = new Clock(new Time(10.0, ETimeUnit.ns), 0.5)
            {
                Clk = clk
            };
            FFT fft = new FFT()
            {
                CLK          = clk,
                in_real      = in_real,
                in_imag      = in_imag,
                data_valid   = data_valid,
                data_ack     = data_ack,
                out_real     = out_real,
                out_imag     = out_imag,
                data_req     = data_req,
                data_ready   = data_ready,
                data_fin_in  = data_fin1,
                data_fin_out = data_fin2
            };
            Source source = new Source()
            {
                RealPath = "in_real.large",
                ImagPath = "in_imag.large",

                data_req   = data_req,
                out_real   = in_real,
                out_imag   = in_imag,
                data_valid = data_valid,
                data_fin   = data_fin1,
                CLK        = clk
            };
            Sink sink = new Sink()
            {
                RealPath = "out_real.large",
                ImagPath = "out_imag.large",

                data_ready = data_ready,
                data_ack   = data_ack,
                in_real    = out_real,
                in_imag    = out_imag,
                data_fin   = data_fin2,
                CLK        = clk
            };

            DesignContext.Instance.Elaborate();
            Log.Verbose = true;
            long startTicks = DateTime.Now.Ticks;

            DesignContext.Instance.Simulate(long.MaxValue);
            long   endTicks   = DateTime.Now.Ticks;
            double durationMS = (double)(endTicks - startTicks) / 10000.0;

            Console.WriteLine("Analysis took " + durationMS + "ms");
        }
Ejemplo n.º 17
0
        public void CreateStagedDecoder(IAutoBinder binder, SLVSignal cwSignal, SLSignal clkSignal, bool registered)
        {
            var valWordInit = StdLogicVector._0s(_vcf.ValueWordWidth);
            var rcwSignal = (SLVSignal)binder.GetSignal(EPortUsage.Default, "D1_CW", null, valWordInit);
            var rcwSignalDesc = rcwSignal.Descriptor;
            SLVSignal rrcwSignal = null;
            if (registered)
            {
                rrcwSignal = (SLVSignal)binder.GetSignal(EPortUsage.Default, "D2_CW", null, valWordInit);
            }

            var syncBuilder = new DefaultAlgorithmBuilder();
            syncBuilder.If(clkSignal.ToSignalRef(SignalRef.EReferencedProperty.RisingEdge));

            syncBuilder.Store(rcwSignal.ToSignalRef(SignalRef.EReferencedProperty.Next),
                ((ISignal)cwSignal[_vcf.ValueWordWidth - 1, 0]).ToSignalRef(SignalRef.EReferencedProperty.Cur));
            if (registered)
            {
                syncBuilder.Store(rrcwSignal.ToSignalRef(SignalRef.EReferencedProperty.Next),
                    rcwSignal.ToSignalRef(SignalRef.EReferencedProperty.Cur));
            }

            foreach (var ms in _strings)
            {
                ms.AssembleStagedDecoderSync(binder, syncBuilder, cwSignal, registered);
            }
            syncBuilder.EndIf();
            var syncFunc = syncBuilder.Complete();
            syncFunc.Name = "cwdecode_sync";
            binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, syncFunc, clkSignal.Descriptor);

            var combBuilder = new DefaultAlgorithmBuilder();
            var sensitivity = new HashSet<ISignalOrPortDescriptor>();
            sensitivity.Add(cwSignal.Descriptor);
            sensitivity.Add(rcwSignalDesc);
            if (registered)
                sensitivity.Add(rrcwSignal.Descriptor);
            foreach (var ms in _strings)
            {
                ms.AssembleStagedDecoderComb(combBuilder, registered ? rrcwSignal : rcwSignal, sensitivity, registered);
            }
            var combFunc = combBuilder.Complete();
            combFunc.Name = "cwdecode_comb";
            binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, combFunc, sensitivity.ToArray());
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates an instance.
        /// </summary>
        /// <param name="userLogic">component under test</param>
        public AXIMasterUserLogicTestbench(AXIMasterUserLogic userLogic)
        {
            user_logic = userLogic;

            _sig_Bus2IP_Clk = new SLSignal();
            _sig_Bus2IP_Resetn = new SLSignal() { InitialValue = '0' };
            _sig_Bus2IP_Data = new SLVSignal(userLogic.SLVDWidth) { InitialValue = StdLogicVector.Xs(userLogic.SLVDWidth) };
            _sig_Bus2IP_BE = new SLVSignal(userLogic.SLVDWidth / 8) { InitialValue = StdLogicVector._0s(userLogic.SLVDWidth / 8) };
            _sig_Bus2IP_RdCE = new SLVSignal(userLogic.NumRegs) { InitialValue = StdLogicVector._0s(userLogic.NumRegs) };
            _sig_Bus2IP_WrCE = new SLVSignal(userLogic.NumRegs) { InitialValue = StdLogicVector._0s(userLogic.NumRegs) };
            _sig_IP2Bus_Data = new SLVSignal(userLogic.SLVDWidth) { InitialValue = StdLogicVector._0s(userLogic.SLVDWidth) };
            _sig_IP2Bus_RdAck = new SLSignal() { InitialValue = '0' };
            _sig_IP2Bus_WrAck = new SLSignal() { InitialValue = '0' };
            _sig_IP2Bus_Error = new SLSignal() { InitialValue = '0' };
            _sig_ip2bus_mstrd_req = new SLSignal() { InitialValue = '0' };
            _sig_ip2bus_mstwr_req = new SLSignal() { InitialValue = '0' };
            _sig_ip2bus_mst_addr = new SLVSignal(userLogic.MasterAXIAddrWidth) { InitialValue = StdLogicVector.Us(userLogic.MasterAXIAddrWidth) };
            _sig_ip2bus_mst_be = new SLVSignal(userLogic.NativeDataWidth/8) { InitialValue = StdLogicVector._1s(userLogic.NativeDataWidth/8) };
            _sig_ip2bus_mst_length = new SLVSignal(userLogic.LengthWidth) { InitialValue = StdLogicVector._0s(userLogic.LengthWidth) };
            _sig_ip2bus_mst_type = new SLSignal() { InitialValue = '0' };
            _sig_ip2bus_mst_lock = new SLSignal() { InitialValue = '0' };
            _sig_ip2bus_mst_reset = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mst_cmdack = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mst_cmplt = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mst_error = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mst_rearbitrate = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mst_cmd_timeout = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mstrd_d = new SLVSignal(userLogic.NativeDataWidth);
            _sig_bus2ip_mstrd_rem = new SLVSignal(userLogic.NativeDataWidth / 8) { InitialValue = StdLogicVector._0s(userLogic.NativeDataWidth / 8) };
            _sig_bus2ip_mstrd_sof_n = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mstrd_eof_n = new SLSignal() { InitialValue = '0' };
            _sig_bus2ip_mstrd_src_rdy_n = new SLSignal() { InitialValue = '1' };
            _sig_bus2ip_mstrd_src_dsc_n = new SLSignal() { InitialValue = '1' };
            _sig_ip2bus_mstrd_dst_rdy_n = new SLSignal() { InitialValue = '1' };
            _sig_ip2bus_mstrd_dst_dsc_n = new SLSignal() { InitialValue = '1' };
            _sig_ip2bus_mstwr_d = new SLVSignal(userLogic.NativeDataWidth);
            _sig_ip2bus_mstwr_rem = new SLVSignal(userLogic.NativeDataWidth / 8) { InitialValue = StdLogicVector._0s(userLogic.NativeDataWidth / 8) };
            _sig_ip2bus_mstwr_src_rdy_n = new SLSignal() { InitialValue = '1' };
            _sig_ip2bus_mstwr_src_dsc_n = new SLSignal() { InitialValue = '1' };
            _sig_ip2bus_mstwr_sof_n = new SLSignal() { InitialValue = '1' };
            _sig_ip2bus_mstwr_eof_n = new SLSignal() { InitialValue = '1' };
            _sig_bus2ip_mstwr_dst_rdy_n = new SLSignal() { InitialValue = '1' };
            _sig_bus2ip_mstwr_dst_dsc_n = new SLSignal() { InitialValue = '1' };

            userLogic.Bus2IP_Clk = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_BE = _sig_Bus2IP_BE;
            userLogic.Bus2IP_Clk = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_Data = _sig_Bus2IP_Data;
            userLogic.Bus2IP_RdCE = _sig_Bus2IP_RdCE;
            userLogic.Bus2IP_Resetn = _sig_Bus2IP_Resetn;
            userLogic.Bus2IP_WrCE = _sig_Bus2IP_WrCE;
            userLogic.IP2Bus_Data = _sig_IP2Bus_Data;
            userLogic.IP2Bus_Error = _sig_IP2Bus_Error;
            userLogic.IP2Bus_RdAck = _sig_IP2Bus_RdAck;
            userLogic.IP2Bus_WrAck = _sig_IP2Bus_WrAck;
            userLogic.ip2bus_mstrd_req = _sig_ip2bus_mstrd_req;
            userLogic.ip2bus_mstwr_req = _sig_ip2bus_mstwr_req;
            userLogic.ip2bus_mst_addr = _sig_ip2bus_mst_addr;
            userLogic.ip2bus_mst_be = _sig_ip2bus_mst_be;
            userLogic.ip2bus_mst_length = _sig_ip2bus_mst_length;
            userLogic.ip2bus_mst_type = _sig_ip2bus_mst_type;
            userLogic.ip2bus_mst_lock = _sig_ip2bus_mst_lock;
            userLogic.ip2bus_mst_reset = _sig_ip2bus_mst_reset;
            userLogic.bus2ip_mst_cmdack = _sig_bus2ip_mst_cmdack;
            userLogic.bus2ip_mst_cmplt = _sig_bus2ip_mst_cmplt;
            userLogic.bus2ip_mst_error = _sig_bus2ip_mst_error;
            userLogic.bus2ip_mst_rearbitrate = _sig_bus2ip_mst_rearbitrate;
            userLogic.bus2ip_mst_cmd_timeout = _sig_bus2ip_mst_cmd_timeout;
            userLogic.bus2ip_mstrd_d = _sig_bus2ip_mstrd_d;
            userLogic.bus2ip_mstrd_rem = _sig_bus2ip_mstrd_rem;
            userLogic.bus2ip_mstrd_sof_n = _sig_bus2ip_mstrd_sof_n;
            userLogic.bus2ip_mstrd_eof_n = _sig_bus2ip_mstrd_eof_n;
            userLogic.bus2ip_mstrd_src_rdy_n = _sig_bus2ip_mstrd_src_rdy_n;
            userLogic.bus2ip_mstrd_src_dsc_n = _sig_bus2ip_mstrd_src_dsc_n;
            userLogic.ip2bus_mstrd_dst_rdy_n = _sig_ip2bus_mstrd_dst_rdy_n;
            userLogic.ip2bus_mstrd_dst_dsc_n = _sig_ip2bus_mstrd_dst_dsc_n;
            userLogic.ip2bus_mstwr_d = _sig_ip2bus_mstwr_d;
            userLogic.ip2bus_mstwr_rem = _sig_ip2bus_mstwr_rem;
            userLogic.ip2bus_mstwr_src_rdy_n = _sig_ip2bus_mstwr_src_rdy_n;
            userLogic.ip2bus_mstwr_src_dsc_n = _sig_ip2bus_mstwr_src_dsc_n;
            userLogic.ip2bus_mstwr_sof_n = _sig_ip2bus_mstwr_sof_n;
            userLogic.ip2bus_mstwr_eof_n = _sig_ip2bus_mstwr_eof_n;
            userLogic.bus2ip_mstwr_dst_rdy_n = _sig_bus2ip_mstwr_dst_rdy_n;
            userLogic.bus2ip_mstwr_dst_dsc_n = _sig_bus2ip_mstwr_dst_dsc_n;

            _clockGen = new Clock(new Time(10.0, ETimeUnit.ns))
            {
                Clk = _sig_Bus2IP_Clk
            };
        }
Ejemplo n.º 19
0
        public ALUTestDesign(int awidth, int bwidth, int pipelineDepth)
        {
            _clk = new SLSignal();
            _a   = new SLVSignal(awidth)
            {
                InitialValue = StdLogicVector._0s(awidth)
            };
            _b = new SLVSignal(bwidth)
            {
                InitialValue = StdLogicVector._0s(bwidth)
            };
            _ba = new SLVSignal(awidth)
            {
                InitialValue = StdLogicVector._0s(awidth)
            };

            _clkGen = new Clock(new Time(10.0, ETimeUnit.ns));
            Bind(() => _clkGen.Clk = _clk);

            _add = new ALU(ALU.EFunction.Add, ALU.EArithMode.Signed, pipelineDepth,
                           awidth, bwidth, Math.Max(awidth, bwidth) + 1);
            Bind(() =>
            {
                _add.Clk = _clk;
                _add.A   = _a;
                _add.B   = _b;
                _add.R   = _rAdd;
            });
            _rAdd = new SLVSignal(_add.RWidth);

            _sub = new ALU(ALU.EFunction.Sub, ALU.EArithMode.Signed, pipelineDepth,
                           awidth, bwidth, Math.Max(awidth, bwidth) + 1);
            Bind(() =>
            {
                _sub.Clk = _clk;
                _sub.A   = _a;
                _sub.B   = _b;
                _sub.R   = _rSub;
            });
            _rSub = new SLVSignal(_sub.RWidth);

            _mul = new ALU(ALU.EFunction.Mul, ALU.EArithMode.Signed, pipelineDepth,
                           awidth, bwidth, awidth + bwidth);
            Bind(() =>
            {
                _mul.Clk = _clk;
                _mul.A   = _a;
                _mul.B   = _b;
                _mul.R   = _rMul;
            });
            _rMul = new SLVSignal(_mul.RWidth);

            _neg = new ALU(ALU.EFunction.Neg, ALU.EArithMode.Signed, pipelineDepth,
                           awidth, 0, awidth + 1);
            Bind(() =>
            {
                _neg.Clk = _clk;
                _neg.A   = _a;
                _neg.R   = _rNeg;
            });
            _rNeg = new SLVSignal(_neg.RWidth);

            _not = new ALU(ALU.EFunction.Not, ALU.EArithMode.Signed, pipelineDepth,
                           awidth, 0, awidth);
            Bind(() =>
            {
                _not.Clk = _clk;
                _not.A   = _a;
                _not.R   = _rNot;
            });
            _rNot = new SLVSignal(_not.RWidth);

            _and = new ALU(ALU.EFunction.And, ALU.EArithMode.Signed, pipelineDepth,
                           awidth, awidth, awidth);
            Bind(() =>
            {
                _and.Clk = _clk;
                _and.A   = _a;
                _and.B   = _ba;
                _and.R   = _rAnd;
            });
            _rAnd = new SLVSignal(_and.RWidth);

            _or = new ALU(ALU.EFunction.Or, ALU.EArithMode.Signed, pipelineDepth,
                          awidth, awidth, awidth);
            Bind(() =>
            {
                _or.Clk = _clk;
                _or.A   = _a;
                _or.B   = _ba;
                _or.R   = _rOr;
            });
            _rOr = new SLVSignal(_or.RWidth);
        }
Ejemplo n.º 20
0
        public Dictionary <string, Dictionary <string, List <SLTestCase> > > LoadTestSuitesToSLTestWorkspace(string testWorkspaceName)
        {
            Dictionary <string, Dictionary <string, List <SLTestCase> > > testSuites =
                new Dictionary <string, Dictionary <string, List <SLTestCase> > >();
            string workspaceResultsPath = GetWorkspaceResultsPath(testWorkspaceName);

            if (!Directory.Exists(workspaceResultsPath))
            {
                return(testSuites);
            }
            XmlReaderSettings xmlSettings = new XmlReaderSettings();

            xmlSettings.ValidationType = ValidationType.None;

            List <string> criteriaDirectories = new List <string>(Directory.EnumerateDirectories(workspaceResultsPath));

            foreach (string criterionDirectory in criteriaDirectories)
            {
                int    startIndexOfCriDirName = criterionDirectory.LastIndexOf('\\');
                string criterionDirectoryName = criterionDirectory.Substring(startIndexOfCriDirName + 1);

                Dictionary <string, List <SLTestCase> > criterionTestSuites = new Dictionary <string, List <SLTestCase> >();
                List <string> outputDirectories = new List <string>(Directory.EnumerateDirectories(criterionDirectory));

                foreach (string outputDirectory in outputDirectories)
                {
                    int    startIndexOfOutDirName = outputDirectory.LastIndexOf('\\');
                    string outptuDirectoryName    = outputDirectory.Substring(startIndexOfOutDirName + 1);

                    List <SLTestCase> outputTestCases   = new List <SLTestCase>();
                    string            testSuiteFilePath = outputDirectory + "\\TestSuite.xml";
                    if (!File.Exists(testSuiteFilePath))
                    {
                        continue;
                    }
                    XmlReader workspaceReader = XmlReader.Create(
                        testSuiteFilePath, xmlSettings);
                    while (workspaceReader.Read())
                    {
                        if (workspaceReader.NodeType == XmlNodeType.Element &&
                            workspaceReader.Name == "TestCase")
                        {
                            SLTestCase slTestCase = new SLTestCase();
                            string     varName, varType;
                            while (workspaceReader.Read())
                            {
                                if (workspaceReader.NodeType == XmlNodeType.Element &&
                                    workspaceReader.Name == "Input")
                                {
                                    do
                                    {
                                        workspaceReader.Read();
                                    }while (workspaceReader.Name != "VarName");
                                    workspaceReader.Read();
                                    varName = workspaceReader.Value;
                                    do
                                    {
                                        workspaceReader.Read();
                                    }while (workspaceReader.Name != "Type");
                                    workspaceReader.Read();
                                    varType = workspaceReader.Value;

                                    if (varType.Equals("Input"))
                                    {
                                        do
                                        {
                                            workspaceReader.Read();
                                        }while (workspaceReader.Name != "NoSegments");
                                        workspaceReader.Read();
                                        int      noSegs   = Int16.Parse(workspaceReader.Value);
                                        SLSignal slSignal = new SLSignal();
                                        for (int i = 0; i <= noSegs; ++i)
                                        {
                                            do
                                            {
                                                workspaceReader.Read();
                                            }while (workspaceReader.Name != "StepTime");
                                            workspaceReader.Read();
                                            float stepTime = float.Parse(workspaceReader.Value);
                                            slSignal.signalStepTimes.Add(stepTime);

                                            do
                                            {
                                                workspaceReader.Read();
                                            }while (workspaceReader.Name != "Value");
                                            workspaceReader.Read();
                                            float sigValue = float.Parse(workspaceReader.Value);

                                            slSignal.signalValues.Add(sigValue);
                                        }
                                        slTestCase.inputSignals.Add(varName, slSignal);
                                    }
                                    else if (varType.Equals("Calibration"))
                                    {
                                        do
                                        {
                                            workspaceReader.Read();
                                        }while (workspaceReader.Name != "Value");
                                        workspaceReader.Read();
                                        slTestCase.calibrationVars.Add(varName, float.Parse(workspaceReader.Value));
                                    }
                                }
                                else if (workspaceReader.NodeType == XmlNodeType.EndElement &&
                                         workspaceReader.Name == "TestCase")
                                {
                                    outputTestCases.Add(slTestCase);
                                    break;
                                }
                            }
                        }
                    }
                    criterionTestSuites.Add(outptuDirectoryName, outputTestCases);
                }
                testSuites.Add(criterionDirectoryName, criterionTestSuites);
            }
            return(testSuites);
        }
Ejemplo n.º 21
0
            public override void Establish(IAutoBinder binder)
            {
                if (_realized)
                    return;

                _addrBits = MathExt.CeilLog2(_array.ArrayObj.Length);
                _dataBits = Marshal.SerializeForHW(_array.ElementType.GetSampleInstance()).Size;

                _clkI = (SLSignal)binder.GetSignal(EPortUsage.Clock, "Clk", null, null);
                _dataOutI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "memIf_dataOut", null, StdLogicVector._0s(_dataBits));
                _addrI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "memIf_addr", null, StdLogicVector._0s(_addrBits));
                _clk = _clkI.Descriptor;
                _addr = _addrI.Descriptor;
                _dataOut = _dataOutI.Descriptor;

                if (NeedWriteAccess)
                {
                    _wrEnI = (SLSignal)binder.GetSignal(EPortUsage.Default, "memIf_wrEn", null, StdLogic._0);
                    _dataInI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "memIf_dataIn", null, StdLogicVector._0s(_dataBits));
                    _wrEn = _wrEnI.Descriptor;
                    _dataIn = _dataInI.Descriptor;
                }

                var memIfBuilder = new MemIfBuilder(this);
                var memIfAlg = memIfBuilder.GetAlgorithm();
                memIfAlg.Name = "MemIf";
                binder.CreateProcess(Process.EProcessKind.Triggered, memIfAlg, _clk);

                _realized = true;
            }
Ejemplo n.º 22
0
        public static void Run()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

            GenTestData();

            Signal<float> in_real = new Signal<float>();
            Signal<float> in_imag = new Signal<float>();
            Signal<bool> data_valid = new Signal<bool>();
            Signal<bool> data_ack = new Signal<bool>();
            Signal<float> out_real = new Signal<float>();
            Signal<float> out_imag = new Signal<float>();
            Signal<bool> data_req = new Signal<bool>();
            Signal<bool> data_ready = new Signal<bool>();
            Signal<bool> data_fin1 = new Signal<bool>();
            Signal<bool> data_fin2 = new Signal<bool>();
            SLSignal clk = new SLSignal();

            Clock cgen = new Clock(new Time(10.0, ETimeUnit.ns), 0.5)
            {
                Clk = clk
            };
            FFT fft = new FFT()
            {
                CLK = clk,
                in_real = in_real,
                in_imag = in_imag,
                data_valid = data_valid,
                data_ack = data_ack,
                out_real = out_real,
                out_imag = out_imag,
                data_req = data_req,
                data_ready = data_ready,
                data_fin_in = data_fin1,
                data_fin_out = data_fin2
            };
            Source source = new Source()
            {
                RealPath = "in_real.large",
                ImagPath = "in_imag.large",

                data_req = data_req,
                out_real = in_real,
                out_imag = in_imag,
                data_valid = data_valid,
                data_fin = data_fin1,
                CLK = clk
            };
            Sink sink = new Sink()
            {
                RealPath = "out_real.large",
                ImagPath = "out_imag.large",

                data_ready = data_ready,
                data_ack = data_ack,
                in_real = out_real,
                in_imag = out_imag,
                data_fin = data_fin2,
                CLK = clk
            };

            DesignContext.Instance.Elaborate();
            Log.Verbose = true;
            long startTicks = DateTime.Now.Ticks;
            DesignContext.Instance.Simulate(long.MaxValue);
            long endTicks = DateTime.Now.Ticks;
            double durationMS = (double)(endTicks - startTicks) / 10000.0;
            Console.WriteLine("Analysis took " + durationMS + "ms");
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Maps a signal to a register.
 /// </summary>
 /// <param name="sig">signal to map</param>
 /// <param name="mode">register access</param>
 /// <param name="reg">register index</param>
 /// <param name="startBit">offset into register</param>
 protected void MapSignal(SLSignal sig, EAccessMode mode, int reg, int startBit)
 {
     if (mode != EAccessMode.Read)
     {
         _writeBits[reg, startBit] = sig;
         _writeSignals.Add(sig);
     }
     if (mode != EAccessMode.Write)
     {
         _readBits[reg, startBit] = sig;
         _readSignals.Add(sig);
     }
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Creates an instance.
        /// </summary>
        /// <param name="userLogic">component under test</param>
        public AXIMasterUserLogicTestbench(AXIMasterUserLogic userLogic)
        {
            user_logic = userLogic;

            _sig_Bus2IP_Clk    = new SLSignal();
            _sig_Bus2IP_Resetn = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_Bus2IP_Data = new SLVSignal(userLogic.SLVDWidth)
            {
                InitialValue = StdLogicVector.Xs(userLogic.SLVDWidth)
            };
            _sig_Bus2IP_BE = new SLVSignal(userLogic.SLVDWidth / 8)
            {
                InitialValue = StdLogicVector._0s(userLogic.SLVDWidth / 8)
            };
            _sig_Bus2IP_RdCE = new SLVSignal(userLogic.NumRegs)
            {
                InitialValue = StdLogicVector._0s(userLogic.NumRegs)
            };
            _sig_Bus2IP_WrCE = new SLVSignal(userLogic.NumRegs)
            {
                InitialValue = StdLogicVector._0s(userLogic.NumRegs)
            };
            _sig_IP2Bus_Data = new SLVSignal(userLogic.SLVDWidth)
            {
                InitialValue = StdLogicVector._0s(userLogic.SLVDWidth)
            };
            _sig_IP2Bus_RdAck = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_IP2Bus_WrAck = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_IP2Bus_Error = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_ip2bus_mstrd_req = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_ip2bus_mstwr_req = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_ip2bus_mst_addr = new SLVSignal(userLogic.MasterAXIAddrWidth)
            {
                InitialValue = StdLogicVector.Us(userLogic.MasterAXIAddrWidth)
            };
            _sig_ip2bus_mst_be = new SLVSignal(userLogic.NativeDataWidth / 8)
            {
                InitialValue = StdLogicVector._1s(userLogic.NativeDataWidth / 8)
            };
            _sig_ip2bus_mst_length = new SLVSignal(userLogic.LengthWidth)
            {
                InitialValue = StdLogicVector._0s(userLogic.LengthWidth)
            };
            _sig_ip2bus_mst_type = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_ip2bus_mst_lock = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_ip2bus_mst_reset = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mst_cmdack = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mst_cmplt = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mst_error = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mst_rearbitrate = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mst_cmd_timeout = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mstrd_d   = new SLVSignal(userLogic.NativeDataWidth);
            _sig_bus2ip_mstrd_rem = new SLVSignal(userLogic.NativeDataWidth / 8)
            {
                InitialValue = StdLogicVector._0s(userLogic.NativeDataWidth / 8)
            };
            _sig_bus2ip_mstrd_sof_n = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mstrd_eof_n = new SLSignal()
            {
                InitialValue = '0'
            };
            _sig_bus2ip_mstrd_src_rdy_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_bus2ip_mstrd_src_dsc_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_ip2bus_mstrd_dst_rdy_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_ip2bus_mstrd_dst_dsc_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_ip2bus_mstwr_d   = new SLVSignal(userLogic.NativeDataWidth);
            _sig_ip2bus_mstwr_rem = new SLVSignal(userLogic.NativeDataWidth / 8)
            {
                InitialValue = StdLogicVector._0s(userLogic.NativeDataWidth / 8)
            };
            _sig_ip2bus_mstwr_src_rdy_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_ip2bus_mstwr_src_dsc_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_ip2bus_mstwr_sof_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_ip2bus_mstwr_eof_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_bus2ip_mstwr_dst_rdy_n = new SLSignal()
            {
                InitialValue = '1'
            };
            _sig_bus2ip_mstwr_dst_dsc_n = new SLSignal()
            {
                InitialValue = '1'
            };

            userLogic.Bus2IP_Clk             = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_BE              = _sig_Bus2IP_BE;
            userLogic.Bus2IP_Clk             = _sig_Bus2IP_Clk;
            userLogic.Bus2IP_Data            = _sig_Bus2IP_Data;
            userLogic.Bus2IP_RdCE            = _sig_Bus2IP_RdCE;
            userLogic.Bus2IP_Resetn          = _sig_Bus2IP_Resetn;
            userLogic.Bus2IP_WrCE            = _sig_Bus2IP_WrCE;
            userLogic.IP2Bus_Data            = _sig_IP2Bus_Data;
            userLogic.IP2Bus_Error           = _sig_IP2Bus_Error;
            userLogic.IP2Bus_RdAck           = _sig_IP2Bus_RdAck;
            userLogic.IP2Bus_WrAck           = _sig_IP2Bus_WrAck;
            userLogic.ip2bus_mstrd_req       = _sig_ip2bus_mstrd_req;
            userLogic.ip2bus_mstwr_req       = _sig_ip2bus_mstwr_req;
            userLogic.ip2bus_mst_addr        = _sig_ip2bus_mst_addr;
            userLogic.ip2bus_mst_be          = _sig_ip2bus_mst_be;
            userLogic.ip2bus_mst_length      = _sig_ip2bus_mst_length;
            userLogic.ip2bus_mst_type        = _sig_ip2bus_mst_type;
            userLogic.ip2bus_mst_lock        = _sig_ip2bus_mst_lock;
            userLogic.ip2bus_mst_reset       = _sig_ip2bus_mst_reset;
            userLogic.bus2ip_mst_cmdack      = _sig_bus2ip_mst_cmdack;
            userLogic.bus2ip_mst_cmplt       = _sig_bus2ip_mst_cmplt;
            userLogic.bus2ip_mst_error       = _sig_bus2ip_mst_error;
            userLogic.bus2ip_mst_rearbitrate = _sig_bus2ip_mst_rearbitrate;
            userLogic.bus2ip_mst_cmd_timeout = _sig_bus2ip_mst_cmd_timeout;
            userLogic.bus2ip_mstrd_d         = _sig_bus2ip_mstrd_d;
            userLogic.bus2ip_mstrd_rem       = _sig_bus2ip_mstrd_rem;
            userLogic.bus2ip_mstrd_sof_n     = _sig_bus2ip_mstrd_sof_n;
            userLogic.bus2ip_mstrd_eof_n     = _sig_bus2ip_mstrd_eof_n;
            userLogic.bus2ip_mstrd_src_rdy_n = _sig_bus2ip_mstrd_src_rdy_n;
            userLogic.bus2ip_mstrd_src_dsc_n = _sig_bus2ip_mstrd_src_dsc_n;
            userLogic.ip2bus_mstrd_dst_rdy_n = _sig_ip2bus_mstrd_dst_rdy_n;
            userLogic.ip2bus_mstrd_dst_dsc_n = _sig_ip2bus_mstrd_dst_dsc_n;
            userLogic.ip2bus_mstwr_d         = _sig_ip2bus_mstwr_d;
            userLogic.ip2bus_mstwr_rem       = _sig_ip2bus_mstwr_rem;
            userLogic.ip2bus_mstwr_src_rdy_n = _sig_ip2bus_mstwr_src_rdy_n;
            userLogic.ip2bus_mstwr_src_dsc_n = _sig_ip2bus_mstwr_src_dsc_n;
            userLogic.ip2bus_mstwr_sof_n     = _sig_ip2bus_mstwr_sof_n;
            userLogic.ip2bus_mstwr_eof_n     = _sig_ip2bus_mstwr_eof_n;
            userLogic.bus2ip_mstwr_dst_rdy_n = _sig_bus2ip_mstwr_dst_rdy_n;
            userLogic.bus2ip_mstwr_dst_dsc_n = _sig_bus2ip_mstwr_dst_dsc_n;

            _clockGen = new Clock(new Time(10.0, ETimeUnit.ns))
            {
                Clk = _sig_Bus2IP_Clk
            };
        }
Ejemplo n.º 25
0
            public override void Establish(IAutoBinder binder)
            {
                if (_realized)
                {
                    return;
                }

                object constValue;
                var    literal = (Literal)_literal;

                if (literal.IsConst(out constValue))
                {
                    var slv = Marshal.SerializeForHW(constValue);
                    _dataOutI = (SLVSignal)binder.GetSignal(EPortUsage.Default, "constSignal_" + constValue.ToString(), null, slv);
                    _dataOut  = _dataOutI.Descriptor;
                }
                else
                {
                    bool needRead = true, needWrite = true;
                    var  fref = _literal as FieldRef;
                    if (fref != null)
                    {
                        needRead  = fref.FieldDesc.IsReadInCurrentContext(Host.Context);
                        needWrite = fref.FieldDesc.IsWrittenInCurrentContext(Host.Context);
                    }

                    var    stlit       = (IStorableLiteral)_literal;
                    string name        = stlit.Name;
                    var    valueSample = _literal.Type.GetSampleInstance();
                    _dataBits = Marshal.SerializeForHW(valueSample).Size;

                    _clkI = (SLSignal)binder.GetSignal(EPortUsage.Clock, null, null, null);
                    _clk  = _clkI.Descriptor;
                    if (needWrite)
                    {
                        _wrEnI   = (SLSignal)binder.GetSignal(EPortUsage.Default, name + "_wrEn", null, StdLogic._0);
                        _wrEn    = _wrEnI.Descriptor;
                        _dataInI = (SLVSignal)binder.GetSignal(EPortUsage.Default, name + "_dataIn", null, StdLogicVector._0s(_dataBits));
                        _dataIn  = _dataInI.Descriptor;
                    }
                    if (needRead)
                    {
                        _dataOutI = (SLVSignal)binder.GetSignal(EPortUsage.Default, name + "_dataOut", null, StdLogicVector._0s(_dataBits));
                        _dataOut  = _dataOutI.Descriptor;
                    }

                    //var apb = new AccessProcessBuilder(this, needRead, needWrite);
                    //var alg = apb.GetAlgorithm();
                    //alg.Name = name + "_process";
                    //binder.CreateProcess(Process.EProcessKind.Triggered, alg, _clk);
                    CommonClockProcess ccp     = null;
                    string             algName = name + "_process";
                    if (Host.Descriptor.HasAttribute <CommonClockProcess>())
                    {
                        ccp = Host.Descriptor.QueryAttribute <CommonClockProcess>();
                        Host.Descriptor.RemoveChild(ccp.CCProc);
                    }
                    else
                    {
                        ccp = new CommonClockProcess(_clk);
                        Host.Descriptor.AddAttribute(ccp);
                    }
                    ccp.AddAccessor(this, needRead, needWrite);
                    var alg = ccp.FrameBuilder.Complete();
                    alg.Name   = algName;
                    ccp.CCProc = binder.CreateProcess(Process.EProcessKind.Triggered, alg, _clk);
                }

                _realized = true;
            }
Ejemplo n.º 26
0
        public override bool Rewrite(CodeDescriptor decompilee, Expression waitObject, IDecompiler stack, IFunctionBuilder builder)
        {
            if (stack.HasAttribute <Analysis.M2M.HLS>())
            {
                return(true);
            }

            var       curps = DesignContext.Instance.CurrentProcess;
            SLSignal  clk   = (SLSignal)curps.Sensitivity[0].Owner;
            SignalRef srEdge;

            if (curps.Predicate.Equals((Func <bool>)clk.RisingEdge))
            {
                srEdge = SignalRef.Create(clk.Descriptor, SignalRef.EReferencedProperty.RisingEdge);
            }
            else
            {
                srEdge = SignalRef.Create(clk.Descriptor, SignalRef.EReferencedProperty.FallingEdge);
            }
            var lrEdge = new LiteralReference(srEdge);

            int  nwait      = 0;
            var  nwaitEx    = waitObject.Children[0];
            bool nwaitConst = nwaitEx.IsConst();

            if (nwaitConst)
            {
                nwait = (int)TypeConversions.ConvertValue(
                    nwaitEx.Eval(DefaultEvaluator.DefaultConstEvaluator),
                    typeof(int));
            }

            var fspec = new FunctionSpec(typeof(void))
            {
                IntrinsicRep = IntrinsicFunctions.Wait(WaitParams.EWaitKind.WaitUntil)
            };

            Variable         v   = null;
            LiteralReference lrV = null;

            if (!nwaitConst || nwait > 3)
            {
                v = new Variable(typeof(int))
                {
                    Name = "_wait_i" + (ictr++)
                };
                builder.DeclareLocal(v);
                lrV = new LiteralReference(v);
                builder.Store(v, LiteralReference.CreateConstant((int)0));
                var loop = builder.Loop();
                builder.If(Expression.Equal(lrV, nwaitEx));
                {
                    builder.Break(loop);
                }
                builder.EndIf();
            }
            int ncalls = 1;

            if (nwaitConst && nwait <= 3)
            {
                ncalls = nwait;
            }
            for (int i = 0; i < ncalls; i++)
            {
                builder.Call(fspec, lrEdge);
            }
            if (!nwaitConst || nwait > 3)
            {
                builder.Store(v, lrV + LiteralReference.CreateConstant((int)1));
                builder.EndLoop();
            }
            return(true);
        }