lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | from enum import Enum |
| 6 | |
| 7 | |
| 8 | class Edge: |
| 9 | """Edge class contains the connection from a node to a node. |
| 10 | |
| 11 | a Node can be a host port, output of async_fifo, port in a socket, |
| 12 | or a device port. |
| 13 | """ |
| 14 | |
| 15 | def __init__(self, us, ds): |
| 16 | self.us = us |
| 17 | self.ds = ds |
| 18 | |
| 19 | def __repr__(self): |
| 20 | return "U(%s) D(%s)" % (self.us.name, self.ds.name) |
| 21 | |
| 22 | |
| 23 | #Edges = List[Edge] |
| 24 | #Clocks = List[str] # If length is more than one, should be exactly two |
| 25 | |
| 26 | # [UpstreamClock, DownstreamClock] |
| 27 | |
| 28 | |
| 29 | class NodeType(Enum): |
| 30 | HOST = 1 |
| 31 | DEVICE = 2 |
| 32 | ASYNC_FIFO = 3 |
| 33 | SOCKET_1N = 4 |
| 34 | SOCKET_M1 = 5 |
| 35 | |
| 36 | |
| 37 | class Node: |
| 38 | """Node class is a port that communicates from/to other Node or TL-UL |
| 39 | input/output. |
| 40 | """ |
| 41 | |
| 42 | name = "" # name: str |
| 43 | # node_type: NodeType |
Timothy Chen | 09d859b | 2019-11-08 14:01:12 -0800 | [diff] [blame^] | 44 | clocks = [] # Clocks # clock domains of the node |
| 45 | resets = [] # Resets # resets of the node |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 46 | # e.g. async_fifo in : clk_core , out : clk_main |
| 47 | |
Timothy Chen | 3193b00 | 2019-10-04 16:56:05 -0700 | [diff] [blame] | 48 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 49 | # If NodeType is Socket out from 1:N then address steering is used |
| 50 | # But this value is also propagated up to a Host from multiple Devices |
| 51 | # Device Node should have address_from, address_to |
| 52 | address_from = 0 #: int |
| 53 | address_to = 0 #: int |
| 54 | |
| 55 | us = [] # Edges # Number of Ports depends on the NodeType |
| 56 | # 1 for Host, Device, 2 for Async FIFO, N for Sockets |
| 57 | ds = [] # Edges |
| 58 | |
Timothy Chen | 61e25e8 | 2019-09-13 14:04:10 -0700 | [diff] [blame] | 59 | # Req/Rsp FIFO. default False |
| 60 | # when False, FIFO fully passthrough, no storage element |
| 61 | # when True, FIFO present with default depth, "pipeline_byp" |
| 62 | # controls passthrough option |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 63 | pipeline = False |
| 64 | |
Timothy Chen | 61e25e8 | 2019-09-13 14:04:10 -0700 | [diff] [blame] | 65 | # FIFO passtru option. default True |
| 66 | pipeline_byp = True |
| 67 | |
Timothy Chen | 09d859b | 2019-11-08 14:01:12 -0800 | [diff] [blame^] | 68 | def __init__(self, name, node_type, clock, reset): |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 69 | self.name = name |
| 70 | self.node_type = node_type |
| 71 | self.clocks = [clock] |
Timothy Chen | 09d859b | 2019-11-08 14:01:12 -0800 | [diff] [blame^] | 72 | self.resets = [reset] |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 73 | self.us = [] |
| 74 | self.ds = [] |