@@ -57,9 +57,6 @@ OTHER DEALINGS IN THE SOFTWARE.
57
57
#define INSTANTIATE_DRIVERS 1
58
58
#define ALIAS_INPUTS 2
59
59
60
- #define COMBINATIONAL 1
61
- #define SEQUENTIAL 2
62
-
63
60
STRING_CACHE *output_nets_sc;
64
61
STRING_CACHE *input_nets_sc;
65
62
@@ -85,8 +82,8 @@ netlist_t *verilog_netlist;
85
82
86
83
int netlist_create_line_number = -2 ;
87
84
88
- int type_of_circuit;
89
-
85
+ circuit_type_e type_of_circuit;
86
+ edge_type_e circuit_edge;
90
87
91
88
/* PROTOTYPES */
92
89
void create_param_table_for_module (ast_node_t * parent_parameter_list, ast_node_t *module_items, char *module_name, char *parent_module);
@@ -283,6 +280,13 @@ void create_param_table_for_module(ast_node_t* parent_parameter_list, ast_node_t
283
280
{
284
281
ast_node_t *var_declare = parent_parameter_list->children [i];
285
282
sc_spot = sc_lookup_string (local_param_table_sc, temp_parameter_list[parameter_count]);
283
+ if (sc_spot == -1 )
284
+ {
285
+ error_message (NETLIST_ERROR, parent_parameter_list->line_number , parent_parameter_list->file_number ,
286
+ " Can't find parameter name %s in module %s\n " ,
287
+ var_declare->children [0 ]->types .identifier ,
288
+ module_name);
289
+ }
286
290
local_param_table_sc->data [sc_spot] = (void *)var_declare->children [5 ];
287
291
}
288
292
@@ -330,12 +334,23 @@ void create_param_table_for_module(ast_node_t* parent_parameter_list, ast_node_t
330
334
}
331
335
332
336
/* now that parameters are all updated, resolve them */
333
- for (i = 0 ; i < parameter_num; i++) {
337
+ for (i = 0 ; i < parameter_num; i++)
338
+ {
334
339
sc_spot = sc_lookup_string (local_param_table_sc, temp_parameter_list[i]);
340
+ if (sc_spot == -1 )
341
+ {
342
+ error_message (NETLIST_ERROR, parent_parameter_list->line_number , parent_parameter_list->file_number ,
343
+ " Can't find parameter name %s in module %s\n " ,
344
+ temp_parameter_list[i],
345
+ module_name);
346
+ }
335
347
ast_node_t *node = (ast_node_t *)local_param_table_sc->data [sc_spot];
336
348
oassert (node);
337
349
node = resolve_node (NULL , module_name, node);
338
- if (node->type != NUMBERS) node = resolve_node (NULL , parent_module, node); // may contain parameters from parent
350
+ if (node->type != NUMBERS)
351
+ {
352
+ node = resolve_node (NULL , parent_module, node); // may contain parameters from parent
353
+ }
339
354
oassert (node->type == NUMBERS);
340
355
local_param_table_sc->data [sc_spot] = (void *)node;
341
356
}
@@ -815,7 +830,8 @@ signal_list_t *netlist_expand_ast_of_module(ast_node_t* node, char *instance_nam
815
830
break ;
816
831
case VAR_DECLARE:
817
832
if (node->types .variable .is_parameter == 0 && node->children [5 ]){
818
- return_sig_list = assignment_alias (node, instance_name_prefix);
833
+ /* we don't create signal list on declaration.*/
834
+ return_sig_list = init_signal_list ();
819
835
}
820
836
skip_children = TRUE ;
821
837
break ;
@@ -885,22 +901,11 @@ signal_list_t *netlist_expand_ast_of_module(ast_node_t* node, char *instance_nam
885
901
case ASSIGN:
886
902
/* combinational path */
887
903
type_of_circuit = COMBINATIONAL;
904
+ circuit_edge = UNDEFINED_SENSITIVITY;
888
905
break ;
889
906
case BLOCKING_STATEMENT:
890
- {
891
- /* if (type_of_circuit == SEQUENTIAL)
892
- error_message(NETLIST_ERROR, node->line_number, node->file_number,
893
- "ODIN doesn't handle blocking statements in Sequential blocks\n");*/
894
-
895
- return_sig_list = assignment_alias (node, instance_name_prefix);
896
- skip_children = TRUE ;
897
- break ;
898
- }
899
907
case NON_BLOCKING_STATEMENT:
900
908
{
901
- /* if (type_of_circuit != SEQUENTIAL)
902
- error_message(NETLIST_ERROR, node->line_number, node->file_number,
903
- "ODIN doesn't handle non blocking statements in combinational blocks\n");*/
904
909
905
910
return_sig_list = assignment_alias (node, instance_name_prefix);
906
911
skip_children = TRUE ;
@@ -1013,13 +1018,9 @@ signal_list_t *netlist_expand_ast_of_module(ast_node_t* node, char *instance_nam
1013
1018
break ;
1014
1019
case ALWAYS:
1015
1020
/* attach the drivers to the driver nets */
1016
- switch (type_of_circuit )
1021
+ switch (circuit_edge )
1017
1022
{
1018
- case FALLING_EDGE_SENSITIVITY:
1019
- {
1020
- terminate_registered_assignment (node, children_signal_list[1 ], local_clock_list, instance_name_prefix);
1021
- break ;
1022
- }
1023
+ case FALLING_EDGE_SENSITIVITY: // fallthrough
1023
1024
case RISING_EDGE_SENSITIVITY:
1024
1025
{
1025
1026
terminate_registered_assignment (node, children_signal_list[1 ], local_clock_list, instance_name_prefix);
@@ -3237,18 +3238,8 @@ signal_list_t *assignment_alias(ast_node_t* assignment, char *instance_name_pref
3237
3238
{
3238
3239
ast_node_t *left;
3239
3240
ast_node_t *right;
3240
- if (assignment->type == VAR_DECLARE){
3241
- left = assignment->children [0 ];
3242
- right = assignment->children [5 ];
3243
-
3244
- /* we don't create signal list on declaration.*/
3245
- return init_signal_list ();
3246
- }
3247
- else
3248
- {
3249
- left = assignment->children [0 ];
3250
- right = assignment->children [1 ];
3251
- }
3241
+ left = assignment->children [0 ];
3242
+ right = assignment->children [1 ];
3252
3243
3253
3244
implicit_memory *left_memory = lookup_implicit_memory_reference_ast (instance_name_prefix, left);
3254
3245
implicit_memory *right_memory = lookup_implicit_memory_reference_ast (instance_name_prefix, right);
@@ -3361,7 +3352,7 @@ signal_list_t *assignment_alias(ast_node_t* assignment, char *instance_name_pref
3361
3352
" Invalid addressing mode for implicit memory %s.\n " , left_memory->name );
3362
3353
3363
3354
// A memory can only be written from a clocked rising edge block.
3364
- if (type_of_circuit != RISING_EDGE_SENSITIVITY )
3355
+ if (type_of_circuit != SEQUENTIAL )
3365
3356
{
3366
3357
out_list = NULL ;
3367
3358
error_message (NETLIST_ERROR, assignment->line_number , assignment->file_number , " %s" ,
@@ -3714,6 +3705,7 @@ void terminate_registered_assignment(ast_node_t *always_node, signal_list_t* ass
3714
3705
ff_node->related_ast_node = always_node;
3715
3706
3716
3707
ff_node->type = FF_NODE;
3708
+ ff_node->edge_type = potential_clocks->pins [local_clock_idx]->sensitivity ;
3717
3709
/* create the unique name for this gate */
3718
3710
// ff_node->name = node_name(ff_node, instance_name_prefix);
3719
3711
/* Name the flipflop based on the name of its output pin */
@@ -4299,13 +4291,13 @@ signal_list_t *create_operation_node(ast_node_t *op, signal_list_t **input_lists
4299
4291
signal_list_t *evaluate_sensitivity_list (ast_node_t *delay_control, char *instance_name_prefix)
4300
4292
{
4301
4293
long i;
4302
- edge_type_e edge_type = UNDEFINED_SENSITIVITY;
4294
+ circuit_edge = UNDEFINED_SENSITIVITY;
4303
4295
signal_list_t *return_sig_list = init_signal_list ();
4304
4296
4305
4297
if (delay_control == NULL )
4306
4298
{
4307
4299
/* Assume always @* */
4308
- edge_type = ASYNCHRONOUS_SENSITIVITY;
4300
+ circuit_edge = ASYNCHRONOUS_SENSITIVITY;
4309
4301
}
4310
4302
else
4311
4303
{
@@ -4328,26 +4320,26 @@ signal_list_t *evaluate_sensitivity_list(ast_node_t *delay_control, char *instan
4328
4320
break ;
4329
4321
}
4330
4322
4331
- if (edge_type == UNDEFINED_SENSITIVITY)
4332
- edge_type = child_sensitivity;
4323
+ if (circuit_edge == UNDEFINED_SENSITIVITY)
4324
+ circuit_edge = child_sensitivity;
4333
4325
4334
- if ( (edge_type != child_sensitivity)
4335
- && ((edge_type == ASYNCHRONOUS_SENSITIVITY) || (child_sensitivity == ASYNCHRONOUS_SENSITIVITY)) )
4336
- error_message (NETLIST_ERROR, delay_control->line_number , delay_control->file_number , " %s" ,
4337
- " Sensitivity list switches between edge sensitive to asynchronous. You can't define something like always @(posedge clock or a).\n " );
4338
-
4339
- switch (edge_type)
4326
+ if (circuit_edge != child_sensitivity)
4327
+ {
4328
+ if (circuit_edge == ASYNCHRONOUS_SENSITIVITY || child_sensitivity == ASYNCHRONOUS_SENSITIVITY)
4329
+ {
4330
+ error_message (NETLIST_ERROR, delay_control->line_number , delay_control->file_number , " %s" ,
4331
+ " Sensitivity list switches between edge sensitive to asynchronous. You can't define something like always @(posedge clock or a).\n " );
4332
+ }
4333
+ }
4334
+
4335
+ switch (child_sensitivity)
4340
4336
{
4341
- /* *
4342
- * TODO: finish support for falling edge, this is left here for future work
4343
- */
4344
4337
case FALLING_EDGE_SENSITIVITY: // falltrhough
4345
- edge_type = RISING_EDGE_SENSITIVITY; // fallthrough
4346
4338
case RISING_EDGE_SENSITIVITY:
4347
4339
{
4348
4340
signal_list_t *temp_list = create_pins (delay_control->children [i]->children [0 ], NULL , instance_name_prefix);
4349
4341
oassert (temp_list->count == 1 );
4350
-
4342
+ temp_list-> pins [ 0 ]-> sensitivity = child_sensitivity;
4351
4343
add_pin_to_signal_list (return_sig_list, temp_list->pins [0 ]);
4352
4344
free_signal_list (temp_list);
4353
4345
break ;
@@ -4358,16 +4350,20 @@ signal_list_t *evaluate_sensitivity_list(ast_node_t *delay_control, char *instan
4358
4350
}
4359
4351
4360
4352
/* update the analysis type of this block of statements */
4361
- if (edge_type == UNDEFINED_SENSITIVITY)
4353
+ if (circuit_edge == UNDEFINED_SENSITIVITY)
4354
+ {
4355
+ // TODO: empty always block will probably appear here
4362
4356
error_message (NETLIST_ERROR, delay_control->line_number , delay_control->file_number , " %s" , " Sensitivity list error...looks empty?\n " );
4363
-
4364
- else if (edge_type == ASYNCHRONOUS_SENSITIVITY)
4357
+ }
4358
+ else if (circuit_edge == ASYNCHRONOUS_SENSITIVITY)
4365
4359
{
4360
+ /* @(*) or @* is here */
4366
4361
free_signal_list (return_sig_list);
4367
4362
return_sig_list = NULL ;
4368
4363
}
4369
4364
4370
- type_of_circuit = edge_type;
4365
+ type_of_circuit = SEQUENTIAL;
4366
+
4371
4367
return return_sig_list;
4372
4368
}
4373
4369
@@ -4785,28 +4781,9 @@ signal_list_t *create_mux_statements(signal_list_t **statement_lists, nnode_t *m
4785
4781
/* Don't match, so this signal is an IMPLIED SIGNAL !!! */
4786
4782
npin_t *pin = combined_lists->pins [i];
4787
4783
4788
- switch (type_of_circuit )
4784
+ switch (circuit_edge )
4789
4785
{
4790
- case RISING_EDGE_SENSITIVITY:
4791
- {
4792
- /* implied signal for mux */
4793
- if (lookup_implicit_memory_input (pin->name ))
4794
- {
4795
- // If the mux feeds an implicit memory, imply zero.
4796
- add_input_pin_to_node (mux_node, get_zero_pin (verilog_netlist), pin_index);
4797
- }
4798
- else
4799
- {
4800
- /* lookup this driver name */
4801
- signal_list_t *this_pin_list = create_pins (NULL , pin->name , instance_name_prefix);
4802
- oassert (this_pin_list->count == 1 );
4803
- // add_a_input_pin_to_node_spot_idx(mux_node, get_zero_pin(verilog_netlist), pin_index);
4804
- add_input_pin_to_node (mux_node, this_pin_list->pins [0 ], pin_index);
4805
- /* clean up */
4806
- free_signal_list (this_pin_list);
4807
- }
4808
- break ;
4809
- }
4786
+ case RISING_EDGE_SENSITIVITY: // fallthrough
4810
4787
case FALLING_EDGE_SENSITIVITY:
4811
4788
{
4812
4789
/* implied signal for mux */
0 commit comments