Kuree / kratos

:crossed_swords: Debuggable hardware generator
https://kratos-doc.readthedocs.io
BSD 2-Clause "Simplified" License
67 stars 9 forks source link

static boolean and loop integer in one if statement #177

Open jake-ke opened 2 years ago

jake-ke commented 2 years ago

the following example code does not work

from kratos import *

class Example(Generator):
    def __init__(self,
                 area_opt=True):

        super().__init__("example")
        self.area_opt = area_opt

        self._b = self.output("b", 2)

        @always_comb
        def tb_ctrl():
            for i in range(2):
                if i == 0 and self.area_opt:
                # if i == 0:
                    self._b[i] = 0
                else:
                    self._b[i] = 1
        self.add_code(tb_ctrl)

if __name__ == "__main__":
    example_dut = Example()
    verilog(example_dut, filename="example.sv")