Esempio n. 1
0
  public void testParamListFunctionWithPkg() throws SVParseException {
    String content =
        "function automatic void foobar(\n"
            + "        input int foobar,\n"
            + "        ref object bar,\n"
            + "        int foo);\n"
            + "    a_type foo, bar;\n"
            + "    b_type foo_q[$];\n"
            + "    int i, j, k;\n"
            + "    uvm_pkg::uvm_resource_db #(my_pkg::my_iface_container #(virtual my_iface)) "
            + "        ::set(\"my_ifaces\", $sformatf(\"my_iface_%01d\",0), ifc) ;"
            + "    for (int i=0; i<5; i++) begin\n"
            + "        a = 5;\n"
            + "    end\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testParamListFunction");

    ISVDBChildItem c = func.getParams().get(1).getChildren().iterator().next();

    assertEquals("bar", SVDBItem.getName(c));
    assertEquals(SVDBParamPortDecl.Direction_Ref, func.getParams().get(1).getDir());
  }
Esempio n. 2
0
  public void testParamListFunction() throws SVParseException {
    String content =
        "function automatic void foobar(\n"
            + // 1
            "        input int foobar,\n"
            + // 2
            "        ref object bar,\n"
            + // 3
            "        int foo);\n"
            + // 4
            "    a_type foo, bar;\n"
            + // 5
            "    b_type foo_q[$];\n"
            + // 6
            "    b_cls #(foobar, bar) elem;\n"
            + "    int i, j, k;\n"
            + "    for (int i=0; i<5; i++) begin\n"
            + "        a = 5;\n"
            + "    end\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testParamListFunction");

    ISVDBChildItem c = func.getParams().get(1).getChildren().iterator().next();

    assertEquals("bar", SVDBItem.getName(c));
    assertEquals(SVDBParamPortDecl.Direction_Ref, func.getParams().get(1).getDir());
  }
Esempio n. 3
0
  // Tests that local variables are correctly recognized and that
  // cast expressions are skipped appropriately
  public void testLocalVarsWithCast() throws SVParseException {
    String content =
        "function void foobar();\n"
            + "    int a = integer'(5);\n"
            + "    int b = longint'(6);\n"
            + "    a = 5;\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testLocalVarsWithCast");

    assertEquals(3, SVDBUtil.getChildrenSize(func));
    SVDBVarDeclItem a = null, b = null;
    for (ISVDBItemBase it_t : func.getChildren()) {
      if (it_t.getType() == SVDBItemType.VarDeclStmt) {
        SVDBVarDeclStmt v = (SVDBVarDeclStmt) it_t;
        for (ISVDBChildItem vi : v.getChildren()) {
          if (SVDBItem.getName(vi).equals("a")) {
            a = (SVDBVarDeclItem) vi;
          } else if (SVDBItem.getName(vi).equals("b")) {
            b = (SVDBVarDeclItem) vi;
          }
        }
      }
    }
    assertNotNull(a);
    assertNotNull(b);
  }
Esempio n. 4
0
  // Tests that local variables are correctly recognized and that
  // cast expressions are skipped appropriately
  public void testLocalTypedef() throws SVParseException {
    String content =
        "function void foobar();\n"
            + "    typedef foo #(BAR) foo_t;\n"
            + "    foo_t              a;\n"
            + "    a = 5;\n"
            + "endfunction\n";

    //		ParserSVDBFileFactory parser = new ParserSVDBFileFactory(null);

    SVDBTask func = parse_tf(content, "testLocalTypedef");

    SVDBVarDeclItem a = null;
    for (ISVDBItemBase it : func.getChildren()) {
      if (it.getType() == SVDBItemType.VarDeclStmt) {
        for (ISVDBChildItem vi : ((SVDBVarDeclStmt) it).getChildren()) {
          if (SVDBItem.getName(vi).equals("a")) {
            a = (SVDBVarDeclItem) vi;
          }
        }
      }
    }

    assertEquals(3, SVDBUtil.getChildrenSize(func));
    assertEquals("foo_t", SVDBItem.getName(SVDBUtil.getFirstChildItem(func)));
    assertNotNull(a);
  }
  public void testClassFunctionLineNumbers() {
    String content =
        "class foobar;\n"
            + // 1
            "    int a;\n"
            + // 2
            "    int b;\n"
            + // 3
            "\n"
            + // 4
            "    function void foobar_f();\n"
            + // 5
            "        a = 5;\n"
            + // 6
            "        b = 6;\n"
            + // 7
            "    endfunction\n"
            + // 8
            "\n"
            + // 9
            "    function void foobar_f2();\n"
            + // 10
            "        a = 4;\n"
            + // 11
            "        b = 12;\n"
            + // 12
            "    endfunction\n"
            + // 13
            "\n"
            + // 14
            "endclass\n"
            + // 15
            "\n"
            + // 16
            "\n" // 17
        ;
    SVDBFile file = SVDBTestUtils.parse(content, "testClassStringFields");

    SVDBClassDecl cls = null;

    assertEquals("Wrong number of file elements", 1, SVDBUtil.getChildrenSize(file));

    cls = (SVDBClassDecl) SVDBUtil.getFirstChildItem(file);

    assertNotNull("Start location not specified", cls.getLocation());
    assertNotNull("End location not specified", cls.getEndLocation());

    assertEquals("Wrong start location", 1, cls.getLocation().getLine());
    assertEquals("Wrong end location", 15, cls.getEndLocation().getLine());

    SVDBTask f1 = null, f2 = null;

    for (ISVDBItemBase it : cls.getChildren()) {
      if (SVDBItem.getName(it).equals("foobar_f")) {
        f1 = (SVDBTask) it;
      }
      if (SVDBItem.getName(it).equals("foobar_f2")) {
        f2 = (SVDBTask) it;
      }
    }

    assertNotNull(f1);
    assertNotNull(f2);
    assertEquals("Wrong foobar_f start location", 5, f1.getLocation().getLine());
    assertEquals("Wrong foobar_f end location", 8, f1.getEndLocation().getLine());

    assertEquals("Wrong foobar_f2 start location", 10, f2.getLocation().getLine());
    assertEquals("Wrong foobar_f2 end location", 13, f2.getEndLocation().getLine());
  }