@@ -1844,55 +1844,87 @@ void graphVizOutputAst_traverse_node(FILE* fp, ast_node_t* node, ast_node_t* fro
1844
1844
int my_label = unique_label_count++;
1845
1845
fprintf (fp, " \t %d [label=<" , my_label);
1846
1846
1847
- if (node->identifier_node ) {
1848
- fprintf (fp, " %s<br/>" , node->identifier_node ->types .identifier );
1849
- }
1850
- fprintf (fp, " %s" , ids_STR[node->type ]);
1851
1847
switch (node->type ) {
1852
1848
case VAR_DECLARE: {
1853
- std::stringstream temp;
1854
- if (node->types .variable .is_input ) temp << " INPUT" ;
1855
- if (node->types .variable .is_output ) temp << " OUTPUT" ;
1856
- if (node->types .variable .is_inout ) temp << " INOUT" ;
1857
- if (node->types .variable .is_port ) temp << " PORT" ;
1858
- if (node->types .variable .is_parameter ) temp << " PARAMETER" ;
1859
- if (node->types .variable .is_wire ) temp << " WIRE" ;
1860
- if (node->types .variable .is_reg ) temp << " REG" ;
1861
-
1862
- fprintf (fp, " : %s" , temp.str ().c_str ());
1849
+ if (node->types .variable .is_input )
1850
+ fprintf (fp, " input" );
1851
+ else if (node->types .variable .is_output )
1852
+ fprintf (fp, " output" );
1853
+ else if (node->types .variable .is_inout )
1854
+ fprintf (fp, " inout" );
1855
+ else if (node->types .variable .is_parameter )
1856
+ fprintf (fp, " parameter" );
1857
+
1858
+ if (node->types .variable .is_wire )
1859
+ fprintf (fp, " wire" );
1860
+ else if (node->types .variable .is_reg )
1861
+ fprintf (fp, " reg" );
1862
+
1863
+ oassert (node->identifier_node != NULL );
1864
+ fprintf (fp, " %s" , node->identifier_node ->types .identifier );
1865
+
1863
1866
break ;
1864
1867
}
1865
1868
case NUMBERS:
1866
- fprintf (fp, " : %s (%s) " ,
1869
+ fprintf (fp, " %s<br/>%s " ,
1867
1870
node->types .vnumber ->to_vstring (' h' ).c_str (),
1868
- node->types .vnumber ->to_vstring (' s ' ).c_str ());
1871
+ node->types .vnumber ->to_vstring (' b ' ).c_str ());
1869
1872
break ;
1870
1873
1871
1874
case UNARY_OPERATION: // fallthrough
1872
1875
case BINARY_OPERATION:
1873
- fprintf (fp, " : %s" , name_based_on_op (node->types .operation .op ));
1876
+ fprintf (fp, " %s" , name_based_on_op (node->types .operation .op ));
1874
1877
break ;
1875
1878
1876
1879
case IDENTIFIERS:
1877
- fprintf (fp, " : %s" , node->types .identifier );
1880
+ oassert (node->types .identifier );
1881
+ fprintf (fp, " %s" , node->types .identifier );
1878
1882
break ;
1879
1883
1880
1884
default :
1885
+ fprintf (fp, " %s" , ids_STR[node->type ]);
1886
+ if (node->identifier_node ) {
1887
+ fprintf (fp, " <br/>%s" , node->identifier_node ->types .identifier );
1888
+ }
1881
1889
break ;
1882
1890
}
1891
+
1883
1892
fprintf (fp, " >];\n " );
1884
1893
1885
1894
/* print out the connection with the previous node */
1886
1895
if (from != NULL ) {
1887
1896
fprintf (fp, " \t %d -> %d;\n " , from_num, my_label);
1888
1897
}
1889
- // if (node->identifier_node) {
1890
- // graphVizOutputAst_traverse_node(fp, node->identifier_node, node, my_label, 1);
1891
- // }
1892
- for (long i = 0 ; i < node->num_children ; i++) {
1893
- graphVizOutputAst_traverse_node (fp, node->children [i], node, my_label);
1898
+
1899
+ if (node->type == VAR_DECLARE) {
1900
+ graphVizOutputAst_Var_Declare (fp, node, my_label);
1901
+ } else {
1902
+ for (long i = 0 ; i < node->num_children ; i++) {
1903
+ graphVizOutputAst_traverse_node (fp, node->children [i], node, my_label);
1904
+ }
1905
+ }
1906
+ }
1907
+
1908
+ /* ---------------------------------------------------------------------------------------------
1909
+ * (function: graphVizOutputAst_Var_Declare)
1910
+ *-------------------------------------------------------------------------------------------*/
1911
+ void graphVizOutputAst_Var_Declare (FILE* fp, ast_node_t * node, int from_num) {
1912
+ for (int i = 0 ; i < 4 ; i += 2 ) {
1913
+ /* range come in pairs so we go two at a time */
1914
+ if (node->children [i] && node->children [i + 1 ]) {
1915
+ /* increase the unique count for other nodes since ours is recorded */
1916
+ int my_label = unique_label_count++;
1917
+ fprintf (fp,
1918
+ " \t %d [label=<RANGE_REF>];\n "
1919
+ " \t %d -> %d;\n " ,
1920
+ my_label, from_num, my_label);
1921
+
1922
+ graphVizOutputAst_traverse_node (fp, node->children [i], node, my_label);
1923
+ graphVizOutputAst_traverse_node (fp, node->children [i + 1 ], node, my_label);
1924
+ }
1894
1925
}
1895
1926
}
1927
+
1896
1928
/* ---------------------------------------------------------------------------------------------
1897
1929
* (function: newVarDeclare) for 2D Array
1898
1930
*-------------------------------------------------------------------------------------------*/
0 commit comments