Skip to content

SystemVerilog: implement package import #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/verilog/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
#include <util/mathematical_types.h>
#include <util/std_expr.h>

#include "verilog_expr.h"
#include "verilog_parser.h"

#define PARSER verilog_parser
Expand Down Expand Up @@ -1158,9 +1159,20 @@ package_import_item_brace:

package_import_item:
package_identifier "::" identifier
{ init($$, ID_verilog_import_item); mto($$, $1); mto($$, $3); }
{ init($$, ID_verilog_import_item);
mto($$, $1);
mto($$, $3);
// add item from package to our scope table
auto &item = to_verilog_import_item(stack_expr($$));
PARSER.current_scope->import_item(item);
}
| package_identifier "::" "*"
{ init($$, ID_verilog_import_item); mto($$, $1); }
{ init($$, ID_verilog_import_item);
mto($$, $1);
// add items from package to our scope table
auto &item = to_verilog_import_item(stack_expr($$));
PARSER.current_scope->import_item(item);
}
;

genvar_declaration:
Expand Down
17 changes: 17 additions & 0 deletions src/verilog/verilog_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1945,4 +1945,21 @@ to_verilog_implicit_typecast_expr(exprt &expr)
return static_cast<verilog_implicit_typecast_exprt &>(expr);
}

class verilog_import_itemt : public binary_exprt
{
public:
};

inline const verilog_import_itemt &to_verilog_import_item(const exprt &expr)
{
verilog_import_itemt::check(expr);
return static_cast<const verilog_import_itemt &>(expr);
}

inline verilog_import_itemt &to_verilog_import_item(exprt &expr)
{
verilog_import_itemt::check(expr);
return static_cast<verilog_import_itemt &>(expr);
}

#endif
19 changes: 19 additions & 0 deletions src/verilog/verilog_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Author: Daniel Kroening, [email protected]
#include <util/cout_message.h>
#include <util/unicode.h>

#include "verilog_expr.h"

#include <fstream>
#include <iostream>
#include <stdio.h>
Expand Down Expand Up @@ -81,3 +83,20 @@ const verilog_parsert::scopet *verilog_parsert::lookup(irep_idt name) const
// not found, give up
return nullptr;
}

/*******************************************************************\

Function: verilog_parsert::scopet::import_item

Inputs:

Outputs:

Purpose:

\*******************************************************************/

void verilog_parsert::scopet::import_item(
const verilog_import_itemt &import_item)
{
}
4 changes: 4 additions & 0 deletions src/verilog/verilog_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Author: Daniel Kroening, [email protected]

int yyverilogparse();

class verilog_import_itemt;

class verilog_parsert:public parsert
{
public:
Expand Down Expand Up @@ -90,6 +92,8 @@ class verilog_parsert:public parsert
// sub-scopes
using scope_mapt = std::map<irep_idt, scopet>;
scope_mapt scope_map;

void import_item(const verilog_import_itemt &);
};

scopet top_scope, *current_scope = &top_scope;
Expand Down
Loading