Skip to content

Commit

Permalink
src: Fix couple of SDF parser TODOs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej.ille committed Aug 26, 2024
1 parent 8a0bcab commit c0d1bb6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/sdf/sdf-node.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static const imask_t has_map[S_LAST_NODE_KIND] = {
(I_IDENT | I_VALUE),

// S_SIGNAL
(I_SUBKIND | I_IDENT | I_DIMS | I_FLAGS | I_VALUE),
(I_SUBKIND | I_IDENT | I_DIMS | I_FLAGS | I_VALUE | I_CONDS),

// S_DELVAL
(I_LITERALS),
Expand Down
40 changes: 26 additions & 14 deletions src/sdf/sdf-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,14 @@ static ident_t p_cell_instance(void)
consume(tLPAREN);
consume(tINSTANCE);

// TODO: Hierarchical identifier shall be optional here!
ident_t hier = optional(tTIMES) ? ident_new("*") :
p_hierarchical_identifier();
ident_t hier = NULL;
if (scan(tTIMES, tID)) {
if (optional(tTIMES))
hier = ident_new("*");
else
hier = p_hierarchical_identifier();
}

consume(tRPAREN);

return hier;
Expand Down Expand Up @@ -1181,7 +1186,8 @@ static sdf_node_t p_path_constraint(void)
sdf_add_signal(constr, p_port_instance());
sdf_add_signal(constr, p_port_instance());

// TODO: Add optional follow-up of "port_instance"
while (scan(tID))
sdf_add_signal(constr, p_port_instance());

sdf_add_value(constr, p_rvalue());
sdf_add_value(constr, p_rvalue());
Expand Down Expand Up @@ -1272,8 +1278,10 @@ static sdf_node_t p_sum_constraint(void)
sdf_add_signal(constr, p_constraint_path());
sdf_add_signal(constr, p_constraint_path());

// TODO: Add optional follow-up constraint paths.
// To decide if it is rvalue or constraint_path, we need second token lookup!
// Both next follow-up tokens start with tLPAREN.
// Decide based on second next token
if (peek_nth(2) == tID)
sdf_add_signal(constr, p_constraint_path());

sdf_add_value(constr, p_rvalue());
if (scan(tLPAREN))
Expand Down Expand Up @@ -1596,11 +1604,15 @@ static sdf_node_t p_port_tchk(void)
consume(tLPAREN);
consume(tCOND);

// TODO: Add optional qstring
sdf_node_t cond = sdf_new(S_COND);

if (scan(tSTRING))
sdf_set_ident(cond, p_qstring());

sdf_set_expr(cond, p_timing_check_condition());

sdf_node_t expr = p_timing_check_condition();
sdf_node_t port = p_port_spec();
sdf_set_expr(port, expr);
sdf_add_cond(port, cond);

consume(tRPAREN);

Expand Down Expand Up @@ -1691,7 +1703,7 @@ static sdf_node_t p_skew_timing_check(void)
\
sdf_node_t tcheck = sdf_new(S_TIMING_CHECK); \
sdf_set_subkind(tcheck, subkind); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_value(tcheck, p_value()); \
\
consume(tRPAREN); \
Expand All @@ -1718,8 +1730,8 @@ DEFINE_1P1V_TCHK(p_period_timing_check, "period timing check", tPERIOD, S_TCHECK
\
sdf_node_t tcheck = sdf_new(S_TIMING_CHECK); \
sdf_set_subkind(tcheck, subkind); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_value(tcheck, p_rvalue()); \
sdf_add_value(tcheck, p_rvalue()); \
\
Expand Down Expand Up @@ -1750,8 +1762,8 @@ DEFINE_2P2RV_TCHK(p_recrem_timing_check, "recrem timing check", tRECREM,
\
sdf_node_t tcheck = sdf_new(S_TIMING_CHECK); \
sdf_set_subkind(tcheck, subkind); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_signal(tcheck, p_port_tchk()); \
sdf_add_value(tcheck, p_value()); \
\
consume(tRPAREN); \
Expand Down

0 comments on commit c0d1bb6

Please sign in to comment.