Exemplo n.º 1
0
    def scenario(self, link):
        with open(link, 'r') as stream:
            try:
                data = yaml.safe_load(stream)

                # Messages
                if 'scenario' in data:
                    messages = data['scenario']

                    for m in messages:
                        src = m['src']
                        dest = m['dest']
                        size = m['size']
                        offset = m['offset']
                        deadline = m['deadline']
                        period = m['period']
                        priority = -1

                        # set random priority (optional)
                        if self._arbitration == 'PRIORITY_PREEMPT' or self._arbitration == 'PRIORITY_NON_PREEMPT':
                            priority = random.randint(0, self._nbvc - 1)

                        # Temporary :: Compute the deadline for our task
                        lower_bound = int(0.7 * period)
                        deadline = random.randint(
                            0, (period - lower_bound + 1) + lower_bound)

                        # Message Creation
                        message = Message(self.counter,
                                          period,
                                          size,
                                          offset,
                                          deadline,
                                          Coordinate(src['i'], src['j']),
                                          Coordinate(dest['i'], dest['j']),
                                          priority=priority)

                        self.messages.append(message)
                        self.counter += 1

                        # Generate task conflict
                        self.conflict_task_by_axe(message, 60, 50, 0)

                # Automatic generation
                elif 'task' in data:
                    nb_task = data['task']
                    method = data['method']
                    load = data['load']

                    if method == 'UuniFast':
                        self.messages = self.uunifast_generate(nb_task, load)

                    # Generate task conflict
                    # for message in self.messages:
                    #     self.conflict_task_by_axe(message, 70, 40, 0)

                return self.messages

            except yaml.YAMLError as exc:
                print(exc)
Exemplo n.º 2
0
    def test_vc_target_output(self):
        self.router = self.noc.router_matrix[2][2]
        dest1 = Coordinate(1, 2)
        dest4 = Coordinate(0, 0)

        # North
        vc_north = self.router.inNorth.vcs[0]
        vc_north1 = self.router.inNorth.vcs[1]

        self.flit.set_destination_info(dest1)
        vc_north.flits.append(self.flit)
        self.router.vc_target_outport(vc_north)

        self.assertEqual(len(self.router.vcs_target_north), 1)

        vc_north1.flits.append(self.flit)
        self.router.vc_target_outport(vc_north1)
        self.assertEqual(len(self.router.vcs_target_north), 2)

        # West
        vc_west = self.router.inWest.vcs[0]

        self.flit.set_destination_info(dest4)
        vc_west.flits.append(self.flit)
        self.router.vc_target_outport(vc_west)

        self.assertEqual(len(self.router.vcs_target_west), 1)
Exemplo n.º 3
0
    def test_is_links_equal(self):
        message1 = Message(1, 12, 256, 0, 0, Coordinate(0, 2),
                           Coordinate(2, 2))
        message2 = Message(1, 12, 256, 0, 0, Coordinate(0, 3),
                           Coordinate(3, 3))
        p1 = self.message.get_xy_path_coordinate(self.noc)
        p2 = message1.get_xy_path_coordinate(self.noc)
        p3 = message2.get_xy_path_coordinate(self.noc)

        self.assertEqual(self.generation.task_overlap(p1, p2), True)
        self.assertEqual(self.generation.task_overlap(p1, p3), False)
Exemplo n.º 4
0
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1])

        self.src = Coordinate(0, 0)
        self.dest = Coordinate(2, 2)
        self.message = Message(1, 23, 256, 0, 0, self.src, self.dest)
        self.packet = Packet(1, self.dest, self.message)

        self.flit = self.packet.flits[0]

        self.proc_engine = self.noc.router_matrix[0][0].proc_engine
        self.router = self.noc.router_matrix[0][0]
Exemplo n.º 5
0
    def generate_conflict_task_by_axe(self, router, ids, axe, min_rate,
                                      offset):

        # determining the link direction (left -> right) or (right -> left)
        direction = self.get_link_direction(ids)

        if axe == 0:  # X axe
            if direction == 0:  # left -> right
                src = Coordinate(router[0].i, 0)
                dest = Coordinate(router[0].i, self._square_size - 1)
            else:  # right -> left
                src = Coordinate(router[0].i, self._square_size - 1)
                dest = Coordinate(router[0].i, 0)

        else:  # Y axe
            if direction == 0:  # up -> down
                src = Coordinate(0, router[0].j)
                dest = Coordinate(self._square_size - 1, router[0].j)
            else:  # down -> up
                src = Coordinate(self._square_size - 1, router[0].j)
                dest = Coordinate(0, router[0].j)

        # generate message
        message = self.generate_communicating_task_by_axe(
            min_rate, offset, src, dest)

        return message
Exemplo n.º 6
0
    def generate_random_coordinate(self):

        # source router coordinate
        src_i = random.randint(0, self.noc.square_size - 1)
        src_j = random.randint(0, self.noc.square_size - 1)

        # destination router coordinate
        dest_i = src_i
        dest_j = src_j
        while src_i == dest_i:
            dest_i = random.randint(0, self.noc.square_size - 1)
        while src_j == dest_j:
            dest_j = random.randint(0, self.noc.square_size - 1)

        return [Coordinate(src_i, src_j), Coordinate(dest_i, dest_j)]
Exemplo n.º 7
0
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1])

        self.src = Coordinate(0, 0)
        self.dest = Coordinate(2, 2)
        self.message = Message(1, 12, 256, 0, 0, self.src, self.dest)
        self.packet = Packet(1, self.dest, self.message)

        self.flit = self.packet.flits[0]

        self.proc_engine = self.noc.router_matrix[0][0].proc_engine
        self.router = self.noc.router_matrix[0][0]

        self.generation = Generation()
        self.generation.set_noc(self.noc)
        self.generation.set_square_size(4)

        self.noc.link_array_filling()
Exemplo n.º 8
0
    def scenario(self, link):
        with open(link, 'r') as stream:
            try:
                data = yaml.load(stream)

                # Messages
                if 'scenario' in data:
                    messages = data['scenario']
                    count = 0
                    for m in messages:
                        src = m['src']
                        dest = m['dest']
                        size = m['size']
                        offset = m['offset']
                        deadline = m['deadline']
                        period = m['period']

                        self.messages.append(
                            Message(
                                count,
                                period,
                                size,
                                offset,
                                deadline,
                                Coordinate(src['i'], src['j']),
                                Coordinate(dest['i'], dest['j']),
                            ))
                        count += 1

                # Automatic generation
                elif 'task' in data:
                    nb_task = data['task']
                    method = data['method']
                    load = data['load']

                    if method == 'UuniFast':
                        self.messages = self.uunifast_generate(nb_task, load)

                return self.messages

            except yaml.YAMLError as exc:
                print(exc)
Exemplo n.º 9
0
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1])
        self.noc.link_array_filling()

        self.message1 = Message(1, 150, 896, 0, 100, Coordinate(0, 3),
                                Coordinate(0, 1))
        self.message2 = Message(2, 150, 256, 0, 100, Coordinate(2, 0),
                                Coordinate(3, 0))
        self.message3 = Message(3, 400, 256, 0, 300, Coordinate(0, 2),
                                Coordinate(3, 0))
        self.message4 = Message(4, 600, 256, 0, 550, Coordinate(2, 0),
                                Coordinate(3, 0))
        self.message5 = Message(5, 300, 3072, 0, 250, Coordinate(0, 1),
                                Coordinate(2, 0))

        self.messages = [
            self.message1, self.message2, self.message3, self.message4,
            self.message5
        ]

        self.qinModel = QinModel(self.noc, self.messages)

        self.tdma = TDMA(self.noc, self.noc.vc_quantum)
Exemplo n.º 10
0
    def test_xy_routing_output(self):
        self.router = self.noc.router_matrix[2][2]
        dest1 = Coordinate(1, 2)
        dest2 = Coordinate(3, 2)
        dest3 = Coordinate(0, 3)
        dest4 = Coordinate(0, 0)
        dest5 = Coordinate(2, 2)

        self.flit.set_destination_info(dest1)
        self.assertEqual(self.router.route_computation(self.flit),
                         self.router.outNorth)
        self.flit.set_destination_info(dest2)
        self.assertEqual(self.router.route_computation(self.flit),
                         self.router.outSouth)
        self.flit.set_destination_info(dest3)
        self.assertEqual(self.router.route_computation(self.flit),
                         self.router.outEast)
        self.flit.set_destination_info(dest4)
        self.assertEqual(self.router.route_computation(self.flit),
                         self.router.outWest)
        self.flit.set_destination_info(dest5)
        self.assertEqual(self.router.route_computation(self.flit),
                         self.router.outPE)
Exemplo n.º 11
0
    def router_initialisation(self, env, id, x, y):

        # ProcessingEngine
        proc_engine = ProcessingEngine(env)

        # Routers construct
        coordinate = Coordinate(x, y)
        router = Router(env, id, coordinate, proc_engine)

        # InPort
        inNorth = InPort(router, Direction.north, self.nbvc, self.vc_size,
                         self.vc_quantum)
        inSouth = InPort(router, Direction.south, self.nbvc, self.vc_size,
                         self.vc_quantum)
        inEast = InPort(router, Direction.east, self.nbvc, self.vc_size,
                        self.vc_quantum)
        inWest = InPort(router, Direction.west, self.nbvc, self.vc_size,
                        self.vc_quantum)
        inPE = InPort(router, Direction.pe, self.nbvc, self.vc_size,
                      self.vc_quantum)

        # OutPort
        outNorth = OutPort(Direction.north)
        outSouth = OutPort(Direction.south)
        outEast = OutPort(Direction.east)
        outWest = OutPort(Direction.west)
        outPE = OutPort(Direction.pe)

        # In/Out Port settings
        router.inport_setting(inNorth, inSouth, inEast, inWest)
        router.outport_setting(outNorth, outSouth, outEast, outWest)

        # Processing Engine
        proc_engine.router_bind(router)
        router.proc_engine_setting(inPE, outPE)

        router.noc_settings(self)

        return router
Exemplo n.º 12
0
 def setUp(self):
     self.src = Coordinate(1, 1)
     self.dest = Coordinate(2, 2)
     self.message = Message(1, 23, 256, 0, 0, self.src, self.dest)
     self.packet = Packet(1, self.dest, self.message)