Skip to content

How to use complex expressions in "vsc.if_then" and “vsc.else_if” constraint? #228

@Hsunagwen

Description

@Hsunagwen

The vsc.if_then constraint does not seem to support complex expressions. Is this problem caused by my use error?And is there a solution to use complex expressions in "vsc.if_then" and “vsc.else_if” constraint?

import vsc

@vsc.randobj
class my_s:
    def __init__(self):
        self.height = vsc.rand_bit_t(14)
        self.width = vsc.rand_bit_t(14)
        self.stride= vsc.rand_bit_t(3)
        self.mode= vsc.rand_bit_t(1)

    @vsc.constraint
    def s_cons(self):
        with vsc.if_then(((self.width / self.stride) % 32 != 0) | ((self.height / self.stride) % 32 != 0)):
            self.mode.inside(vsc.rangelist(1))
        with vsc.else_then:
            self.mode.inside(vsc.rangelist(0))

s = my_s()
s.width = 768
s.height = 800
s.stride = 2
width vsc.raw_mode():
    s.width.rand_mode = False
width vsc.raw_mode():
    s.height.rand_mode = False
width vsc.raw_mode():
    s.stride.rand_mode = False
s.randomize(solve_fail_debug=1)

This will prompt an error:
TypeError: unsupported operand type(s) for /: 'ValueScalar' and 'ValueScalar'

pyvsc version: 0.8.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions