Port.py 722 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/python
  2. # vim: set fileencoding=utf8
  3. # Created:20080211
  4. # By Jeff Connelly
  5. IN = "in"
  6. OUT = "out"
  7. INOUT = "inout"
  8. class Port(object):
  9. def __init__(self, name, direction, type, length = 0):
  10. self.name = name
  11. assert direction in [IN, OUT, INOUT], \
  12. "Port direction %s is invalid" % (direction,)
  13. self.direction = direction
  14. self.type = type
  15. self.value = []
  16. self.length = length
  17. def __str__(self):
  18. return "<Port: %s, %s, %s, %s>" % (self.name, self.direction, self.type, self.length)
  19. if __name__ == "__main__":
  20. a = Port("a", IN, None)
  21. b = Port("b", IN, None)
  22. c = Port("c", OUT, None)
  23. print a
  24. print b
  25. print c