Hi Giacomo,

You cannot include a header in an .sm file. As far as I know, you also
can't use general enums in SLICC either. You could take advantage of the
fact that enums are compatible with integers, possibly, to get around this.
You can also declare enums in the SLICC, but that will create another enum
type. See src/mem/ruby/protocol/RubySlicc_Exports.sm for some examples of
SLICC enums. For example, RubyRequestType is used in the gem5 C++ code, but
the enum is declared in SLICC.

Generally, if you need to reference a type outside of SLICC, you have to
expose it by using the `external_type` keyword or by creating a SLICC
`structure` and declaring it as `external=True`. You can do this wherever
you want in the SLICC code before you use the type (i.e., you don't have to
do it in RubySlicc_Types.sm). SLICC `structures` are equivalent to C++
classes and `external_type`s can be classes, typedefs, etc. You can try to
declare your enum as an external type, but you won't be able to use the
enumeration constants in SLICC, as far as I know.

This is a good example of what I was taught about SLICC/Ruby when I was
first learning about it from Brad: Whenever you do anything new with SLICC,
you'll have to make modifications to the language.

I'm not certain of this, but it's most likely that if you want to use a
gem5 enum in SLICC, you'll have to extend the compiler to support that (or
just find a way around it).

Cheers,
Jason

On Tue, Jan 28, 2020 at 3:36 AM Giacomo Travaglini <
[email protected]> wrote:

> A question to the Ruby experts:
>
> How can I include a header file in a .sm one?
> More specifically I would like to refer to a gem5 enum from within the sm
> file.
>
> Thanks
>
> Giacomo
> IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
> _______________________________________________
> gem5-dev mailing list
> [email protected]
> http://m5sim.org/mailman/listinfo/gem5-dev
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to