soc_maker 0.1.1

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 (116) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/History.txt +4 -0
  4. data/LICENSE +678 -0
  5. data/README.rdoc +228 -0
  6. data/Rakefile +46 -0
  7. data/bin/soc_maker_cli +80 -0
  8. data/bin/soc_maker_parser +85 -0
  9. data/core_lib/cores/adv_debug_sys/01_adv_debug_sys.yaml +245 -0
  10. data/core_lib/cores/or1200_rel2/01_or1200.yaml +208 -0
  11. data/core_lib/cores/or1200_rel2/02_or1200_files.yaml +421 -0
  12. data/core_lib/cores/or1200_rel2/03_or1200_sparam.yaml +188 -0
  13. data/core_lib/cores/or1200_rel2/or1200_defines.v.in +1799 -0
  14. data/core_lib/cores/ram_wb/ram_wb.yaml +102 -0
  15. data/core_lib/cores/ram_wb/ram_wb_b3.v.in +259 -0
  16. data/core_lib/cores/uart16550/01_uart16550.yaml +99 -0
  17. data/core_lib/cores/uart16550/02_uart16550_files.yaml +70 -0
  18. data/core_lib/cores/wb_connect/minsoc_tc_top.v +1802 -0
  19. data/core_lib/cores/wb_connect/wb_connect.yaml +733 -0
  20. data/core_lib/inc.yaml +13 -0
  21. data/core_lib/interfaces/clk_rst/clk.yaml +9 -0
  22. data/core_lib/interfaces/clk_rst/rst.yaml +9 -0
  23. data/core_lib/interfaces/clk_rst/single.yaml +7 -0
  24. data/core_lib/interfaces/debug/debug.yaml +32 -0
  25. data/core_lib/interfaces/jtag/jtag.yaml +13 -0
  26. data/core_lib/interfaces/jtag/jtag_tap.yaml +22 -0
  27. data/core_lib/interfaces/power/or_power.yaml +25 -0
  28. data/core_lib/interfaces/uart/uart.yaml +21 -0
  29. data/core_lib/interfaces/wishbone/wishbone_ma_b3.yaml +54 -0
  30. data/core_lib/interfaces/wishbone/wishbone_sl_b3.yaml +51 -0
  31. data/doc/class_arch.uml +5113 -0
  32. data/doc/fig/hierarchical.svg +273 -0
  33. data/examples/or1200_test/or1200_test.cmd +78 -0
  34. data/examples/or1200_test/or1200_test.rb +136 -0
  35. data/examples/or1200_test/rtl/or1200_test_top.vhd +274 -0
  36. data/examples/or1200_test/rtl/s3astarter.ucf +10 -0
  37. data/examples/or1200_test/rtl/xilinx_internal_jtag.v +438 -0
  38. data/examples/or1200_test/rtl/xilinx_internal_jtag_options.v +12 -0
  39. data/examples/or1200_test/sw/README.txt +35 -0
  40. data/examples/or1200_test/sw/bin2vmem.c +159 -0
  41. data/examples/or1200_test/sw/board.h +24 -0
  42. data/examples/or1200_test/sw/compile.sh +18 -0
  43. data/examples/or1200_test/sw/except.S +152 -0
  44. data/examples/or1200_test/sw/int.c +79 -0
  45. data/examples/or1200_test/sw/int.h +14 -0
  46. data/examples/or1200_test/sw/interconnect.h +17 -0
  47. data/examples/or1200_test/sw/interrupts.c +14 -0
  48. data/examples/or1200_test/sw/main.c +16 -0
  49. data/examples/or1200_test/sw/or1200.h +454 -0
  50. data/examples/or1200_test/sw/orp.ld +60 -0
  51. data/examples/or1200_test/sw/reset.S +112 -0
  52. data/examples/or1200_test/sw/support.c +123 -0
  53. data/examples/or1200_test/sw/support.h +33 -0
  54. data/examples/or1200_test/sw/tick.c +30 -0
  55. data/examples/or1200_test/sw/tick.h +2 -0
  56. data/examples/or1200_test/sw/uart.c +136 -0
  57. data/examples/or1200_test/sw/uart.h +126 -0
  58. data/lib/soc_maker.rb +324 -0
  59. data/lib/soc_maker/cli.rb +544 -0
  60. data/lib/soc_maker/conf.rb +310 -0
  61. data/lib/soc_maker/core_def.rb +579 -0
  62. data/lib/soc_maker/core_inst.rb +305 -0
  63. data/lib/soc_maker/err.rb +211 -0
  64. data/lib/soc_maker/hdl_coder.rb +500 -0
  65. data/lib/soc_maker/hdl_file.rb +166 -0
  66. data/lib/soc_maker/hdl_parser.rb +431 -0
  67. data/lib/soc_maker/ifc_def.rb +193 -0
  68. data/lib/soc_maker/ifc_port.rb +133 -0
  69. data/lib/soc_maker/ifc_spc.rb +180 -0
  70. data/lib/soc_maker/lib.rb +289 -0
  71. data/lib/soc_maker/lib_inc.rb +109 -0
  72. data/lib/soc_maker/parameter.rb +149 -0
  73. data/lib/soc_maker/soc_def.rb +847 -0
  74. data/lib/soc_maker/sparameter.rb +289 -0
  75. data/lib/soc_maker/version.rb +8 -0
  76. data/lib/soc_maker/ypp.rb +130 -0
  77. data/soc_maker.gemspec +28 -0
  78. data/spec/cli_cmds1.txt +39 -0
  79. data/spec/cli_spec.rb +49 -0
  80. data/spec/conf_spec.rb +44 -0
  81. data/spec/core_def_spec.rb +503 -0
  82. data/spec/core_inst_spec.rb +169 -0
  83. data/spec/hdl_file_spec.rb +154 -0
  84. data/spec/hdl_parser_spec.rb +201 -0
  85. data/spec/ifc_def_spec.rb +121 -0
  86. data/spec/ifc_port_spec.rb +92 -0
  87. data/spec/ifc_spc_spec.rb +196 -0
  88. data/spec/lib_inc_spec.rb +99 -0
  89. data/spec/lib_spec.rb +209 -0
  90. data/spec/parameter_spec.rb +86 -0
  91. data/spec/soc_def_spec.rb +611 -0
  92. data/spec/soc_maker_spec.rb +7 -0
  93. data/spec/sparameter_spec.rb +182 -0
  94. data/spec/spec_helper.rb +78 -0
  95. data/spec/test_soc.yaml +105 -0
  96. data/spec/test_soc2.yaml +60 -0
  97. data/spec/test_soc_lib/cores/core_A_rel1/00_core_a.yaml +75 -0
  98. data/spec/test_soc_lib/cores/core_A_rel1/01_core_a.yaml +57 -0
  99. data/spec/test_soc_lib/cores/core_A_rel1/core_a.vhd +29 -0
  100. data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg.vhd.src +3 -0
  101. data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg2.vhd.src +4 -0
  102. data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg3.v.src +6 -0
  103. data/spec/test_soc_lib/cores/core_B_rel1/core_b.vhd +25 -0
  104. data/spec/test_soc_lib/cores/core_B_rel1/core_b.yaml +36 -0
  105. data/spec/test_soc_lib/cores/core_C_v1/core_C.vhd +57 -0
  106. data/spec/test_soc_lib/cores/core_C_v1/core_c.yaml +42 -0
  107. data/spec/test_soc_lib/cores/soc_A/soc_A.yaml +12 -0
  108. data/spec/test_soc_lib/cores/soc_maker_include.yaml +6 -0
  109. data/spec/test_soc_lib/ifcs/core_AB_ifc/bidir_ifc.yaml +19 -0
  110. data/spec/test_soc_lib/ifcs/core_AB_ifc/core_AB_ifc.yaml +15 -0
  111. data/spec/test_soc_lib/ifcs/core_AB_ifc/top_ifc.yaml +9 -0
  112. data/spec/test_soc_lib/soc_maker_include.yaml +4 -0
  113. data/spec/yaml_examples.rb +367 -0
  114. data/spec/ypp_spec.rb +156 -0
  115. data/test/test_soc_maker.rb +0 -0
  116. metadata +255 -0
@@ -0,0 +1,500 @@
1
+ ###############################################################
2
+ #
3
+ # File: hdl_coder.rb
4
+ #
5
+ # Author: Christian Hättich
6
+ #
7
+ # Project: System-On-Chip Maker
8
+ #
9
+ # Target: Linux / Windows / Mac
10
+ #
11
+ # Language: ruby
12
+ #
13
+ #
14
+ ###############################################################
15
+ #
16
+ #
17
+ # Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
18
+ #
19
+ # This program is free software: you can redistribute it and/or modify
20
+ # it under the terms of the GNU General Public License as published by
21
+ # the Free Software Foundation, either version 3 of the License, or
22
+ # (at your option) any later version.
23
+ #
24
+ # This program is distributed in the hope that it will be useful,
25
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ # GNU General Public License for more details.
28
+ #
29
+ # You should have received a copy of the GNU General Public License
30
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
31
+ #
32
+ #
33
+ ###############################################################
34
+ module SOCMaker
35
+
36
+ #
37
+ # Please see VHDLCoder and VerilogCoder
38
+ #
39
+ class HDLCoder
40
+
41
+ include ERR
42
+
43
+
44
+ #
45
+ # Only calls clear (see clear).
46
+ #
47
+ def initialize
48
+ clear
49
+ end
50
+
51
+ #
52
+ # This method creates and clears three strings:
53
+ # - @decl_part: declarations
54
+ # - @asgn_part: assignments
55
+ # - @inst_part: instantiations
56
+ #
57
+ def clear
58
+ @decl_part = ""; # declaration
59
+ @asgn_part = ""; # assignment
60
+ @inst_part = ""; # instantiation
61
+ end
62
+
63
+
64
+ end
65
+
66
+
67
+ #
68
+ # Verilog coder class: not implemented, yet.
69
+ #
70
+ class VerilogCoder < HDLCoder
71
+
72
+ #
73
+ # Adds verilog file suffix
74
+ #
75
+ def filename( name )
76
+ return name + ".v"
77
+ end
78
+
79
+ end
80
+
81
+ #
82
+ # VHDL coder class: is used to create and implement VHDL
83
+ # cores by SOCMaker::SOCDef
84
+ #
85
+ class VHDLCoder < HDLCoder
86
+
87
+
88
+
89
+
90
+ #
91
+ # Add a component declaration to the declaration-string @decl_part
92
+ # This for example looks like
93
+ # component <<name>> is
94
+ # generic(
95
+ # g1 : ...
96
+ # g2 : ...
97
+ # ...
98
+ # );
99
+ # port(
100
+ # p1 : ...
101
+ # p2 : ...
102
+ # p3 : ...
103
+ # ...
104
+ # )
105
+ # end component <<name>>;
106
+ #
107
+ # In addition, we add some VHDL comments (author, mail, license)
108
+ #
109
+ # +core_name+:: name of the core
110
+ # +core_spec+:: core definition (of type SOCMaker::CoreDef)
111
+ #
112
+ #
113
+ def add_core_component( core_name, core_spec )
114
+
115
+ @decl_part << "--\n"
116
+ @decl_part << "-- core author: #{core_spec.author} - #{core_spec.authormail}\n"
117
+ @decl_part << "-- license: #{core_spec.license}\n"
118
+ @decl_part << "--\n"
119
+ @decl_part << "component #{core_spec.toplevel} is\n"
120
+ generic_str = entity_generic_str( core_spec );
121
+ @decl_part << "generic ( #{ generic_str });\n" if generic_str.size > 0
122
+ @decl_part << "port( \n" << entity_port_str( core_spec ) <<" );\n"
123
+ @decl_part << "end component #{core_spec.toplevel};\n"
124
+ #entity_generic_str( core_spec )
125
+ end
126
+
127
+ #
128
+ # Adds vhdl file suffix to name
129
+ #
130
+ def filename( name )
131
+ return name + ".vhd"
132
+ end
133
+
134
+ #
135
+ # Creates a the generic part for a core entity or component declaration.
136
+ # The result is something like
137
+ # generic_1 : integer := 4;
138
+ # generic_2 : natural := 1;
139
+ # generic_3 : std_logic := '0'
140
+ #
141
+ # +return+:: a string holding the generic data as VHDL code
142
+ #
143
+ #
144
+ def entity_generic_str( core )
145
+
146
+ generic_str = ""
147
+ core.generics do |gen_name, gen_type, gen_val, is_last|
148
+ generic_str << gen_name << " : " << gen_type << " := " << gen_val.to_s
149
+ generic_str << ";" unless is_last
150
+ generic_str << "\n"
151
+ end
152
+ return generic_str
153
+ end
154
+
155
+
156
+ #
157
+ # Create a string, which lists all signals of 'core'
158
+ # The method iterates over all interfaces:
159
+ # For each interface, this method iterates over all ports:
160
+ # For each port, the definition from the 'soc_lib' is loaded and
161
+ # the VHDL code according to the definition is added
162
+ # The result is simething like
163
+ # port_1 : in std_logic;
164
+ # port_2 : out std_logic_vector( 4-1 downto 0 );
165
+ # port_3 : in std_logic
166
+ #
167
+ #
168
+ # +core+:: the core, which is used to create the entity description
169
+ # +return+:: a string holding the entity description of a core as VHDL code
170
+ #
171
+ def entity_port_str( core )
172
+ port_string = ""
173
+
174
+ core.ports do |port_name, port_dir, port_len, port_default, port_ref, is_last |
175
+
176
+ # The string we are add in every iteration looks for example like
177
+ # myportname1 : out std_logic_vector( 6-1 downto 0 )
178
+ # or
179
+ # myportname2 : in std_logic
180
+ #
181
+ port_string << port_name.to_s << " : "
182
+
183
+
184
+
185
+ # port direction
186
+ if port_dir == 2
187
+ port_string << " inout "
188
+ elsif port_dir == 1
189
+ port_string << " in "
190
+ else
191
+ port_string << " out "
192
+ end
193
+
194
+ # port type / length
195
+ if( port_len.is_a?( String ) ||
196
+ ( port_len.is_a?( Fixnum ) && port_len > 1 )
197
+ )
198
+ port_string << " std_logic_vector( #{port_len}-1 downto 0 ) "
199
+ elsif ( port_len.is_a?( Fixnum ) && port_len == 1 )
200
+ port_string << " std_logic "
201
+ else
202
+ processing_error "failed to generate entity port entry because of wrong port-length type/value",
203
+ port_length_class: port_len.class,
204
+ port_length: port_len,
205
+ core: core.name,
206
+ port: port_name
207
+ end
208
+
209
+ # end of the line
210
+ port_string << ";" unless is_last
211
+ port_string << "\n"
212
+ end
213
+ return port_string
214
+ end
215
+
216
+
217
+
218
+ #
219
+ # Checks, if this instance/interface has an entry in top_cons.
220
+ # If yes, the top-level connection is returned, otherwise an
221
+ # empty Hash
222
+ #
223
+ # +inst_name+:: name of the instance
224
+ # +ifc_name+:: name of the interface
225
+ # +top_cons+:: connection Hash
226
+ # +return+:: {} if no entry exists, otherwise the top-level part of the entry
227
+ #
228
+ def is_ifc_connected?( inst_name, ifc_name, top_cons )
229
+ top_cons.each do |con_name, con_entry|
230
+ if con_entry[ :mapping ][ 0 ][ inst_name.to_sym ] == ifc_name.to_sym
231
+ return con_entry[ :mapping ][ 1 ]
232
+ elsif con_entry[ :mapping ][ 1 ][ inst_name.to_sym ] == ifc_name.to_sym
233
+ return con_entry[ :mapping ][ 0 ]
234
+ end
235
+ end
236
+ return {}
237
+ end
238
+
239
+
240
+ #
241
+ # This method create VHDL code to instanciate a core instance.
242
+ # The result is added to @inst_part and looks for example like
243
+ # inst_name : core_name
244
+ # generic_map(
245
+ # generic_1 => 3;
246
+ # generic_2 => -1;
247
+ # ....
248
+ # )
249
+ # port_map(
250
+ # p1 => inst_name_p1,
251
+ # p2 => inst_name_p2,
252
+ # ...
253
+ # );
254
+ # In addition, for every port signal, a internal signal is
255
+ # defined and added to @decl_part.
256
+ # This looks for example like
257
+ # signal inst_name_p1 : std_logic;
258
+ # signal inst_name_p2 : std_logic_vector( 4-1 downto 0 );
259
+ #
260
+ # +inst_name+:: name of the instance
261
+ # +inst+:: object of type SOCMaker::CoreInst, whih represents the instance
262
+ #
263
+ def add_core_instance( inst_name, inst, top_cons, top_ifcs, soc )
264
+
265
+ @inst_part << inst_name << " : " << inst.defn.toplevel << "\n"
266
+ generic_str = ""
267
+ inst.generics do |generic, type, value, is_last|
268
+ generic_str << "#{generic} => #{value}"
269
+ generic_str << "," unless is_last
270
+ generic_str << "\n"
271
+ end
272
+ @inst_part << "generic map( \n#{generic_str} )\n" if generic_str.size > 0
273
+ port_str = ""
274
+
275
+
276
+ inst.defn.interfaces.each_with_index do |(ifc_name, ifc), i_ifc|
277
+
278
+ top_con = is_ifc_connected?( inst_name, ifc_name, top_cons )
279
+ if top_con.size > 0
280
+ # direct assignment to entity-port
281
+ inst.ports( ifc_name ) do |port_name, dir, length, default, ref, is_last|
282
+ top_port = soc.port( top_con.values.first, ref.to_sym )
283
+ port_str << "#{port_name} => #{top_port[0]}"
284
+ port_str << "," unless (is_last && i_ifc == inst.defn.interfaces.size-1)
285
+ port_str << "\n"
286
+ end
287
+
288
+ else
289
+ # assignment to signal (which is used later)
290
+ #
291
+ inst.ports( ifc_name ) do |port_name, dir, length, default, ref, is_last|
292
+ port_str << "#{port_name} => #{inst_name}_#{port_name}"
293
+ port_str << "," unless (is_last && i_ifc == inst.defn.interfaces.size-1)
294
+ port_str << "\n"
295
+ if length > 1
296
+ @decl_part << "signal #{inst_name}_#{port_name} : std_logic_vector( #{length}-1 downto 0 );\n"
297
+ else
298
+ @decl_part << "signal #{inst_name}_#{port_name} : std_logic;\n"
299
+ end
300
+ end
301
+
302
+ end
303
+ end
304
+
305
+
306
+ @inst_part << "port map( \n#{port_str} );\n\n\n" if port_str.size > 0
307
+
308
+ end
309
+
310
+ #
311
+ # This method adds VHDL code to @asgn_part, which sets
312
+ # default values to an interface.
313
+ # This looks for example like
314
+ # some_port1 <= ( others => '0' );
315
+ # some_port2 <= '1';
316
+ #
317
+ # +inst+:: instance, which has the interface (of type SOCMaker::CoreInst)
318
+ # +inst_name+:: name of the instance
319
+ # +ifc_name+:: name of the interface
320
+ #
321
+ def add_ifc_default_assignment( inst, inst_name, ifc_name )
322
+
323
+ tmp = ""
324
+ inst.ports( ifc_name ) do |port_name, dir, length, default_val, ref, is_last|
325
+ if dir == 1 # assign default value only if it is an input
326
+ if length > 1
327
+ tmp << "#{inst_name}_#{port_name} <= ( others => '#{default_val}' );\n"
328
+ else
329
+ tmp << "#{inst_name}_#{port_name} <= '#{default_val}';\n"
330
+ end
331
+ end
332
+ end
333
+ @asgn_part << tmp
334
+ end
335
+
336
+ #
337
+ # This method is used to add VHDL code, which connects two interfaces
338
+ #
339
+ # +ifc_spec+:: interface specification
340
+ # +con_name+:: connection name
341
+ # +length+:: Hash, which contains the signal length for each port
342
+ # +src_inst+:: Array wich source instances
343
+ # +dst_inst+:: Array with destination instances
344
+ # +src_ifc+:: Hash with source interfaces
345
+ # +dst_ifc+:: Hash with destination interfaces
346
+ #
347
+ def add_ifc_connection( ifc_spec, con_name, length, src_inst, dst_inst, src_ifc, dst_ifc )
348
+
349
+ ###
350
+ #
351
+ # declaration
352
+ #
353
+ #
354
+ ifc_spec.ports.each do |port_name, port|
355
+ @decl_part << "signal #{con_name}_#{port_name.to_s} : "
356
+ if length[ port_name ] > 1
357
+ @decl_part << " std_logic_vector( #{length[ port_name ]}-1 downto 0 ) "
358
+ else
359
+ @decl_part << " std_logic "
360
+ end
361
+ # end of the line
362
+ @decl_part << ";\n"
363
+ end
364
+
365
+
366
+ ###
367
+ #
368
+ # assignment
369
+ #
370
+ #
371
+ ifc_spec.ports.each do |port_name, port_setup|
372
+
373
+
374
+ if port_setup[ :dir ] == 0
375
+ src_inst_sel = src_inst
376
+ dst_inst_sel = dst_inst
377
+ src_ifc_sel = src_ifc
378
+ dst_ifc_sel = dst_ifc
379
+ else
380
+ src_inst_sel = dst_inst
381
+ dst_inst_sel = src_inst
382
+ src_ifc_sel = dst_ifc
383
+ dst_ifc_sel = src_ifc
384
+ end
385
+
386
+
387
+ # length == 0 means, that no
388
+ # signal is assigned to this connection
389
+ if length[ port_name ] > 0
390
+
391
+ port_tmp_name = "#{con_name}_#{port_name.to_s}"
392
+
393
+
394
+ # combine all sources
395
+ tmp = "#{port_tmp_name} <= "
396
+ # loop over instances
397
+ src_inst_sel.each_with_index do |(inst_name, inst), i|
398
+ ( tmp_name, port) = inst.port( src_ifc_sel[ inst_name ], port_name )
399
+ if port != nil
400
+ tmp << "#{inst_name}_#{tmp_name}"
401
+ tmp << " and \n" unless i == src_inst_sel.size-1
402
+ else
403
+
404
+ if length[ port_name ] > 1
405
+ tmp << "( others => '#{port_setup[ :default ] }' )"
406
+ else
407
+ tmp << "'#{port_setup[ :default ] }'"
408
+ end
409
+ end
410
+ end
411
+ tmp << ";\n"
412
+ @asgn_part << tmp
413
+
414
+ tmp = ""
415
+ assigned = false
416
+ # assign to destination
417
+ dst_inst_sel.each_with_index do |(inst_name, inst), i|
418
+ ( tmp_name, port) = inst.port( dst_ifc_sel[ inst_name ], port_name )
419
+ if port != nil
420
+ tmp << "#{inst_name}_#{tmp_name} <= #{port_tmp_name};\n"
421
+ assigned = true
422
+ end
423
+ end
424
+ @asgn_part << tmp if assigned
425
+ else
426
+ SOCMaker::logger.info( "Port #{port_name.to_s} of" +
427
+ "connection #{con_name} is not assigned" )
428
+ end
429
+
430
+ end
431
+ end
432
+
433
+
434
+ #
435
+ # This method returns the VHDL code, which was created by this instance.
436
+ # It contains
437
+ # - the entity string
438
+ # - all component and signal declarations
439
+ # - all assignments
440
+ # - all core instanciations
441
+ #
442
+ def get_hdl_code( soc, entity_name )
443
+ entity_str = SOCMaker::conf[ :LIC ].split(/\n/).map{ |s| "-- "+s }.join("\n") + "\n"
444
+ entity_str << "-- Auto-Generated by #{SOCMaker::conf[ :app_name ]} \n"
445
+ entity_str << "-- Date: #{Time.now}\n"
446
+ entity_str << SOCMaker::conf[ :vhdl_include ] + "\n"
447
+ entity_str << "entity #{entity_name} is \n"
448
+ tmp = entity_port_str( soc )
449
+ entity_str << "port( \n" << tmp << " );\n" if tmp.size > 0
450
+ entity_str << "end entity #{entity_name};\n\n\n"
451
+ entity_str << "ARCHITECTURE IMPL of #{entity_name} is \n"
452
+ entity_str << @decl_part
453
+ entity_str << "\n\n"
454
+ entity_str << "begin"
455
+ entity_str << "\n\n"
456
+ entity_str << "--"
457
+ entity_str << "-- assignments "
458
+ entity_str << "--"
459
+ entity_str << "\n\n"
460
+ entity_str << @asgn_part
461
+ entity_str << "\n\n"
462
+ entity_str << "--"
463
+ entity_str << "-- instances "
464
+ entity_str << "--"
465
+ entity_str << "\n\n"
466
+ entity_str << @inst_part
467
+ entity_str << "end ARCHITECTURE IMPL;"
468
+ return entity_str
469
+ end
470
+
471
+ #
472
+ # Method, which adds VHDL code to @asgn_part, which connects toplevel signals
473
+ # to intermediate signals.
474
+ # +soc+:: the soc, for which the signals are added
475
+ # +entity_name+:: name of the entity
476
+ #
477
+ def add_toplevel_sig( soc, entity_name, top_con_ifc )
478
+
479
+ remaining_ifc = soc.interfaces.keys - top_con_ifc
480
+ remaining_ifc = remaining_ifc.map{ |ifc| ifc.to_s }
481
+ soc.ports( *remaining_ifc ) do |port_name, dir, length, default, ref, is_last|
482
+ if dir == 0
483
+ @asgn_part << "#{port_name} <= #{entity_name}_#{port_name}"
484
+ else
485
+ @asgn_part << "#{entity_name}_#{port_name} <= #{port_name} "
486
+ end
487
+ @asgn_part << ";\n"
488
+ if length > 1
489
+ @decl_part << "signal #{entity_name}_#{port_name} : std_logic_vector( #{length}-1 downto 0 );\n"
490
+ else
491
+ @decl_part << "signal #{entity_name}_#{port_name} : std_logic;\n"
492
+ end
493
+ end
494
+ end
495
+
496
+
497
+ end
498
+ end
499
+
500
+ # vim: noai:ts=2:sw=2