Skip to content

Commit 7a9d7c4

Browse files
authored
Merge pull request #906 from CAS-Atlantic/mor1k
ODIN II: add support for .vh files
2 parents e890892 + 0cbfb31 commit 7a9d7c4

File tree

6 files changed

+32
-35
lines changed

6 files changed

+32
-35
lines changed

ODIN_II/SRC/enum_str.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
const char *file_extension_supported_STR[] =
44
{
5-
".v"
5+
".v",
6+
".vh"
67
};
78

89
const char *edge_type_e_STR[] =

ODIN_II/SRC/include/odin_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ extern const char *ids_STR [];
162162
enum file_extension_supported
163163
{
164164
VERILOG,
165+
VERILOG_HEADER,
165166
file_extension_supported_END
166167
};
167168

ODIN_II/SRC/include/odin_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ long shift_left_value_with_overflow_check(long input_value, long shift_by);
1111

1212
std::string get_file_extension(std::string input_file);
1313
void create_directory(std::string path);
14+
void assert_supported_file_extension(std::string input_file, int file_number);
1415

1516
const char *name_based_on_op(operation_list op);
1617
const char *name_based_on_ids(ids op);

ODIN_II/SRC/odin_util.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,33 @@ void create_directory(std::string path)
8686
}
8787
}
8888

89+
void assert_supported_file_extension(std::string input_file, int file_number)
90+
{
91+
bool supported = false;
92+
std::string extension = get_file_extension(input_file);
93+
for(int i = 0; i< file_extension_supported_END && ! supported; i++)
94+
{
95+
supported = (extension == std::string(file_extension_supported_STR[i]) );
96+
}
97+
98+
if(! supported)
99+
{
100+
std::string supported_extension_list = "";
101+
for(int i=0; i<file_extension_supported_END; i++)
102+
{
103+
supported_extension_list += " ";
104+
supported_extension_list += file_extension_supported_STR[i];
105+
}
106+
107+
error_message(ARG_ERROR, -1, file_number,
108+
"File (%s) has an unsupported extension (%s), Odin only support { %s }",
109+
input_file.c_str(),
110+
extension.c_str(),
111+
supported_extension_list.c_str()
112+
);
113+
}
114+
}
115+
89116
/*---------------------------------------------------------------------------------------------
90117
* (function: name_based_on_op)
91118
* Get the string version of an operation

ODIN_II/SRC/parse_making_ast.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,34 +78,6 @@ short to_view_parse;
7878
ast_node_t *newFunctionAssigning(ast_node_t *expression1, ast_node_t *expression2, int line_number);
7979
ast_node_t *resolve_ports(ids top_type, ast_node_t *symbol_list);
8080

81-
82-
static void assert_supported_file_extension(std::string input_file, int file_number)
83-
{
84-
bool supported = false;
85-
std::string extension = get_file_extension(input_file);
86-
for(int i = 0; i< file_extension_supported_END && ! supported; i++)
87-
{
88-
supported = (extension == std::string(file_extension_supported_STR[i]) );
89-
}
90-
91-
if(! supported)
92-
{
93-
std::string supported_extension_list = "";
94-
for(int i=0; i<file_extension_supported_END; i++)
95-
{
96-
supported_extension_list += " ";
97-
supported_extension_list += file_extension_supported_STR[i];
98-
}
99-
100-
error_message(ARG_ERROR, -1, file_number,
101-
"File (%s) has an unsupported extension (%s), Odin only support { %s }",
102-
input_file.c_str(),
103-
extension.c_str(),
104-
supported_extension_list.c_str()
105-
);
106-
}
107-
}
108-
10981
/*---------------------------------------------------------------------------------------------
11082
* (function: parse_to_ast)
11183
*-------------------------------------------------------------------------------------------*/
@@ -808,12 +780,6 @@ ast_node_t *markAndProcessSymbolListWith(ids top_type, ids id, ast_node_t *symbo
808780
symbol_list->children[i] = markAndProcessPortWith(top_type, id, NO_ID, symbol_list->children[i], is_signed);
809781
break;
810782
case WIRE:
811-
if ((symbol_list->children[i]->num_children == 6 && symbol_list->children[i]->children[5] != NULL)
812-
|| (symbol_list->children[i]->num_children == 8 && symbol_list->children[i]->children[7] != NULL))
813-
{
814-
error_message(NETLIST_ERROR, symbol_list->children[i]->line_number, symbol_list->children[i]->file_number, "%s",
815-
"Nets cannot be initialized\n");
816-
}
817783
if (is_signed)
818784
{
819785
/* cannot support signed nets right now */

ODIN_II/SRC/verilog_preprocessor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ void veri_preproc_bootstraped(FILE *original_source, FILE *preproc_producer, ver
505505
}
506506
else if (NULL != (new_include = add_veri_include(file_path.c_str(), line_number, current_include)))
507507
{
508+
assert_supported_file_extension(file_path, -1);
508509
printf("Including file %s\n", new_include->path);
509510
veri_preproc_bootstraped(included_file, preproc_producer, new_include);
510511
}

0 commit comments

Comments
 (0)