systemc-clang icon indicating copy to clipboard operation
systemc-clang copied to clipboard

Variable declaration (hVardecl) is not in the front the a process

Open zhuanhao-wu opened this issue 1 year ago • 0 comments

https://github.com/intel/systemc-compiler/blob/main/tests/method/test_ff_latch.cpp#L128

Notice that the i__local_3 of the for loop is declared after a hVarAssign, and it should be in front of the process.

void async_rst_tff() {
    sc_uint<16> b = 0;

    async_rst_tff_out = 0x0;
    async_rst_tff_out2 = 0x0;
    async_rst_tff_out3 = 0x0;

    wait();             // 0

    while (true) {
        sc_uint<16> a = async_rst_tff_out.read();
        async_rst_tff_out2 = data_in.read() ^ async_rst_tff_out2.read();

        for (int i = 0; i< 16; i++) {
            if (data_in.read()[i]) {
                a[i]  = !async_rst_tff_out.read()[i];
            }
        }
        async_rst_tff_out = a;


        for (int i = 0; i< 16; i++) {
            if (data_in.read()[i]) {
                b[i]  = !async_rst_tff_out3.read()[i];
            }
        }
        async_rst_tff_out3 = b;


        wait();         // 1

  }
}


hVarAssign  NONAME [
  hVarref a_async_rst_tff_thread_1 NOLIST
  hSigAssignR read [
    hVarref async_rst_tff_out NOLIST
  ]
]
hBinop = [
  hVarref async_rst_tff_out2 NOLIST
  hBinop ^ [
    hSigAssignR read [
      hVarref data_in NOLIST
    ]
    hSigAssignR read [
      hVarref async_rst_tff_out2 NOLIST
    ]
  ]
]
hVarAssign  NONAME [
  hVarref i_async_rst_tff_thread_2 NOLIST
  hLiteral 0 NOLIST
]
hVardecl i__local_3 [
  hTypeinfo  NONAME [
    hType int NOLIST
  ]
]
hForStmt  NONAME [
  hVarAssign  NONAME [
    hVarref i__local_3 NOLIST
    hLiteral 0 NOLIST
...

zhuanhao-wu avatar Oct 03 '22 17:10 zhuanhao-wu