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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [soc_def_spec.rb] - Diff between revs 9 and 10

Show entire file | Details | Blame | View Log

Rev 9 Rev 10
Line 63... Line 63...
  #   - one static parameter
  #   - one static parameter
  #
  #
  FULL_SOC_YAML = '''SOCM_SOC
  FULL_SOC_YAML = '''SOCM_SOC
name: my_soc
name: my_soc
description: A test SOC
description: A test SOC
version: rel2
id: my_soc,rel2
date: 1.1.2014
date: 1.1.2014
license: LGPL
license: LGPL
licensefile:
licensefile:
toplevel: soc_top
toplevel: soc_top
author: Christian Haettich
author: Christian Haettich
Line 77... Line 77...
 
 
 
 
SOC_YAML_WITH_CORE = '''SOCM_SOC
SOC_YAML_WITH_CORE = '''SOCM_SOC
name: my_soc
name: my_soc
description: A test SOC
description: A test SOC
version: rel2
id: my_soc,rel2
date: 1.1.2014
date: 1.1.2014
license: LGPL
license: LGPL
licensefile:
licensefile:
author: Christian Haettich
author: Christian Haettich
authormail: feddischson@opencores.org
authormail: feddischson@opencores.org
Line 123... Line 123...
 
 
describe SOCMaker::SOCDef, "processing verification" do
describe SOCMaker::SOCDef, "processing verification" do
 
 
    before( :each )do
    before( :each )do
      file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
      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 )
      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
    end
 
 
    describe "adding/removing cores, connections etc." do
    describe "adding/removing cores, connections etc." do
 
 
 
 
Line 168... Line 168...
        @soc.rm( "a_con" ).should be == false
        @soc.rm( "a_con" ).should be == false
      end
      end
 
 
      it "should return nil if a instance is added twice" do
      it "should return nil if a instance is added twice" do
        @soc.cores[ :core_inst ] = SOCMaker::CoreInst.new( "mycorerel1" )
        @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
      end
 
 
      it "should return non-nil value, if a instance is added once" do
      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
      end
 
 
      # in one of the first version, we returned nil, but now this is
      # in one of the first version, we returned nil, but now this is
      # used to extend a interface
      # used to extend a interface
      it "should not return nil if a connection is added twice" do
      it "should not return nil if a connection is added twice" do
        @soc.cons[ :a_con ] = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
        @soc.cons[ :a_con ] = { rule: "or", mapping: [ { :core_a => :ifc_a }, { :core_b => :ifc_b } ] }
        @soc.add_connection(  "core_a", "ifc_a", "core_c", "ifc_b", "a_con" ).should_not be == nil
        @soc.add_connection(  "core_a", "ifc_a", "core_c", "ifc_b", "a_con" ).should_not be == nil
      end
      end
 
 
      it "should raise a library error when adding an unknown core" do
      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 )
          to raise_error( SOCMaker::ERR::LibError )
      end
      end
 
 
      it "should create a dir and return the absolute path for a core inside the build/hdl dir" do
      it "should create a dir and return the absolute path for a core inside the build/hdl dir" do
        SOCMaker::conf[ :build_dir ] = "./spec/tmp_build"
        SOCMaker::conf[ :build_dir ] = "./spec/tmp_build"
Line 226... Line 226...
        expect{ @soc.add_connection(  "core_a", "ifc_a", "core_c", "ifc_b", "a_new_con" ) }.
        expect{ @soc.add_connection(  "core_a", "ifc_a", "core_c", "ifc_b", "a_new_con" ) }.
          to raise_error( SOCMaker::ERR::ProcessingError )
          to raise_error( SOCMaker::ERR::ProcessingError )
      end
      end
 
 
      it "should raise an ProcessingError if a interface doesn't exist" do
      it "should raise an ProcessingError if a interface doesn't exist" do
        @soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycorerel1" )
        @soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "mycore,rel1" )
        @soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycorerel1" )
        @soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "mycore,rel1" )
        expect{ @soc.add_connection(  "core_a", "ifc_a", "core_b", "ifc_c", "a_new_con" ) }.
        expect{ @soc.add_connection(  "core_a", "ifc_a", "core_b", "ifc_c", "a_new_con" ) }.
          to raise_error( SOCMaker::ERR::ProcessingError )
          to raise_error( SOCMaker::ERR::ProcessingError )
      end
      end
 
 
 
 
      it "should raise an ProcessingError if the ifc.-version is wrong" do
      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_spc1 = SOCMaker::IfcSpc.new( "myifc", "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_spc2 = SOCMaker::IfcSpc.new( "myifc", "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_1 = SOCMaker::IfcDef.new( "myifc", "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_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" ) }
        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_b = SOCMaker::CoreDef.new( "core_b", "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_a ] = ifc_def_0
        core_a.interfaces[ :ifc_b ] = ifc_def_1
        core_a.interfaces[ :ifc_b ] = ifc_def_1
        core_b.interfaces[ :ifc_a ] = ifc_def_0
        core_b.interfaces[ :ifc_a ] = ifc_def_0
        core_b.interfaces[ :ifc_b ] = ifc_def_1
        core_b.interfaces[ :ifc_b ] = ifc_def_1
 
 
        SOCMaker::lib.add_ifc( ifc_spc1 )
        SOCMaker::lib.add_ifc( ifc_spc1 )
        SOCMaker::lib.add_ifc( ifc_spc2 )
        SOCMaker::lib.add_ifc( ifc_spc2 )
        SOCMaker::lib.add_core( core_a )
        SOCMaker::lib.add_core( core_a )
        SOCMaker::lib.add_core( core_b )
        SOCMaker::lib.add_core( core_b )
        @soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "core_av1" )
        @soc.cores[ :core_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
        @soc.cores[ :core_b ] = SOCMaker::CoreInst.new( "core_bv1" )
        @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" ) }.
        expect { @soc.add_connection(  "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" ) }.
          to raise_error( SOCMaker::ERR::ProcessingError )
          to raise_error( SOCMaker::ERR::ProcessingError )
      end
      end
 
 
 
 
 
 
 
 
      it "should add a connection entry" do
      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 ),
        ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
                                                              b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
                                                              b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
 
        ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 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 ) } )
                                                              b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
 
 
 
        file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
        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_b = SOCMaker::CoreDef.new( "core_b", "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_a ] = ifc_def_0
        core_a.interfaces[ :ifc_b ] = ifc_def_1
        core_a.interfaces[ :ifc_b ] = ifc_def_1
        core_b.interfaces[ :ifc_a ] = ifc_def_0
        core_b.interfaces[ :ifc_a ] = ifc_def_0
        core_b.interfaces[ :ifc_b ] = ifc_def_1
        core_b.interfaces[ :ifc_b ] = ifc_def_1
 
 
Line 285... Line 285...
        SOCMaker::lib.add_core( core_a )
        SOCMaker::lib.add_core( core_a )
        SOCMaker::lib.add_core( core_b )
        SOCMaker::lib.add_core( core_b )
 
 
 
 
 
 
        @soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
        @soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_a,v1" )
        @soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_bv1" )
        @soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_b,v1" )
        @soc.consistency_check
        @soc.consistency_check
        @soc.add_connection(  "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" )
        @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} ] }
        @soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{inst_b: :ifc_b} ] }
      end
      end
 
 
Line 306... Line 306...
 
 
        ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
        ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { a: SOCMaker::IfcPort.new( "port_a", 1 ),
                                                              b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
                                                              b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
 
        file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
        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_a ] = ifc_def_0
        core_a.interfaces[ :ifc_b ] = ifc_def_1
        core_a.interfaces[ :ifc_b ] = ifc_def_1
 
 
        SOCMaker::lib.add_ifc( ifc_spc )
        SOCMaker::lib.add_ifc( ifc_spc )
        SOCMaker::lib.add_core( core_a )
        SOCMaker::lib.add_core( core_a )
 
 
 
 
       SOCMaker::lib.add_core( @soc )
       SOCMaker::lib.add_core( @soc )
       @soc.interfaces[ :t1 ] = ifc_def_1
       @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.consistency_check
       @soc.add_connection(  "inst_a", "ifc_a", @soc.name, "t1", "a_new_con" )
       @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.name.to_sym => :t1} ] }
       @soc.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{ @soc.id.to_sym => :t1} ] }
     end
     end
 
 
 
 
 
 
      it "should raise an error, if a parameter of unkonwn core is set" do
      it "should raise an error, if a parameter of unkonwn core is set" do
Line 340... Line 340...
        file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
        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", "v1", file, "top" )
        parameter = SOCMaker::Parameter.new( "integer" )
        parameter = SOCMaker::Parameter.new( "integer" )
        core_a.inst_parameters[ :p1 ] = parameter
        core_a.inst_parameters[ :p1 ] = parameter
        SOCMaker::lib.add_core( core_a )
        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 ) }.
        expect{ @soc.set_param( "inst_a", "px", 1234 ) }.
          to raise_error( SOCMaker::ERR::ProcessingError )
          to raise_error( SOCMaker::ERR::ProcessingError )
        expect{ @soc.get_param( "inst_a", "px" ) }.
        expect{ @soc.get_param( "inst_a", "px" ) }.
          to raise_error( SOCMaker::ERR::ProcessingError )
          to raise_error( SOCMaker::ERR::ProcessingError )
      end
      end
 
 
      it "should set a parameter and provide a parameter" do
      it "should set a parameter and provide a parameter" do
        file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
        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" )
        parameter = SOCMaker::Parameter.new( "integer" )
        core_a.inst_parameters[ :p1 ] = parameter
        core_a.inst_parameters[ :p1 ] = parameter
        SOCMaker::lib.add_core( core_a )
        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.set_param( "inst_a", "p1", 1234 )
        @soc.cores[ :inst_a ].params[ :p1 ].should be == 1234
        @soc.cores[ :inst_a ].params[ :p1 ].should be == 1234
        @soc.get_param( "inst_a", "p1" ).should be == 1234
        @soc.get_param( "inst_a", "p1" ).should be == 1234
      end
      end
 
 
Line 374... Line 374...
      end
      end
 
 
      it "should an error, a static parameter doesn't exist" do
      it "should an error, a static parameter doesn't exist" do
 
 
        file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
        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 )
        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 )
          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 )
          to raise_error( SOCMaker::ERR::ProcessingError )
      end
      end
 
 
      it "should set a static-parameter and provide this static parameter" do
      it "should set a static-parameter and provide this static parameter" do
 
 
        file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
        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" )
        pentry = SOCMaker::SParameterEntry.new( "integer", "TOK" )
        parameter = SOCMaker::SParameter.new( "file/path.vhd.src",
        parameter = SOCMaker::SParameter.new( "file/path.vhd.src",
                                              "file/path.vhd",
                                              "file/path.vhd",
                                              'parameters' => { p1: pentry } )
                                              'parameters' => { p1: pentry } )
        core_a.static_parameters[ :p1 ] = parameter
        core_a.static_parameters[ :p1 ] = parameter
        SOCMaker::lib.add_core( core_a )
        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.set_sparam( "core_a,v1", "p1", 1234 )
        @soc.static[ :core_av1 ][ :p1 ].should be == 1234
        @soc.static[ "core_a,v1".to_sym ][ :p1 ].should be == 1234
        @soc.get_sparam( "core_av1", "p1" ).should be == 1234
        @soc.get_sparam( "core_a,v1", "p1" ).should be == 1234
      end
      end
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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