Skip to content

Write logic for structs

Retiré du book:

It is also possible to add methods that set field values::

type my_struct_t
    data  : u32
    valid : bool

    def push!(value: u32)
        data  = value
        valid = True

    def pop!() : u32
        valid = False
        = data
let my_struct : my_struct_t
my_struct.push!(some_data) when dest_is_ready
reg my_struct : my_struct_t init ?
reg got : u32 init 0
    = my_struct.pop!() when my_struct.valid
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information