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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [core_inst_spec.rb] - Diff between revs 8 and 10

Show entire file | Details | Blame | View Log

Rev 8 Rev 10
Line 54... Line 54...
  end
  end
 
 
 
 
  it "should raise an error, if parameters are given, which doesn't exist in the definition" do
  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" ) }
     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 )
     expect{
     expect{
         inst = SOCMaker::CoreInst.new( "mycorerel1", { "aparameter".to_sym => 4 } )
         inst = SOCMaker::CoreInst.new( "mycore,rel1", { "aparameter".to_sym => 4 } )
         inst.consistency_check }.
         inst.consistency_check }.
     to raise_error( SOCMaker::ERR::ValueError )
     to raise_error( SOCMaker::ERR::ValueError )
     SOCMaker::lib.rm_core( core )
     SOCMaker::lib.rm_core( core )
 
 
  end
  end
Line 69... Line 69...
  it "should auto-complete generics with default values" do
  it "should auto-complete generics with default values" do
 
 
     # create core with one file and one instance parameter
     # create core with one file and one instance parameter
     file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
     file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
     parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" )  }
     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
     core.inst_parameters = parameters
     SOCMaker::lib.add_core( core )
     SOCMaker::lib.add_core( core )
 
 
     inst = SOCMaker::CoreInst.new( "mycorerel1", {}  )
     inst = SOCMaker::CoreInst.new( "mycore,rel1", {}  )
     inst.consistency_check
     inst.consistency_check
     inst.params[ :param1 ].should be == 0
     inst.params[ :param1 ].should be == 0
     SOCMaker::lib.rm_core( core )
     SOCMaker::lib.rm_core( core )
  end
  end
 
 
Line 86... Line 86...
#describe SOCMaker::CoreDef, "HDL interaction" do
#describe SOCMaker::CoreDef, "HDL interaction" do
 
 
#   it 'should return true and false for implements_port?, when a port is implemented and
#   it 'should return true and false for implements_port?, when a port is implemented and
#       not implemented' do
#       not implemented' 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" )
#      ifc_spc    = SOCMaker::IfcSpc.new( "a_ifc", "v1", "ports" => { p1: 1, p2: 0 } )
#      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 ) } )
#      ifc        = SOCMaker::IfcDef.new( "a_ifc", "v1", 1, { p1: SOCMaker::IfcPort.new( "p1", 1 ) } )
#      core.interfaces[ :i1 ] = ifc
#      core.interfaces[ :i1 ] = ifc
#      SOCMaker::lib.add_core( core )
#      SOCMaker::lib.add_core( core )
#      SOCMaker::lib.add_ifc( ifc_spc )
#      SOCMaker::lib.add_ifc( ifc_spc )
 
 
#      o1 = SOCMaker::CoreInst.new( "mycorerel1", {}  )
#      o1 = SOCMaker::CoreInst.new( "mycore,rel1", {}  )
#      o1.consistency_check
#      o1.consistency_check
#      o1.implements_port?( 'i1', 'p1' ).should be == true
#      o1.implements_port?( 'i1', 'p1' ).should be == true
#      o1.implements_port?( 'i1', 'p2' ).should be == false
#      o1.implements_port?( 'i1', 'p2' ).should be == false
#    end
#    end
#end
#end
Line 105... Line 105...
describe SOCMaker::CoreDef, "object handling, en-decoding:" do
describe SOCMaker::CoreDef, "object handling, en-decoding:" do
 
 
  it "should be possible to encode and decode a core instance" do
  it "should be possible to encode and decode a core instance" do
    file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
    file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
    parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" )  }
    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
    core.inst_parameters = parameters
    SOCMaker::lib.add_core( core )
    SOCMaker::lib.add_core( core )
 
 
    o1 = SOCMaker::CoreInst.new( "mycorerel1", {}  )
    o1 = SOCMaker::CoreInst.new( "mycore,rel1", {}  )
    yaml_str = o1.to_yaml
    yaml_str = o1.to_yaml
    o2 = YAML::load( yaml_str )
    o2 = YAML::load( yaml_str )
    o1.should be == o2
    o1.should be == o2
  end
  end
 
 
  it "should return false for two non-equal objects" do
  it "should return false for two non-equal objects" do
    file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
    file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
    parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" )  }
    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
    core.inst_parameters = parameters
    SOCMaker::lib.add_core( core )
    SOCMaker::lib.add_core( core )
 
 
    o1 = SOCMaker::CoreInst.new( "mycorerel1" )
    o1 = SOCMaker::CoreInst.new( "mycore,rel1" )
    o1.consistency_check
    o1.consistency_check
    o2 = Marshal::load(Marshal.dump(o1))
    o2 = Marshal::load(Marshal.dump(o1))
    o2.type << "X"
    o2.type << "X"
    ( o2 == o1 ).should be == false
    ( o2 == o1 ).should be == false
    o2 = Marshal::load(Marshal.dump(o1))
    o2 = Marshal::load(Marshal.dump(o1))
Line 135... Line 135...
  end
  end
 
 
   it "should call coder functions for each core-def. (stub-version)" do
   it "should call coder functions for each core-def. (stub-version)" do
 
 
     SOCMaker::lib.clear
     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()
     coder = double()
 
 
     added_cores = {}
     added_cores = {}
Line 173... Line 173...
 
 
 
 
 
 
 
 
     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" )
     SOCMaker::lib.add_core( core_a )
     SOCMaker::lib.add_core( core_a )
     SOCMaker::lib.add_core( core_b )
     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 )
     SOCMaker::lib.add_ifc( ifc_spc )
     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 ) } )
 
 
 
 
     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
 
 
 
 
     i1 = SOCMaker::CoreInst.new( "core_av1" )
     i1 = SOCMaker::CoreInst.new( "core_a,v1" )
     i2 = SOCMaker::CoreInst.new( "core_av1" )
     i2 = SOCMaker::CoreInst.new( "core_a,v1" )
     i3 = SOCMaker::CoreInst.new( "core_bv1" )
     i3 = SOCMaker::CoreInst.new( "core_b,v1" )
     i4 = SOCMaker::CoreInst.new( "core_bv1" )
     i4 = SOCMaker::CoreInst.new( "core_b,v1" )
 
 
     soc.cores[ :inst_a ] = i1
     soc.cores[ :inst_a ] = i1
     soc.cores[ :inst_b ] = i2
     soc.cores[ :inst_b ] = i2
     soc.cores[ :inst_c ] = i3
     soc.cores[ :inst_c ] = i3
     soc.cores[ :inst_d ] = i4
     soc.cores[ :inst_d ] = i4
     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" )
 
 
 
 
     SOCMaker::lib.add_core( soc )
     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.consistency_check
 
 
     soc_inst.stub( :gen_toplevel_con ) do |name_arg,
     soc_inst.stub( :gen_toplevel_con ) do |name_arg,
                                        rule_arg,
                                        rule_arg,
                                        m0_arg,
                                        m0_arg,
Line 226... Line 226...
     file_mock = double()
     file_mock = double()
     file_mock.stub( :write )
     file_mock.stub( :write )
     File.should_receive(:open).and_yield(file_mock)
     File.should_receive(:open).and_yield(file_mock)
 
 
     soc_inst.gen_toplevel( coder );
     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_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 } } }
     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
     dir_path.should be == dir_path_ref
   end
   end
 
 
Line 243... Line 243...
     SOCMaker::conf[ :hdl_dir   ] = 'b'
     SOCMaker::conf[ :hdl_dir   ] = 'b'
     coder = SOCMaker::VHDLCoder.new
     coder = SOCMaker::VHDLCoder.new
     SOCMaker::lib.refresh( './spec/test_soc_lib' )
     SOCMaker::lib.refresh( './spec/test_soc_lib' )
     soc = SOCMaker::from_f( './spec/test_soc.yaml' );
     soc = SOCMaker::from_f( './spec/test_soc.yaml' );
     SOCMaker::lib.add_core( soc )
     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.consistency_check
     soc_inst.gen_toplevel( coder );
     soc_inst.gen_toplevel( coder );
     soc.copy_files
     soc.copy_files
    #p soc.cons
    #p soc.cons
    #puts soc.to_yaml
    #puts soc.to_yaml

powered by: WebSVN 2.1.0

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