1 |
3 |
feddischso |
###############################################################
|
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 .
|
31 |
|
|
#
|
32 |
|
|
#
|
33 |
|
|
###############################################################
|
34 |
|
|
#
|
35 |
|
|
# Description:
|
36 |
|
|
# Test spec. for SOCMaker::SOCDef
|
37 |
|
|
#
|
38 |
|
|
#
|
39 |
|
|
#
|
40 |
|
|
###############################################################
|
41 |
|
|
require_relative( 'spec_helper' )
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
describe SOCMaker::SOCDef, "structure verification for loading a core-definition" do
|
45 |
|
|
|
46 |
|
|
# not implemented at the moment
|
47 |
|
|
|
48 |
|
|
# test for invalid path
|
49 |
|
|
# it "should raise an error if a non-existing path is given" do
|
50 |
|
|
# expect { SOCMaker::from_f( 'blabla.txt' ) }.
|
51 |
|
|
# to raise_error( IOError )
|
52 |
|
|
# end
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
#
|
58 |
|
|
# A yaml example, which contains
|
59 |
|
|
# - a full definition
|
60 |
|
|
# - an interface with one port
|
61 |
|
|
# - one hdl file
|
62 |
|
|
# - one instance parameter
|
63 |
|
|
# - one static parameter
|
64 |
|
|
#
|
65 |
|
|
FULL_SOC_YAML = '''SOCM_SOC
|
66 |
|
|
name: my_soc
|
67 |
|
|
description: A test SOC
|
68 |
10 |
feddischso |
id: my_soc,rel2
|
69 |
3 |
feddischso |
date: 1.1.2014
|
70 |
|
|
license: LGPL
|
71 |
|
|
licensefile:
|
72 |
|
|
toplevel: soc_top
|
73 |
|
|
author: Christian Haettich
|
74 |
|
|
authormail: feddischson@opencores.org
|
75 |
|
|
repocmd: svn co http://some-address/
|
76 |
|
|
'''
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
SOC_YAML_WITH_CORE = '''SOCM_SOC
|
80 |
|
|
name: my_soc
|
81 |
|
|
description: A test SOC
|
82 |
10 |
feddischso |
id: my_soc,rel2
|
83 |
3 |
feddischso |
date: 1.1.2014
|
84 |
|
|
license: LGPL
|
85 |
|
|
licensefile:
|
86 |
|
|
author: Christian Haettich
|
87 |
|
|
authormail: feddischson@opencores.org
|
88 |
|
|
repocmd: svn co http://some-address/
|
89 |
|
|
toplevel: soc_top
|
90 |
|
|
cores:
|
91 |
|
|
:inst1: SOCM_INST
|
92 |
|
|
type: mycorerel1
|
93 |
|
|
'''
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
# process all valid YAMLs
|
101 |
|
|
# each should result in a CoreDef
|
102 |
|
|
it 'should return a class of type SOCDef when loading a full soc-def' do
|
103 |
|
|
SOCMaker::from_s( FULL_SOC_YAML ).class.should == SOCMaker::SOCDef
|
104 |
|
|
end
|
105 |
|
|
|
106 |
|
|
it "should rise an error if soc is loaded with a core, which is not in our library" do
|
107 |
|
|
SOCMaker::lib.clear
|
108 |
7 |
feddischso |
expect { SOCMaker::from_s( SOC_YAML_WITH_CORE ).consistency_check }.
|
109 |
3 |
feddischso |
to raise_error( SOCMaker::ERR::LibError )
|
110 |
|
|
end
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
it "should return an SOC-object if soc is loaded with a core, which is in our library" do
|
114 |
|
|
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
115 |
|
|
core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
|
116 |
|
|
SOCMaker::lib.add_core( core )
|
117 |
|
|
soc = SOCMaker::from_s( SOC_YAML_WITH_CORE )
|
118 |
|
|
soc.class.should be SOCMaker::SOCDef
|
119 |
|
|
end
|
120 |
|
|
|
121 |
|
|
end
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
describe SOCMaker::SOCDef, "processing verification" do
|
125 |
|
|
|
126 |
|
|
before( :each )do
|
127 |
|
|
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
128 |
10 |
feddischso |
core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
|
129 |
3 |
feddischso |
SOCMaker::lib.add_core( core )
|
130 |
10 |
feddischso |
@soc = SOCMaker::SOCDef.new( "Test SOC", "test-soc,v1", "my_soc_top" )
|
131 |
3 |
feddischso |
end
|
132 |
|
|
|
133 |
|
|
describe "adding/removing cores, connections etc." do
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
it "inst_in_use should return true, if there is already an core instance with that name" do
|
137 |
|
|
@soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycorerel1" )
|
138 |
|
|
@soc.inst_in_use?( "core_inst" ).should be == true
|
139 |
|
|
end
|
140 |
|
|
|
141 |
|
|
it "inst_in_use should return false, if there is no core instance with that name" do
|
142 |
|
|
@soc.inst_in_use?( "core_inst" ).should be == false
|
143 |
|
|
end
|
144 |
|
|
|
145 |
|
|
it "inst_in_use should return true, if there is already an connection instance with that name" do
|
146 |
|
|
@soc.cons[ :a_con ] = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
147 |
|
|
@soc.inst_in_use?( "a_con" ).should be == true
|
148 |
|
|
end
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
it "removing a core instance should be possible" do
|
153 |
|
|
@soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycorerel1" )
|
154 |
|
|
@soc.inst_in_use?( "core_inst" ).should be == true
|
155 |
|
|
@soc.rm( "core_inst" ).should be == true
|
156 |
|
|
@soc.inst_in_use?( "core_inst" ).should be == false
|
157 |
|
|
end
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
it "removing a connection instance should be possible" do
|
161 |
|
|
@soc.cons[ :a_con ] = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
162 |
|
|
@soc.inst_in_use?( "a_con" ).should be == true
|
163 |
|
|
@soc.rm( "a_con" ).should be == true
|
164 |
|
|
@soc.inst_in_use?( "a_con" ).should be == false
|
165 |
|
|
end
|
166 |
|
|
|
167 |
|
|
it "should return false, when removing a non-existance instance" do
|
168 |
|
|
@soc.rm( "a_con" ).should be == false
|
169 |
|
|
end
|
170 |
|
|
|
171 |
|
|
it "should return nil if a instance is added twice" do
|
172 |
|
|
@soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycorerel1" )
|
173 |
10 |
feddischso |
@soc.add_core( "mycore,rel1", "core_inst" ).should be == false
|
174 |
3 |
feddischso |
end
|
175 |
|
|
|
176 |
|
|
it "should return non-nil value, if a instance is added once" do
|
177 |
10 |
feddischso |
@soc.add_core( "mycore,rel1", "core_inst" ).should_not be == false
|
178 |
3 |
feddischso |
end
|
179 |
|
|
|
180 |
9 |
feddischso |
# in one of the first version, we returned nil, but now this is
|
181 |
|
|
# used to extend a interface
|
182 |
|
|
it "should not return nil if a connection is added twice" do
|
183 |
3 |
feddischso |
@soc.cons[ :a_con ] = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
184 |
9 |
feddischso |
@soc.add_connection( "core_a", "ifc_a", "core_c", "ifc_b", "a_con" ).should_not be == nil
|
185 |
3 |
feddischso |
end
|
186 |
|
|
|
187 |
|
|
it "should raise a library error when adding an unknown core" do
|
188 |
10 |
feddischso |
expect{ @soc.add_core( "some_unknown_core,v_xyz", "test" ) }.
|
189 |
3 |
feddischso |
to raise_error( SOCMaker::ERR::LibError )
|
190 |
|
|
end
|
191 |
|
|
|
192 |
|
|
it "should create a dir and return the absolute path for a core inside the build/hdl dir" do
|
193 |
|
|
SOCMaker::conf[ :build_dir ] = "./spec/tmp_build"
|
194 |
|
|
SOCMaker::conf[ :hdl_dir ] = "hdl"
|
195 |
|
|
path = File.expand_path "./spec/tmp_build/hdl/a_core"
|
196 |
|
|
FileUtils.rmdir( path ) if File.directory?( path )
|
197 |
9 |
feddischso |
res = SOCMaker::Component::get_and_ensure_dst_dir!( "a_core" )
|
198 |
3 |
feddischso |
File.directory?( path ).should be == true
|
199 |
|
|
res.should be == path
|
200 |
|
|
end
|
201 |
|
|
|
202 |
|
|
it "should return false, when an interface is not used" do
|
203 |
|
|
# setup interface ifc_b and ifc_c, test for ifc_a
|
204 |
|
|
a_con = { rule: "or", mapping: [ { :core_a => :ifc_b }, { :core_b => :ifc_c } ] }
|
205 |
|
|
@soc.cons[ :my_con ] = a_con
|
206 |
|
|
@soc.ifc_in_use?( "core_a", "ifc_a" ).should be == false
|
207 |
|
|
end
|
208 |
|
|
|
209 |
|
|
it "should return true, if an interface is used" do
|
210 |
|
|
a_con = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
211 |
|
|
@soc.cons[ :my_con ] = a_con
|
212 |
|
|
@soc.ifc_in_use?( "core_a", "ifc_a" ).should be == true
|
213 |
|
|
end
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
it "should raise an SOCMaker::ERR::ProcessingError add_connection tries to add a interface, wich is already used" do
|
217 |
|
|
a_con = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
|
218 |
|
|
@soc.cons[ :my_con ] = a_con
|
219 |
|
|
expect{ @soc.add_connection( "core_a", "ifc_a", "core_b", "ifc_c", "a_new_con" ) }.
|
220 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
221 |
|
|
expect{ @soc.add_connection( "core_a", "ifc_a", "core_c", "ifc_b", "a_new_con" ) }.
|
222 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
223 |
|
|
end
|
224 |
|
|
|
225 |
|
|
it "should raise an SOCMaker::ERR::ProcessingError if a connection is added from a non-existing core instance" do
|
226 |
|
|
expect{ @soc.add_connection( "core_a", "ifc_a", "core_c", "ifc_b", "a_new_con" ) }.
|
227 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
228 |
|
|
end
|
229 |
|
|
|
230 |
|
|
it "should raise an ProcessingError if a interface doesn't exist" do
|
231 |
10 |
feddischso |
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
232 |
|
|
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
|
233 |
3 |
feddischso |
expect{ @soc.add_connection( "core_a", "ifc_a", "core_b", "ifc_c", "a_new_con" ) }.
|
234 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
235 |
|
|
end
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
it "should raise an ProcessingError if the ifc.-version is wrong" do
|
239 |
|
|
|
240 |
10 |
feddischso |
ifc_spc1 = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
241 |
|
|
ifc_spc2 = SOCMaker::IfcSpc.new( "myifc", "myifc,v2", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
242 |
|
|
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ) } )
|
243 |
|
|
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v2", 1, { b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
244 |
3 |
feddischso |
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
245 |
10 |
feddischso |
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
|
246 |
|
|
core_b = SOCMaker::CoreDef.new( "core_b", "core_a,v1", file, "top" )
|
247 |
3 |
feddischso |
core_a.interfaces[ :ifc_a ] = ifc_def_0
|
248 |
|
|
core_a.interfaces[ :ifc_b ] = ifc_def_1
|
249 |
|
|
core_b.interfaces[ :ifc_a ] = ifc_def_0
|
250 |
|
|
core_b.interfaces[ :ifc_b ] = ifc_def_1
|
251 |
|
|
|
252 |
|
|
SOCMaker::lib.add_ifc( ifc_spc1 )
|
253 |
|
|
SOCMaker::lib.add_ifc( ifc_spc2 )
|
254 |
|
|
SOCMaker::lib.add_core( core_a )
|
255 |
|
|
SOCMaker::lib.add_core( core_b )
|
256 |
10 |
feddischso |
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
257 |
|
|
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "core_b,v1" )
|
258 |
3 |
feddischso |
expect { @soc.add_connection( "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" ) }.
|
259 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
260 |
|
|
end
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
it "should add a connection entry" do
|
266 |
|
|
|
267 |
10 |
feddischso |
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
268 |
8 |
feddischso |
|
269 |
10 |
feddischso |
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
270 |
|
|
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
271 |
8 |
feddischso |
|
272 |
10 |
feddischso |
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
273 |
|
|
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
274 |
8 |
feddischso |
|
275 |
|
|
|
276 |
3 |
feddischso |
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
277 |
10 |
feddischso |
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
|
278 |
|
|
core_b = SOCMaker::CoreDef.new( "core_b", "core_b,v1", file, "top" )
|
279 |
3 |
feddischso |
core_a.interfaces[ :ifc_a ] = ifc_def_0
|
280 |
|
|
core_a.interfaces[ :ifc_b ] = ifc_def_1
|
281 |
|
|
core_b.interfaces[ :ifc_a ] = ifc_def_0
|
282 |
|
|
core_b.interfaces[ :ifc_b ] = ifc_def_1
|
283 |
|
|
|
284 |
|
|
SOCMaker::lib.add_ifc( ifc_spc )
|
285 |
|
|
SOCMaker::lib.add_core( core_a )
|
286 |
|
|
SOCMaker::lib.add_core( core_b )
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
10 |
feddischso |
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
291 |
|
|
@soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_b,v1" )
|
292 |
7 |
feddischso |
@soc.consistency_check
|
293 |
3 |
feddischso |
@soc.add_connection( "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" )
|
294 |
|
|
@soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{inst_b: :ifc_b} ] }
|
295 |
|
|
end
|
296 |
|
|
|
297 |
5 |
feddischso |
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
it "should add a connection entry, which connects the toplevel's port" do
|
301 |
|
|
|
302 |
8 |
feddischso |
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
|
303 |
|
|
|
304 |
|
|
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
305 |
|
|
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
306 |
|
|
|
307 |
|
|
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
|
308 |
|
|
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
|
309 |
|
|
|
310 |
5 |
feddischso |
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
311 |
10 |
feddischso |
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
|
312 |
5 |
feddischso |
core_a.interfaces[ :ifc_a ] = ifc_def_0
|
313 |
|
|
core_a.interfaces[ :ifc_b ] = ifc_def_1
|
314 |
|
|
|
315 |
|
|
SOCMaker::lib.add_ifc( ifc_spc )
|
316 |
|
|
SOCMaker::lib.add_core( core_a )
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
SOCMaker::lib.add_core( @soc )
|
320 |
|
|
@soc.interfaces[ :t1 ] = ifc_def_1
|
321 |
10 |
feddischso |
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
322 |
7 |
feddischso |
@soc.consistency_check
|
323 |
10 |
feddischso |
@soc.add_connection( "inst_a", "ifc_a", @soc.id, "t1", "a_new_con" )
|
324 |
|
|
@soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{ @soc.id.to_sym => :t1} ] }
|
325 |
5 |
feddischso |
end
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
3 |
feddischso |
it "should raise an error, if a parameter of unkonwn core is set" do
|
330 |
|
|
expect{ @soc.set_param( "a_unknown_core", "p1", 1234 ) }.
|
331 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
332 |
|
|
end
|
333 |
|
|
|
334 |
|
|
it "should raise an error, if a parameter of unkonwn core is requested" do
|
335 |
|
|
expect{ @soc.get_param( "a_unknown_core", "p1" ) }.
|
336 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
337 |
|
|
end
|
338 |
|
|
|
339 |
|
|
it "should raise an error, if a unknown parameter is set and requested" do
|
340 |
|
|
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
341 |
|
|
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
|
342 |
|
|
parameter = SOCMaker::Parameter.new( "integer" )
|
343 |
|
|
core_a.inst_parameters[ :p1 ] = parameter
|
344 |
|
|
SOCMaker::lib.add_core( core_a )
|
345 |
10 |
feddischso |
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
346 |
3 |
feddischso |
expect{ @soc.set_param( "inst_a", "px", 1234 ) }.
|
347 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
348 |
|
|
expect{ @soc.get_param( "inst_a", "px" ) }.
|
349 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
350 |
|
|
end
|
351 |
|
|
|
352 |
|
|
it "should set a parameter and provide a parameter" do
|
353 |
|
|
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
354 |
10 |
feddischso |
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
|
355 |
3 |
feddischso |
parameter = SOCMaker::Parameter.new( "integer" )
|
356 |
|
|
core_a.inst_parameters[ :p1 ] = parameter
|
357 |
|
|
SOCMaker::lib.add_core( core_a )
|
358 |
10 |
feddischso |
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
359 |
3 |
feddischso |
@soc.set_param( "inst_a", "p1", 1234 )
|
360 |
|
|
@soc.cores[ :inst_a ].params[ :p1 ].should be == 1234
|
361 |
|
|
@soc.get_param( "inst_a", "p1" ).should be == 1234
|
362 |
|
|
end
|
363 |
|
|
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
it "should raise an error, if a static-parameter of unkonwn core is set" do
|
367 |
|
|
expect{ @soc.set_sparam( "a_unknown_core", "p1", 1234 ) }.
|
368 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
369 |
|
|
end
|
370 |
|
|
|
371 |
|
|
it "should raise an error, if a statoc-parameter of unkonwn core is requested" do
|
372 |
|
|
expect{ @soc.get_sparam( "a_unknown_core", "p1" ) }.
|
373 |
|
|
to raise_error( SOCMaker::ERR::ProcessingError )
|
374 |
|
|
end
|
375 |
|
|
|
376 |
|
|
it "should an error, a static parameter doesn't exist" do
|
377 |
|
|
|
378 |
|
|
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
379 |
10 |
feddischso |
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
|
380 |
3 |
feddischso |
SOCMaker::lib.add_core( core_a )
|
381 |
10 |
feddischso |
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
382 |
3 |
feddischso |
|
383 |
10 |
feddischso |
expect{ @soc.set_sparam( "core_a,v1", "p1", 1234 ) }.
|
384 |
3 |
feddischso |
to raise_error( SOCMaker::ERR::ProcessingError )
|
385 |
10 |
feddischso |
expect{ @soc.get_sparam( "core_a,v1", "p1" ) }.
|
386 |
3 |
feddischso |
to raise_error( SOCMaker::ERR::ProcessingError )
|
387 |
|
|
end
|
388 |
|
|
|
389 |
|
|
it "should set a static-parameter and provide this static parameter" do
|
390 |
|
|
|
391 |
|
|
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
392 |
10 |
feddischso |
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
|
393 |
3 |
feddischso |
pentry = SOCMaker::SParameterEntry.new( "integer", "TOK" )
|
394 |
|
|
parameter = SOCMaker::SParameter.new( "file/path.vhd.src",
|
395 |
|
|
"file/path.vhd",
|
396 |
|
|
'parameters' => { p1: pentry } )
|
397 |
|
|
core_a.static_parameters[ :p1 ] = parameter
|
398 |
|
|
SOCMaker::lib.add_core( core_a )
|
399 |
10 |
feddischso |
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
|
400 |
3 |
feddischso |
|
401 |
10 |
feddischso |
@soc.set_sparam( "core_a,v1", "p1", 1234 )
|
402 |
|
|
@soc.static[ "core_a,v1".to_sym ][ :p1 ].should be == 1234
|
403 |
|
|
@soc.get_sparam( "core_a,v1", "p1" ).should be == 1234
|
404 |
3 |
feddischso |
end
|
405 |
|
|
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
end
|
413 |
|
|
|
414 |
|
|
describe SOCMaker::SOCDef, "object handling, en-decoding:" do
|
415 |
|
|
|
416 |
|
|
it "should be possible to encode and decode a core instance" do
|
417 |
|
|
yaml_str = @soc.to_yaml
|
418 |
|
|
o2 = YAML::load( yaml_str )
|
419 |
|
|
@soc.should be == o2
|
420 |
|
|
end
|
421 |
|
|
|
422 |
|
|
it "should return false for two non-equal objects" do
|
423 |
|
|
o2 = Marshal::load(Marshal.dump(@soc))
|
424 |
|
|
o2.name << "X"
|
425 |
|
|
( o2 == @soc ).should be == false
|
426 |
|
|
end
|
427 |
|
|
|
428 |
|
|
end
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
end
|
432 |
|
|
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
# vim: noai:ts=2:sw=2
|