@@ -23,6 +23,7 @@ OTHER DEALINGS IN THE SOFTWARE.
23
23
#include <string.h>
24
24
#include <stdio.h>
25
25
#include <stdlib.h>
26
+ #include <string.h>
26
27
#include "types.h"
27
28
#include "globals.h"
28
29
#include "errors.h"
@@ -476,7 +477,8 @@ void convert_ast_to_netlist_recursing_via_modules(ast_node_t* current_module, ch
476
477
signal_list_t * list = NULL ;
477
478
478
479
/* BASE CASE is when there are no other instantiations of modules in this module */
479
- if (current_module -> types .module .size_module_instantiations == 0 && current_module -> types .function .size_function_instantiations == 0 )
480
+ if (current_module -> types .module .size_module_instantiations == 0 &&
481
+ current_module -> types .function .size_function_instantiations == 0 )
480
482
{
481
483
list = netlist_expand_ast_of_module (current_module , instance_name );
482
484
}
@@ -734,7 +736,7 @@ signal_list_t *netlist_expand_ast_of_module(ast_node_t* node, char *instance_nam
734
736
break ;
735
737
case INITIALS :
736
738
/* define initial value of latchs */
737
- define_latchs_initial_value_inside_initial_statement (node -> children [0 ],instance_name_prefix );
739
+ define_latchs_initial_value_inside_initial_statement (node -> children [0 ], instance_name_prefix );
738
740
skip_children = TRUE;
739
741
break ;
740
742
case FUNCTION_INSTANCE :
@@ -1345,8 +1347,7 @@ nnet_t* define_nets_with_driver(ast_node_t* var_declare, char *instance_name_pre
1345
1347
if (var_declare -> types .variable .is_initialized ){
1346
1348
initial_value = var_declare -> types .variable .initial_value ;
1347
1349
}
1348
-
1349
-
1350
+
1350
1351
/* This register declaration is a range as opposed to a single bit so we need to define each element */
1351
1352
/* assume digit 1 is largest */
1352
1353
for (i = node_min -> types .number .value ; i <= node_max -> types .number .value ; i ++ )
@@ -2836,8 +2837,12 @@ signal_list_t *assignment_alias(ast_node_t* assignment, char *instance_name_pref
2836
2837
if (assignment -> type == VAR_DECLARE ){
2837
2838
left = assignment -> children [0 ];
2838
2839
right = assignment -> children [5 ];
2840
+
2841
+ /*we don't create signal list on declaration.*/
2842
+ return init_signal_list ();
2839
2843
}
2840
- else {
2844
+ else
2845
+ {
2841
2846
left = assignment -> children [0 ];
2842
2847
right = assignment -> children [1 ];
2843
2848
}
@@ -2927,7 +2932,7 @@ signal_list_t *assignment_alias(ast_node_t* assignment, char *instance_name_pref
2927
2932
if (!is_valid_implicit_memory_reference_ast (instance_name_prefix , left ))
2928
2933
error_message (NETLIST_ERROR , assignment -> line_number , assignment -> file_number ,
2929
2934
"Invalid addressing mode for implicit memory %s.\n" , left_memory -> name );
2930
-
2935
+
2931
2936
// A memory can only be written from a clocked sequential block.
2932
2937
if (type_of_circuit != SEQUENTIAL )
2933
2938
{
@@ -3026,7 +3031,8 @@ signal_list_t *assignment_alias(ast_node_t* assignment, char *instance_name_pref
3026
3031
}
3027
3032
free_signal_list (in_1 );
3028
3033
}
3029
- else {
3034
+ else
3035
+ {
3030
3036
if (output_size < in_1 -> count )
3031
3037
{
3032
3038
/* need to shrink the output list */
@@ -3091,47 +3097,52 @@ signal_list_t *assignment_alias(ast_node_t* assignment, char *instance_name_pref
3091
3097
return return_list ;
3092
3098
}
3093
3099
3094
- void define_latchs_initial_value_inside_initial_statement (ast_node_t * initial_node , char * instance_name_prefix ){
3100
+ void define_latchs_initial_value_inside_initial_statement (ast_node_t * initial_node , char * instance_name_prefix )
3101
+ {
3095
3102
int i ;
3096
3103
long sc_spot ;
3097
- ast_node_t * left ;
3098
- ast_node_t * right ;
3104
+ ast_node_t * assignee ;
3105
+ ast_node_t * value ;
3099
3106
char * word_to_set_latch_initial_value ;
3100
- for (i = 0 ; i < initial_node -> num_children ; i ++ ){
3101
- if ((initial_node -> children [i ]-> type == BLOCKING_STATEMENT || initial_node -> children [i ]-> type == NON_BLOCKING_STATEMENT ) && initial_node -> children [i ]-> children [1 ]-> type == NUMBERS ){
3107
+ for (i = 0 ; i < initial_node -> num_children ; i ++ )
3108
+ {
3109
+ /*check to see if, for each member of the initial block, if the assignment to a given variable is a number and not
3110
+ a complex statement*/
3111
+ if ((initial_node -> children [i ]-> type == BLOCKING_STATEMENT || initial_node -> children [i ]-> type == NON_BLOCKING_STATEMENT )
3112
+ && initial_node -> children [i ]-> children [1 ]-> type == NUMBERS )
3113
+ {
3114
+ //Assignee
3115
+ assignee = initial_node -> children [i ]-> children [0 ];
3102
3116
3103
- left = initial_node -> children [i ]-> children [0 ];
3104
- right = initial_node -> children [i ]-> children [1 ];
3105
-
3106
- word_to_set_latch_initial_value = (char * )calloc (strlen (left -> types .identifier )+ 40 ,sizeof (char ));
3117
+ //Value
3118
+ value = initial_node -> children [i ]-> children [1 ];
3119
+
3120
+ //Create out string.
3121
+ word_to_set_latch_initial_value = (char * )calloc (strlen (assignee -> types .identifier )+ 40 , sizeof (char ));
3107
3122
strcpy (word_to_set_latch_initial_value ,instance_name_prefix );
3108
3123
strcat (word_to_set_latch_initial_value ,"^" );
3109
-
3110
- strcat (word_to_set_latch_initial_value ,left -> types .identifier );
3124
+ strcat (word_to_set_latch_initial_value ,assignee -> types .identifier );
3111
3125
strcat (word_to_set_latch_initial_value ,"_latch_initial_value" );
3112
-
3113
3126
sc_spot = sc_lookup_string (local_symbol_table_sc , word_to_set_latch_initial_value );
3114
3127
3115
- if (sc_spot != -1 ){
3116
- ((nnode_t * )(local_symbol_table_sc -> data [sc_spot ]))-> has_initial_value = 1 ;
3117
- if (right -> types .number .value > 1 )
3118
- ((nnode_t * )(local_symbol_table_sc -> data [sc_spot ]))-> initial_value = 0 ;
3119
- else ((nnode_t * )(local_symbol_table_sc -> data [sc_spot ]))-> initial_value = right -> types .number .value ;
3120
- free (word_to_set_latch_initial_value );
3128
+ if (sc_spot != -1 )
3129
+ {
3130
+ /*found the entry so simply udpdate node info*/
3131
+
3132
+ /*here, I think we can have a check for if the ast ndoe is marked as alread being initialized, then we can assume
3133
+ that someone has placed an assignment for that node before our initial block, so we just die and tell them they are
3134
+ stupid.*/
3135
+ ((ast_node_t * )(local_symbol_table_sc -> data [sc_spot ]))-> types .variable .is_initialized = TRUE;
3136
+ ((ast_node_t * )(local_symbol_table_sc -> data [sc_spot ]))-> types .variable .initial_value = value -> types .number .value ;
3137
+ //free(word_to_set_latch_initial_value);
3121
3138
}
3122
- else {
3139
+ else
3140
+ {
3141
+ /*could not find entry, so add it then update the node*/
3123
3142
sc_spot = sc_add_string (local_symbol_table_sc , word_to_set_latch_initial_value );
3124
- if (right -> types .number .value > 1 ) {
3125
- local_symbol_table_sc -> data [sc_spot ] = (char * )calloc (2 ,sizeof (char ));
3126
- ((char * )(local_symbol_table_sc -> data [sc_spot ]))[0 ] = '0' ;//local_symbol_table_sc->data[sc_spot] = "0";
3127
- //strcpy((char *)(local_symbol_table_sc->data[sc_spot]),"0");
3128
- }
3129
- else {
3130
- local_symbol_table_sc -> data [sc_spot ] = (char * )calloc (2 ,sizeof (char ));
3131
- ((char * )(local_symbol_table_sc -> data [sc_spot ]))[0 ] = right -> types .number .value ;
3132
- //strcpy((char *)(local_symbol_table_sc->data[sc_spot]),right->types.number.value);
3133
- //strcpy(local_symbol_table_sc->data[sc_spot],right->types.number.value);
3134
- }
3143
+ local_symbol_table_sc -> data [sc_spot ] = assignee ;
3144
+ ((ast_node_t * )(local_symbol_table_sc -> data [sc_spot ]))-> types .variable .is_initialized = TRUE;
3145
+ ((ast_node_t * )(local_symbol_table_sc -> data [sc_spot ]))-> types .variable .initial_value = value -> types .number .value ;
3135
3146
}
3136
3147
}
3137
3148
}
@@ -3302,7 +3313,7 @@ void terminate_registered_assignment(ast_node_t *always_node, signal_list_t* ass
3302
3313
3303
3314
for (j = i - 1 ; j >= 0 ; j -- ){
3304
3315
3305
- if (list_dependence_pin [j ]-> net -> driver_pin &&
3316
+ if (list_dependence_pin [j ] && list_dependence_pin [ j ] -> net -> driver_pin &&
3306
3317
list_dependence_type [j ] && list_dependence_type [j ] == BLOCKING_STATEMENT &&
3307
3318
strcmp (ref_string ,assignment -> pins [j ]-> node -> name ) == 0 ){
3308
3319
@@ -5480,3 +5491,4 @@ signal_list_t *create_hard_block(ast_node_t* block, char *instance_name_prefix)
5480
5491
return return_list ;
5481
5492
}
5482
5493
#endif
5494
+
0 commit comments