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 5 and 7

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 5 Rev 7
Line 103... Line 103...
    SOCMaker::from_s( FULL_SOC_YAML ).class.should == SOCMaker::SOCDef
    SOCMaker::from_s( FULL_SOC_YAML ).class.should == SOCMaker::SOCDef
  end
  end
 
 
  it "should rise an error if soc is loaded with a core, which is not in our library" do
  it "should rise an error if soc is loaded with a core, which is not in our library" do
    SOCMaker::lib.clear
    SOCMaker::lib.clear
    expect { SOCMaker::from_s( SOC_YAML_WITH_CORE ) }.
    expect { SOCMaker::from_s( SOC_YAML_WITH_CORE ).consistency_check }.
      to raise_error( SOCMaker::ERR::LibError )
      to raise_error( SOCMaker::ERR::LibError )
  end
  end
 
 
 
 
  it "should return an SOC-object if soc is loaded with a core, which is in our library" do
  it "should return an SOC-object if soc is loaded with a core, which is in our library" do
Line 279... Line 279...
 
 
 
 
 
 
        @soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
        @soc.cores[ :inst_a ] = SOCMaker::CoreInst.new( "core_av1" )
        @soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_bv1" )
        @soc.cores[ :inst_b ] = SOCMaker::CoreInst.new( "core_bv1" )
 
        @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 303... Line 304...
 
 
 
 
       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_av1" )
 
       @soc.consistency_check
       @soc.add_connection(  "inst_a", "ifc_a", @soc.name, "t1", "a_new_con" )
       @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.cons[ :a_new_con ].should be == { rule:'or', mapping: [ {inst_a: :ifc_a},{ @soc.name.to_sym => :t1} ] }
     end
     end
 
 
 
 
Line 388... Line 390...
        @soc.get_sparam( "core_av1", "p1" ).should be == 1234
        @soc.get_sparam( "core_av1", "p1" ).should be == 1234
      end
      end
 
 
 
 
 
 
      it "should call coder functions for each core-def. (stub-version)" do
 
 
 
        coder = double()
 
 
 
        added_cores = {}
 
        coder.stub( :add_core_declaration ) do |name_arg, def_arg|
 
          added_cores[ name_arg.to_sym ] = def_arg
 
        end
 
 
 
        added_instances = {}
 
        coder.stub( :add_core_inst ) do |name_arg, inst_arg|
 
          added_instances[ name_arg.to_sym ] = inst_arg
 
        end
 
 
 
        coder.stub( :get_entity ){ |arg_soc,arg_str| }
 
 
 
        coder.stub( :is_a? ){ SOCMaker::VHDLCoder }
 
 
 
        added_cons = {}
 
        @soc.stub( :gen_toplevel_con ) do |name_arg,
 
                                           rule_arg,
 
                                           m0_arg,
 
                                           m1_arg |
 
          added_cons[ name_arg.to_sym ] = { rule: rule_arg,
 
                                            m0: m0_arg, m1: m1_arg }
 
        end
 
 
 
        dir_path = ""
 
        FileUtils.stub( :mkdir_p ) { |arg| dir_path = arg }
 
        SOCMaker::conf[ :build_dir ] = 'a'
 
        SOCMaker::conf[ :hdl_dir   ] = 'b'
 
        dir_path_ref = "a/b"
 
 
 
 
 
 
 
 
 
        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" )
 
        SOCMaker::lib.add_core( core_a )
 
        SOCMaker::lib.add_core( core_b )
 
 
 
        ifc_spc = SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { port_a: 1, port_b: 0 } )
 
        SOCMaker::lib.add_ifc( ifc_spc )
 
        ifc_def_1 = SOCMaker::IfcDef.new( "myifc", "v1", 0, { a: SOCMaker::IfcPort.new( "port_a", 1 ) } )
 
        ifc_def_0 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { b: SOCMaker::IfcPort.new( "port_b", 1 ) } )
 
 
 
 
 
        core_a.interfaces[ :ifc_a ] = ifc_def_0
 
        core_a.interfaces[ :ifc_b ] = ifc_def_1
 
        core_b.interfaces[ :ifc_a ] = ifc_def_0
 
        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" )
 
 
 
        @soc.cores[ :inst_a ] = i1
 
        @soc.cores[ :inst_b ] = i2
 
        @soc.cores[ :inst_c ] = i3
 
        @soc.cores[ :inst_d ] = i4
 
        @soc.add_connection(  "inst_a", "ifc_a", "inst_b", "ifc_b", "a_new_con" )
 
 
 
 
 
        # file writing stub
 
        file_mock = double()
 
        file_mock.stub( :write )
 
        File.should_receive(:open).and_yield(file_mock)
 
 
 
        @soc.gen_toplevel( coder )
 
        added_cores.should be == { :core_av1 => core_a, :core_bv1 => 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
 
      end
 
 
 
 
 
      it "should create valid vhdl output with our test library" do
 
 
 
        SOCMaker::conf[ :build_dir ] = 'spec/tmp_build2'
 
        SOCMaker::conf[ :hdl_dir   ] = 'b'
 
        coder = SOCMaker::VHDLCoder.new
 
        SOCMaker::lib.refresh( './spec/test_soc_lib' )
 
        soc = SOCMaker::from_f( './spec/test_soc.yaml' );
 
        soc.gen_toplevel( coder );
 
        soc.copy_files
 
       #p soc.cons
 
       #puts soc.to_yaml
 
      end
 
 
 
 
 
 
 
    end
    end
 
 

powered by: WebSVN 2.1.0

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