Exemplo n.º 1
0
        public virtual void ClockCycle()
        {
            _simulatorContext.DeltaCycle = 0;
            do
            {
                _simulatorContext.CurrentTime++;

                var stageResult = _topLevel.DeltaCycle(_simulatorContext.DeltaCycle);
                _simulatorContext.TotalDeltaCycles++;

                TraceSignals();

                // no modules were modified during stage iteration, all converged
                if (stageResult == RTLModuleStageResult.Stable)
                {
                    break;
                }
            }while (++_simulatorContext.DeltaCycle < _simulatorContext.MaxDeltaCycles);

            if (_simulatorContext.DeltaCycle >= _simulatorContext.MaxDeltaCycles)
            {
                throw new MaxStageIterationReachedException();
            }

            OnPostStage?.Invoke(_topLevel);

            _simulatorContext.CurrentTime = _simulatorContext.Clock * 2 * _simulatorContext.MaxDeltaCycles + _simulatorContext.MaxDeltaCycles;

            // clock fall is not handled in RTL module, all sync is done of clock rise at the moment
            _simulatorContext.ClockSignal?.SetValue(false);
            TraceSignals();

            // clock rise will commit all changes
            _simulatorContext.Clock++;
            _simulatorContext.CurrentTime = _simulatorContext.Clock * 2 * _simulatorContext.MaxDeltaCycles;
            _simulatorContext.ClockSignal?.SetValue(true);
            _topLevel.Commit();
            TraceSignals();
            OnPostCommit?.Invoke(_topLevel);
        }
        public void ClockCycle()
        {
            _simulatorContext.CurrentTime = _simulatorContext.Clock * 2 * _simulatorContext.MaxStageIterations;
            _simulatorContext.ClockSignal?.SetValue(true);

            _simulatorContext.Iteration = 0;
            do
            {
                _simulatorContext.CurrentTime++;

                var modified = _topLevel.Stage(_simulatorContext.Iteration);

                TraceSignals();

                // no modules were modified during stage iteration, all converged
                if (!modified)
                {
                    break;
                }
            }while (++_simulatorContext.Iteration < _simulatorContext.MaxStageIterations);

            if (_simulatorContext.Iteration >= _simulatorContext.MaxStageIterations)
            {
                throw new MaxStageIterationReachedException();
            }

            OnPostStage?.Invoke(_topLevel);

            _simulatorContext.CurrentTime = _simulatorContext.Clock * 2 * _simulatorContext.MaxStageIterations + _simulatorContext.MaxStageIterations;
            _simulatorContext.ClockSignal?.SetValue(false);
            TraceSignals();

            _topLevel.Commit();
            OnPostCommit?.Invoke(_topLevel);

            _simulatorContext.Clock++;
        }