OpenCores
URL https://opencores.org/ocsvn/soc_maker/soc_maker/trunk

Subversion Repositories soc_maker

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /soc_maker/trunk/spec
    from Rev 9 to Rev 10
    Reverse comparison

Rev 9 → Rev 10

/core_def_spec.rb
65,7 → 65,7
FULL_YAML = '''SOCM_CORE
name: core_A
description: A test IP-core
version: rel1
id: core_A,rel1
date: 1.1.2014
license: LGPL
licensefile:
77,7 → 77,7
:ifc01: SOCM_IFC
name: core_AB_ifc
dir: 0
version: "1"
id: core_AB_ifc,1
ports:
:sig_con1a: SOCM_PORT
defn: sig_a
121,7 → 121,7
# minimalistic def with one vhdl file
MIN_YAML1 = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
135,7 → 135,7
# vhdl and one verilog file
MIN_YAML2 = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
185,7 → 185,7
# def with toplevel.size == 0
F_YAML_TOPLEVEL = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: ''
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
199,7 → 199,7
# def with hdlfiles.class != Hash
F_YAML_FILE_HASH = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
- test1.vhd
214,7 → 214,7
# minimal setup with one interface
MIN_YAML_IFC = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
223,7 → 223,7
:ifc01: SOCM_IFC
name: a_ifc_def
dir: 0
version: "1"
id: a_ifc_def,1
ports:
:sig_con1a: SOCM_PORT
defn: sig_a
238,7 → 238,7
# minimal setup with one instance parameter
MIN_YAML_INSTP = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
254,7 → 254,7
# empty hash for param1
F_YAML_INSTP_EMPTY = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
268,7 → 268,7
# minimal def with one static parameter
MIN_YAML_STATIC = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
290,7 → 290,7
# empty static parameter
F_YAML_STATIC_EMPTY = '''SOCM_CORE
name: core_A
version: rel1
id: core_A,rel1
toplevel: top_A
hdlfiles:
:core_a.vhd: SOCM_HDL_FILE
315,7 → 315,7
 
it "should return a CoreDef object, if the object is created via new" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
c = SOCMaker::CoreDef.new( "acore", "v1", file, "top" )
c = SOCMaker::CoreDef.new( "acore", "acore,v1", file, "top" )
c.class.should be == SOCMaker::CoreDef
end
475,7 → 475,7
 
it "should be possible to encode and decode a core definition" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
o1 = SOCMaker::CoreDef.new( "acore", "v1", file, "top" )
o1 = SOCMaker::CoreDef.new( "acore", "acore,v1", file, "top" )
yaml_str = o1.to_yaml
o2 = YAML::load( yaml_str )
o1.should be == o2
483,9 → 483,9
 
it "should return false for two non-equal objects" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
o1 = SOCMaker::CoreDef.new( "acore", "v1", file, "top" )
o1 = SOCMaker::CoreDef.new( "acore", "acore,v1", file, "top" )
o2 = Marshal::load(Marshal.dump(o1))
o2.version = "v2"
o2.id = "acore,v2"
( o2 == o1 ).should be == false
o2 = Marshal::load(Marshal.dump(o1))
o2.hdlfiles[ "file.vhd".to_sym ].use_syn = false
/ifc_spc_spec.rb
49,7 → 49,7
IFC_YAML_VALID = """
SOCM_IFC_SPC
name: core_ifc
version: '1'
id: 'core_ifc,1'
ports:
:sig_a:
:dir: 1
62,7 → 62,7
IFC_YAML_INVALID = """
SOCM_IFC_SPC
:name: core_ifc
:version: '1'
:id: 'core_ifc,1'
:ports:
:sig_a: '12'
:sig_b: 1
72,7 → 72,7
IFC_YAML_INVALID2 = """
SOCM_IFC_SPC
:name: core_ifc
:version: '1'
:id: 'core_ifc,1'
:ports:
:sig_a:
:sig_b: 1
94,12 → 94,12
to raise_error( SOCMaker::ERR::ValueError )
end
it "should raise an error if the version is not a string" do
it "should raise an error if the id is not a string" do
expect{ SOCMaker::IfcSpc.new( "myifc", 234, { :p1 => "a-string" } ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
it "should raise an error if the version is an a empty string" do
it "should raise an error if the id is an a empty string" do
expect{ SOCMaker::IfcSpc.new( "myifc", "", { :p1 => "a-string" } ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
106,7 → 106,7
it "should raise an error if a port direction is neither 0 nor 1" do
expect{ SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { :p1 => "a-string" } ) }.
expect{ SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { :p1 => "a-string" } ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
/lib_spec.rb
111,21 → 111,33
describe "library access" do
it "should be possible to add, get and remove a core" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
c = SOCMaker::CoreDef.new( "acore", "v1", file, "top" )
c = SOCMaker::CoreDef.new( "A core", "acore,v1", file, "top" )
@lib.add_core( c )
@lib.get_core( "acore", "v1" ).should be == c
@lib.get_core( "acore,v1" ).should be == c
@lib.rm_core( c )
expect { @lib.get_core( "acore", "v1" ) }.
expect { @lib.get_core( "acore,v1" ) }.
to raise_error( SOCMaker::ERR::LibError )
end
 
it "should be possible to add, get and remove an interface" do
i = SOCMaker::IfcSpc.new( "myifc", "v2" )
i = SOCMaker::IfcSpc.new( "My Interface", "myifc,v2" )
 
# removing with instance
@lib.add_ifc( i )
@lib.get_ifc( "myifc", "v2" ).should be == i
@lib.get_ifc( "myifc,v2" ).should be == i
@lib.rm_ifc( i )
expect { @lib.get_ifc( "myifc", "v2" ) }.
 
expect { @lib.get_ifc( "myifc,v2" ) }.
to raise_error( SOCMaker::ERR::LibError )
 
# removing with id
@lib.add_ifc( i )
@lib.get_ifc( "myifc,v2" ).should be == i
@lib.rm_ifc( i.id )
 
expect { @lib.get_ifc( "myifc,v2" ) }.
to raise_error( SOCMaker::ERR::LibError )
 
end
 
it "should process all folders in add_include" do
143,9 → 155,9
 
it "should load all elements from our test library" do
@lib.refresh( './spec/test_soc_lib' )
core_A = @lib.get_core( "core_A", "rel1" )
core_B = @lib.get_core( "core_B", "rel1" )
core_AB_ifc = @lib.get_ifc( "core_AB_ifc", "1" )
core_A = @lib.get_core( "core_A,rel1" )
core_B = @lib.get_core( "core_B,rel1" )
core_AB_ifc = @lib.get_ifc( "core_AB_ifc,1" )
core_A.class.should be SOCMaker::CoreDef
core_B.class.should be SOCMaker::CoreDef
core_AB_ifc.class.should be SOCMaker::IfcSpc
/test_soc.yaml
1,7 → 1,7
SOCM_SOC
name: test_soc
description: 'This is a test SOC'
version: v1
id: test_soc,v1
date: '13. May 2014'
license: 'GPL'
licensefile: ''
12,7 → 12,7
:top_ifc: SOCM_IFC
name: core_AB_ifc
dir: 0
version: "1"
id: core_AB_ifc,1
ports:
:sig_con1a: SOCM_PORT
defn: sig_a
29,22 → 29,22
static_parameters: {}
cores:
:inst_a: SOCM_INST
type: core_Arel1
type: core_A,rel1
params:
:param1: 8
:param2: 8
:param3: 16
:inst_b: SOCM_INST
type: core_Arel1
type: core_A,rel1
params:
:param1: 8
:param2: 16
:param3: 16
:inst_c: SOCM_INST
type: core_Brel1
type: core_B,rel1
params: {}
:inst_d: SOCM_INST
type: core_Brel1
type: core_B,rel1
params: {}
 
static:
/ifc_def_spec.rb
46,46 → 46,42
tmp_port = SOCMaker::IfcPort.new( "abc" )
 
it "should return a SOCMaker::IfcDef object when creating with new" do
s = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port } )
s = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port } )
s.class.should be SOCMaker::IfcDef
end
 
it "should raise an error if the name is not a string" do
expect{ SOCMaker::IfcDef.new( 4, "v1", 1, { test: tmp_port } ) }.
expect{ SOCMaker::IfcDef.new( 4, "myifc,v1", 1, { test: tmp_port } ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
it "should raise an error if the direction is neither 0 nor 1 " do
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { test: tmp_port } ) }.
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { test: tmp_port } ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
 
 
it "should raise an error if no ports are given " do
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { } ) }.
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { } ) }.
to raise_error( SOCMaker::ERR::StructureError )
end
 
 
it "should raise an error if a ports is nil " do
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: nil} ) }.
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: nil} ) }.
to raise_error( SOCMaker::ERR::StructureError )
end
 
it "should raise an error if a ports is not of type SOCMaker::IfcPort " do
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: "string-type"} ) }.
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: "string-type"} ) }.
to raise_error( SOCMaker::ERR::StructureError )
end
 
it "should raise an error if no ports are given (nil)" do
expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, nil ) }.
expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, nil ) }.
to raise_error( SOCMaker::ERR::StructureError )
end
 
it "should auto-convert a numerical version to string version" do
s = SOCMaker::IfcDef.new( "myifc", 1, 1, { test: tmp_port } )
s.version.should be == "1"
end
end
 
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
92,14 → 88,14
tmp_port = SOCMaker::IfcPort.new( "abc" )
 
it "should return false for two non-equal objects" do
o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port } )
o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port } )
o2 = Marshal::load(Marshal.dump(o1))
o2.version = "v2"
o2.id = "myifc,v2"
( o2 == o1 ).should be == false
end
 
it "should be possible to encode and decode a interface definition" do
o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port } )
o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port } )
yaml_str = o1.to_yaml
o2 = YAML::load( yaml_str )
o1.should be == o2
/core_inst_spec.rb
56,10 → 56,10
 
it "should raise an error, if parameters are given, which doesn't exist in the definition" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
SOCMaker::lib.add_core( core )
expect{
inst = SOCMaker::CoreInst.new( "mycorerel1", { "aparameter".to_sym => 4 } )
inst = SOCMaker::CoreInst.new( "mycore,rel1", { "aparameter".to_sym => 4 } )
inst.consistency_check }.
to raise_error( SOCMaker::ERR::ValueError )
SOCMaker::lib.rm_core( core )
71,11 → 71,11
# create core with one file and one instance parameter
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" ) }
core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
core.inst_parameters = parameters
SOCMaker::lib.add_core( core )
 
inst = SOCMaker::CoreInst.new( "mycorerel1", {} )
inst = SOCMaker::CoreInst.new( "mycore,rel1", {} )
inst.consistency_check
inst.params[ :param1 ].should be == 0
SOCMaker::lib.rm_core( core )
88,7 → 88,7
# it 'should return true and false for implements_port?, when a port is implemented and
# not implemented' do
# file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
# core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
# core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
# ifc_spc = SOCMaker::IfcSpc.new( "a_ifc", "v1", "ports" => { p1: 1, p2: 0 } )
# ifc = SOCMaker::IfcDef.new( "a_ifc", "v1", 1, { p1: SOCMaker::IfcPort.new( "p1", 1 ) } )
# core.interfaces[ :i1 ] = ifc
95,7 → 95,7
# SOCMaker::lib.add_core( core )
# SOCMaker::lib.add_ifc( ifc_spc )
 
# o1 = SOCMaker::CoreInst.new( "mycorerel1", {} )
# o1 = SOCMaker::CoreInst.new( "mycore,rel1", {} )
# o1.consistency_check
# o1.implements_port?( 'i1', 'p1' ).should be == true
# o1.implements_port?( 'i1', 'p2' ).should be == false
107,11 → 107,11
it "should be possible to encode and decode a core instance" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" ) }
core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
core.inst_parameters = parameters
SOCMaker::lib.add_core( core )
 
o1 = SOCMaker::CoreInst.new( "mycorerel1", {} )
o1 = SOCMaker::CoreInst.new( "mycore,rel1", {} )
yaml_str = o1.to_yaml
o2 = YAML::load( yaml_str )
o1.should be == o2
120,11 → 120,11
it "should return false for two non-equal objects" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" ) }
core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
core.inst_parameters = parameters
SOCMaker::lib.add_core( core )
 
o1 = SOCMaker::CoreInst.new( "mycorerel1" )
o1 = SOCMaker::CoreInst.new( "mycore,rel1" )
o1.consistency_check
o2 = Marshal::load(Marshal.dump(o1))
o2.type << "X"
137,7 → 137,7
it "should call coder functions for each core-def. (stub-version)" do
SOCMaker::lib.clear
soc = SOCMaker::SOCDef.new( "test_soc", "v1", "my_soc_top" )
soc = SOCMaker::SOCDef.new( "test_soc", "test_soc,v1", "my_soc_top" )
 
 
coder = double()
175,18 → 175,18
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_b = SOCMaker::CoreDef.new( "core_b", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
core_b = SOCMaker::CoreDef.new( "core_b", "core_b,v1", file, "top" )
SOCMaker::lib.add_core( core_a )
SOCMaker::lib.add_core( core_b )
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { port_a: { dir: 1}, port_b: { dir: 0 } } )
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: { dir: 1}, port_b: { dir: 0 } } )
SOCMaker::lib.add_ifc( ifc_spc )
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
core_a.interfaces[ :ifc_a ] = ifc_def_0
195,10 → 195,10
core_b.interfaces[ :ifc_b ] = ifc_def_1
i1 = SOCMaker::CoreInst.new( "core_av1" )
i2 = SOCMaker::CoreInst.new( "core_av1" )
i3 = SOCMaker::CoreInst.new( "core_bv1" )
i4 = SOCMaker::CoreInst.new( "core_bv1" )
i1 = SOCMaker::CoreInst.new( "core_a,v1" )
i2 = SOCMaker::CoreInst.new( "core_a,v1" )
i3 = SOCMaker::CoreInst.new( "core_b,v1" )
i4 = SOCMaker::CoreInst.new( "core_b,v1" )
soc.cores[ :inst_a ] = i1
soc.cores[ :inst_b ] = i2
209,7 → 209,7
 
SOCMaker::lib.add_core( soc )
soc_inst = SOCMaker::CoreInst.new( 'test_socv1' )
soc_inst = SOCMaker::CoreInst.new( 'test_soc,v1' )
soc_inst.consistency_check
 
soc_inst.stub( :gen_toplevel_con ) do |name_arg,
228,7 → 228,7
File.should_receive(:open).and_yield(file_mock)
soc_inst.gen_toplevel( coder );
added_cores.should be == { :core_av1 => core_a, :core_bv1 => core_b }
added_cores.should be == { "core_a,v1".to_sym => core_a, "core_b,v1".to_sym => core_b }
added_instances.should be == { inst_a: i1, inst_b: i2, inst_c: i3, inst_d: i4 }
added_cons.should be == { a_new_con: { rule: "or", m0: {inst_a: :ifc_a}, m1: {inst_b: :ifc_b } } }
dir_path.should be == dir_path_ref
245,7 → 245,7
SOCMaker::lib.refresh( './spec/test_soc_lib' )
soc = SOCMaker::from_f( './spec/test_soc.yaml' );
SOCMaker::lib.add_core( soc )
soc_inst = SOCMaker::CoreInst.new( 'test_socv1' )
soc_inst = SOCMaker::CoreInst.new( 'test_soc,v1' )
soc_inst.consistency_check
soc_inst.gen_toplevel( coder );
soc.copy_files
/test_soc_lib/ifcs/core_AB_ifc/top_ifc.yaml
1,6 → 1,6
SOCM_IFC_SPC
name: top_ifc
version: "1"
name: Top IFC
id: top_ifc,1
ports:
:sig_1:
:dir: 1
/test_soc_lib/ifcs/core_AB_ifc/core_AB_ifc.yaml
1,6 → 1,6
SOCM_IFC_SPC
name: core_AB_ifc
version: "1"
name: Core AB Interface
id: core_AB_ifc,1
ports:
:sig_a:
:dir: 1
/test_soc_lib/cores/core_A_rel1/00_core_a.yaml
1,7 → 1,7
SOCM_CORE
name: core_A
description: A test IP-core
version: rel1
name: Core A
description: A test IP-core, which has no functionallity
id: core_A,rel1
date: 1.1.2014
license: LGPL
licensefile:
13,7 → 13,7
:ifc01: SOCM_IFC
name: core_AB_ifc
dir: 0
version: "1"
id: core_AB_ifc,1
ports:
:sig_con1a: SOCM_PORT
defn: sig_a
27,7 → 27,7
:ifc02: SOCM_IFC
name: core_AB_ifc
dir: 1
version: "1"
id: core_AB_ifc,1
ports:
:sig_con1ax: SOCM_PORT
defn: sig_a
/test_soc_lib/cores/core_B_rel1/core_b.yaml
1,7 → 1,7
SOCM_CORE
name: core_B
name: Core B
description: B test IP-core
version: rel1
id: core_B,rel1
date: 1.1.2014
license: LGPL
licensefile:
13,7 → 13,7
:myifc: SOCM_IFC
name: core_AB_ifc
dir: 1
version: "1"
id: core_AB_ifc,1
ports:
:mysig_con1a: SOCM_PORT
defn: sig_a
/soc_def_spec.rb
65,7 → 65,7
FULL_SOC_YAML = '''SOCM_SOC
name: my_soc
description: A test SOC
version: rel2
id: my_soc,rel2
date: 1.1.2014
license: LGPL
licensefile:
79,7 → 79,7
SOC_YAML_WITH_CORE = '''SOCM_SOC
name: my_soc
description: A test SOC
version: rel2
id: my_soc,rel2
date: 1.1.2014
license: LGPL
licensefile:
125,9 → 125,9
before( :each )do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )
core = SOCMaker::CoreDef.new( "My Core", "mycore,rel1", file, "top" )
SOCMaker::lib.add_core( core )
@soc = SOCMaker::SOCDef.new( "test-soc", "v1", "my_soc_top" )
@soc = SOCMaker::SOCDef.new( "Test SOC", "test-soc,v1", "my_soc_top" )
end
 
describe "adding/removing cores, connections etc." do
170,11 → 170,11
 
it "should return nil if a instance is added twice" do
@soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycorerel1" )
@soc.add_core( "mycore", "rel1", "core_inst" ).should be == false
@soc.add_core( "mycore,rel1", "core_inst" ).should be == false
end
 
it "should return non-nil value, if a instance is added once" do
@soc.add_core( "mycore", "rel1", "core_inst" ).should_not be == false
@soc.add_core( "mycore,rel1", "core_inst" ).should_not be == false
end
 
# in one of the first version, we returned nil, but now this is
185,7 → 185,7
end
 
it "should raise a library error when adding an unknown core" do
expect{ @soc.add_core( "some_unknown_core", "v_xyz", "test" ) }.
expect{ @soc.add_core( "some_unknown_core,v_xyz", "test" ) }.
to raise_error( SOCMaker::ERR::LibError )
end
 
228,8 → 228,8
end
 
it "should raise an ProcessingError if a interface doesn't exist" do
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycorerel1" )
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycorerel1" )
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
expect{ @soc.add_connection( "core_a", "ifc_a", "core_b", "ifc_c", "a_new_con" ) }.
to raise_error( SOCMaker::ERR::ProcessingError )
end
237,13 → 237,13
 
it "should raise an ProcessingError if the ifc.-version is wrong" do
 
ifc_spc1 = SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
ifc_spc2 = SOCMaker::IfcSpc.new( "myifc", "v2", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ) } )
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v2", 1, { b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
ifc_spc1 = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
ifc_spc2 = SOCMaker::IfcSpc.new( "myifc", "myifc,v2", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ) } )
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v2", 1, { b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_b = SOCMaker::CoreDef.new( "core_b", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
core_b = SOCMaker::CoreDef.new( "core_b", "core_a,v1", file, "top" )
core_a.interfaces[ :ifc_a ] = ifc_def_0
core_a.interfaces[ :ifc_b ] = ifc_def_1
core_b.interfaces[ :ifc_a ] = ifc_def_0
253,8 → 253,8
SOCMaker::lib.add_ifc( ifc_spc2 )
SOCMaker::lib.add_core( core_a )
SOCMaker::lib.add_core( core_b )
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "core_bv1" )
@soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
@soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "core_b,v1" )
expect { @soc.add_connection( "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" ) }.
to raise_error( SOCMaker::ERR::ProcessingError )
end
264,18 → 264,18
 
it "should add a connection entry" do
 
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
ifc_spc = SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { port_a: {dir:1}, port_b: {dir:0} } )
 
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
 
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_b = SOCMaker::CoreDef.new( "core_b", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
core_b = SOCMaker::CoreDef.new( "core_b", "core_b,v1", file, "top" )
core_a.interfaces[ :ifc_a ] = ifc_def_0
core_a.interfaces[ :ifc_b ] = ifc_def_1
core_b.interfaces[ :ifc_a ] = ifc_def_0
287,8 → 287,8
 
 
 
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_bv1" )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
@soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_b,v1" )
@soc.consistency_check
@soc.add_connection( "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" )
@soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{inst_b: :ifc_b} ] }
308,7 → 308,7
b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
core_a.interfaces[ :ifc_a ] = ifc_def_0
core_a.interfaces[ :ifc_b ] = ifc_def_1
318,10 → 318,10
 
SOCMaker::lib.add_core( @soc )
@soc.interfaces[ :t1 ] = ifc_def_1
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
@soc.consistency_check
@soc.add_connection( "inst_a", "ifc_a", @soc.name, "t1", "a_new_con" )
@soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{ @soc.name.to_sym => :t1} ] }
@soc.add_connection( "inst_a", "ifc_a", @soc.id, "t1", "a_new_con" )
@soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{ @soc.id.to_sym => :t1} ] }
end
 
 
342,7 → 342,7
parameter = SOCMaker::Parameter.new( "integer" )
core_a.inst_parameters[ :p1 ] = parameter
SOCMaker::lib.add_core( core_a )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
expect{ @soc.set_param( "inst_a", "px", 1234 ) }.
to raise_error( SOCMaker::ERR::ProcessingError )
expect{ @soc.get_param( "inst_a", "px" ) }.
351,11 → 351,11
it "should set a parameter and provide a parameter" do
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
parameter = SOCMaker::Parameter.new( "integer" )
core_a.inst_parameters[ :p1 ] = parameter
SOCMaker::lib.add_core( core_a )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
@soc.set_param( "inst_a", "p1", 1234 )
@soc.cores[ :inst_a ].params[ :p1 ].should be == 1234
@soc.get_param( "inst_a", "p1" ).should be == 1234
376,13 → 376,13
it "should an error, a static parameter doesn't exist" do
 
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
SOCMaker::lib.add_core( core_a )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
 
expect{ @soc.set_sparam( "core_av1", "p1", 1234 ) }.
expect{ @soc.set_sparam( "core_a,v1", "p1", 1234 ) }.
to raise_error( SOCMaker::ERR::ProcessingError )
expect{ @soc.get_sparam( "core_av1", "p1" ) }.
expect{ @soc.get_sparam( "core_a,v1", "p1" ) }.
to raise_error( SOCMaker::ERR::ProcessingError )
end
 
389,7 → 389,7
it "should set a static-parameter and provide this static parameter" do
 
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
core_a = SOCMaker::CoreDef.new( "core_a", "v1", file, "top" )
core_a = SOCMaker::CoreDef.new( "core_a", "core_a,v1", file, "top" )
pentry = SOCMaker::SParameterEntry.new( "integer", "TOK" )
parameter = SOCMaker::SParameter.new( "file/path.vhd.src",
"file/path.vhd",
396,11 → 396,11
'parameters' => { p1: pentry } )
core_a.static_parameters[ :p1 ] = parameter
SOCMaker::lib.add_core( core_a )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
@soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
 
@soc.set_sparam( "core_av1", "p1", 1234 )
@soc.static[ :core_av1 ][ :p1 ].should be == 1234
@soc.get_sparam( "core_av1", "p1" ).should be == 1234
@soc.set_sparam( "core_a,v1", "p1", 1234 )
@soc.static[ "core_a,v1".to_sym ][ :p1 ].should be == 1234
@soc.get_sparam( "core_a,v1", "p1" ).should be == 1234
end
 
 
/component_spec.rb
66,43 → 66,23
to raise_error( SOCMaker::ERR::ValueError )
end
 
it 'should raise an error, if the name doesnt start with [a-zA-Z]' do
expect{ SOCMaker::Component.new( "4abc", "v1", "top" ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
 
it 'should raise an error, if the name conatins invalid symbols' do
expect{ SOCMaker::Component.new( "abc$abc", "v1", "top" ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
 
 
 
 
 
# test the version
it "should raise an error, if the version is nil" do
# test the id
it "should raise an error, if the id is nil" do
expect{ SOCMaker::Component.new( "acore", nil, "top" ) }.
to raise_error( SOCMaker::ERR::StructureError )
end
 
it "should raise an error, if the version has zero-length" do
it "should raise an error, if the id has zero-length" do
expect{ SOCMaker::Component.new( "acore", "", "top" ) }.
to raise_error( SOCMaker::ERR::StructureError )
end
it "should raise an error, if the version is not of type string neither of type Numerical" do
it "should raise an error, if the id is not of type string " do
expect{ SOCMaker::Component.new( "acore", [ 1, 2, 3 ], "top" ) }.
to raise_error( SOCMaker::ERR::ValueError )
end
 
it "should cast a numerical version to a string version" do
c = SOCMaker::Component.new( "acore", 3, "top" )
c.class.should be == SOCMaker::Component
c.version = "3"
end
 
 
%w[ description date license licensefile
author authormail vccmd ].each do |m|
it "should auto-set #{m} to an empty string" do
150,6 → 130,7
 
it 'should iterate over all generics (inst. parameters)' do
 
 
p1 = SOCMaker::Parameter.new( "integer" )
p2 = SOCMaker::Parameter.new( "string" )
p3 = SOCMaker::Parameter.new( "integer" )
180,8 → 161,8
it 'should iterate over all ports' do
 
SOCMaker::lib.clear
ifc_s1 = SOCMaker::IfcSpc.new( "i1", "v1", 'ports' => { p1:{dir:1}, p2:{dir:1}, p3:{dir:0} } )
ifc_s2 = SOCMaker::IfcSpc.new( "i2", "v1", 'ports' => { x1:{dir:1}, x2:{dir:0} } )
ifc_s1 = SOCMaker::IfcSpc.new( "Interface 1", "i1,v1", 'ports' => { p1:{dir:1}, p2:{dir:1}, p3:{dir:0} } )
ifc_s2 = SOCMaker::IfcSpc.new( "Interface 2", "i2,v1", 'ports' => { x1:{dir:1}, x2:{dir:0} } )
SOCMaker::lib.add_ifc( ifc_s1 )
SOCMaker::lib.add_ifc( ifc_s2 )
 
191,11 → 172,11
x1 = SOCMaker::IfcPort.new( "x1", 1 )
x2 = SOCMaker::IfcPort.new( "x2", 2 )
 
ifc_d1 = SOCMaker::IfcDef.new( "i1", "v1", 0, { m_p1: p1, m_p2: p2, m_p3: p3 } )
ifc_d2 = SOCMaker::IfcDef.new( "i2", "v1", 0, { m_x1: x1, m_x2: x2 } )
ifc_d1 = SOCMaker::IfcDef.new( "i1", "i1,v1", 0, { m_p1: p1, m_p2: p2, m_p3: p3 } )
ifc_d2 = SOCMaker::IfcDef.new( "i2", "i2,v1", 0, { m_x1: x1, m_x2: x2 } )
 
c = SOCMaker::Component.new( "acore", "v1", "top",
c = SOCMaker::Component.new( "A core", "acore,v1", "top",
{ 'interfaces' => { i1: ifc_d1, i2: ifc_d2 } } )
 
r_name = []
219,7 → 200,6
r_name = []
r_dir = []
 
p c.interfaces
c.ports( "i1" ) do |arg_name,arg_dir, arg_default, arg_is_last|
#r_def << arg_def
r_name << arg_name

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.