Verilog Parser
verilog_ast.c File Reference

Contains definitions of functions which operate on the Verilog Abstract Syntax Tree (AST) More...

#include <assert.h>
#include <stdio.h>
#include "verilog_ast.h"
#include "verilog_preprocessor.h"

Functions

void ast_append_attribute (ast_node_attributes *parent, ast_node_attributes *toadd)
 Creates and returns a new attribute node with the specified value and name. More...
 
ast_identifier ast_append_identifier (ast_identifier parent, ast_identifier child)
 Used to construct linked lists of hierarchical identifiers. More...
 
char * ast_expression_tostring (ast_expression *exp)
 A utility function for converting an ast expression tree back into a string representation. More...
 
void ast_extend_concatenation (ast_concatenation *element, ast_expression *repeat, void *data)
 Adds a new data element on to the end of a concatenation. More...
 
void ast_extend_if_else (ast_if_else *conditional_statements, ast_list *new_statements)
 Adds an additional conditional (ha..) to an existing if-else statement. More...
 
ast_statement_blockast_extract_statement_block (ast_statement_type type, ast_statement *body)
 Takes a body statement (type = STM_BLK) and splits it into it's event trigger and statements.
 
int ast_identifier_cmp (ast_identifier a, ast_identifier b)
 Acts like strcmp but works on ast identifiers.
 
void ast_identifier_set_index (ast_identifier id, ast_expression *index)
 Used to set the index field of an identifier. More...
 
void ast_identifier_set_range (ast_identifier id, ast_range *range)
 Used to set the range field of an identifier. More...
 
char * ast_identifier_tostring (ast_identifier id)
 Simply returns the fully qualified representation of an identifier as a string. More...
 
ast_node_attributes * ast_new_attributes (ast_identifier name, ast_expression *value)
 Creates and returns as a pointer a new attribute descriptor. More...
 
ast_expression * ast_new_binary_expression (ast_expression *left, ast_expression *right, ast_operator operation, ast_node_attributes *attr, ast_boolean constant)
 Creates a new primary expression with the supplied operation and operands. More...
 
ast_block_item_declaration * ast_new_block_item_declaration (ast_block_item_declaration_type type, ast_node_attributes *attributes)
 Creates and returns a new block item declaration of the specified type. More...
 
ast_block_reg_declarationast_new_block_reg_declaration (ast_boolean is_signed, ast_range *range, ast_list *identifiers)
 Creates and returns a new block register declaration descriptor. More...
 
ast_assignment * ast_new_blocking_assignment (ast_lvalue *lval, ast_expression *expression, ast_timing_control_statement *delay_or_event)
 Creates and returns a new blocking procedural assignment object. More...
 
ast_case_itemast_new_case_item (ast_list *conditions, ast_statement *body)
 Create and return a new item in a cast statement. More...
 
ast_case_statementast_new_case_statement (ast_expression *expression, ast_list *cases, ast_case_statement_type type)
 Creates and returns a new case statement. More...
 
ast_cmos_switch_instanceast_new_cmos_switch_instance (ast_identifier name, ast_lvalue *output_terminal, ast_expression *ncontrol_terminal, ast_expression *pcontrol_terminal, ast_expression *input_terminal)
 A single CMOS switch (transistor) instance.
 
ast_concatenation * ast_new_concatenation (ast_concatenation_type type, ast_expression *repeat, void *first_value)
 Creates a new AST concatenation element with the supplied type and initial starting value. More...
 
ast_expression * ast_new_conditional_expression (ast_expression *condition, ast_expression *if_true, ast_expression *if_false, ast_node_attributes *attr)
 Creates a new conditional expression node. More...
 
ast_conditional_statementast_new_conditional_statement (ast_statement *statement, ast_expression *condition)
 Creates and returns a new conditional statement. More...
 
ast_config_declarationast_new_config_declaration (ast_identifier identifier, ast_identifier design_statement, ast_list *rule_statements)
 Creates and returns a new config declaration node.
 
ast_config_rule_statementast_new_config_rule_statement (ast_boolean is_default, ast_identifier clause_1, ast_identifier clause_2)
 Creates and returns a new configuration rule statment node. More...
 
ast_primaryast_new_constant_primary (ast_primary_value_type type)
 Creates a new ast primary which is part of a constant expression tree with the supplied type and value. More...
 
ast_assignment * ast_new_continuous_assignment (ast_list *assignments, ast_drive_strength *strength, ast_delay3 *delay)
 Creates and returns a new continuous assignment object. More...
 
ast_delay2 * ast_new_delay2 (ast_delay_value *min, ast_delay_value *max)
 Create a new delay2 instance.
 
ast_delay3 * ast_new_delay3 (ast_delay_value *min, ast_delay_value *avg, ast_delay_value *max)
 Create a new delay3 instance.
 
ast_delay_ctrlast_new_delay_ctrl_mintypmax (ast_expression *mintypmax)
 creates and returns a new delay control statement.
 
ast_delay_ctrlast_new_delay_ctrl_value (ast_delay_value *value)
 creates and returns a new delay control statement.
 
ast_delay_valueast_new_delay_value (ast_delay_value_type type, void *data)
 Create a new delay value.
 
ast_disable_statementast_new_disable_statement (ast_identifier id)
 Creates and returns a pointer to a new disable statement.
 
ast_edge_sensitive_full_path_declarationast_new_edge_sensitive_full_path_declaration (ast_edge edge, ast_list *input_terminal, ast_operator polarity, ast_list *output_terminal, ast_expression *data_source, ast_list *delay_value)
 Describes a parallel edge sensitive path declaration. More...
 
ast_edge_sensitive_parallel_path_declarationast_new_edge_sensitive_parallel_path_declaration (ast_edge edge, ast_identifier input_terminal, ast_operator polarity, ast_identifier output_terminal, ast_expression *data_source, ast_list *delay_value)
 Describes a single edge sensitive path declaration. More...
 
ast_concatenation * ast_new_empty_concatenation (ast_concatenation_type type)
 Creates and returns a new empty concatenation of the specified type. More...
 
ast_enable_gate_instanceast_new_enable_gate_instance (ast_identifier name, ast_lvalue *output_terminal, ast_expression *enable_terminal, ast_expression *input_terminal)
 A single Enable gate instance.
 
ast_enable_gate_instancesast_new_enable_gate_instances (ast_gatetype_n_input type, ast_delay3 *delay, ast_drive_strength *drive_strength, ast_list *instances)
 Creates collection of enable gates with the same type and properties.
 
ast_event_controlast_new_event_control (ast_event_control_type type, ast_event_expression *expression)
 Creates and returns a new event control specifier.
 
ast_event_expression * ast_new_event_expression (ast_edge trigger_edge, ast_expression *expression)
 Creates a new event expression node. More...
 
ast_event_expression * ast_new_event_expression_sequence (ast_event_expression *left, ast_event_expression *right)
 Creates a new event expression node, which is itself a sequence of sub-expressions.
 
ast_expression * ast_new_expression_primary (ast_primary *p)
 Creates and returns a new expression primary. More...
 
ast_loop_statementast_new_for_loop_statement (ast_statement *inner_statement, ast_single_assignment *initial_condition, ast_single_assignment *modify_assignment, ast_expression *continue_condition)
 Creates and returns a new for loop statement. More...
 
ast_loop_statementast_new_forever_loop_statement (ast_statement *inner_statement)
 Creates and returns a new forever loop statement. More...
 
ast_function_call * ast_new_function_call (ast_identifier id, ast_boolean constant, ast_boolean system, ast_node_attributes *attr, ast_list *arguments)
 Creates and returns a new node representing a function call. More...
 
ast_function_declarationast_new_function_declaration (ast_boolean automatic, ast_boolean is_signed, ast_boolean function_or_block, ast_range_or_type *rot, ast_identifier identifier, ast_list *item_declarations, ast_statement *statements)
 Creates and returns a function declaration node. More...
 
ast_function_item_declarationast_new_function_item_declaration ()
 Creates and returns a new function item declaration. More...
 
ast_gate_instantiationast_new_gate_instantiation (ast_gate_type type)
 Creates and returns a new gate instantiation descriptor. More...
 
ast_generate_block * ast_new_generate_block (ast_identifier identifier, ast_list *generate_items)
 Creates and returns a new block of generate items.
 
ast_statement * ast_new_generate_item (ast_statement_type type, void *construct)
 Creates and returns a new item which exists inside a generate statement. More...
 
ast_loop_statementast_new_generate_loop_statement (ast_list *inner_statements, ast_single_assignment *initial_condition, ast_single_assignment *modify_assignment, ast_expression *continue_condition)
 Creates and returns a new generate loop statement. More...
 
ast_assignment * ast_new_hybrid_assignment (ast_hybrid_assignment_type type, ast_single_assignment *assignment)
 Creates a new hybrid assignment of the specified type. More...
 
ast_assignment * ast_new_hybrid_lval_assignment (ast_hybrid_assignment_type type, ast_lvalue *lval)
 Creates a new hybrid assignment of the specified type. More...
 
ast_identifier ast_new_identifier (char *identifier, unsigned int from_line)
 Creates and returns a new node representing an identifier. More...
 
ast_if_elseast_new_if_else (ast_conditional_statement *if_condition, ast_statement *else_condition)
 Creates a new if-then-else-then statement. More...
 
ast_expression * ast_new_index_expression (ast_expression *left)
 Creates a new range index expression with the supplied operands. More...
 
ast_library_declarationast_new_library_declaration (ast_identifier identifier, ast_list *file_paths, ast_list *incdirs)
 Creates a new library declaration node.
 
ast_library_descriptionsast_new_library_description (ast_library_item_type type)
 Creates and returns a new library description object.
 
ast_lvalueast_new_lvalue_concat (ast_lvalue_type type, ast_concatenation *concat)
 Creates and returns a new ast_lvalue pointer, with the data type being a concatenation holder of either NET_CONCATENATION or VAR_CONCATENATION.
 
ast_lvalueast_new_lvalue_id (ast_lvalue_type type, ast_identifier id)
 Creates and returns a new ast_lvalue pointer, with the data type being a single identifier of either NET_IDENTIFIER or VAR_IDENTIFIER.
 
ast_expression * ast_new_mintypmax_expression (ast_expression *min, ast_expression *typ, ast_expression *max)
 Creates a new (min,typical,maximum) expression. More...
 
ast_module_declaration * ast_new_module_declaration (ast_node_attributes *attributes, ast_identifier identifier, ast_list *parameters, ast_list *ports, ast_list *constructs)
 Creates a new module instantiation. More...
 
ast_module_instanceast_new_module_instance (ast_identifier instance_identifier, ast_list *port_connections)
 Creates and returns a new instance of a module with a given identifer and set of port connections.
 
ast_module_instantiationast_new_module_instantiation (ast_identifier module_identifer, ast_list *module_parameters, ast_list *module_instances)
 Creates and returns a new set of module instances with shared parameters.
 
ast_module_item * ast_new_module_item (ast_node_attributes *attributes, ast_module_item_type type)
 Creates and returns a new module item descriptor. More...
 
ast_primaryast_new_module_path_primary (ast_primary_value_type type)
 Creates a new ast primary which is part of a constant expression tree with the supplied type and value. More...
 
ast_mos_switch_instanceast_new_mos_switch_instance (ast_identifier name, ast_lvalue *output_terminal, ast_expression *enable_terminal, ast_expression *input_terminal)
 A single MOS switch (transistor) instance.
 
ast_n_input_gate_instanceast_new_n_input_gate_instance (ast_identifier name, ast_list *input_terminals, ast_lvalue *output_terminal)
 An N-input gate instance. e.g. 3-to-1 NAND.
 
ast_n_input_gate_instancesast_new_n_input_gate_instances (ast_gatetype_n_input type, ast_delay3 *delay, ast_drive_strength *drive_strength, ast_list *instances)
 Creates collection of n-input gates with the same type and properties.
 
ast_n_output_gate_instanceast_new_n_output_gate_instance (ast_identifier name, ast_list *outputs, ast_expression *input)
 Creates and returns a new n_output gate instance. More...
 
ast_n_output_gate_instancesast_new_n_output_gate_instances (ast_n_output_gatetype type, ast_delay2 *delay, ast_drive_strength *drive_strength, ast_list *instances)
 Creates and returns a set of n_output gates with the same properties.
 
ast_port_connectionast_new_named_port_connection (ast_identifier port_name, ast_expression *expression)
 Creates and returns a new port connection representation. More...
 
ast_listast_new_net_declaration (ast_type_declaration *type_dec)
 Creates a new net declaration object. More...
 
ast_assignment * ast_new_nonblocking_assignment (ast_lvalue *lval, ast_expression *expression, ast_timing_control_statement *delay_or_event)
 Creates and returns a new nonblocking procedural assignment object. More...
 
ast_number * ast_new_number (ast_number_base base, ast_number_representation representation, char *digits)
 Creates a new number representation object. More...
 
ast_parameter_declarationsast_new_parameter_declarations (ast_list *assignments, ast_boolean signed_values, ast_boolean local, ast_range *range, ast_parameter_type type)
 creates and returns a new set of parameter declarations of the same type More...
 
ast_pass_enable_switchast_new_pass_enable_switch (ast_identifier name, ast_lvalue *terminal_1, ast_lvalue *terminal_2, ast_expression *enable)
 Creates and returns a new pass enable switch instance.
 
ast_pass_enable_switchesast_new_pass_enable_switches (ast_pass_enable_switchtype type, ast_delay2 *delay, ast_list *switches)
 Creates and returns a collection of pass enable switches.
 
ast_pass_switch_instanceast_new_pass_switch_instance (ast_identifier name, ast_lvalue *terminal_1, ast_lvalue *terminal_2)
 A single pass transistor instance.
 
ast_path_declarationast_new_path_declaration (ast_path_declaration_type type)
 Creates and returns a new path declaration type. Expects that the data be filled in manually;.
 
ast_port_declarationast_new_port_declaration (ast_port_direction direction, ast_net_type net_type, ast_boolean net_signed, ast_boolean is_reg, ast_boolean is_variable, ast_range *range, ast_list *port_names)
 Creates and returns a new port declaration representation. More...
 
ast_primaryast_new_primary (ast_primary_value_type type)
 Creates a new ast primary which is part of an expression tree with the supplied type and value. More...
 
ast_primaryast_new_primary_function_call (ast_function_call *call)
 Creates a new AST primary wrapper around a function call. More...
 
ast_primitive_pull_strengthast_new_primitive_pull_strength (ast_pull_direction direction, ast_primitive_strength strength_1, ast_primitive_strength strength_0)
 Creates and returns a new structure describing primitive net strength.
 
ast_pull_gate_instanceast_new_pull_gate_instance (ast_identifier name, ast_lvalue *output_terminal)
 Describes a single pull gate instance.
 
ast_pull_strengthast_new_pull_stregth (ast_primitive_strength strength_1, ast_primitive_strength strength_2)
 Create and return a new pull strength indicator for 1 and 0.
 
ast_pulse_control_specparamast_new_pulse_control_specparam (ast_expression *reject_limit, ast_expression *error_limit)
 Creates and returns a new pulse control data structure.
 
ast_range * ast_new_range (ast_expression *upper, ast_expression *lower)
 Creates and returns a new range or dimension representation node.
 
ast_expression * ast_new_range_expression (ast_expression *left, ast_expression *right)
 Creates a new range expression with the supplied operands. More...
 
ast_range_or_typeast_new_range_or_type (ast_boolean is_range)
 Creates and returns a new object storing either a range or a type. More...
 
ast_listast_new_reg_declaration (ast_type_declaration *type_dec)
 Creates a new reg declaration object. More...
 
ast_loop_statementast_new_repeat_loop_statement (ast_statement *inner_statement, ast_expression *continue_condition)
 Creates and returns a repeat loop statement. More...
 
ast_simple_full_path_declarationast_new_simple_full_path_declaration (ast_list *input_terminals, ast_operator polarity, ast_list *output_terminals, ast_list *delay_value)
 Creates and returns a pointer to a new simple full path declaration.
 
ast_simple_parallel_path_declarationast_new_simple_parallel_path_declaration (ast_identifier input_terminal, ast_operator polarity, ast_identifier output_terminal, ast_list *delay_value)
 Creates and returns a pointer to a new simple parallel path declaration.
 
ast_single_assignment * ast_new_single_assignment (ast_lvalue *lval, ast_expression *expression)
 Creates and returns a new assignment. More...
 
ast_source_itemast_new_source_item (ast_source_item_type type)
 Creates and returns a new source item representation. More...
 
ast_statement * ast_new_statement (ast_node_attributes *attr, ast_boolean is_function_statement, void *data, ast_statement_type type)
 Creates a new AST statement and returns it. More...
 
ast_statement_blockast_new_statement_block (ast_block_type type, ast_identifier block_identifier, ast_list *declarations, ast_list *statements)
 Creates and returns a new statement block of the specified type. More...
 
ast_expression * ast_new_string_expression (ast_string string)
 Creates a new string expression. More...
 
ast_switch_gateast_new_switch_gate_d2 (ast_switchtype type, ast_delay2 *delay)
 Instances a new switch type with a delay2.
 
ast_switch_gateast_new_switch_gate_d3 (ast_switchtype type, ast_delay3 *delay)
 Instances a new switch type with a delay3.
 
ast_switchesast_new_switches (ast_switch_gate *type, ast_list *switches)
 creat and return a new collection of AST switches. More...
 
ast_identifier ast_new_system_identifier (char *identifier, unsigned int from_line)
 Creates and returns a new node representing an identifier. More...
 
ast_task_declarationast_new_task_declaration (ast_boolean automatic, ast_identifier identifier, ast_list *ports, ast_list *declarations, ast_statement *statements)
 Creates and returns a new task declaration statement. More...
 
ast_task_enable_statementast_new_task_enable_statement (ast_list *expressions, ast_identifier identifier, ast_boolean is_system)
 creates and returns a pointer to a new task-enable statement.
 
ast_task_portast_new_task_port (ast_port_direction direction, ast_boolean reg, ast_boolean is_signed, ast_range *range, ast_task_port_type type, ast_list *identifiers)
 
ast_timing_control_statementast_new_timing_control_statement_delay (ast_timing_control_statement_type type, ast_statement *statement, ast_delay_ctrl *delay_ctrl)
 Creates and returns a new timing control statement node.
 
ast_timing_control_statementast_new_timing_control_statement_event (ast_timing_control_statement_type type, ast_expression *repeat, ast_statement *statement, ast_event_control *event_ctrl)
 Creates and returns a new timing control statement node.
 
ast_type_declarationast_new_type_declaration (ast_declaration_type type)
 Creates and returns a node to represent the declaration of a new module item construct. More...
 
ast_udp_bodyast_new_udp_combinatoral_body (ast_list *combinatorial_entries)
 Creates and returns a new combinatorial UDP body representation.
 
ast_udp_combinatorial_entryast_new_udp_combinatoral_entry (ast_list *input_levels, ast_udp_next_state output_symbol)
 Creates a new combinatorial entry for a UDP node.
 
ast_udp_declarationast_new_udp_declaration (ast_node_attributes *attributes, ast_identifier identifier, ast_list *ports, ast_udp_body *body)
 Creates a new UDP declaration node. More...
 
ast_udp_initial_statementast_new_udp_initial_statement (ast_identifier output_port, ast_number *initial_value)
 Creates a new initial statement node.
 
ast_udp_portast_new_udp_input_port (ast_list *identifiers, ast_node_attributes *attributes)
 Creates a new UDP port AST node. More...
 
ast_udp_instanceast_new_udp_instance (ast_identifier identifier, ast_range *range, ast_lvalue *output, ast_list *inputs)
 Creates a new instance of a UDP. More...
 
ast_udp_instantiationast_new_udp_instantiation (ast_list *instances, ast_identifier identifier, ast_drive_strength *drive_strength, ast_delay2 *delay)
 Creates a new list of UDP instances with shared properties. More...
 
ast_udp_portast_new_udp_port (ast_port_direction direction, ast_identifier identifier, ast_node_attributes *attributes, ast_boolean reg, ast_expression *default_value)
 Creates a new UDP port AST node. More...
 
ast_udp_bodyast_new_udp_sequential_body (ast_udp_initial_statement *initial_statement, ast_list *sequential_entries)
 Creates and returns a new sequential UDP body representation.
 
ast_udp_sequential_entryast_new_udp_sequential_entry (ast_udp_seqential_entry_prefix prefix_type, ast_list *levels_or_edges, ast_level_symbol current_state, ast_udp_next_state output)
 Creates a new sequntial body entry for a UDP node.
 
ast_expression * ast_new_unary_expression (ast_primary *operand, ast_operator operation, ast_node_attributes *attr, ast_boolean constant)
 Creates a new unary expression with the supplied operation. More...
 
ast_listast_new_var_declaration (ast_type_declaration *type_dec)
 Creates a new variable declaration object. More...
 
ast_wait_statementast_new_wait_statement (ast_expression *wait_for, ast_statement *statement)
 Creates and returns a new wait statement.
 
ast_loop_statementast_new_while_loop_statement (ast_statement *inner_statement, ast_expression *continue_condition)
 Creates and returns a while loop statement. More...
 
char * ast_number_tostring (ast_number *n)
 A utility function for converting an ast number into a string. More...
 
char * ast_operator_tostring (ast_operator op)
 Returns the string representation of an operator;.
 
char * ast_primary_tostring (ast_primary *p)
 A utility function for converting an ast expression primaries back into a string representation. More...
 
void ast_set_meta_info (ast_metadata *meta)
 Responsible for setting the line number and file of each node's meta data member. More...
 
void verilog_free_source_tree (verilog_source_tree *tofree)
 Releases a source tree object from memory. More...
 
verilog_source_treeverilog_new_source_tree ()
 Creates and returns a new, empty source tree. More...
 

Variables

verilog_source_treeyy_verilog_source_tree
 Global source tree object, used to store parsed constructs. More...
 

Detailed Description

Contains definitions of functions which operate on the Verilog Abstract Syntax Tree (AST)

Function Documentation

void ast_set_meta_info ( ast_metadata meta)

Responsible for setting the line number and file of each node's meta data member.

Parameters
[in,out]meta- A pointer to the metadata member to modify.