简体   繁体   中英

SystemC:Reading Input From Command Line .read()[index]

I am new to SystemC. I know that systemC is a library added to C++ although some may say it is a languages. My question is I have the code below, and I don't get what will be the value of dataout.read()[i-1]; . Please help. I tried to search answers online, but I cannot find any.

   sc_inout<sc_int<8> > dataout;
    sc_int<8> data;

    for(i = 7; i > 0; i--)
                    data[i] = dataout.read()[i-1];

SystemC is a library for C++. So you have to learn C++ language before learning SystemC.

You can get a value of object by printing it to console or using debugger.

For example:

for(i = 7; i > 0; i--)
    std::cout << dataout.read()[i-1] << std::endl;

[] is the bit accessor on an sc_int<> type.
.read() on the sc_inout<> port gets you the value that was written to the port in your example it returns an sc_int<8> the [i-1] get's you a bit which is assigned to a different bit in data with data[i] = . It looks like someone is trying to shift the bits. What the actual value is will depend one what has been written to dataout. There is nothing there related to reading the command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM