예제 #1
0
        public void should_calculate_latency_from_first_to_last_time_flit_was_sent()
        {
            var flit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = flit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 5, Flit = flit });
            distributor.Distribute(1, 5);

            evaluator.Latency.Should().Be.EqualTo(5);
        }
예제 #2
0
        public void should_correlate_flit_events_in_one_count()
        {
            var flit = new Flit();
            distributor.SendMessage(new FlitEvent { ClockCycle = 1, Flit = flit });
            distributor.SendMessage(new FlitEvent { ClockCycle = 2, Flit = flit });
            distributor.Distribute(1, 2);

            evaluator.FlitsSent.Should().Be.EqualTo(1);
        }
예제 #3
0
        public void should_correlate_hops_for_same_flits()
        {
            var flit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = flit});
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 2, Flit = flit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 3, Flit = flit });
            distributor.Distribute(1, 3);

            evaluator.HopCount.Should().Be.EqualTo(3);
        }
예제 #4
0
        public void should_count_latency_for_separated_flits()
        {
            var firstFlit = new Flit();
            var secondFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 5, Flit = secondFlit });
            distributor.Distribute(1, 5);

            evaluator.Latency.Should().Be.EqualTo(1);
        }
예제 #5
0
        public RoutingAvailabilityExpression HasAvailableChannelFor(Flit flit)
        {
            var channel = routingAlgorithm.Route(Channels);
            var isAvailable = (!channel.IsFull() && !channel.IsReservedForOtherThan(flit));

            return new RoutingAvailabilityExpression(
                isAvailable: isAvailable,
                routeIfAvailableAction: () => { if (isAvailable) this.Route(flit, channel); }
            );
        }
예제 #6
0
        public void should_calculate_average_latency_from_multiple_flits()
        {
            var firstFlit = new Flit();
            var secondFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 2, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 5, Flit = secondFlit });
            distributor.Distribute(1, 5);

            evaluator.Latency.Should().Be.EqualTo(1.5);
        }
예제 #7
0
        public void should_be_marked_as_reserved_after_reservation()
        {
            var buffer = MockRepository.GenerateStub<IBuffer>();
            var channel = new Channel(buffer);
            var flit = new Flit();

            channel.Reserve(flit);

            channel.IsReservedForOtherThan(flit).Should().Be.False();
            channel.IsReservedForOtherThan(new Flit()).Should().Be.True();
        }
예제 #8
0
        public void should_calculate_average_hops_for_different_flits()
        {
            var firstFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 1, Flit = firstFlit });
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 2, Flit = firstFlit });

            var secondFlit = new Flit();
            distributor.SendMessage(new FlitAcceptedEvent { ClockCycle = 3, Flit = secondFlit });

            distributor.Distribute(1, 3);

            evaluator.HopCount.Should().Be.EqualTo(1.5);
        }
예제 #9
0
파일: BufferTests.cs 프로젝트: caiokf/senoc
        public void peek_should_return_the_first_flit_put_on_queue()
        {
            var bufferDepth = 2;
            var queue = new QueueBuffer(bufferDepth: bufferDepth);
            var flit1 = new Flit();
            var flit2 = new Flit();

            queue.Put(flit1);
            queue.Put(flit2);

            var peek = queue.Peek();
            peek.Should().Be.EqualTo(flit1);
            peek.Should().Not.Be.EqualTo(flit2);
        }
예제 #10
0
        public void should_verify_if_channels_are_available_when_receiving_flit()
        {
            var switchingMatrix = MockRepository.GenerateMock<ISwitchingMatrix>();
            var router = new Router(switchingMatrix);
            distributor.AddListener(router);
            var flit = new Flit();

            switchingMatrix.Expect(x => x.HasAvailableChannelFor(flit))
                .Return(new RoutingAvailabilityExpression(true));

            distributor.SendMessage(new FlitEvent { ClockCycle = 1, Flit = flit, CurrentReceiver = router });
            distributor.Distribute(1);

            switchingMatrix.VerifyAllExpectations();
        }
예제 #11
0
        public void should_not_have_channel_for_flit_when_buffers_full()
        {
            var returningChannel = MockRepository.GenerateMock<IChannel>();
            var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>();
            var flit = new Flit();

            returningChannel.Expect(x => x.IsFull()).Return(true);
            returningChannel.Expect(x => x.IsReservedForOtherThan(flit)).Return(false);
            routingAlgorithm.Stub(x => x.Route(null)).IgnoreArguments().Return(returningChannel);

            var switchingMatrix = new SwitchingMatrix(routingAlgorithm);
            switchingMatrix.AddChannel(returningChannel);

            switchingMatrix.HasAvailableChannelFor(flit).IsAvailable.Should().Be.False();
        }
예제 #12
0
        public void should_reserve_channel_for_flit_when_the_head_pass_by()
        {
            var returningChannel = MockRepository.GenerateMock<IChannel>();
            var routingAlgorithm = MockRepository.GenerateStub<IRoutingAlgorithm>();
            var flit = new Flit { Type = FlitType.Header };

            returningChannel.Stub(x => x.IsFull()).Return(false);
            returningChannel.Stub(x => x.IsReservedForOtherThan(flit)).Return(false);
            routingAlgorithm.Stub(x => x.Route(null)).IgnoreArguments().Return(returningChannel);

            var switchingMatrix = new SwitchingMatrix(routingAlgorithm);
            switchingMatrix.AddChannel(returningChannel);

            returningChannel.Expect(x => x.Reserve(flit));
            switchingMatrix.HasAvailableChannelFor(flit).RouteIfAvailable();

            returningChannel.VerifyAllExpectations();
        }
예제 #13
0
파일: BufferTests.cs 프로젝트: caiokf/senoc
        public void take_should_return_the_first_flit_put_on_queue()
        {
            var bufferDepth = 2;
            var queue = new QueueBuffer(bufferDepth: bufferDepth);
            var flit1 = new Flit();
            var flit2 = new Flit();

            queue.Put(flit1);
            queue.Put(flit2);

            var take = queue.Take();
            take.Should().Be.EqualTo(flit1);
            take.Should().Not.Be.EqualTo(flit2);
        }
예제 #14
0
파일: Channel.cs 프로젝트: caiokf/senoc
 public void Reserve(Flit flit)
 {
     reservedFor = flit;
 }
예제 #15
0
파일: Channel.cs 프로젝트: caiokf/senoc
 public void Release(Flit flit)
 {
     reservedFor = null;
 }
예제 #16
0
파일: Channel.cs 프로젝트: caiokf/senoc
 public bool IsReservedForOtherThan(Flit flit)
 {
     return (reservedFor != null) && (reservedFor != flit);
 }
예제 #17
0
파일: QueueBuffer.cs 프로젝트: caiokf/senoc
 public virtual void Put(Flit flit)
 {
     if (items.Count < bufferDepth)
         items.Enqueue(flit);
 }
예제 #18
0
 public override void Put(Flit flit)
 {
     items.Enqueue(flit);
 }
예제 #19
0
 private void Route(Flit flit, IChannel channel)
 {
     if (flit.Type == FlitType.Header) channel.Reserve(flit);
     if (flit.Type == FlitType.Tail) channel.Release(flit);
 }