English 中文(简体)
Understanding types in SystemC
原标题:

I am a beginner in SystemC programming and there is one thing I noticed (looking in the SystemC official documentation): all types that I used to deal with in VHDL simulations have not been "ported" to SystemC.

I mean:

  1. Consider std_logic in the VHDL standard library, there is not an equivalent in SystemC, however, in the SystemC documentation, I see many examples using bool.
  2. Consider std_logic_vector, I see no equivalent in SystemC. Instead I can see, in many examples, usage of sc_int.

So I m thinking that SystemC does not provide types in order to manage single bits or electric signals, but it provides a higher abstraction like in every common C/C++ applications.

Is it so or am I missing something?

最佳回答
  1. Consider std_logic in the vhdl standard library, there is not an equivalent in SystemC, however, in the sysc documentation, I see many examples using bool.
  2. Consider std_logic_vector, I see no equivalent in sysc. Instead I can see, in many examples, usage of sc_int.

It s not all that correct.

In SystemC you can use sc_logic and sc_lv< T > as std_logic and std_logic_vector respectively.

You can assign to SC_LOGIC_0 or SC_LOGIC_1 literals to sc_logic.

While you can use integer, hex or even bit-specific literal to assign sc_lv< T > a value.

For example:

class some_device : sc_module
{
    sc_out< sc_lv<32> > address;
    sc_out< sc_logic > write_enable;

    SC_CTOR (some_device)
    {
        write_enable.initialize(SC_LOGIC_0);

        /* The following three lines do the same thing. 
         * Obviously you won t use all three at the same time... */
        address.initialize(0b00001111000011110000111100001111);
        address.initialize(0x0F0F0F0F);
        address.iniziatize(252645135);
    }
}

Hope that helps.

问题回答

It does have some types: sc_int, sc_bv (bitvector) etc.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签