ipxact-tools 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. data/config/detector.yml +63 -0
  2. data/lib/ipxact_tools.rb +287 -0
  3. data/lib/ipxact_tools/graph_pathfinder.rb +191 -0
  4. data/lib/ipxact_tools/interrupt_line_detector.rb +98 -0
  5. data/spec/integration/integration_spec.rb +254 -0
  6. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port.h +135 -0
  7. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port.tpp +247 -0
  8. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port_base.h +189 -0
  9. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_router.h +205 -0
  10. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_router.tpp +278 -0
  11. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_slave_base.h +115 -0
  12. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_slave_base.tpp +126 -0
  13. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_target_port.h +168 -0
  14. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_target_port_base.h +133 -0
  15. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_tlm_if.h +280 -0
  16. data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/user_types.h +38 -0
  17. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/Leon2Platform.xml +77 -0
  18. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/design_Leon2Platform.xml +156 -0
  19. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/tlmsrc/Leon2Platform.h +149 -0
  20. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/apbSubSystem.xml +406 -0
  21. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/design_apbSubSystem.xml +135 -0
  22. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/tlmsrc/apbSubSystem.h +133 -0
  23. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/Leon2Platform.xml +77 -0
  24. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/design_Leon2Platform.xml +157 -0
  25. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/tlmsrc/Leon2Platform.h +150 -0
  26. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/apbSubSystem.xml +422 -0
  27. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/designConfig_apbSubSystem.xml +79 -0
  28. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/design_apbSubSystem.xml +184 -0
  29. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/tlmsrc/apbSubSystem.h +164 -0
  30. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/Leon2Platform.xml +105 -0
  31. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/design_Leon2Platform.xml +157 -0
  32. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/tlmsrc/Leon2Platform.h +152 -0
  33. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/apbSubSystem.xml +429 -0
  34. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/designConfig_apbSubSystem.xml +64 -0
  35. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/design_apbSubSystem.xml +150 -0
  36. data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/tlmsrc/apbSubSystem.h +167 -0
  37. data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbbus/1.4/ahbbus22.xml +236 -0
  38. data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbbus/1.4/tlmsrc/ahbbus.h +52 -0
  39. data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/ahbram.xml +184 -0
  40. data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/tlmsrc/ahbram.cc +93 -0
  41. data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/tlmsrc/ahbram.h +77 -0
  42. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbbus/1.4/apbbus8.xml +544 -0
  43. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbbus/1.4/tlmsrc/apbbus.h +55 -0
  44. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbmst/1.4/apbmst.xml +209 -0
  45. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbmst/1.4/tlmsrc/apbmst.h +53 -0
  46. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/apbram.xml +395 -0
  47. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.cc +89 -0
  48. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.h +69 -0
  49. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.v +82 -0
  50. data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.vhd +132 -0
  51. data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/cgu.xml +686 -0
  52. data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/tlmsrc/cgu.cc +121 -0
  53. data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/tlmsrc/cgu.h +81 -0
  54. data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/cgu.xml +707 -0
  55. data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/tlmsrc/cgu.cc +121 -0
  56. data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/tlmsrc/cgu.h +81 -0
  57. data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/dma.xml +272 -0
  58. data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/tlmsrc/dma.cc +230 -0
  59. data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/tlmsrc/dma.h +116 -0
  60. data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/irqctrl.xml +530 -0
  61. data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/tlmsrc/irqctrl.cc +211 -0
  62. data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/tlmsrc/irqctrl.h +108 -0
  63. data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/processor.xml +423 -0
  64. data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/tlmsrc/processor.cc +331 -0
  65. data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/tlmsrc/processor.h +121 -0
  66. data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/pv2apb.xml +240 -0
  67. data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/tlmsrc/pv2apb.cc +153 -0
  68. data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/tlmsrc/pv2apb.h +77 -0
  69. data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/pv2tac.xml +154 -0
  70. data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/tlmsrc/pv2tac.cc +114 -0
  71. data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/tlmsrc/pv2tac.h +67 -0
  72. data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/rgu.xml +766 -0
  73. data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/tlmsrc/rgu.cc +126 -0
  74. data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/tlmsrc/rgu.h +105 -0
  75. data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/scmlAdaptor.xml +154 -0
  76. data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/tlmsrc/scmladaptor.cc +100 -0
  77. data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/tlmsrc/scmladaptor.h +62 -0
  78. data/spec/test_data/spiritconsortium.org/Leon2TLM/serial_device/1.0/serial_device.xml +151 -0
  79. data/spec/test_data/spiritconsortium.org/Leon2TLM/serial_device/1.0/tlmsrc/serial_device.h +85 -0
  80. data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/timers.xml +460 -0
  81. data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/tlmsrc/timers.cc +201 -0
  82. data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/tlmsrc/timers.h +102 -0
  83. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart.h +152 -0
  84. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_fifo.h +113 -0
  85. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_memory_map.h +96 -0
  86. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_types.h +60 -0
  87. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart.cc +125 -0
  88. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_interrupt_handler.cc +136 -0
  89. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_register_bank.cc +129 -0
  90. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_serial_tx_rx.cc +145 -0
  91. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/uart_scml.xml +372 -0
  92. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/Leon2_uart.h +216 -0
  93. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/def_Leon2_uart.h +34 -0
  94. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlm_field.h +72 -0
  95. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlm_register.h +129 -0
  96. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlmreg_Leon2_uart.h +133 -0
  97. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/Leon2_uart.cc +316 -0
  98. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/tlmreg_Leon2_uart.cc +197 -0
  99. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/user_specific_Leon2_uart.cc +146 -0
  100. data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/uart_tac.xml +222 -0
  101. data/spec/unit/graph_pathfinder_spec.rb +128 -0
  102. metadata +272 -0
@@ -0,0 +1,98 @@
1
+ # Copyright (C) 2011 TIMA Laboratory
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+
17
+ require 'yaml'
18
+
19
+ # {IPXACT::Tools::InterruptLineDetector} instances are used for
20
+ # detecting interrupt lines from a data path.
21
+ #
22
+ # @author Guillaume Godet-Bar
23
+ #
24
+ class IPXACT::Tools::InterruptLineDetector
25
+
26
+ @@detector_stats = []
27
+
28
+ def symbol_probability(symbol, state)
29
+ port = symbol
30
+
31
+ bus_name_p = @@detector_stats[:bus_name_regex].collect {|el| port[:name] =~ el[0] ? el[1] : 0.1}.max
32
+ bus_library_name_p = @@detector_stats[:bus_library_regex].collect {|el| port[:bus_id].name =~ el[0] ? el[1] : 0.1}.max
33
+
34
+ res = nil
35
+ if state == :int
36
+ (bus_name_p * bus_library_name_p) / (bus_name_p * bus_library_name_p + (1.0 - bus_name_p) * (1.0 - bus_library_name_p))
37
+ else
38
+ ((1.0 - bus_name_p) * (1.0 - bus_library_name_p)) / (bus_name_p * bus_library_name_p + (1.0 - bus_name_p) * (1.0 - bus_library_name_p))
39
+ end
40
+ end
41
+
42
+ def viterbi(symbol_queue)
43
+ return [] if symbol_queue.empty?
44
+
45
+ current_symbol = symbol_queue.shift
46
+
47
+ initial_values = @@detector_stats[:states].inject({}) do |acc, state|
48
+ acc[state] = {
49
+ :prob => @@detector_stats[:initial_state][state] * symbol_probability(current_symbol, state),
50
+ :previous => nil
51
+ }
52
+ acc
53
+ end
54
+
55
+ stat_stack = [initial_values]
56
+
57
+ @previous = initial_values
58
+
59
+ stat_stack += symbol_queue.collect do |symbol|
60
+ new_states = {}
61
+ previous_max = @previous.max {|a, b| a[1][:prob] <=> b[1][:prob]}
62
+ @@detector_stats[:states].inject({}) do |acc, state|
63
+ stats = @@detector_stats[:states].collect{|o_state| {:prob => previous_max[1][:prob] * @@detector_stats[:transition_matrix][o_state][state] * symbol_probability(symbol, state), :previous => previous_max[0]}}
64
+ acc[state] = stats.max{|a, b| a[:prob] <=> b[:prob]}
65
+ new_states[state] = acc[state]
66
+ acc
67
+ end
68
+ @previous = new_states
69
+ end
70
+
71
+ stat_stack
72
+ end
73
+
74
+ def render_seq(viterbi_stack)
75
+ seq = []
76
+ stack_el = viterbi_stack.pop
77
+ while stack_el
78
+ el = stack_el.max{|a, b| a[1][:prob] <=> b[1][:prob]}
79
+ seq << el[0]
80
+ stack_el = viterbi_stack.pop
81
+ end
82
+ seq.reverse
83
+ end
84
+
85
+ def self.convert_pairs(pairs)
86
+ pairs.collect do |pair|
87
+ regex = Regexp.new(pair[0].gsub(/^\/(.+)\/.?$/, '\1'), pair[0].end_with?('i'))
88
+ [regex, pair[1]]
89
+ end
90
+ end
91
+
92
+ if @@detector_stats.empty?
93
+ @@detector_stats = YAML.load(File.open(File.join(File.dirname(__FILE__), '../../config/detector.yml')).read)
94
+ @@detector_stats[:bus_name_regex] = convert_pairs(@@detector_stats[:bus_name_regex])
95
+ @@detector_stats[:bus_library_regex] = convert_pairs(@@detector_stats[:bus_library_regex])
96
+ end
97
+
98
+ end
@@ -0,0 +1,254 @@
1
+ require File.join File.dirname(__FILE__), '../../lib/ipxact_tools'
2
+
3
+ PLATFORM_PATH = File.join File.dirname(__FILE__), '../test_data/spiritconsortium.org/Leon2TLM'
4
+ DESIGN_PATH = File.join File.dirname(__FILE__), '../test_data/spiritconsortium.org/Leon2TLM'
5
+
6
+ describe "The data calculation functions of our IPXACT tool" do
7
+ it "should be able to find valid data paths when building a driver" do
8
+ expected_data_path = [
9
+ [
10
+ {
11
+ :component_instance => 'i_proc',
12
+ :port_name => "AHB_Master",
13
+ },
14
+ {
15
+ :component_instance => 'i_ahb',
16
+ :port_name => 'AHB_MirroredMaster0'
17
+ }
18
+ ],
19
+ [
20
+ {
21
+ :component_instance => 'i_ahb',
22
+ :port_name => 'AHB_MirroredSlave1'
23
+ },
24
+ {
25
+ :component_instance => 'i_h2p',
26
+ :port_name => 'AHB_Slave'
27
+ }
28
+ ],
29
+ [
30
+ {
31
+ :component_instance => 'i_h2p',
32
+ :port_name => 'APB_Master'
33
+ },
34
+ {
35
+ :component_instance => 'i_apb',
36
+ :port_name => 'APB_MirroredMaster'
37
+ }
38
+ ],
39
+ [
40
+ {
41
+ :component_instance => 'i_apb',
42
+ :port_name => 'APB_MirroredSlave7'
43
+ },
44
+ {
45
+ :component_instance => 'i_dma',
46
+ :port_name => 'APB_Slave'
47
+ }
48
+ ]
49
+ ]
50
+
51
+ components = IPXACT::load_components(PLATFORM_PATH)
52
+ designs = IPXACT::load_designs(PLATFORM_PATH)
53
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
54
+
55
+ data_path = nil
56
+ lambda {
57
+ data_path = IPXACT::Tools.resolve_data_path(platform, 'i_proc', 'i_dma')
58
+ }.should_not raise_exception
59
+ data_path.should eql(expected_data_path)
60
+ end
61
+
62
+ it "should be able to determine the dma component's base address from the interconnect path" do
63
+ # DMA remap address : 0x30000000 + 0x7000 = 0x30007000
64
+ components = IPXACT::load_components(PLATFORM_PATH)
65
+ designs = IPXACT::load_designs(PLATFORM_PATH)
66
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
67
+ data_path = IPXACT::Tools::resolve_data_path(platform, 'i_proc', 'i_dma')
68
+
69
+ base_address = IPXACT::Tools::resolve_base_address(platform, data_path)
70
+ base_address.should == 0x30007000 # AHB remap + APB remap (as defined in the apbSubsystem design file)
71
+ end
72
+
73
+
74
+ it "should be able to determine the cgu component's base address from the interconnect path" do
75
+ components = IPXACT::load_components(PLATFORM_PATH)
76
+ designs = IPXACT::load_designs(PLATFORM_PATH)
77
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.2"], components, designs)
78
+ data_path = IPXACT::Tools::resolve_data_path(platform, 'i_proc', 'i_cgu')
79
+
80
+ base_address = IPXACT::Tools::resolve_base_address(platform, data_path)
81
+ base_address.should == 0x30004000
82
+ end
83
+
84
+ it "should be able to take into account the component registers' corresponding address block's base address" do
85
+ components = IPXACT::load_components(PLATFORM_PATH)
86
+ designs = IPXACT::load_designs(PLATFORM_PATH)
87
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.2"], components, designs)
88
+ data_path = IPXACT::Tools::resolve_data_path(platform, 'i_proc', 'i_uart_scml')
89
+
90
+ base_address = IPXACT::Tools::resolve_base_address(platform, data_path)
91
+ port_id = data_path.last[1]
92
+ component = platform.rec_get_subcomponent('i_uart_scml')
93
+ port = component.port(port_id[:port_name])
94
+
95
+ # N.B. There's a remap address error in the "IP-XACT_TLM_Examples_AppNote_V1.5" document that's
96
+ # released with the IP-XACT specification: remap address for the i_uart_scml instance does not match
97
+ # what is actually in the Leon2Platform file.
98
+ (base_address + port[:port_data][:base_address].to_i(16)).should == 0x30000000 + 0x2000 + 0xB0000000
99
+ end
100
+
101
+ context "data path validation" do
102
+ it "should return an empty diagnosis if the given path is valid" do
103
+ valid_data_path = [
104
+ [
105
+ {
106
+ :component_instance => 'i_proc',
107
+ :port_name => "AHB_Master",
108
+ },
109
+ {
110
+ :component_instance => 'i_ahb',
111
+ :port_name => 'AHB_MirroredMaster0'
112
+ }
113
+ ],
114
+ [
115
+ {
116
+ :component_instance => 'i_ahb',
117
+ :port_name => 'AHB_MirroredSlave1'
118
+ },
119
+ {
120
+ :component_instance => 'i_h2p',
121
+ :port_name => 'AHB_Slave'
122
+ }
123
+ ],
124
+ [
125
+ {
126
+ :component_instance => 'i_h2p',
127
+ :port_name => 'APB_Master'
128
+ },
129
+ {
130
+ :component_instance => 'i_apb',
131
+ :port_name => 'APB_MirroredMaster'
132
+ }
133
+ ],
134
+ [
135
+ {
136
+ :component_instance => 'i_apb',
137
+ :port_name => 'APB_MirroredSlave7'
138
+ },
139
+ {
140
+ :component_instance => 'i_dma',
141
+ :port_name => 'APB_Slave'
142
+ }
143
+ ]
144
+ ]
145
+
146
+ components = IPXACT::load_components(PLATFORM_PATH)
147
+ designs = IPXACT::load_designs(PLATFORM_PATH)
148
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
149
+
150
+ diagnosis = IPXACT::Tools.validate_data_path(platform, valid_data_path)
151
+ diagnosis.errors.should be_empty
152
+ diagnosis.warnings.should be_empty
153
+ end
154
+
155
+ it "should return an error if the first element of the data path is not a master" do
156
+ first_element = \
157
+ [
158
+ {
159
+ :component_instance => 'i_ahb',
160
+ :port_name => 'AHB_MirroredSlave1'
161
+ },
162
+ {
163
+ :component_instance => 'i_h2p',
164
+ :port_name => 'AHB_Slave'
165
+ }
166
+ ]
167
+ incomplete_data_path = [
168
+ first_element,
169
+ [
170
+ {
171
+ :component_instance => 'i_h2p',
172
+ :port_name => 'APB_Master'
173
+ },
174
+ {
175
+ :component_instance => 'i_apb',
176
+ :port_name => 'APB_MirroredMaster'
177
+ }
178
+ ],
179
+ [
180
+ {
181
+ :component_instance => 'i_apb',
182
+ :port_name => 'APB_MirroredSlave7'
183
+ },
184
+ {
185
+ :component_instance => 'i_dma',
186
+ :port_name => 'APB_Slave'
187
+ }
188
+ ]
189
+ ]
190
+ components = IPXACT::load_components(PLATFORM_PATH)
191
+ designs = IPXACT::load_designs(PLATFORM_PATH)
192
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
193
+
194
+ diagnosis = IPXACT::Tools.validate_data_path(platform, incomplete_data_path)
195
+ diagnosis.errors.should_not be_empty
196
+ diagnosis.errors.should include(IPXACT::Tools::ValidationError.new(:first_element_not_a_master => first_element))
197
+ end
198
+
199
+ it "should be able to discover potential interrupt lines in an interconnect path" do
200
+ interrupt_line = \
201
+ [
202
+ {
203
+ :component_instance => 'i_dma',
204
+ :port_name => "INT_Master",
205
+ },
206
+ {
207
+ :component_instance => 'i_sub',
208
+ :port_name => 'INT_Slave'
209
+ }
210
+ ]
211
+ data_path_with_interrupt = \
212
+ [
213
+ [
214
+ {
215
+ :component_instance => 'i_h2p',
216
+ :port_name => 'APB_Master'
217
+ },
218
+ {
219
+ :component_instance => 'i_apb',
220
+ :port_name => 'APB_MirroredMaster'
221
+ }
222
+ ],
223
+ [
224
+ {
225
+ :component_instance => 'i_apb',
226
+ :port_name => 'APB_MirroredSlave7'
227
+ },
228
+ {
229
+ :component_instance => 'i_dma',
230
+ :port_name => 'APB_Slave'
231
+ }
232
+ ],
233
+ interrupt_line,
234
+ [
235
+ {
236
+ :component_instance => 'i_proc',
237
+ :port_name => 'APB_Slave'
238
+ },
239
+ {
240
+ :component_instance => 'i_sub',
241
+ :port_name => 'APB_MSlave_6'
242
+ }
243
+ ]
244
+ ]
245
+ components = IPXACT::load_components(PLATFORM_PATH)
246
+ designs = IPXACT::load_designs(PLATFORM_PATH)
247
+ platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
248
+
249
+ diagnosis = IPXACT::Tools.validate_data_path(platform, data_path_with_interrupt)
250
+ diagnosis.errors.should_not be_empty
251
+ diagnosis.errors.should include(IPXACT::Tools::ValidationError.new(:probable_interrupt_line => interrupt_line))
252
+ end
253
+ end
254
+ end
@@ -0,0 +1,135 @@
1
+ /*****************************************************************************
2
+ Revision: $Revision: 1506 $
3
+ Date: $Date: 2009-04-26 01:51:56 -0500 (Sun, 26 Apr 2009) $
4
+
5
+ Copyright (c) 2008, 2009 The SPIRIT Consortium.
6
+
7
+ This work forms part of a deliverable of The SPIRIT Consortium.
8
+
9
+ Use of these materials are governed by the legal terms and conditions
10
+ outlined in the disclaimer available from www.spiritconsortium.org.
11
+
12
+ This source file is provided on an AS IS basis. The SPIRIT
13
+ Consortium disclaims any warranty express or implied including
14
+ any warranty of merchantability and fitness for use for a
15
+ particular purpose.
16
+
17
+ The user of the source file shall indemnify and hold The SPIRIT
18
+ Consortium and its members harmless from any damages or liability.
19
+ Users are requested to provide feedback to The SPIRIT Consortium
20
+ using either mailto:feedback@lists.spiritconsortium.org or the forms at
21
+ http://www.spiritconsortium.org/about/contact_us/
22
+
23
+ This file may be copied, and distributed, with or without
24
+ modifications; but these notices must be included on any copy.
25
+
26
+ The following code is derived, directly or indirectly, from the SystemC
27
+ source code Copyright (c) 1996-2004 by all Contributors.
28
+ All Rights reserved.
29
+
30
+ The contents of this file are subject to the restrictions and limitations
31
+ set forth in the SystemC Open Source License Version 2.4 (the "License");
32
+ You may not use this file except in compliance with such restrictions and
33
+ limitations. You may obtain instructions on how to receive a copy of the
34
+ License at http://www.systemc.org/. Software distributed by Contributors
35
+ under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
36
+ ANY KIND, either express or implied. See the License for the specific
37
+ language governing rights and limitations under the License.
38
+
39
+ *****************************************************************************/
40
+
41
+
42
+ #ifndef _PV_INITIATOR_PORT_H_
43
+ #define _PV_INITIATOR_PORT_H_
44
+
45
+ /*------------------------------------------------------------------------------
46
+ * Includes
47
+ *----------------------------------------------------------------------------*/
48
+ #include <vector>
49
+
50
+ #include "systemc.h"
51
+
52
+ #include "tlm.h"
53
+
54
+ #include "pv_tlm_if.h"
55
+ #include "pv_initiator_port_base.h"
56
+ #include "pv_target_port.h"
57
+
58
+ //----------------------------------------------------------------------------
59
+ template<typename ADDRESS,typename DATA,int N = 1>
60
+ class pv_initiator_port :
61
+ public sc_port<tlm::tlm_transport_if<pv_request<ADDRESS,DATA>,pv_response<DATA> >, N>,
62
+ public pv_initiator_port_base,
63
+ public virtual pv_tlm_if<ADDRESS,DATA> {
64
+
65
+ typedef pv_request<ADDRESS,DATA> request_type;
66
+ typedef pv_response<DATA> response_type;
67
+
68
+ typedef tlm::tlm_transport_if<request_type,response_type> interface_type;
69
+
70
+ typedef sc_export<interface_type> sc_target_port_type;
71
+ typedef sc_port<interface_type,N> sc_initiator_port_type;
72
+
73
+ typedef pv_target_port<ADDRESS,DATA> pv_target_port_type;
74
+ typedef pv_initiator_port<ADDRESS,DATA,N> pv_initiator_port_type;
75
+
76
+ typedef pv_target_port_base target_port_base_type;
77
+ typedef pv_initiator_port_base initiator_port_base_type;
78
+
79
+ public:
80
+
81
+ //--------------
82
+ // Constructor
83
+ //--------------
84
+ pv_initiator_port(const char * port_name);
85
+
86
+
87
+ //---------------------------------------
88
+ // Execute the transaction transfer
89
+ void do_transport(request_type& request,
90
+ response_type& response,
91
+ unsigned int target_port_rank = 0);
92
+
93
+ //-------------------------------------------------------------------
94
+ //Abstract class pv_tlm_if methods implementation: used as convenience API
95
+
96
+ virtual tlm::tlm_status read(const ADDRESS& address,
97
+ DATA& data,
98
+ const unsigned int byte_enable = tlm::NO_BE,
99
+ const tlm::tlm_mode mode = tlm::REGULAR,
100
+ const unsigned int export_id = 0
101
+ );
102
+
103
+ virtual tlm::tlm_status write(const ADDRESS& address,
104
+ const DATA& data,
105
+ const unsigned int byte_enable = tlm::NO_BE,
106
+ const tlm::tlm_mode mode = tlm::REGULAR,
107
+ const unsigned int export_id = 0
108
+ );
109
+
110
+ //------------------
111
+ //Additional methods
112
+ void before_end_of_elaboration();
113
+ void end_of_elaboration();
114
+
115
+ void bind(pv_target_port_type&);
116
+ void operator() (pv_target_port_type&);
117
+
118
+ void bind(sc_port_b<interface_type>&);
119
+ void operator() (sc_port_b<interface_type>&);
120
+
121
+ void bind(interface_type&);
122
+ void operator() (interface_type&);
123
+
124
+ protected:
125
+ bool is_interface_bound_twice(sc_export_base&);
126
+ };
127
+
128
+
129
+
130
+ // Class implementation
131
+ #include "./pv_initiator_port.tpp"
132
+
133
+ #endif /* _PV_INITIATOR_PORT_H_ */
134
+
135
+