GeMRTOS
avalon_bridge_hw.tcl
Go to the documentation of this file.
1 # (C) 2001-2013 Altera Corporation. All rights reserved.
2 # Your use of Altera Corporation's design tools, logic functions and other
3 # software and tools, and its AMPP partner logic functions, and any output
4 # files any of the foregoing (including device programming or simulation
5 # files), and any associated documentation or information are expressly subject
6 # to the terms and conditions of the Altera Program License Subscription
7 # Agreement, Altera MegaCore Function License Agreement, or other applicable
8 # license agreement, including, without limitation, that your use is for the
9 # sole purpose of programming logic devices manufactured by Altera and sold by
10 # Altera or its authorized distributors. Please refer to the applicable
11 # agreement for further details.
12 
13 
14 # +-----------------------------------
15 # |
16 # | avalon_bridge "Avalon-MM Pipeline Bridge"
17 # |
18 # +-----------------------------------
19 
20 # +-----------------------------------
21 # | request TCL package from ACDS 10.0
22 # |
23 package require -exact sopc 10.0
24 # |
25 # +-----------------------------------
26 
27 # +-----------------------------------
28 # | module avalon_bridge
29 # |
30 set_module_property DESCRIPTION "GRTOS Avalon bridge module"
31 set_module_property NAME GRTOS_Avalon_Bridge
32 set_module_property VERSION 13.0
33 set_module_property GROUP gRTOS
34 set_module_property INTERNAL true
35 set_module_property AUTHOR "Ricardo Cayssials"
36 set_module_property DISPLAY_NAME "GRTOS Avalon bridge module"
37 set_module_property TOP_LEVEL_HDL_FILE avalon_bridge.vhd
38 set_module_property TOP_LEVEL_HDL_MODULE avalon_bridge
39 set_module_property INSTANTIATE_IN_SYSTEM_MODULE true
40 set_module_property EDITABLE true
41 set_module_property ELABORATION_CALLBACK elaborate
42 set_module_property ANALYZE_HDL FALSE
43 set_module_property SIMULATION_MODEL_IN_VHDL true
44 set_module_property HIDE_FROM_SOPC true
45 #set_module_property DATASHEET_URL http://www.altera.com/literature/hb/qts/qsys_interconnect.pdf
46 
47 
48 # |
49 # +-----------------------------------
50 
51 # +-----------------------------------
52 # | files
53 # |
54 add_file avalon_bridge.vhd {SYNTHESIS SIMULATION}
55 
56 # |
57 # +-----------------------------------
58 
59 # +-----------------------------------
60 # | parameters
61 # |
62 
63 # Number of Processors
64 add_parameter NProcessors INTEGER 1 "Number of System Processors"
65 set_parameter_property NProcessors DEFAULT_VALUE 1
66 set_parameter_property NProcessors DISPLAY_NAME "Number of Processors"
67 set_parameter_property NProcessors TYPE INTEGER
68 set_parameter_property NProcessors UNITS None
69 set_parameter_property NProcessors ALLOWED_RANGES {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32}
70 set_parameter_property NProcessors DESCRIPTION "Number of System Processors"
71 set_parameter_property NProcessors HDL_PARAMETER true
72 
73 
74 add_parameter DATA_WIDTH INTEGER 32
75 set_parameter_property DATA_WIDTH DEFAULT_VALUE 32
76 set_parameter_property DATA_WIDTH DISPLAY_NAME {Data width}
77 set_parameter_property DATA_WIDTH TYPE INTEGER
78 set_parameter_property DATA_WIDTH UNITS None
79 set_parameter_property DATA_WIDTH DISPLAY_HINT ""
80 set_parameter_property DATA_WIDTH AFFECTS_GENERATION false
81 set_parameter_property DATA_WIDTH HDL_PARAMETER true
82 set_parameter_property DATA_WIDTH DESCRIPTION {Bridge data width}
83 
84 add_parameter SYMBOL_WIDTH INTEGER 8
85 set_parameter_property SYMBOL_WIDTH DEFAULT_VALUE 8
86 set_parameter_property SYMBOL_WIDTH DISPLAY_NAME {Symbol width}
87 set_parameter_property SYMBOL_WIDTH TYPE INTEGER
88 set_parameter_property SYMBOL_WIDTH UNITS None
89 set_parameter_property SYMBOL_WIDTH DISPLAY_HINT ""
90 set_parameter_property SYMBOL_WIDTH AFFECTS_GENERATION false
91 set_parameter_property SYMBOL_WIDTH HDL_PARAMETER false
92 set_parameter_property SYMBOL_WIDTH DESCRIPTION {Symbol (byte) width}
93 
94 add_parameter ADDRESS_WIDTH INTEGER 32
95 set_parameter_property ADDRESS_WIDTH DEFAULT_VALUE 32
96 set_parameter_property ADDRESS_WIDTH DISPLAY_NAME {Address width}
97 set_parameter_property ADDRESS_WIDTH TYPE INTEGER
98 set_parameter_property ADDRESS_WIDTH UNITS None
99 set_parameter_property ADDRESS_WIDTH DISPLAY_HINT ""
100 set_parameter_property ADDRESS_WIDTH AFFECTS_GENERATION false
101 set_parameter_property ADDRESS_WIDTH HDL_PARAMETER true
102 set_parameter_property ADDRESS_WIDTH DESCRIPTION {Bridge address width}
103 
104 add_parameter BURSTCOUNT_WIDTH INTEGER 1
105 set_parameter_property BURSTCOUNT_WIDTH DEFAULT_VALUE 1
106 set_parameter_property BURSTCOUNT_WIDTH DISPLAY_NAME {Burstcount width}
107 set_parameter_property BURSTCOUNT_WIDTH VISIBLE false
108 set_parameter_property BURSTCOUNT_WIDTH DERIVED true
109 set_parameter_property BURSTCOUNT_WIDTH TYPE INTEGER
110 set_parameter_property BURSTCOUNT_WIDTH UNITS None
111 set_parameter_property BURSTCOUNT_WIDTH DISPLAY_HINT ""
112 set_parameter_property BURSTCOUNT_WIDTH AFFECTS_GENERATION false
113 set_parameter_property BURSTCOUNT_WIDTH HDL_PARAMETER true
114 set_parameter_property BURSTCOUNT_WIDTH DESCRIPTION {Bridge burstcount width}
115 
116 
117 add_parameter LINEWRAPBURSTS INTEGER 0
118 set_parameter_property LINEWRAPBURSTS DISPLAY_NAME "Line wrap bursts"
119 set_parameter_property LINEWRAPBURSTS TYPE INTEGER
120 set_parameter_property LINEWRAPBURSTS AFFECTS_ELABORATION true
121 set_parameter_property LINEWRAPBURSTS HDL_PARAMETER false
122 set_parameter_property LINEWRAPBURSTS DISPLAY_HINT BOOLEAN
123 set_parameter_property LINEWRAPBURSTS AFFECTS_GENERATION false
124 set_parameter_property LINEWRAPBURSTS DESCRIPTION "This parameter allows you to match the behavior of some memory devices that implement a wrapping burst instead of an incrementing burst. The difference between the two is that with a wrapping burst, when the address reaches a burst boundary, the address wraps back to the previous burst boundary so that only the low-order bits are required for address counting"
125 
126 add_parameter DEVICE_FAMILY STRING
127 set_parameter_property DEVICE_FAMILY SYSTEM_INFO {DEVICE_FAMILY}
128 set_parameter_property DEVICE_FAMILY DESCRIPTION DEVICE_FAMILY
129 set_parameter_property DEVICE_FAMILY HDL_PARAMETER true
130 add_display_item "" DEVICE_FAMILY PARAMETER
131 
132 add_parameter BYTEEN_WIDTH INTEGER
133 set_parameter_property BYTEEN_WIDTH DERIVED true
134 set_parameter_property BYTEEN_WIDTH TYPE INTEGER
135 set_parameter_property BYTEEN_WIDTH UNITS None
136 set_parameter_property BYTEEN_WIDTH HDL_PARAMETER true
137 add_display_item "" BYTEEN_WIDTH PARAMETER
138 
139 add_parameter MAX_BURST_SIZE INTEGER 1
140 set_parameter_property MAX_BURST_SIZE DISPLAY_NAME {Maximum burst size (words)}
141 set_parameter_property MAX_BURST_SIZE AFFECTS_GENERATION true
142 set_parameter_property MAX_BURST_SIZE HDL_PARAMETER false
143 set_parameter_property MAX_BURST_SIZE DESCRIPTION {Specifies the maximum burst size}
144 set_parameter_property MAX_BURST_SIZE ALLOWED_RANGES "1,2,4,8,16,32,64,128,256,512,1024"
145 
146 add_parameter ADDRESS_UNITS STRING "SYMBOLS"
147 set_parameter_property ADDRESS_UNITS DISPLAY_NAME {Address units}
148 set_parameter_property ADDRESS_UNITS UNITS None
149 set_parameter_property ADDRESS_UNITS DISPLAY_HINT ""
150 set_parameter_property ADDRESS_UNITS AFFECTS_GENERATION false
151 set_parameter_property ADDRESS_UNITS HDL_PARAMETER false
152 set_parameter_property ADDRESS_UNITS ALLOWED_RANGES "SYMBOLS,WORDS"
153 set_parameter_property ADDRESS_UNITS DESCRIPTION {Address units (Symbols[bytes]/Words)}
154 
155 add_parameter MAX_PENDING_RESPONSES INTEGER 32
156 set_parameter_property MAX_PENDING_RESPONSES DISPLAY_NAME {Maximum pending read transactions}
157 set_parameter_property MAX_PENDING_RESPONSES TYPE INTEGER
158 set_parameter_property MAX_PENDING_RESPONSES UNITS None
159 set_parameter_property MAX_PENDING_RESPONSES DISPLAY_HINT ""
160 set_parameter_property MAX_PENDING_RESPONSES AFFECTS_GENERATION false
161 set_parameter_property MAX_PENDING_RESPONSES DESCRIPTION {Controls the Avalon-MM maximum pending read transactions interface property of the bridge}
162 
163 
164 # |
165 # +-----------------------------------
166 
167 # +-----------------------------------
168 # | connection point clk
169 # |
170 add_interface clk clock end
171 add_interface reset reset end
172 
173 set_interface_property clk ENABLED true
174 set_interface_property reset ENABLED true
175 set_interface_property reset ASSOCIATED_CLOCK clk
176 
177 add_interface_port clk clk clk Input 1
178 add_interface_port reset reset reset Input 1
179 # |
180 # +-----------------------------------
181 
182 
183 
184 proc elaborate { } {
185 
186  set data_width [ get_parameter_value DATA_WIDTH ]
187  set sym_width [ get_parameter_value SYMBOL_WIDTH ]
188  set byteen_width [ expr $data_width / $sym_width ]
189  set mprt [ get_parameter_value MAX_PENDING_RESPONSES ]
190  set aunits [ get_parameter_value ADDRESS_UNITS ]
191  set burst_size [ get_parameter_value MAX_BURST_SIZE ]
192  set linewrap [ get_parameter_value LINEWRAPBURSTS ]
193 
194  set burstcount_width [ expr int (ceil (log($burst_size) / log(2))) + 1 ]
195  set_parameter_value BURSTCOUNT_WIDTH $burstcount_width
196 
197  set data_width [ get_parameter_value DATA_WIDTH ]
198  set symbol_width [ get_parameter_value SYMBOL_WIDTH ]
199  set byteen_width [ expr int (ceil ($data_width / $symbol_width )) ]
200  set_parameter_value BYTEEN_WIDTH $byteen_width
201 
202  set Processors [get_parameter_value NProcessors]
203  for {set i 1} {$i <= $Processors} {incr i} {
204  # ############################################################
205  # +-----------------------------------
206  # | connection point s0
207  # |
208  add_interface s$i avalon end
209  set_interface_property s$i addressAlignment DYNAMIC
210  set_interface_property s$i associatedClock clk
211  set_interface_property s$i bridgesToMaster m$i
212  set_interface_property s$i burstOnBurstBoundariesOnly false
213  set_interface_property s$i explicitAddressSpan 0
214  set_interface_property s$i holdTime 0
215  set_interface_property s$i isMemoryDevice false
216  set_interface_property s$i isNonVolatileStorage false
217  set_interface_property s$i linewrapBursts false
218  set_interface_property s$i maximumPendingReadTransactions 4
219  set_interface_property s$i printableDevice false
220  set_interface_property s$i readLatency 0
221  set_interface_property s$i readWaitTime 0
222  set_interface_property s$i setupTime 0
223  set_interface_property s$i timingUnits Cycles
224  set_interface_property s$i writeWaitTime 0
225 
226  set_interface_property s$i ASSOCIATED_CLOCK clk
227  set_interface_property s$i associatedReset reset
228  set_interface_property s$i ENABLED true
229 
230  add_interface_port s$i s${i}_waitrequest waitrequest Output 1
231  add_interface_port s$i s${i}_readdata readdata Output DATA_WIDTH
232  add_interface_port s$i s${i}_readdatavalid readdatavalid Output 1
233  add_interface_port s$i s${i}_burstcount burstcount Input BURSTCOUNT_WIDTH
234  add_interface_port s$i s${i}_writedata writedata Input DATA_WIDTH
235  add_interface_port s$i s${i}_address address Input ADDRESS_WIDTH
236  add_interface_port s$i s${i}_write write Input 1
237  add_interface_port s$i s${i}_read read Input 1
238  add_interface_port s$i s${i}_byteenable byteenable Input 4
239  add_interface_port s$i s${i}_debugaccess debugaccess Input 1
240 
241  # +-----------------------------------
242  # | connection point m0
243  # |
244  add_interface m$i avalon start
245  set_interface_property m$i associatedClock clk
246  set_interface_property m$i burstOnBurstBoundariesOnly false
247  set_interface_property m$i doStreamReads false
248  set_interface_property m$i doStreamWrites false
249  set_interface_property m$i linewrapBursts false
250 
251  set_interface_property m$i ASSOCIATED_CLOCK clk
252  set_interface_property m$i associatedReset reset
253  set_interface_property m$i ENABLED true
254 
255  add_interface_port m$i m${i}_waitrequest waitrequest Input 1
256  add_interface_port m$i m${i}_readdata readdata Input DATA_WIDTH
257  add_interface_port m$i m${i}_readdatavalid readdatavalid Input 1
258  add_interface_port m$i m${i}_burstcount burstcount Output BURSTCOUNT_WIDTH
259  add_interface_port m$i m${i}_writedata writedata Output DATA_WIDTH
260  add_interface_port m$i m${i}_address address Output ADDRESS_WIDTH
261  add_interface_port m$i m${i}_write write Output 1
262  add_interface_port m$i m${i}_read read Output 1
263  add_interface_port m$i m${i}_byteenable byteenable Output 4
264  add_interface_port m$i m${i}_debugaccess debugaccess Output 1
265  # |
266  # +-----------------------------------
267 
268 
269  # ############################################################
270 
271  set_port_property m${i}_byteenable WIDTH $byteen_width
272  set_port_property s${i}_byteenable WIDTH $byteen_width
273 
274  set_interface_property m${i} bitsPerSymbol $sym_width
275  set_interface_property s${i} bitsPerSymbol $sym_width
276 
277  set_interface_property m$i addressUnits $aunits
278  set_interface_property s$i addressUnits $aunits
279 
280  set_interface_property s$i maximumPendingReadTransactions $mprt
281 
282  set_interface_property m$i linewrapBursts $linewrap
283  set_interface_property s$i linewrapBursts $linewrap
284  }
285 
286 
287 
288 }