コード例 #1
0
            public override void Establish(IAutoBinder binder)
            {
                if (_allocated)
                {
                    return;
                }

                _brAltFlagP = (SLVSignal)binder.GetSignal(EPortUsage.Default, "BCU_BrP", null, StdLogicVector._0s(1));
                _brAltFlagN = (SLVSignal)binder.GetSignal(EPortUsage.Default, "BCU_BrN", null, StdLogicVector._1s(1));

                _curState = binder.GetSignal(EPortUsage.State, "BCU_CurState", null, null).Descriptor;
                _tState   = _curState.ElementType.CILType;
                Array  enumValues   = _tState.GetEnumValues();
                int    numStates    = enumValues.Length;
                object defaultState = Activator.CreateInstance(_tState);

                _incState  = binder.GetSignal(EPortUsage.Default, "BCU_IncState", null, defaultState).Descriptor;
                _altState  = binder.GetSignal(EPortUsage.Default, "BCU_AltState", null, defaultState).Descriptor;
                _nextState = binder.GetSignal(EPortUsage.Default, "BCU_NextState", null, defaultState).Descriptor;
                IncStateProcessBuilder ispb = new IncStateProcessBuilder(this);
                Function incStateFn         = ispb.GetAlgorithm();

                incStateFn.Name = "BCU_IncState";
                binder.CreateProcess(Process.EProcessKind.Triggered, incStateFn, _curState);
                SyncProcessBuilder spb         = new SyncProcessBuilder(this, binder);
                Function           syncStateFn = spb.GetAlgorithm();

                syncStateFn.Name = "BCU_FSM";
                ISignalOrPortDescriptor sdClock = binder.GetSignal <StdLogic>(EPortUsage.Clock, "Clk", null, '0').Descriptor;

                binder.CreateProcess(Process.EProcessKind.Triggered, syncStateFn, sdClock);

                _allocated = true;
            }
コード例 #2
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());
        }
コード例 #3
0
        public void CreateControlpath(FlowMatrix flowSpec, string procName)
        {
            var sens = flowSpec.FlowSources.Select(sr => sr.Desc)
                       .Concat(Enumerable.Repeat((ISignalOrPortDescriptor)_stateSignal.Descriptor, 1))
                       .Distinct();
            var tscTempl = new TristateConcTemplate(this, flowSpec);
            var tscFunc  = tscTempl.GetAlgorithm();

            _binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, tscFunc, sens.ToArray());
            var fudTempl = new FUDriveTemplate(this, flowSpec, tscTempl.NonTristateTargets);
            var fudFunc  = fudTempl.GetAlgorithm();

            _binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, fudFunc, sens.ToArray());
        }
コード例 #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;
            }
コード例 #5
0
        public void CreateControlpath(FlowMatrix flowSpec, string procName)
        {
            int    ncsteps = flowSpec.NumCSteps;
            string report  = _mcd.ComputeEncoding(flowSpec, _maxSelWidth);

            _curCW = (SLVSignal)_binder.GetSignal <StdLogicVector>(EPortUsage.Default, "CurCW", null,
                                                                   StdLogicVector._0s(_mcd.CWWidth));
            var clkInst = _binder.GetSignal <StdLogic>(EPortUsage.Clock, "Clk", null, '0');

            if (_staged)
            {
                _mcd.CreateStagedDecoder(_binder, _curCW, (SLSignal)clkInst, _registered);
            }
            else
            {
                _mcd.CreateDecoder(_binder, _curCW);
            }
            CreateROM(ncsteps);
            for (int cstep = 0; cstep < ncsteps; cstep++)
            {
                var cw = _mcd.Encode(cstep, flowSpec.GetFlow(cstep));
                _romIf.PreWrite(StdLogicVector.FromUInt((uint)cstep, _pc.Size), cw);
            }

            var syncTempl = new SyncTemplate(this);
            var syncFunc  = syncTempl.GetAlgorithm();

            _binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, syncFunc, clkInst.Descriptor);

            _host.Descriptor.GetDocumentation().Documents.Add(new Document(procName + "_HMA_report.txt", report));
        }
コード例 #6
0
            public ProcessDescriptor CreateProcess(Process.EProcessKind kind, Function func, params ISignalOrPortDescriptor[] sensitivity)
            {
                func.Name = _dpb._psName + "_FuPs" + _dpb._nextFUProcessIndex + "_" + func.Name;
                var result = _orgBinder.CreateProcess(kind, func, sensitivity);

                ++_dpb._nextFUProcessIndex;
                return(result);
            }
コード例 #7
0
        public void CreateControlpath(FlowMatrix flowSpec, string procName)
        {
            flowSpec.ReplaceDontCares();
            var sens = flowSpec.FlowSources.Select(sr => sr.Desc)
                       .Concat(Enumerable.Repeat((ISignalOrPortDescriptor)_stateSignal.Descriptor, 1))
                       .Distinct();
            var fudTempl = new FUDriveTemplate(this, flowSpec);
            var fudFunc  = fudTempl.GetAlgorithm();

            _binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, fudFunc, sens.ToArray());
            _host.Descriptor.GetDocumentation().Documents.Add(new Document(procName + "_FSM_report.txt", flowSpec.GetMUXReport()));
        }
コード例 #8
0
        public void CreateDecoder(IAutoBinder binder, SLVSignal cwSignal)
        {
            var pbuilder    = new DefaultAlgorithmBuilder();
            var sensitivity = new HashSet <ISignalOrPortDescriptor>();

            sensitivity.Add(cwSignal.Descriptor);
            foreach (var ms in _strings)
            {
                ms.AssembleDecoder(pbuilder, cwSignal, sensitivity);
            }
            var decFunc = pbuilder.Complete();

            decFunc.Name = "cwdecode";
            binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, decFunc, sensitivity.ToArray());
        }
コード例 #9
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;
        }
コード例 #10
0
            public override void Establish(IAutoBinder binder)
            {
                if (_realized)
                {
                    return;
                }

                _inSignals = _argWidths.Select((w, i) =>
                                               (SLVSignal)binder.GetSignal(EPortUsage.Default, "concat" + i, null,
                                                                           StdLogicVector.Us(w))).ToArray();
                int total = _argWidths.Sum();

                _outSignal = (SLVSignal)binder.GetSignal(EPortUsage.Default, "concout", null, StdLogicVector.Us(total));
                var pb  = new ConcatProcessBuilder(this);
                var alg = pb.GetAlgorithm();

                alg.Name = "concatenize";
                binder.CreateProcess(Process.EProcessKind.Triggered, alg, _inSignals.Select(s => s.Descriptor).ToArray());
                _realized = true;
            }
コード例 #11
0
        public void Establish(IAutoBinder binder)
        {
            if (_established)
            {
                return;
            }

            if (!_portSignal.ElementType.CILType.Equals(typeof(StdLogicVector)))
            {
                var signalInst = binder.GetSignal(EPortUsage.Default, _port.Name + "_slv", null,
                                                  Marshal.SerializeForHW(_portSignal.InitialValue));
                _slvSignal = signalInst.Descriptor;
                var templ = new ConvProcessBuilder(this);
                var alg   = templ.GetAlgorithm();
                binder.CreateProcess(Process.EProcessKind.Triggered, alg, _portSignal);
            }
            else
            {
                _slvSignal = _portSignal;
            }

            _established = true;
        }
コード例 #12
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;
            }
コード例 #13
0
            public override void Establish(IAutoBinder binder)
            {
                if (_realized)
                    return;

                _inSignals = _argWidths.Select((w, i) => 
                    (SLVSignal)binder.GetSignal(EPortUsage.Default, "concat" + i, null,
                    StdLogicVector.Us(w))).ToArray();
                int total = _argWidths.Sum();
                _outSignal = (SLVSignal)binder.GetSignal(EPortUsage.Default, "concout", null, StdLogicVector.Us(total));
                var pb = new ConcatProcessBuilder(this);
                var alg = pb.GetAlgorithm();
                alg.Name = "concatenize";
                binder.CreateProcess(Process.EProcessKind.Triggered, alg, _inSignals.Select(s => s.Descriptor).ToArray());
                _realized = true;
            }
コード例 #14
0
ファイル: InlineBCU.cs プロジェクト: venusdharan/systemsharp
            public override void Establish(IAutoBinder binder)
            {
                if (_allocated)
                    return;

                _brAltFlagP = (SLVSignal)binder.GetSignal(EPortUsage.Default, "BCU_BrP", null, StdLogicVector._0s(1));
                _brAltFlagN = (SLVSignal)binder.GetSignal(EPortUsage.Default, "BCU_BrN", null, StdLogicVector._1s(1));

                _curState = binder.GetSignal(EPortUsage.State, "BCU_CurState", null, null).Descriptor;
                _tState = _curState.ElementType.CILType;
                Array enumValues = _tState.GetEnumValues();
                int numStates = enumValues.Length;
                object defaultState = Activator.CreateInstance(_tState);
                _incState = binder.GetSignal(EPortUsage.Default, "BCU_IncState", null, defaultState).Descriptor;
                _altState = binder.GetSignal(EPortUsage.Default, "BCU_AltState", null, defaultState).Descriptor;
                _nextState = binder.GetSignal(EPortUsage.Default, "BCU_NextState", null, defaultState).Descriptor;
                IncStateProcessBuilder ispb = new IncStateProcessBuilder(this);
                Function incStateFn = ispb.GetAlgorithm();
                incStateFn.Name = "BCU_IncState";
                binder.CreateProcess(Process.EProcessKind.Triggered, incStateFn, _curState);
                SyncProcessBuilder spb = new SyncProcessBuilder(this, binder);
                Function syncStateFn = spb.GetAlgorithm();
                syncStateFn.Name = "BCU_FSM";
                ISignalOrPortDescriptor sdClock = binder.GetSignal<StdLogic>(EPortUsage.Clock, "Clk", null, '0').Descriptor;
                binder.CreateProcess(Process.EProcessKind.Triggered, syncStateFn, sdClock);

                _allocated = true;
            }
コード例 #15
0
 public void CreateDecoder(IAutoBinder binder, SLVSignal cwSignal)
 {
     var pbuilder = new DefaultAlgorithmBuilder();
     var sensitivity = new HashSet<ISignalOrPortDescriptor>();
     sensitivity.Add(cwSignal.Descriptor);
     foreach (var ms in _strings)
     {
         ms.AssembleDecoder(pbuilder, cwSignal, sensitivity);
     }
     var decFunc = pbuilder.Complete();
     decFunc.Name = "cwdecode";
     binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, decFunc, sensitivity.ToArray());
 }
コード例 #16
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;
            }
コード例 #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());
        }
コード例 #18
0
        private void InstantiateControlLogic()
        {
            if (_memLookup == null)
            {
                // All registers unused, nothing to instantiate
                return;
            }

            int rcount          = 0;
            int mcount          = 0;
            var regsCur         = new List <SignalBase>();
            var regsNext        = new List <SignalBase>();
            var memInstances    = new List <SimpleDPRAM>();
            var memAddrRSignals = new List <SignalBase>();
            var memAddrWSignals = new List <SignalBase>();
            var memDInSignals   = new List <SignalBase>();
            var memDOutSignals  = new List <SignalBase>();
            var memWrEnSignals  = new List <SignalBase>();

            int scount = _tempRegTypes.Length;

            _idxMap   = Arrays.Same(-1, scount);
            _isMemMap = Arrays.Same(false, scount);

            foreach (var grp in _memLookup)
            {
                if (grp.Count() <= 800000)
                {
                    // Implement as register
                    foreach (int slot in grp)
                    {
                        if (IsUnused(slot))
                        {
                            continue;
                        }

                        _idxMap[slot] = rcount;

                        var    regType = _tempRegTypes[slot];
                        string name    = "R" + rcount + "_cur";
                        var    regCur  = _binder.GetSignal(EPortUsage.Default, name, null, regType.GetSampleInstance());
                        //regCur.Descriptor.TagTemporary(rcount);
                        name = "R" + rcount + "_next";
                        var regNext = _binder.GetSignal(EPortUsage.Default, name, null, regType.GetSampleInstance());
                        //regNext.Descriptor.TagTemporary(rcount);

                        regsCur.Add(regCur);
                        regsNext.Add(regNext);

                        ++rcount;
                    }
                }
                else
                {
                    // Implement as memory
                    foreach (int slot in grp)
                    {
                        _isMemMap[slot] = true;
                        _idxMap[slot]   = mcount;
                    }

                    int rep = grp.Key;

                    string name     = "M" + rcount + "_AddrR";
                    var    sigAddrR = _binder.GetSignal <StdLogicVector>(EPortUsage.Default, name, null, _memAddrs[rep]);
                    name = "M" + rcount + "_AddrW";
                    var sigAddrW = _binder.GetSignal <StdLogicVector>(EPortUsage.Default, name, null, _memAddrs[rep]);
                    name = "M" + rcount + "_DIn";
                    var regType = _tempRegTypes[rep];
                    var sigDIn  = _binder.GetSignal <StdLogicVector>(EPortUsage.Default, name, null, (StdLogicVector)regType.GetSampleInstance());
                    name = "M" + rcount + "_DOut";
                    var sigDOut = _binder.GetSignal <StdLogicVector>(EPortUsage.Default, name, null, (StdLogicVector)regType.GetSampleInstance());
                    name = "M" + rcount + "_WrEn";
                    var sigWrEn = _binder.GetSignal <StdLogic>(EPortUsage.Default, name, null, StdLogic._0);

                    var mem = new SimpleDPRAM(
                        (uint)grp.Count(),
                        (uint)TypeLowering.Instance.GetWireWidth(regType))
                    {
                        Clk     = _binder.GetSignal <StdLogic>(EPortUsage.Clock, null, null, StdLogic._0),
                        RdAddr  = sigAddrR,
                        WrAddr  = sigAddrW,
                        DataIn  = sigDIn,
                        DataOut = sigDOut,
                        WrEn    = sigWrEn
                    };
                    _host.Descriptor.AddChild(mem.Descriptor, "Mem" + rcount);

                    memInstances.Add(mem);
                    memAddrRSignals.Add(sigAddrR);
                    memAddrWSignals.Add(sigAddrW);
                    memDInSignals.Add(sigDIn);
                    memDOutSignals.Add(sigDOut);
                    memWrEnSignals.Add(sigWrEn);

                    ++mcount;
                }
            }

            _regsCur  = regsCur.ToArray();
            _regsNext = regsNext.ToArray();

            _memInstances    = memInstances.ToArray();
            _memAddrRSignals = memAddrRSignals.ToArray();
            _memAddrWSignals = memAddrWSignals.ToArray();
            _memDInSignals   = memDInSignals.ToArray();
            _memDOutSignals  = memDOutSignals.ToArray();
            _memWrSignals    = memWrEnSignals.ToArray();

            var syncTempl             = new SyncTemplate(this);
            var syncFunc              = syncTempl.GetAlgorithm();
            Signal <StdLogic> clkInst = _binder.GetSignal <StdLogic>(EPortUsage.Clock, "Clk", null, '0');

            _binder.CreateProcess(SystemSharp.Components.Process.EProcessKind.Triggered, syncFunc, clkInst.Descriptor);
        }
コード例 #19
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;
            }