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,121 @@
1
+ ###############################################################
2
+ #
3
+ # File: ifc_spc_spec.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
+ # Test specification for SOCMaker::IfcDef
37
+ #
38
+ #
39
+ #
40
+ #
41
+ ###############################################################
42
+ require_relative( 'spec_helper' )
43
+
44
+ describe SOCMaker::IfcDef do
45
+ before( :each ){ @tmp_port = SOCMaker::IfcPort.new( "abc" ) }
46
+ describe "#initialize" do
47
+
48
+
49
+ it "returns a SOCMaker::IfcDef object when creating with new" do
50
+ s = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: @tmp_port } )
51
+ expect( s.class ).to be( SOCMaker::IfcDef )
52
+ end
53
+
54
+ it "raises an error if the name is not a string" do
55
+ expect{ SOCMaker::IfcDef.new( 4, "myifc,v1", 1, { test: @tmp_port } ) }.
56
+ to raise_error( SOCMaker::ERR::InitError )
57
+ end
58
+
59
+ it "raises an error if the direction is neither 0 nor 1 " do
60
+ expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { test: @tmp_port } ) }.
61
+ to raise_error( SOCMaker::ERR::InitError )
62
+ end
63
+
64
+
65
+ it "raises an error if no ports are given " do
66
+ expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { } ) }.
67
+ to raise_error( SOCMaker::ERR::InitError )
68
+ end
69
+
70
+
71
+ it "raises an error if a ports is nil " do
72
+ expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: nil} ) }.
73
+ to raise_error( SOCMaker::ERR::InitError )
74
+ end
75
+
76
+ it "raises an error if a ports is not of type SOCMaker::IfcPort " do
77
+ expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: "string-type"} ) }.
78
+ to raise_error( SOCMaker::ERR::InitError )
79
+ end
80
+
81
+ it "raises an error if no ports are given (nil)" do
82
+ expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, nil ) }.
83
+ to raise_error( SOCMaker::ERR::InitError )
84
+ end
85
+ end
86
+
87
+ describe "object handling, en-decoding" do
88
+
89
+ it "returns false for two non-equal objects" do
90
+ o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: @tmp_port } )
91
+ o2 = Marshal::load(Marshal.dump(o1))
92
+ o2.id = "myifc,v2"
93
+ expect( o2 == o1 ).to be( false )
94
+ end
95
+
96
+ it "is possible to encode and decode a interface definition" do
97
+ o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: @tmp_port } )
98
+ yaml_str = o1.to_yaml
99
+ o2 = YAML::load( yaml_str )
100
+ expect( o1 ).to eq( o2 )
101
+ end
102
+ end
103
+
104
+ describe "#consistence_check" do
105
+ it "raise an error if a port reference exists multiple times" do
106
+ p1 = SOCMaker::IfcPort.new( "p1" )
107
+ p2 = SOCMaker::IfcPort.new( "p2" )
108
+ p3 = SOCMaker::IfcPort.new( "p3" )
109
+ p4 = SOCMaker::IfcPort.new( "p3" )
110
+
111
+ o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1,
112
+ { t1: p1, t2: p2, t3: p3, t4: p4 } )
113
+ expect{ o1.consistence_check }.to raise_error( SOCMaker::ERR::ConsistenceError )
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+
120
+ # vim: noai:ts=2:sw=2
121
+
@@ -0,0 +1,92 @@
1
+ ###############################################################
2
+ #
3
+ # File: ifc_port_spec.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
+ # Test specification for SOCMaker::IfcPort
37
+ #
38
+ #
39
+ #
40
+ #
41
+ ###############################################################
42
+ require_relative( 'spec_helper' )
43
+
44
+
45
+
46
+
47
+ describe SOCMaker::IfcPort do
48
+ describe "#initialize" do
49
+ it "returns an object of type SOCMaker::IfcPort" do
50
+ o = SOCMaker::IfcPort.new( "abc", 1 )
51
+ expect( o.class ).to be( SOCMaker::IfcPort )
52
+ end
53
+
54
+ it "raises an error if the definition reference is nil" do
55
+ expect{ SOCMaker::IfcPort.new( nil, 1 ) }.
56
+ to raise_error( SOCMaker::ERR::InitError )
57
+ end
58
+
59
+ it "raises an error if the definition reference is an empty string" do
60
+ expect{ SOCMaker::IfcPort.new( "", 1 ) }.
61
+ to raise_error( SOCMaker::ERR::InitError )
62
+ end
63
+
64
+ it "raises an error if the length is neither a fixnum nor a string" do
65
+ expect{ SOCMaker::IfcPort.new( "abc", {} ) }.
66
+ to raise_error( SOCMaker::ERR::InitError )
67
+ end
68
+ end
69
+ end
70
+
71
+ describe "object handling, en-decoding" do
72
+
73
+ it "returns false for two non-equal objects" do
74
+ o1 = SOCMaker::IfcPort.new( "abc", 1 )
75
+ o2 = Marshal::load(Marshal.dump(o1))
76
+ o2.len = 4
77
+ expect( o2 == o1 ).to be ( false )
78
+ end
79
+
80
+ it "is possible to encode and decode a interface definition" do
81
+ o1 = SOCMaker::IfcPort.new( "abc", 1 )
82
+ yaml_str = o1.to_yaml
83
+ o2 = YAML::load( yaml_str )
84
+ expect( o1 ).to eq( o2 )
85
+ end
86
+
87
+ end
88
+
89
+
90
+ # vim: noai:ts=2:sw=2
91
+
92
+
@@ -0,0 +1,196 @@
1
+ ###############################################################
2
+ #
3
+ # File: ifc_spc_spec.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
+ # Test specification for SOCMaker::IfcSpc
37
+ #
38
+ #
39
+ #
40
+ #
41
+ ###############################################################
42
+ require_relative( 'spec_helper' )
43
+
44
+ require "yaml_examples.rb"
45
+
46
+
47
+
48
+ describe SOCMaker::IfcSpc do
49
+ include_context "yaml examples"
50
+
51
+ describe "#initialize" do
52
+
53
+ it "returns a SOCMaker::IfcSpc object when creating with new" do
54
+ s = SOCMaker::IfcSpc.new( "My interface", "myifc,v1" )
55
+ expect( s.class ).to be( SOCMaker::IfcSpc )
56
+ end
57
+
58
+ it "raises an error if the name is not a string" do
59
+ expect{ SOCMaker::IfcSpc.new( 1234, "myifc,v1" ) }.
60
+ to raise_error( SOCMaker::ERR::InitError )
61
+ end
62
+
63
+ it "raises an error if the name is an empty string" do
64
+ expect{ SOCMaker::IfcSpc.new( "", "myifc,v1" ) }.
65
+ to raise_error( SOCMaker::ERR::InitError )
66
+ end
67
+
68
+ it "raises an error if the id is not a string" do
69
+ expect{ SOCMaker::IfcSpc.new( "myifc", 234 ) }.
70
+ to raise_error( SOCMaker::ERR::InitError )
71
+ end
72
+
73
+ it "raises an error if the id is an a empty string" do
74
+ expect{ SOCMaker::IfcSpc.new( "myifc", "" ) }.
75
+ to raise_error( SOCMaker::ERR::InitError )
76
+ end
77
+
78
+ it "raises an error if the multiplicity has != 2 entries" do
79
+ expect{
80
+ SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
81
+ 'ports' => { :p1 => { dir: 1 } },
82
+ 'multiplicity' => [ 1, 0, 1 ] )
83
+ }.to raise_error( SOCMaker::ERR::InitError )
84
+ end
85
+
86
+ it "raises an error if the multiplicity is not '*' nor >= 0" do
87
+ expect{
88
+ SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
89
+ 'ports' => { :p1 => { dir: 1 } },
90
+ 'multiplicity' => [ -1, 0 ] )
91
+ }.to raise_error( SOCMaker::ERR::InitError )
92
+
93
+ expect{
94
+ SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
95
+ 'ports' => { :p1 => { dir: 1 } },
96
+ 'multiplicity' => [ 0, -3 ] )
97
+ }.to raise_error( SOCMaker::ERR::InitError )
98
+
99
+ expect{
100
+ SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
101
+ 'ports' => { :p1 => { dir: 1 } },
102
+ 'multiplicity' => [ 4, 'a' ] )
103
+ }.to raise_error( SOCMaker::ERR::InitError )
104
+
105
+ expect{
106
+ SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
107
+ 'ports' => { :p1 => { dir: 1 } },
108
+ 'multiplicity' => [ 5, 'abc' ] )
109
+ }.to raise_error( SOCMaker::ERR::InitError )
110
+ end
111
+ end
112
+
113
+ describe "SOCMaker::from_s" do
114
+
115
+ it "loads from yaml" do
116
+ c = SOCMaker::from_s( @IFC_YAML_VALID )
117
+ c.class.should be == SOCMaker::IfcSpc
118
+ end
119
+
120
+
121
+ it "raises an error if a port direction is neither 0 nor 1" do
122
+ expect{ SOCMaker::from_s( @IFC_YAML_INVALID ) }.
123
+ to raise_error( SOCMaker::ERR::InitError )
124
+ end
125
+
126
+ it "raises an error if a port direction is nil" do
127
+ expect{ SOCMaker::from_s( @IFC_YAML_INVALID2 ) }.
128
+ to raise_error( SOCMaker::ERR::InitError )
129
+ end
130
+ end
131
+
132
+
133
+ describe "#ok?" do
134
+ it "provides correct multiplicity info" do
135
+
136
+ ifc = SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
137
+ 'ports' => { :p1 => { dir: 1 } },
138
+ 'multiplicity' => [ 5, '*' ] )
139
+
140
+ expect( ifc.n_connections_ok?( 0, 4 ) ).to be ( true )
141
+ expect( ifc.n_connections_ok?( 0, 5 ) ).to be ( true )
142
+ expect( ifc.n_connections_ok?( 0, 6 ) ).to be ( false )
143
+ expect( ifc.n_connections_ok?( 1, 0 ) ).to be ( true )
144
+ expect( ifc.n_connections_ok?( 1, 10000 ) ).to be ( true )
145
+
146
+ end
147
+ end
148
+
149
+
150
+ describe "object handling" do
151
+ it "compares two objects" do
152
+
153
+ ifc = SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
154
+ 'ports' => { :p1 => { dir: 1 } },
155
+ 'multiplicity' => [ 5, '*' ] )
156
+ yaml_str = SOCMaker::YPP.from_yaml( ifc.to_yaml )
157
+ ifc2 = SOCMaker::from_s( yaml_str )
158
+ ifc2.should be == ifc
159
+ ifc.should be == ifc2
160
+
161
+ ifc.name << "X"
162
+ ifc.should_not be == ifc2
163
+ ifc.name = ifc2.name
164
+
165
+ ifc.id = :some_id
166
+ ifc.should_not be == ifc2
167
+ ifc.id = ifc2.id
168
+
169
+
170
+ ifc.multiplicity[ 0 ] = 1234
171
+ ifc.should_not be == ifc2
172
+ ifc.multiplicity[ 0 ] = ifc2.multiplicity[ 0 ]
173
+
174
+
175
+ ifc.ports[ :px ] = { dir: 1 }
176
+ ifc.should_not be == ifc2
177
+ ifc.id = ifc2.id
178
+
179
+ end
180
+
181
+ it "creates a yaml output" do
182
+
183
+ ifc = SOCMaker::IfcSpc.new( "my ifc", "my_ifc,v1",
184
+ 'ports' => { :p1 => { dir: 1 } },
185
+ 'multiplicity' => [ 5, '*' ] )
186
+ yaml_str = SOCMaker::YPP.from_yaml( ifc.to_yaml )
187
+ ifc2 = SOCMaker::from_s( yaml_str )
188
+ expect( yaml_str.size ).to be > 0
189
+ ifc2 = SOCMaker::from_s( yaml_str )
190
+ expect( ifc2 ).to eq( ifc )
191
+ end
192
+ end
193
+ end
194
+
195
+
196
+ # vim: noai:ts=2:sw=2
@@ -0,0 +1,99 @@
1
+ ###############################################################
2
+ #
3
+ # File: lib_inc_spec.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
+ # Test specification for SOCMaker::HDLFile
37
+ #
38
+ #
39
+ #
40
+ ###############################################################
41
+
42
+ describe SOCMaker::LibInc do
43
+
44
+ describe "#initialize" do
45
+
46
+ it "returns an object of type SOCMaker::LibInc" do
47
+ o = SOCMaker::LibInc.new( 'dirs' => [ 'a/dir/ectory' ] )
48
+ expect( o.class).to be( SOCMaker::LibInc )
49
+ end
50
+
51
+ it "raises an error, if no paths are given" do
52
+ expect{ SOCMaker::LibInc.new }.
53
+ to raise_error( SOCMaker::ERR::InitError )
54
+ end
55
+
56
+ it "raises an error, if nil is given as path" do
57
+ expect{ SOCMaker::LibInc.new( 'dirs' => nil ) }.
58
+ to raise_error( SOCMaker::ERR::InitError )
59
+ end
60
+
61
+ it "raises an error, if paths are not given as array" do
62
+ expect{ SOCMaker::LibInc.new( 'dirs' => { p1: "1" } ) }.
63
+ to raise_error( SOCMaker::ERR::InitError )
64
+ end
65
+
66
+ it "raises an error, a path is an empty string" do
67
+ expect{ SOCMaker::LibInc.new( 'dirs' => ["valid/path", "" ] ) }.
68
+ to raise_error( SOCMaker::ERR::InitError )
69
+ end
70
+
71
+ it "raises an error, a path is not a string" do
72
+ expect{ SOCMaker::LibInc.new( 'dirs' => ["valid/path", 3 ] ) }.
73
+ to raise_error( SOCMaker::ERR::InitError )
74
+ end
75
+ end
76
+
77
+ describe "object handling, en-decoding:" do
78
+
79
+ it "should be possible to encode and decode a core instance" do
80
+ o1 = SOCMaker::LibInc.new( 'dirs' => [ 'a/dir/ectory' ] )
81
+ yaml_str = o1.to_yaml
82
+ o2 = YAML::load( yaml_str )
83
+ expect( o1 ).to eq( o2 )
84
+ end
85
+
86
+ it "should return false for two non-equal objects" do
87
+ o1 = SOCMaker::LibInc.new( 'dirs' => [ 'a/dir/ectory' ] )
88
+ o2 = Marshal::load(Marshal.dump(o1))
89
+ o2.dirs[ 0 ] << "X"
90
+ expect( o2 == o1 ).to be( false )
91
+ end
92
+
93
+ end
94
+
95
+
96
+
97
+ end
98
+
99
+