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.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/History.txt +4 -0
- data/LICENSE +678 -0
- data/README.rdoc +228 -0
- data/Rakefile +46 -0
- data/bin/soc_maker_cli +80 -0
- data/bin/soc_maker_parser +85 -0
- data/core_lib/cores/adv_debug_sys/01_adv_debug_sys.yaml +245 -0
- data/core_lib/cores/or1200_rel2/01_or1200.yaml +208 -0
- data/core_lib/cores/or1200_rel2/02_or1200_files.yaml +421 -0
- data/core_lib/cores/or1200_rel2/03_or1200_sparam.yaml +188 -0
- data/core_lib/cores/or1200_rel2/or1200_defines.v.in +1799 -0
- data/core_lib/cores/ram_wb/ram_wb.yaml +102 -0
- data/core_lib/cores/ram_wb/ram_wb_b3.v.in +259 -0
- data/core_lib/cores/uart16550/01_uart16550.yaml +99 -0
- data/core_lib/cores/uart16550/02_uart16550_files.yaml +70 -0
- data/core_lib/cores/wb_connect/minsoc_tc_top.v +1802 -0
- data/core_lib/cores/wb_connect/wb_connect.yaml +733 -0
- data/core_lib/inc.yaml +13 -0
- data/core_lib/interfaces/clk_rst/clk.yaml +9 -0
- data/core_lib/interfaces/clk_rst/rst.yaml +9 -0
- data/core_lib/interfaces/clk_rst/single.yaml +7 -0
- data/core_lib/interfaces/debug/debug.yaml +32 -0
- data/core_lib/interfaces/jtag/jtag.yaml +13 -0
- data/core_lib/interfaces/jtag/jtag_tap.yaml +22 -0
- data/core_lib/interfaces/power/or_power.yaml +25 -0
- data/core_lib/interfaces/uart/uart.yaml +21 -0
- data/core_lib/interfaces/wishbone/wishbone_ma_b3.yaml +54 -0
- data/core_lib/interfaces/wishbone/wishbone_sl_b3.yaml +51 -0
- data/doc/class_arch.uml +5113 -0
- data/doc/fig/hierarchical.svg +273 -0
- data/examples/or1200_test/or1200_test.cmd +78 -0
- data/examples/or1200_test/or1200_test.rb +136 -0
- data/examples/or1200_test/rtl/or1200_test_top.vhd +274 -0
- data/examples/or1200_test/rtl/s3astarter.ucf +10 -0
- data/examples/or1200_test/rtl/xilinx_internal_jtag.v +438 -0
- data/examples/or1200_test/rtl/xilinx_internal_jtag_options.v +12 -0
- data/examples/or1200_test/sw/README.txt +35 -0
- data/examples/or1200_test/sw/bin2vmem.c +159 -0
- data/examples/or1200_test/sw/board.h +24 -0
- data/examples/or1200_test/sw/compile.sh +18 -0
- data/examples/or1200_test/sw/except.S +152 -0
- data/examples/or1200_test/sw/int.c +79 -0
- data/examples/or1200_test/sw/int.h +14 -0
- data/examples/or1200_test/sw/interconnect.h +17 -0
- data/examples/or1200_test/sw/interrupts.c +14 -0
- data/examples/or1200_test/sw/main.c +16 -0
- data/examples/or1200_test/sw/or1200.h +454 -0
- data/examples/or1200_test/sw/orp.ld +60 -0
- data/examples/or1200_test/sw/reset.S +112 -0
- data/examples/or1200_test/sw/support.c +123 -0
- data/examples/or1200_test/sw/support.h +33 -0
- data/examples/or1200_test/sw/tick.c +30 -0
- data/examples/or1200_test/sw/tick.h +2 -0
- data/examples/or1200_test/sw/uart.c +136 -0
- data/examples/or1200_test/sw/uart.h +126 -0
- data/lib/soc_maker.rb +324 -0
- data/lib/soc_maker/cli.rb +544 -0
- data/lib/soc_maker/conf.rb +310 -0
- data/lib/soc_maker/core_def.rb +579 -0
- data/lib/soc_maker/core_inst.rb +305 -0
- data/lib/soc_maker/err.rb +211 -0
- data/lib/soc_maker/hdl_coder.rb +500 -0
- data/lib/soc_maker/hdl_file.rb +166 -0
- data/lib/soc_maker/hdl_parser.rb +431 -0
- data/lib/soc_maker/ifc_def.rb +193 -0
- data/lib/soc_maker/ifc_port.rb +133 -0
- data/lib/soc_maker/ifc_spc.rb +180 -0
- data/lib/soc_maker/lib.rb +289 -0
- data/lib/soc_maker/lib_inc.rb +109 -0
- data/lib/soc_maker/parameter.rb +149 -0
- data/lib/soc_maker/soc_def.rb +847 -0
- data/lib/soc_maker/sparameter.rb +289 -0
- data/lib/soc_maker/version.rb +8 -0
- data/lib/soc_maker/ypp.rb +130 -0
- data/soc_maker.gemspec +28 -0
- data/spec/cli_cmds1.txt +39 -0
- data/spec/cli_spec.rb +49 -0
- data/spec/conf_spec.rb +44 -0
- data/spec/core_def_spec.rb +503 -0
- data/spec/core_inst_spec.rb +169 -0
- data/spec/hdl_file_spec.rb +154 -0
- data/spec/hdl_parser_spec.rb +201 -0
- data/spec/ifc_def_spec.rb +121 -0
- data/spec/ifc_port_spec.rb +92 -0
- data/spec/ifc_spc_spec.rb +196 -0
- data/spec/lib_inc_spec.rb +99 -0
- data/spec/lib_spec.rb +209 -0
- data/spec/parameter_spec.rb +86 -0
- data/spec/soc_def_spec.rb +611 -0
- data/spec/soc_maker_spec.rb +7 -0
- data/spec/sparameter_spec.rb +182 -0
- data/spec/spec_helper.rb +78 -0
- data/spec/test_soc.yaml +105 -0
- data/spec/test_soc2.yaml +60 -0
- data/spec/test_soc_lib/cores/core_A_rel1/00_core_a.yaml +75 -0
- data/spec/test_soc_lib/cores/core_A_rel1/01_core_a.yaml +57 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a.vhd +29 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg.vhd.src +3 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg2.vhd.src +4 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg3.v.src +6 -0
- data/spec/test_soc_lib/cores/core_B_rel1/core_b.vhd +25 -0
- data/spec/test_soc_lib/cores/core_B_rel1/core_b.yaml +36 -0
- data/spec/test_soc_lib/cores/core_C_v1/core_C.vhd +57 -0
- data/spec/test_soc_lib/cores/core_C_v1/core_c.yaml +42 -0
- data/spec/test_soc_lib/cores/soc_A/soc_A.yaml +12 -0
- data/spec/test_soc_lib/cores/soc_maker_include.yaml +6 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/bidir_ifc.yaml +19 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/core_AB_ifc.yaml +15 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/top_ifc.yaml +9 -0
- data/spec/test_soc_lib/soc_maker_include.yaml +4 -0
- data/spec/yaml_examples.rb +367 -0
- data/spec/ypp_spec.rb +156 -0
- data/test/test_soc_maker.rb +0 -0
- metadata +255 -0
data/spec/lib_spec.rb
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: soc_lib_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
|
+
#
|
37
|
+
#
|
38
|
+
#
|
39
|
+
#
|
40
|
+
###############################################################
|
41
|
+
require_relative( 'spec_helper' )
|
42
|
+
|
43
|
+
|
44
|
+
describe SOCMaker::Lib do
|
45
|
+
|
46
|
+
before( :each )do
|
47
|
+
@lib = SOCMaker::Lib.new
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#initialize" do
|
51
|
+
subject { SOCMaker::Lib.new }
|
52
|
+
its( :class ) { should == SOCMaker::Lib }
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
describe "#refresh" do
|
59
|
+
|
60
|
+
context "path loading" do
|
61
|
+
it "calls process_include for each path given as argument" do
|
62
|
+
paths_res = []
|
63
|
+
@lib.stub( :process_include ) do |arg|
|
64
|
+
paths_res << arg
|
65
|
+
end
|
66
|
+
paths = [ "first_path", "second_path" ]
|
67
|
+
@lib.refresh( paths )
|
68
|
+
expect( paths_res ).to eq( paths )
|
69
|
+
end
|
70
|
+
|
71
|
+
it "cals process_include for each path from config, if no argument is given" do
|
72
|
+
paths_res = []
|
73
|
+
@lib.stub( :process_include ) do |arg|
|
74
|
+
paths_res << arg
|
75
|
+
end
|
76
|
+
paths = [ "first_path", "second_path" ]
|
77
|
+
SOCMaker::conf[ :cores_search_path ] = paths
|
78
|
+
@lib.refresh( )
|
79
|
+
expect( paths_res ).to eq( paths )
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "yaml include loading" do
|
84
|
+
it "returns two objects" do
|
85
|
+
|
86
|
+
obs = []
|
87
|
+
@lib.stub( :get_all_yaml_in_str ) do |arg|
|
88
|
+
"SOCM_INCLUDE\ndirs:\n- folder_a\n- folder_b\n- folder_c\nSOCM_INCLUDE\ndirs:\n- folder_d\n- folder_e\n- folder_f\n"
|
89
|
+
end
|
90
|
+
@lib.stub( :add_include ) do |arg|
|
91
|
+
obs << arg
|
92
|
+
end
|
93
|
+
@lib.refresh( [ "some_path" ] )
|
94
|
+
expect( obs ).to eq ( [ SOCMaker::LibInc.new( 'dirs' => ["folder_a", "folder_b", "folder_c"] ),
|
95
|
+
SOCMaker::LibInc.new( 'dirs' => ["folder_d", "folder_e", "folder_f"] ) ] )
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#process_include" do
|
101
|
+
|
102
|
+
it "raises an ProcessingError if a folder is included twice" do
|
103
|
+
expect do
|
104
|
+
@lib.process_include( "./empty_soc_lib_folder" )
|
105
|
+
@lib.process_include( "./empty_soc_lib_folder" )
|
106
|
+
end.
|
107
|
+
to raise_error( SOCMaker::ERR::InitError )
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#add_core/#rm_core/#add_ifc/#rm_ifc" do
|
112
|
+
|
113
|
+
it "should be possible to add, get and remove a core" do
|
114
|
+
c = SOCMaker::CoreDef.new( "A core", "acore,v1", "top" )
|
115
|
+
@lib.add_core( c )
|
116
|
+
@lib.get_core( :"acore,v1" ).should be == c
|
117
|
+
@lib.rm_core( c )
|
118
|
+
@lib.add_core( c )
|
119
|
+
@lib.rm_core( c.id )
|
120
|
+
expect { @lib.get_core( :"acore,v1" ) }.
|
121
|
+
to raise_error( SOCMaker::ERR::ProcessingError )
|
122
|
+
expect { @lib.rm_core( 123 ) }.
|
123
|
+
to raise_error( SOCMaker::ERR::ProcessingError )
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should be possible to add, get and remove an interface" do
|
127
|
+
i = SOCMaker::IfcSpc.new( "My Interface", "myifc,v2" )
|
128
|
+
|
129
|
+
# removing with instance
|
130
|
+
@lib.add_ifc( i )
|
131
|
+
@lib.get_ifc( :"myifc,v2" ).should be == i
|
132
|
+
@lib.rm_ifc( i )
|
133
|
+
|
134
|
+
expect { @lib.get_ifc( :"myifc,v2" ) }.
|
135
|
+
to raise_error( SOCMaker::ERR::ProcessingError )
|
136
|
+
|
137
|
+
# removing with id
|
138
|
+
@lib.add_ifc( i )
|
139
|
+
@lib.get_ifc( :"myifc,v2" ).should be == i
|
140
|
+
@lib.rm_ifc( i.id )
|
141
|
+
|
142
|
+
expect { @lib.get_ifc( :"myifc,v2" ) }
|
143
|
+
.to raise_error( SOCMaker::ERR::ProcessingError )
|
144
|
+
|
145
|
+
expect { @lib.rm_ifc( 4 ) }
|
146
|
+
.to raise_error( SOCMaker::ERR::ProcessingError )
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "#add_include" do
|
152
|
+
it "should process all folders in add_include" do
|
153
|
+
all_folders = ["folder_a", "folder_b", "folder_c" ]
|
154
|
+
i = SOCMaker::LibInc.new( 'dirs' => all_folders )
|
155
|
+
all_folders_res = []
|
156
|
+
@lib.stub( :process_include ) do |arg|
|
157
|
+
all_folders_res << arg
|
158
|
+
end
|
159
|
+
@lib.send( :add_include, i, "./" )
|
160
|
+
all_folders.each_with_index do |f,index|
|
161
|
+
File.expand_path( File.join( "./", f ) ).should be == all_folders_res[ index ]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
describe "#refresh" do
|
168
|
+
it "should load all elements from our test library" do
|
169
|
+
@lib.refresh( './spec/test_soc_lib' )
|
170
|
+
core_A = @lib.get_core( :"core_A,rel1" )
|
171
|
+
core_B = @lib.get_core( :"core_B,rel1" )
|
172
|
+
core_AB_ifc = @lib.get_ifc( :"core_AB_ifc,1" )
|
173
|
+
expect( core_A.class ).to be( SOCMaker::CoreDef )
|
174
|
+
expect( core_B.class ).to be( SOCMaker::CoreDef )
|
175
|
+
expect( core_AB_ifc.class ).to be( SOCMaker::IfcSpc )
|
176
|
+
expect( core_A.static_parameters.size ).to be( 3 )
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
describe "#to_s" do
|
182
|
+
|
183
|
+
context "string creation" do
|
184
|
+
it{ expect( @lib.to_s ).not_to be_nil }
|
185
|
+
it{ expect( @lib.to_s.size ).to be > 0 }
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "#cores" do
|
190
|
+
|
191
|
+
it "should be possible to add, get and remove a core" do
|
192
|
+
c1 = SOCMaker::CoreDef.new( "A core", "acore,v1", "top" )
|
193
|
+
c2 = SOCMaker::CoreDef.new( "A core", "acore,v2", "top" )
|
194
|
+
c3 = SOCMaker::CoreDef.new( "A core", "acore,v3", "top" )
|
195
|
+
|
196
|
+
@lib.add_core( c1 )
|
197
|
+
@lib.add_core( c2 )
|
198
|
+
@lib.add_core( c3 )
|
199
|
+
cores = {}
|
200
|
+
@lib.cores { |k,v| cores[k] = v }
|
201
|
+
expect( cores ).to eq( "acore,v1" => c1,
|
202
|
+
"acore,v2" => c2,
|
203
|
+
"acore,v3" => c3 )
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# vim: noai:ts=2:sw=2
|
209
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: parameter_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::Parameter
|
37
|
+
#
|
38
|
+
#
|
39
|
+
#
|
40
|
+
#
|
41
|
+
###############################################################
|
42
|
+
require_relative( 'spec_helper' )
|
43
|
+
|
44
|
+
require "yaml_examples.rb"
|
45
|
+
|
46
|
+
|
47
|
+
describe SOCMaker::Parameter do
|
48
|
+
|
49
|
+
describe "#initialize" do
|
50
|
+
|
51
|
+
it "returns an object of type SOCMaker::Parameter when creating it with new" do
|
52
|
+
o = SOCMaker::Parameter.new( "integer" )
|
53
|
+
expect( o.class).to be( SOCMaker::Parameter )
|
54
|
+
end
|
55
|
+
|
56
|
+
it "raises an error if the type is not a string" do
|
57
|
+
expect{ SOCMaker::Parameter.new( 3 ) }.
|
58
|
+
to raise_error( SOCMaker::ERR::InitError )
|
59
|
+
end
|
60
|
+
|
61
|
+
it "raises an error if the type is a string with zero length" do
|
62
|
+
expect{ SOCMaker::Parameter.new( "" ) }.
|
63
|
+
to raise_error( SOCMaker::ERR::InitError )
|
64
|
+
end
|
65
|
+
|
66
|
+
it "raises an error if the type is nil" do
|
67
|
+
expect{ SOCMaker::Parameter.new( "" ) }.
|
68
|
+
to raise_error( SOCMaker::ERR::InitError )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "SOCMaker::from_s" do
|
73
|
+
include_context "yaml examples"
|
74
|
+
|
75
|
+
it 'raises an error if the type value of an instance param. is empty' do
|
76
|
+
expect{ SOCMaker::from_s( @F_YAML_INSTP_TYPE ) }.
|
77
|
+
to raise_error( SOCMaker::ERR::InitError )
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# vim: noai:ts=2:sw=2
|
84
|
+
|
85
|
+
|
86
|
+
|
@@ -0,0 +1,611 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: soc_def_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 spec. for SOCMaker::SOCDef
|
37
|
+
#
|
38
|
+
######################
|
39
|
+
#
|
40
|
+
# Some helpful links about rspec:
|
41
|
+
#
|
42
|
+
# http://lmws.net/describe-vs-context-in-rspec
|
43
|
+
# http://betterspecs.org/
|
44
|
+
# https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
45
|
+
#
|
46
|
+
#
|
47
|
+
#
|
48
|
+
###############################################################
|
49
|
+
require_relative( 'spec_helper' )
|
50
|
+
|
51
|
+
require "yaml_examples.rb"
|
52
|
+
|
53
|
+
describe SOCMaker::SOCDef do
|
54
|
+
|
55
|
+
include_context "yaml examples"
|
56
|
+
|
57
|
+
# not implemented at the moment
|
58
|
+
|
59
|
+
# test for invalid path
|
60
|
+
# it "should raise an error if a non-existing path is given" do
|
61
|
+
# expect { SOCMaker::from_f( 'blabla.txt' ) }.
|
62
|
+
# to raise_error( IOError )
|
63
|
+
# end
|
64
|
+
|
65
|
+
describe "loading via SOCMaker::from_s" do
|
66
|
+
|
67
|
+
after( :each ){ SOCMaker::lib.clear }
|
68
|
+
|
69
|
+
it 'returns a class of type SOCDef when loading a full soc-def' do
|
70
|
+
SOCMaker::from_s( @FULL_SOC_YAML ).class.should == SOCMaker::SOCDef
|
71
|
+
end
|
72
|
+
|
73
|
+
it "raises ConsistenceError when a core-def. doesn't exist" do
|
74
|
+
expect { SOCMaker::from_s( @SOC_YAML_WITH_CORE ).consistence_check }.
|
75
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns an SOC-object" do
|
79
|
+
core = SOCMaker::CoreDef.new( "mycore", "rel1", "top" )
|
80
|
+
SOCMaker::lib.add_core( core )
|
81
|
+
soc = SOCMaker::from_s( @SOC_YAML_WITH_CORE )
|
82
|
+
expect( soc.class ).to be SOCMaker::SOCDef
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
describe "#initialize" do
|
89
|
+
subject{ @soc = SOCMaker::SOCDef.new( "Test SOC", "test-soc,v1", "my_soc_top" ) }
|
90
|
+
its( :name ) { should == "Test SOC" }
|
91
|
+
its( :id ) { should == :"test-soc,v1" }
|
92
|
+
its( :toplevel ) { should == "my_soc_top" }
|
93
|
+
its( :cores ) { should == {} }
|
94
|
+
its( :static ) { should == {} }
|
95
|
+
its( :cons ) { should == {} }
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
describe "core, interface, parameter and connection handling" do
|
102
|
+
|
103
|
+
before( :each )do
|
104
|
+
@core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", "top" )
|
105
|
+
|
106
|
+
@ifc_spc1 = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} }, 'multiplicity' => [ 2, 1 ] )
|
107
|
+
@ifc_spc2 = SOCMaker::IfcSpc.new( "myifc", "myifc,v2", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
108
|
+
|
109
|
+
@ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
110
|
+
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
111
|
+
|
112
|
+
@ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
113
|
+
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
114
|
+
|
115
|
+
|
116
|
+
@core.interfaces[ :ifc_a ] = @ifc_def_0
|
117
|
+
@core.interfaces[ :ifc_b ] = @ifc_def_1
|
118
|
+
@core.interfaces[ :ifc_c ] = @ifc_def_0
|
119
|
+
@core.interfaces[ :ifc_d ] = @ifc_def_1
|
120
|
+
@core.interfaces[ :ifc_e ] = @ifc_def_0
|
121
|
+
@core.interfaces[ :ifc_f ] = @ifc_def_1
|
122
|
+
|
123
|
+
SOCMaker::lib.add_ifc( @ifc_spc1 )
|
124
|
+
SOCMaker::lib.add_ifc( @ifc_spc2 )
|
125
|
+
SOCMaker::lib.add_core( @core )
|
126
|
+
@soc = SOCMaker::SOCDef.new( "Test SOC", "test-soc,v1", "my_soc_top" )
|
127
|
+
end
|
128
|
+
|
129
|
+
after( :each ) do
|
130
|
+
SOCMaker::lib.clear
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#inst_in_use?" do
|
134
|
+
|
135
|
+
it "returns true, if there is already an core instance with that name" do
|
136
|
+
@soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
137
|
+
expect( @soc.inst_in_use?( :core_inst ) ).to be( true )
|
138
|
+
end
|
139
|
+
|
140
|
+
it "returns false, if there is no core instance with that name" do
|
141
|
+
expect( @soc.inst_in_use?( :core_inst ) ).to be( false )
|
142
|
+
end
|
143
|
+
|
144
|
+
it "inst_in_use should return true, if there is already an connection instance with that name" do
|
145
|
+
@soc.cons[ :a_con ] = { mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
146
|
+
expect( @soc.inst_in_use?( :a_con ) ).to be( true )
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "#ifc_in_use?" do
|
152
|
+
it "should return false, when an interface is not used" do
|
153
|
+
# setup interface ifc_b and ifc_c, test for ifc_a
|
154
|
+
a_con = { mapping: [ { :core_a => :ifc_b }, { :core_b => :ifc_c } ] }
|
155
|
+
@soc.cons[ :my_con ] = a_con
|
156
|
+
expect( @soc.ifc_in_use?( :core_a, :ifc_a ) ).to be( false )
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return true, if an interface is used" do
|
160
|
+
a_con = { mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
161
|
+
@soc.cons[ :my_con ] = a_con
|
162
|
+
expect( @soc.ifc_in_use?( :core_a, :ifc_a ) ).to be( true )
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
describe "#rm and #inst_in_use" do
|
168
|
+
|
169
|
+
it do
|
170
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
171
|
+
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
172
|
+
@soc.add_connection( :new_connection, :core_a, :ifc_a, :core_b, :ifc_b )
|
173
|
+
|
174
|
+
expect( @soc.inst_in_use?( :core_a ) ).to be( true )
|
175
|
+
|
176
|
+
@soc.rm( :core_a )
|
177
|
+
expect( @soc.inst_in_use?( :core_a ) ).to be( false )
|
178
|
+
expect( @soc.cons[ :new_connection ][:mapping][ 1 ].size ).to be( 0 )
|
179
|
+
expect( @soc.cons[ :new_connection ][:mapping][ 0 ].size ).to be( 1 )
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
it do
|
184
|
+
@soc.cons[ :a_con ] = { mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
185
|
+
expect( @soc.inst_in_use?( :a_con ) ).to be( true )
|
186
|
+
@soc.rm( :a_con )
|
187
|
+
expect( @soc.inst_in_use?( :a_con ) ).to be( false )
|
188
|
+
end
|
189
|
+
|
190
|
+
it "raises an error, when removing a non-existance instance" do
|
191
|
+
expect{ @soc.rm( :a_con ) }.to raise_error( SOCMaker::ERR::ConsistenceError )
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
describe "#add_core" do
|
198
|
+
|
199
|
+
it "should raise an error if an instance is added twice" do
|
200
|
+
@soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
201
|
+
expect{ @soc.add_core( :"mycore,rel1", :core_inst ) }
|
202
|
+
.to raise_error( SOCMaker::ERR::ConsistenceError )
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should return non-nil value, if a instance is added once" do
|
206
|
+
expect( @soc.add_core( :"mycore,rel1", :core_inst ) ).not_to be( false )
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should raise a processing error when adding an unknown core" do
|
210
|
+
expect{ @soc.add_core( :"some_unknown_core,v_xyz", :test ) }.
|
211
|
+
to raise_error( SOCMaker::ERR::ProcessingError )
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
describe "#add_connection" do
|
217
|
+
|
218
|
+
it "raises an error, if a wrong number of arguments is given" do
|
219
|
+
|
220
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
221
|
+
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
222
|
+
@soc.cores[ :core_c ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
223
|
+
@soc.cores[ :core_d ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
224
|
+
@soc.cores[ :core_e ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
225
|
+
@soc.cores[ :core_f ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
226
|
+
@soc.cores[ :core_g ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
227
|
+
|
228
|
+
expect{ @soc.add_connection( :new_connection ) }
|
229
|
+
.to raise_error( SOCMaker::ERR::ProcessingError )
|
230
|
+
|
231
|
+
expect{ @soc.add_connection( :new_connection, :core_a ) }
|
232
|
+
.to raise_error( SOCMaker::ERR::ProcessingError )
|
233
|
+
|
234
|
+
expect{ @soc.add_connection( :new_connection, :core_a, :ifc_a, :core_b ) }
|
235
|
+
.to raise_error( SOCMaker::ERR::ProcessingError )
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
it "raises an error, if a core doesn't exist in a SOC" do
|
240
|
+
|
241
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
242
|
+
expect{ @soc.add_connection( :new_connection, :core_a, :ifc_a, :core_b, :ifc_b ) }
|
243
|
+
.to raise_error( SOCMaker::ERR::ConsistenceError )
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
it "raises an error, if an interface doesn't exist in a core" do
|
248
|
+
|
249
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
250
|
+
expect{ @soc.add_connection( :new_connection, :core_a, :ifc_x ) }
|
251
|
+
.to raise_error( SOCMaker::ERR::ConsistenceError )
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
it "raises an error, if the location of a connection entry is not the direction" do
|
257
|
+
|
258
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
259
|
+
@soc.cons[ :a_con ] = { mapping: [ { :core_a => :ifc_a }, { } ] }
|
260
|
+
expect{ @soc.consistence_check }
|
261
|
+
.to raise_error( SOCMaker::ERR::ConsistenceError )
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
it "raises an error, if an interface is used twice" do
|
266
|
+
|
267
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
268
|
+
@soc.cons[ :a_con ] = { mapping: [ {} ,{ :core_a => :ifc_a } ] }
|
269
|
+
expect{ @soc.add_connection( :new_connection, :core_a, :ifc_a ) }
|
270
|
+
.to raise_error( SOCMaker::ERR::ConsistenceError )
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
it "connects two instances" do
|
275
|
+
|
276
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
277
|
+
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
278
|
+
@soc.add_connection( :new_connection, :core_a, :ifc_a, :core_b, :ifc_b )
|
279
|
+
con_entry = @soc.cons[ :new_connection ]
|
280
|
+
expect( con_entry.class ).to be ( Hash )
|
281
|
+
expect( con_entry[ :mapping ].class ).to be ( Array )
|
282
|
+
expect( con_entry[ :mapping ].size ).to be ( 2 )
|
283
|
+
expect( con_entry[ :mapping ][0].class ).to be ( Hash )
|
284
|
+
expect( con_entry[ :mapping ][1].class ).to be ( Hash )
|
285
|
+
expect( con_entry[ :mapping ][0].size ).to be ( 1 )
|
286
|
+
expect( con_entry[ :mapping ][1].size ).to be ( 1 )
|
287
|
+
expect( con_entry[ :mapping ][0][ :core_b ] ).to be ( :ifc_b )
|
288
|
+
expect( con_entry[ :mapping ][1][ :core_a ] ).to be ( :ifc_a )
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
it "limits the number of connections entries" do
|
293
|
+
# the multiplicity is defined at the beginning (see above)
|
294
|
+
|
295
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
296
|
+
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
297
|
+
@soc.add_connection( :new_connection, :core_a, :ifc_a, :core_b, :ifc_b )
|
298
|
+
expect{ @soc.add_connection( :new_connection, :core_a, :ifc_c ) }
|
299
|
+
.to raise_error( SOCMaker::ERR::ConsistenceError )
|
300
|
+
|
301
|
+
end
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
it "raises a ConsistenceError if the ifc.-version is wrong" do
|
307
|
+
|
308
|
+
ifc_spc1 = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
309
|
+
ifc_spc2 = SOCMaker::IfcSpc.new( "myifc", "myifc,v2", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
310
|
+
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ) } )
|
311
|
+
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v2", 1, { b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
312
|
+
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", "top" )
|
313
|
+
core_b = SOCMaker::CoreDef.new( "core_b", "core_a,v1", "top" )
|
314
|
+
core_a.interfaces[ :ifc_a ] = ifc_def_0
|
315
|
+
core_a.interfaces[ :ifc_b ] = ifc_def_1
|
316
|
+
core_b.interfaces[ :ifc_a ] = ifc_def_0
|
317
|
+
core_b.interfaces[ :ifc_b ] = ifc_def_1
|
318
|
+
|
319
|
+
SOCMaker::lib.add_ifc( ifc_spc1 )
|
320
|
+
SOCMaker::lib.add_ifc( ifc_spc2 )
|
321
|
+
SOCMaker::lib.add_core( core_a )
|
322
|
+
SOCMaker::lib.add_core( core_b )
|
323
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
324
|
+
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "core_b,v1" )
|
325
|
+
expect { @soc.add_connection( :a_new_con, :inst_a, :ifc_a, :inst_b, :ifc_b ) }.
|
326
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
it "adds a connection entry, which connects the toplevel ports" do
|
332
|
+
|
333
|
+
@soc.interfaces[ :t1 ] = @ifc_def_0
|
334
|
+
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
335
|
+
@soc.add_connection( :another_con, :inst_a, :ifc_a, @soc.toplevel.to_sym, :t1, )
|
336
|
+
expect( @soc.cons[ :another_con ] ).to eq( { mapping: [ { @soc.toplevel.to_sym => :t1}, {inst_a: :ifc_a} ] } )
|
337
|
+
end
|
338
|
+
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
|
343
|
+
describe "#set_param and #get_param" do
|
344
|
+
|
345
|
+
it "raises an error, if a parameter of unkonwn core is set" do
|
346
|
+
expect{ @soc.set_param( :a_unknown_core, :p1, 1234 ) }.
|
347
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
348
|
+
end
|
349
|
+
|
350
|
+
it "raises an error, if a parameter of unkonwn core is requested" do
|
351
|
+
expect{ @soc.get_param( :a_unknown_core, :p1 ) }.
|
352
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
353
|
+
end
|
354
|
+
|
355
|
+
it "raises an error, if a unknown parameter is set and requested" do
|
356
|
+
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", "top" )
|
357
|
+
parameter = SOCMaker::Parameter.new( "integer" )
|
358
|
+
core_a.inst_parameters[ :p1 ] = parameter
|
359
|
+
SOCMaker::lib.add_core( core_a )
|
360
|
+
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
361
|
+
expect{ @soc.set_param( :inst_a, :px, 1234 ) }.
|
362
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
363
|
+
expect{ @soc.get_param( :inst_a, :px ) }.
|
364
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
365
|
+
end
|
366
|
+
|
367
|
+
it "sets a parameter and provides a parameter" do
|
368
|
+
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", "top" )
|
369
|
+
parameter = SOCMaker::Parameter.new( "integer" )
|
370
|
+
core_a.inst_parameters[ :p1 ] = parameter
|
371
|
+
SOCMaker::lib.add_core( core_a )
|
372
|
+
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
373
|
+
@soc.set_param( :inst_a, :p1, 1234 )
|
374
|
+
expect( @soc.cores[ :inst_a ].params[ :p1 ] ).to be( 1234 )
|
375
|
+
expect( @soc.get_param( :inst_a, :p1 ) ).to be( 1234 )
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
describe "#set_sparam and #get_sparam" do
|
380
|
+
|
381
|
+
it "raise an error, if a static-parameter of unkonwn core is set" do
|
382
|
+
expect{ @soc.set_sparam( :a_unknown_core, :p1, 1234 ) }.
|
383
|
+
to raise_error( SOCMaker::ERR::ProcessingError )
|
384
|
+
end
|
385
|
+
|
386
|
+
it "raise an error, if a statoc-parameter of unkonwn core is requested" do
|
387
|
+
expect{ @soc.get_sparam( :a_unknown_core, :p1 ) }.
|
388
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
389
|
+
end
|
390
|
+
|
391
|
+
it "raises an error, a static parameter doesn't exist" do
|
392
|
+
|
393
|
+
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", "top" )
|
394
|
+
SOCMaker::lib.add_core( core_a )
|
395
|
+
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
396
|
+
|
397
|
+
expect{ @soc.set_sparam( :"core_a,v1", :p1, 1234 ) }.
|
398
|
+
to raise_error( SOCMaker::ERR::ProcessingError )
|
399
|
+
expect{ @soc.get_sparam( :"core_a,v1", :p1 ) }.
|
400
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
401
|
+
end
|
402
|
+
|
403
|
+
it "sets a static-parameter and provides this static parameter" do
|
404
|
+
|
405
|
+
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", "top" )
|
406
|
+
pentry = SOCMaker::SParameterEntry.new( "integer", "TOK" )
|
407
|
+
parameter = SOCMaker::SParameter.new( "file/path.vhd.src",
|
408
|
+
"file/path.vhd",
|
409
|
+
'parameters' => { p1: pentry } )
|
410
|
+
core_a.static_parameters[ :p1 ] = parameter
|
411
|
+
SOCMaker::lib.add_core( core_a )
|
412
|
+
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
413
|
+
|
414
|
+
@soc.set_sparam( :"core_a,v1", :p1, 1234 )
|
415
|
+
@soc.static[ "core_a,v1".to_sym ][ :p1 ].should be == 1234
|
416
|
+
@soc.get_sparam( :"core_a,v1", :p1 ).should be == 1234
|
417
|
+
end
|
418
|
+
|
419
|
+
end
|
420
|
+
|
421
|
+
describe "#to_s" do
|
422
|
+
it "creates some string representation" do
|
423
|
+
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
424
|
+
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
425
|
+
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
426
|
+
SOCMaker::lib.add_ifc( ifc_spc )
|
427
|
+
@soc.interfaces[ :t1 ] = ifc_def_0
|
428
|
+
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
429
|
+
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
430
|
+
@soc.add_connection( :new_connection, :core_a, :ifc_a, :core_b, :ifc_b )
|
431
|
+
expect( @soc.to_s ).not_to be_nil
|
432
|
+
expect( @soc.to_s.size ).to be > 0
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
describe "object handling and en/decoding:" do
|
439
|
+
|
440
|
+
it "should be possible to encode and decode a core instance" do
|
441
|
+
yaml_str = @soc.to_yaml
|
442
|
+
o2 = YAML::load( yaml_str )
|
443
|
+
@soc.should be == o2
|
444
|
+
end
|
445
|
+
|
446
|
+
it "should return false for two non-equal objects" do
|
447
|
+
o2 = Marshal::load(Marshal.dump(@soc))
|
448
|
+
o2.name << "X"
|
449
|
+
( o2 == @soc ).should be == false
|
450
|
+
end
|
451
|
+
|
452
|
+
end
|
453
|
+
|
454
|
+
|
455
|
+
end
|
456
|
+
|
457
|
+
|
458
|
+
describe "#consistence_check" do
|
459
|
+
before( :each )do
|
460
|
+
@soc = SOCMaker::SOCDef.new( "Test SOC", "test-soc,v1", "my_soc_top" )
|
461
|
+
end
|
462
|
+
context "error handling" do
|
463
|
+
it "raises an error, if a inconsistent connection exists" do
|
464
|
+
@soc.cons[ :a_con ] = { mapping: [ {inst_a: :ifc01}, {inst_b: :ifc01} ] }
|
465
|
+
expect{ @soc.consistence_check }.to raise_error( SOCMaker::ERR::ConsistenceError )
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
describe "#gen_toplevel" do
|
473
|
+
|
474
|
+
before( :each ) do
|
475
|
+
|
476
|
+
@soc = SOCMaker::SOCDef.new( "test_soc", "test_soc,v1", "my_soc_top" )
|
477
|
+
|
478
|
+
|
479
|
+
@coder = double()
|
480
|
+
|
481
|
+
@added_cores = {}
|
482
|
+
@coder.stub( :add_core_component ) do |name_arg, def_arg|
|
483
|
+
@added_cores[ name_arg.to_sym ] = def_arg
|
484
|
+
end
|
485
|
+
|
486
|
+
@added_instances = {}
|
487
|
+
@coder.stub( :add_core_instance ) do |name_arg, inst_arg|
|
488
|
+
@added_instances[ name_arg.to_sym ] = inst_arg
|
489
|
+
end
|
490
|
+
|
491
|
+
@coder.stub( :get_hdl_code ){ |arg_coder| }
|
492
|
+
|
493
|
+
@coder.stub( :is_a? ){ SOCMaker::VHDLCoder }
|
494
|
+
|
495
|
+
@coder.stub( :filename ){ |x| x + ".vhd" }
|
496
|
+
|
497
|
+
@coder.stub( :add_ifc_default_assignment )
|
498
|
+
|
499
|
+
@coder.stub( :add_ifc_connection )
|
500
|
+
|
501
|
+
@coder.stub( :add_toplevel_sig )
|
502
|
+
|
503
|
+
@added_cons = {}
|
504
|
+
|
505
|
+
@dir_path = ""
|
506
|
+
FileUtils.stub( :mkdir_p ) { |arg| @dir_path = arg }
|
507
|
+
SOCMaker::conf[ :build_dir ] = 'a'
|
508
|
+
SOCMaker::conf[ :hdl_dir ] = 'b'
|
509
|
+
@dir_path_ref = "a/b/test_soc_v1"
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
@core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", "top" )
|
515
|
+
@core_b = SOCMaker::CoreDef.new( "core_b", "core_b,v1", "top" )
|
516
|
+
SOCMaker::lib.add_core( @core_a )
|
517
|
+
SOCMaker::lib.add_core( @core_b )
|
518
|
+
|
519
|
+
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: { dir: 1}, port_b: { dir: 0 } } )
|
520
|
+
SOCMaker::lib.add_ifc( ifc_spc )
|
521
|
+
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
522
|
+
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
523
|
+
|
524
|
+
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
525
|
+
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
526
|
+
|
527
|
+
|
528
|
+
@core_a.interfaces[ :ifc_a ] = ifc_def_0
|
529
|
+
@core_a.interfaces[ :ifc_b ] = ifc_def_1
|
530
|
+
@core_b.interfaces[ :ifc_a ] = ifc_def_0
|
531
|
+
@core_b.interfaces[ :ifc_b ] = ifc_def_1
|
532
|
+
|
533
|
+
|
534
|
+
@i1 = SOCMaker::CoreInst.new( "core_a,v1" )
|
535
|
+
@i2 = SOCMaker::CoreInst.new( "core_a,v1" )
|
536
|
+
@i3 = SOCMaker::CoreInst.new( "core_b,v1" )
|
537
|
+
@i4 = SOCMaker::CoreInst.new( "core_b,v1" )
|
538
|
+
|
539
|
+
@soc.cores[ :inst_a ] = @i1
|
540
|
+
@soc.cores[ :inst_b ] = @i2
|
541
|
+
@soc.cores[ :inst_c ] = @i3
|
542
|
+
@soc.cores[ :inst_d ] = @i4
|
543
|
+
@soc.add_connection( :a_new_con, :inst_a, :ifc_a, :inst_b, :ifc_b )
|
544
|
+
|
545
|
+
@soc.stub( :gen_toplevel_con ) do |name_arg,
|
546
|
+
m0_arg,
|
547
|
+
m1_arg |
|
548
|
+
@added_cons[ name_arg.to_sym ] = { m0: m0_arg, m1: m1_arg }
|
549
|
+
end
|
550
|
+
|
551
|
+
# file writing stub
|
552
|
+
file_mock = double()
|
553
|
+
file_mock.stub( :write )
|
554
|
+
File.should_receive(:open).and_yield(file_mock)
|
555
|
+
end
|
556
|
+
|
557
|
+
after( :each ) do
|
558
|
+
SOCMaker::lib.clear
|
559
|
+
end
|
560
|
+
|
561
|
+
it "calls all necessary coder functions (stub-version)" do
|
562
|
+
|
563
|
+
@soc.gen_toplevel( @coder );
|
564
|
+
expect( @added_cores ) .to eq( { "core_a,v1".to_sym => @core_a, "core_b,v1".to_sym => @core_b } )
|
565
|
+
expect( @added_instances ).to eq( { inst_a: @i1, inst_b: @i2, inst_c: @i3, inst_d: @i4 } )
|
566
|
+
expect( @added_cons ) .to eq( { a_new_con: { m0: {inst_b: :ifc_b } , m1: {inst_a: :ifc_a} } } )
|
567
|
+
expect( @dir_path ) .to eq( File.expand_path( @dir_path_ref ) )
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
describe "#deploy" do
|
572
|
+
|
573
|
+
after( :each ) do
|
574
|
+
SOCMaker::lib.clear
|
575
|
+
end
|
576
|
+
|
577
|
+
it "creates valid vhdl output with our test library" do
|
578
|
+
|
579
|
+
SOCMaker::conf[ :build_dir ] = 'spec/tmp_build'
|
580
|
+
SOCMaker::conf[ :hdl_dir ] = 'b'
|
581
|
+
coder = SOCMaker::VHDLCoder.new
|
582
|
+
SOCMaker::lib.refresh( './spec/test_soc_lib' )
|
583
|
+
soc = SOCMaker::from_f( './spec/test_soc.yaml' );
|
584
|
+
SOCMaker::lib.add_core( soc )
|
585
|
+
|
586
|
+
SOCMaker::deploy_soc( soc, coder )
|
587
|
+
end
|
588
|
+
|
589
|
+
|
590
|
+
it "creates valid vhdl output with our test library (hierarchical example)" do
|
591
|
+
|
592
|
+
SOCMaker::conf[ :build_dir ] = 'spec/tmp_build'
|
593
|
+
SOCMaker::conf[ :hdl_dir ] = 'xyz'
|
594
|
+
|
595
|
+
SOCMaker::lib.refresh( './spec/test_soc_lib' )
|
596
|
+
soc = SOCMaker::from_f( './spec/test_soc.yaml' );
|
597
|
+
SOCMaker::lib.add_core( soc )
|
598
|
+
|
599
|
+
soc_top = SOCMaker::from_f( './spec/test_soc2.yaml' );
|
600
|
+
SOCMaker::lib.add_core( soc_top )
|
601
|
+
SOCMaker::deploy_soc( soc_top, SOCMaker::VHDLCoder.new )
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
605
|
+
|
606
|
+
end
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
# vim: noai:ts=2:sw=2
|