blob: 841edfeee812aa138f51d1ffc3cf5e0a6ba9af0f [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4
5from enum import Enum
6
7
8class 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
29class NodeType(Enum):
30 HOST = 1
31 DEVICE = 2
32 ASYNC_FIFO = 3
33 SOCKET_1N = 4
34 SOCKET_M1 = 5
35
36
37class 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 Chen09d859b2019-11-08 14:01:12 -080044 clocks = [] # Clocks # clock domains of the node
45 resets = [] # Resets # resets of the node
lowRISC Contributors802543a2019-08-31 12:12:56 +010046 # e.g. async_fifo in : clk_core , out : clk_main
47
Timothy Chen3193b002019-10-04 16:56:05 -070048
lowRISC Contributors802543a2019-08-31 12:12:56 +010049 # 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 Chen61e25e82019-09-13 14:04:10 -070059 # 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 Contributors802543a2019-08-31 12:12:56 +010063 pipeline = False
64
Timothy Chen61e25e82019-09-13 14:04:10 -070065 # FIFO passtru option. default True
66 pipeline_byp = True
67
Timothy Chen09d859b2019-11-08 14:01:12 -080068 def __init__(self, name, node_type, clock, reset):
lowRISC Contributors802543a2019-08-31 12:12:56 +010069 self.name = name
70 self.node_type = node_type
71 self.clocks = [clock]
Timothy Chen09d859b2019-11-08 14:01:12 -080072 self.resets = [reset]
lowRISC Contributors802543a2019-08-31 12:12:56 +010073 self.us = []
74 self.ds = []