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,289 @@
1
+ ###############################################################
2
+ #
3
+ # File: sparameter.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
+ #
35
+ # Description:
36
+ #
37
+
38
+
39
+ module SOCMaker
40
+
41
+
42
+
43
+ # A small classes, used to group information
44
+ # and to verify, auto-correct and auto-complete
45
+ # this information:
46
+ # This class represents a static parameter, which is
47
+ # only defined once within a system. Usually, these
48
+ # static parameters are mapped into a vhdl package or
49
+ # verilog include file.
50
+ # The following fields are defined:
51
+ # - #path (of the file, which is used as input)
52
+ # - #file_dst (output file destination)
53
+ # - #parameters (hash of SParameterEntry values)
54
+ # At the moment, the token within the value of the parameter-hash
55
+ # is used as regular expression to replace this token
56
+ # in the input file by the key of the parameter-hash, and
57
+ # write the result to the destination file.
58
+ #
59
+ class SParameter
60
+ include ERR
61
+
62
+
63
+ # Path of the file, which is used as input
64
+ attr_accessor :path
65
+
66
+ # Path of the destination file
67
+ attr_accessor :file_dst
68
+
69
+ # Hash of SParameterEntry, each entry represents a parameter
70
+ attr_accessor :parameters
71
+
72
+ # This constructor expects the source file path, the destination
73
+ # file path. The paremters can be passed as optional arguments.
74
+ #
75
+ # +path+:: source file path
76
+ # +file_dst+:: destination file path
77
+ #
78
+ #
79
+ def initialize( path, file_dst, optional = {} )
80
+ init_with( { 'path' => path,
81
+ 'file_dst' => file_dst }.merge( optional ) )
82
+ end
83
+
84
+ #
85
+ # Encoder method (to yaml)
86
+ #
87
+ # +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
88
+ #
89
+ def encode_with( coder )
90
+ init_error_if !coder.is_a?( Psych::Coder ),
91
+ 'coder is not given as Psych::Coder'
92
+ %w[ path file_dst parameters ].
93
+ each { |v| coder[ v ] = instance_variable_get "@#{v}" }
94
+ end
95
+
96
+ #
97
+ # Initialization method (from yaml)
98
+ #
99
+ # +coder+:: An instance of the Psych::Coder to init this class from a YAML file
100
+ #
101
+ #
102
+ def init_with( coder )
103
+ init_error_if !( coder.is_a?( Hash ) || coder.is_a?( Psych::Coder ) ),
104
+ 'coder is not given as Hash neither as Psych::Coder'
105
+
106
+ # path
107
+ init_error 'no file path specified for static parameter',
108
+ field: 'path' if coder[ 'path' ] == nil
109
+ @path = coder[ 'path' ]
110
+
111
+ init_error 'file path specified for static parameter is not of type string',
112
+ field: 'path' if !@path.is_a?( String )
113
+
114
+ init_error 'file path specified for static parameter has zero length',
115
+ field: 'path' if @path.size == 0
116
+
117
+
118
+ # file_dst (file-destination)
119
+ init_error 'no destination file directory given for static parameter',
120
+ instance: @path,
121
+ field: 'file_dst' if coder[ 'file_dst' ] == nil
122
+
123
+ @file_dst = coder[ 'file_dst' ]
124
+ init_error 'destination file directory given for static parameter is not of type string',
125
+ instance: @path,
126
+ field: 'file_dst' if !@file_dst.is_a?( String )
127
+
128
+ init_error 'file path specified for static parameter has zero length',
129
+ field: 'path' if @file_dst.size == 0
130
+
131
+
132
+ @parameters = coder[ 'parameters' ] || {}
133
+ @parameters.each do |name, param|
134
+ init_error 'Static parameter entry not defined',
135
+ instance: name if param == nil
136
+
137
+ init_error 'Static parameter entry not SOCMaker::SParameterEntry (use SOCM_SENTRY)',
138
+ instance: name if !param.is_a?( SOCMaker::SParameterEntry )
139
+ end
140
+
141
+ end
142
+
143
+
144
+
145
+ #
146
+ # Deployment function. It takes the source file from core_dir,
147
+ # iterates over all parameters and checks, if the parameter is
148
+ # in avaliable in param. If not, the default value is taken.
149
+ # all parameters are added to the source file and the result
150
+ # is saved in dst_dir.
151
+ #
152
+ # +param+:: A parameter hash, like { :name => value }
153
+ # +core_dir:++ The core source directory, where the parameter source file is located
154
+ # +dst_dir+:: The destination directory, where the result is saved. This dir. must exist.
155
+ #
156
+ def deploy( param, core_dir, dst_dir )
157
+
158
+ token_val_map = {}
159
+ @parameters.each do |param_name,sparam_entry|
160
+
161
+ if param != nil and
162
+ param[ param_name ] != nil
163
+ # use value defined in soc-spec
164
+ tmp = param[ param_name ]
165
+ else
166
+ # use default value from core-spec
167
+ tmp = sparam_entry.default
168
+ end
169
+
170
+ if sparam_entry.type == "enum"
171
+ token_val_map[ sparam_entry.token ] = sparam_entry.choice[ tmp.to_i ]
172
+ elsif sparam_entry.type == "bool"
173
+ if tmp == true
174
+ token_val_map[ sparam_entry.token ] = sparam_entry.choice
175
+ else
176
+ token_val_map[ sparam_entry.token ] = ""
177
+ end
178
+ else
179
+ token_val_map[ sparam_entry.token ] = tmp
180
+ end
181
+
182
+
183
+ end
184
+
185
+ # create file paths
186
+ src_path = File.join( core_dir, @path )
187
+ #dst_dir = CoreDef::get_and_ensure_dst_dir!( dir_name )
188
+ dst_path = File.join( dst_dir, @file_dst )
189
+
190
+
191
+ # process each line of input file
192
+ # and replace tokens by value via
193
+ # regular expression
194
+ File.open( dst_path, 'w' ) do |dst_f|
195
+ File.open( src_path ) do |src_f|
196
+ SOCMaker::logger.proc( "create #{dst_path} from #{ src_path} " )
197
+ while line = src_f.gets
198
+ token_val_map.each { |token, val| line = line.sub( Regexp.new( token.to_s ), val.to_s ) }
199
+ dst_f.puts line
200
+ end
201
+ end
202
+ end
203
+
204
+ end
205
+
206
+
207
+ #
208
+ # Equality operator
209
+ #
210
+ def ==(o)
211
+ o.class == self.class &&
212
+ o.parameters == self.parameters &&
213
+ o.file_dst == self.file_dst &&
214
+ o.path == self.path
215
+ end
216
+
217
+
218
+
219
+ end
220
+
221
+
222
+ #
223
+ # This class is used to organize static parameters within SOCMaker::SParameter.
224
+ # This class is derived from Parameter and adds the attribute 'token'.
225
+ #
226
+ class SParameterEntry < Parameter
227
+
228
+ #
229
+ # Token, which is replaced during generation by the parameter.
230
+ #
231
+ attr_accessor :token
232
+
233
+ # The constructor expects
234
+ def initialize( type, token, optional = {} )
235
+ init_with( { 'type' => type,
236
+ 'token' => token }.merge( optional ) )
237
+
238
+ end
239
+
240
+ #
241
+ # Encoder method (to yaml)
242
+ #
243
+ # +coder+:: An instance of the Psych::Coder to encode this class to a YAML file
244
+ #
245
+ def encode_with( coder )
246
+ init_error_if !coder.is_a?( Psych::Coder ),
247
+ 'coder is not given as Psych::Coder'
248
+ super coder
249
+ coder[ 'token' ] = @token
250
+ end
251
+
252
+ #
253
+ # Initialization method (from yaml)
254
+ #
255
+ # +coder+:: An instance of the Psych::Coder to init this class from a YAML file
256
+ #
257
+ #
258
+ def init_with( coder )
259
+
260
+ init_error_if !( coder.is_a?( Hash ) || coder.is_a?( Psych::Coder ) ),
261
+ 'coder is not given as Hash neither as Psych::Coder'
262
+ super coder
263
+
264
+ init_error 'no token specified',
265
+ field: token if coder[ 'token' ] == nil
266
+
267
+ @token = coder[ 'token' ]
268
+ init_error 'token is not a string' if !@token.is_a?( String )
269
+ init_error 'token has zero size' if @token.size == 0
270
+ end
271
+
272
+
273
+
274
+
275
+ #
276
+ # Equality operator
277
+ #
278
+ def ==(o)
279
+ o.class == self.class &&
280
+ o.token == self.token &&
281
+ super( o )
282
+ end
283
+
284
+
285
+ end
286
+ end
287
+
288
+
289
+ # vim: noai:ts=2:sw=2
@@ -0,0 +1,8 @@
1
+ module SOCMaker
2
+
3
+ #
4
+ # The SoC-Maker Version
5
+ #
6
+ VERSION = "0.1.1"
7
+
8
+ end
@@ -0,0 +1,130 @@
1
+ ###############################################################
2
+ #
3
+ # File: ypp.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
+
35
+
36
+
37
+ module SOCMaker
38
+
39
+
40
+ #
41
+ #
42
+ # YAML Pre-Processor:
43
+ # We use it only in a static way, no objects are created
44
+ # (private ctor).
45
+ # There are two methods:
46
+ # - SOCMaker::YPP::to_yaml( a_string )
47
+ # - SOCMaker::YPP::from_yaml( a_string )
48
+ #
49
+ # The static method to_yaml replaces our custom tags (like SOCM_CORE)
50
+ # with YAML object identifiers (like '--- ruby/object::SOCMaker::CoreDef')
51
+ #
52
+ # The static method from_yaml does the inverse to to_yaml: it replaces the
53
+ # object identifiers with our custom tags.
54
+ #
55
+ # See also SOCMaker::Conf YPP_LUT YPP_INV_LUT and YPP_INV_REGEX,
56
+ # these are the lookup tables and regular expressions used for this
57
+ # processing
58
+ #
59
+ # Goal:
60
+ # This is used to have a nicer YAML file and without the need of writing
61
+ # loong object identifier lines.
62
+ #
63
+ #
64
+ class YPP
65
+
66
+ class << self
67
+
68
+
69
+ #
70
+ # This method does the pre-processing and
71
+ # replaces our custom tags with yaml-tags, like
72
+ # --- !ruby/object:SOCMaker:: ....
73
+ # In addition, if a block is given, the string
74
+ # is separated into substrings and each sub-string is passed to
75
+ # the block. This allows to process YAML strings, which contain multiple
76
+ # objects. Each object is passed (as yaml string) to the block.
77
+ #
78
+ def to_yaml( string )
79
+
80
+ SOCMaker::conf[ :YPP_LUT ].each do |r, repl|
81
+ string = string.gsub r, repl
82
+ end
83
+ if block_given?
84
+ strings = split_with_match( string, SOCMaker::conf[ :YPP_SPLIT_REGEX ] ) if string != nil
85
+ strings.each{ |x| yield( x ) }
86
+ end
87
+ return string
88
+ end
89
+
90
+
91
+ #
92
+ # This method does the inverse to to_yaml.
93
+ #
94
+ def from_yaml( string )
95
+ string.gsub SOCMaker::conf[ :YPP_INV_REGEX ] do |words|
96
+
97
+ # if there is a white-space at the beginning ($1 != nil), we keep
98
+ # the white-space, if there is no white-space we won't keep it
99
+ ws = $1.nil? ? "" : " "
100
+ SOCMaker::conf[ :YPP_INV_LUT ].has_key?( $2 ) ? ws + SOCMaker::conf[ :YPP_INV_LUT ][ $2 ] : words
101
+ end
102
+ end
103
+
104
+
105
+ #
106
+ # This method is used to split concatenated yaml object strings.
107
+ #
108
+ def split_with_match(string, regex)
109
+ indices = []
110
+ strings = []
111
+ return [] if string == nil or string.size == 0
112
+ string.scan( regex ) { |c| indices << $~.offset(0)[0] }
113
+ return [] if indices.size == 0
114
+ indices = [ indices, indices[ 1..-1].map{ |x| x-1 } << string.size-1 ]
115
+ indices[0].zip( indices[1] ).each{ |x| strings<< string[ x[0]..x[1] ] }
116
+ return strings
117
+ end
118
+
119
+
120
+ end
121
+
122
+ private
123
+ def initialize
124
+ end
125
+
126
+
127
+ end # CoreDef
128
+ end # SOCMaker
129
+
130
+ # vim: noai:ts=2:sw=2
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "soc_maker/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "soc_maker"
7
+ s.version = SOCMaker::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Christian Haettich"]
10
+ s.email = ["feddischson [ at ] opencores.org"]
11
+ s.homepage = "https://github.com/feddischson/soc_maker"
12
+ s.summary = %q{System-On-Chip Maker}
13
+ s.description = %q{System-On-Chip Maker: a tool to design and create SoCs in a simple way, written in Ruby. }
14
+ s.licenses = ['LGPL-3.0']
15
+
16
+
17
+ s.add_development_dependency "rspec", "~>3.2"
18
+ s.add_development_dependency "rspec-its", "~>1.2"
19
+ s.add_development_dependency "bones", "~>3.8"
20
+ s.add_development_dependency "simplecov", "~>0.10"
21
+
22
+ s.required_ruby_version = '>=2.0.0'
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
+ s.require_paths = ["lib"]
28
+ end