Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. from myhdl import *
  2.  
  3. class Interface():
  4.  
  5. def __init__(self):
  6. self.data = Signal(False)
  7.  
  8. class HDLClass1(object):
  9.  
  10. @block
  11. def model(self, clock, input_interface, output_interface):
  12.  
  13. internal_in = Interface()
  14. internal_out = Interface()
  15.  
  16. @always_comb
  17. def assignments():
  18. internal_in.data.next = input_interface.data
  19. output_interface.data.next = internal_out.data
  20.  
  21. @always(clock.posedge)
  22. def do_something():
  23. internal_out.data.next = internal_in.data.next
  24.  
  25. return do_something, assignments
  26.  
  27. class HDLClass2(HDLClass1):
  28. pass
  29.  
  30. class Pipeline(object):
  31.  
  32. def __init__(self):
  33.  
  34. self.class1_inst = HDLClass1()
  35. self.class2_inst = HDLClass2()
  36.  
  37. @block
  38. def pipeline_hdl(
  39. self, clock, input_interface, output_interface):
  40.  
  41. intermediate_interface = Interface()
  42.  
  43. class1_hdl_inst = self.class1_inst.model(
  44. clock, input_interface, intermediate_interface)
  45.  
  46. class2_hdl_inst = self.class2_inst.model(
  47. clock, intermediate_interface, output_interface)
  48.  
  49. return class1_hdl_inst, class2_hdl_inst
  50.  
  51. def build_it():
  52. pipeline = Pipeline()
  53.  
  54. clock = Signal(False)
  55. reset = Signal(False)
  56. input_interface = Interface()
  57. output_interface = Interface()
  58.  
  59. inst = pipeline.pipeline_hdl(clock, input_interface, output_interface)
  60. inst.convert()
  61.  
  62. if __name__ == '__main__':
  63. build_it()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement