1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MyHDLに出てくるデコレータをReferenceから整理しました。

instance()

最も一般的なデコレータです。自動的にgeneratorを作ります。

def ClkDriver(clk, period=20):
    
    lowTime = int(period/2)
    highTime = period - lowTime

    @instance
    def driveClk():
        while True:
            yield delay(lowTime)
            clk.next = 1
            yield delay(highTime)
            clk.next = 0

    return driveClk

always()

決まったパターンで使うデコレータ。クロックの立ち上がりで動作する回路の例

    @always(clk.posedge)
    def write():
        if we:
            mem[addr].next = din

always_comb()

組み合わせ回路を記述するデコレータ。

    @always_comb
    def read():
        dout.next = mem[addr]

always_seq()

順序回路を記述するデコレータ。

def Inc(count, enable, clock, reset):
    @always_seq(clock.posedge, reset=reset)
    def incLogic():
        if enable:
            count.next = count + 1

    return incLogic
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?