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); }
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); }
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); }
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); }
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); } ); }
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); }
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(); }
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); }
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); }
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(); }
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(); }
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(); }
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); }
public void Reserve(Flit flit) { reservedFor = flit; }
public void Release(Flit flit) { reservedFor = null; }
public bool IsReservedForOtherThan(Flit flit) { return (reservedFor != null) && (reservedFor != flit); }
public virtual void Put(Flit flit) { if (items.Count < bufferDepth) items.Enqueue(flit); }
public override void Put(Flit flit) { items.Enqueue(flit); }
private void Route(Flit flit, IChannel channel) { if (flit.Type == FlitType.Header) channel.Reserve(flit); if (flit.Type == FlitType.Tail) channel.Release(flit); }