From 70fc742c9dce9f19622f7a9e44555776adf824ea Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 11 Mar 2010 12:22:41 -0800 Subject: [PATCH] Add support for primitive types of ports. The infrastructure is already there, all that's missing is the syntax in the parser. --- parse.y | 68 ++++++++++++++++++++++++++++++-------------------------- pform.cc | 6 ++++- pform.h | 1 + 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/parse.y b/parse.y index cf81e608f..290c13565 100644 --- a/parse.y +++ b/parse.y @@ -1857,6 +1857,7 @@ list_of_port_declarations pform_module_define_port(@3, name, port_declaration_context.port_type, port_declaration_context.port_net_type, + port_declaration_context.var_type, port_declaration_context.sign_flag, port_declaration_context.range, 0); delete[]$3; @@ -1876,91 +1877,96 @@ list_of_port_declarations port_declaration : attribute_list_opt - K_input net_type_opt signed_opt range_opt IDENTIFIER + K_input net_type_opt primitive_type_opt signed_opt range_opt IDENTIFIER { Module::port_t*ptmp; - perm_string name = lex_strings.make($6); + perm_string name = lex_strings.make($7); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::PINPUT, - $3, $4, $5, $1); + $3, $4, $5, $6, $1); port_declaration_context.port_type = NetNet::PINPUT; port_declaration_context.port_net_type = $3; - port_declaration_context.sign_flag = $4; + port_declaration_context.var_type = $4; + port_declaration_context.sign_flag = $5; delete port_declaration_context.range; - port_declaration_context.range = $5; + port_declaration_context.range = $6; delete $1; - delete[]$6; + delete[]$7; $$ = ptmp; } | attribute_list_opt - K_inout net_type_opt signed_opt range_opt IDENTIFIER + K_inout net_type_opt primitive_type_opt signed_opt range_opt IDENTIFIER { Module::port_t*ptmp; - perm_string name = lex_strings.make($6); + perm_string name = lex_strings.make($7); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::PINOUT, - $3, $4, $5, $1); + $3, $4, $5, $6, $1); port_declaration_context.port_type = NetNet::PINOUT; port_declaration_context.port_net_type = $3; - port_declaration_context.sign_flag = $4; + port_declaration_context.var_type = $4; + port_declaration_context.sign_flag = $5; delete port_declaration_context.range; - port_declaration_context.range = $5; + port_declaration_context.range = $6; delete $1; - delete[]$6; + delete[]$7; $$ = ptmp; } | attribute_list_opt - K_output net_type_opt signed_opt range_opt IDENTIFIER + K_output net_type_opt primitive_type_opt signed_opt range_opt IDENTIFIER { Module::port_t*ptmp; - perm_string name = lex_strings.make($6); + perm_string name = lex_strings.make($7); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::POUTPUT, - $3, $4, $5, $1); + $3, $4, $5, $6, $1); port_declaration_context.port_type = NetNet::POUTPUT; port_declaration_context.port_net_type = $3; - port_declaration_context.sign_flag = $4; + port_declaration_context.var_type = $4; + port_declaration_context.sign_flag = $5; delete port_declaration_context.range; - port_declaration_context.range = $5; + port_declaration_context.range = $6; delete $1; - delete[]$6; + delete[]$7; $$ = ptmp; } | attribute_list_opt - K_output var_type signed_opt range_opt IDENTIFIER + K_output var_type primitive_type_opt signed_opt range_opt IDENTIFIER { Module::port_t*ptmp; - perm_string name = lex_strings.make($6); + perm_string name = lex_strings.make($7); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::POUTPUT, - $3, $4, $5, $1); + $3, $4, $5, $6, $1); port_declaration_context.port_type = NetNet::POUTPUT; port_declaration_context.port_net_type = $3; - port_declaration_context.sign_flag = $4; + port_declaration_context.var_type = $4; + port_declaration_context.sign_flag = $5; delete port_declaration_context.range; - port_declaration_context.range = $5; + port_declaration_context.range = $6; delete $1; - delete[]$6; + delete[]$7; $$ = ptmp; } | attribute_list_opt - K_output var_type signed_opt range_opt IDENTIFIER '=' expression + K_output var_type primitive_type_opt signed_opt range_opt IDENTIFIER '=' expression { Module::port_t*ptmp; - perm_string name = lex_strings.make($6); + perm_string name = lex_strings.make($7); ptmp = pform_module_port_reference(name, @2.text, @2.first_line); pform_module_define_port(@2, name, NetNet::POUTPUT, - $3, $4, $5, $1); + $3, $4, $5, $6, $1); port_declaration_context.port_type = NetNet::POUTPUT; port_declaration_context.port_net_type = $3; - port_declaration_context.sign_flag = $4; + port_declaration_context.var_type = $4; + port_declaration_context.sign_flag = $5; delete port_declaration_context.range; - port_declaration_context.range = $5; + port_declaration_context.range = $6; - pform_make_reginit(@6, name, $8); + pform_make_reginit(@7, name, $9); delete $1; - delete[]$6; + delete[]$7; $$ = ptmp; } ; diff --git a/pform.cc b/pform.cc index 9340c9a05..47b212cb2 100644 --- a/pform.cc +++ b/pform.cc @@ -1772,6 +1772,7 @@ void pform_module_define_port(const struct vlltype&li, perm_string name, NetNet::PortType port_type, NetNet::Type type, + ivl_variable_type_t data_type, bool signed_flag, svector*range, svector*attr) @@ -1786,8 +1787,11 @@ void pform_module_define_port(const struct vlltype&li, return; } + // The default type for all flavor of ports is LOGIC. + if (data_type == IVL_VT_NO_TYPE) + data_type = IVL_VT_LOGIC; - cur = new PWire(name, type, port_type, IVL_VT_LOGIC); + cur = new PWire(name, type, port_type, data_type); FILE_NAME(cur, li); cur->set_signed(signed_flag); diff --git a/pform.h b/pform.h index a769bee8e..acfa58bf0 100644 --- a/pform.h +++ b/pform.h @@ -153,6 +153,7 @@ extern void pform_module_define_port(const struct vlltype&li, perm_string name, NetNet::PortType, NetNet::Type type, + ivl_variable_type_t data_type, bool signed_flag, svector*range, svector*attr);