LoginSignup
0
0

More than 3 years have passed since last update.

windowsでiverilog その50

Posted at

概要

windowsでiverilogやってみた。
polyphonyで浮動小数点やってみる。
大小比較やってみた。

サンプルコード

import polyphony
from polyphony import testbench, module, is_worker_running
from polyphony.io import Port
from polyphony.typing import bit, bit32

@module
class gt:
    def __init__(self):
        self.a = Port(bit32, 'in')
        self.b = Port(bit32, 'in')
        self.c = Port(bit, 'out')
        self.append_worker(self.worker)
    def worker(self):
        while is_worker_running():
            a0:bit32 = self.a.rd()
            b0:bit32 = self.b.rd()
            c0:bit = 0
            if (a0 < b0):
                c0 = 1
            self.c(c0)

m = gt()

@testbench
def test(m):
    m.a.wr(0x3f000000)
    m.b.wr(0x3f800000)
    print ("0.5 < 1.0")
    c = m.c.rd()
    print(c)
    m.a.wr(0x40000000)
    m.b.wr(0x3f800000)
    print ("2.0 < 1.0")
    c = m.c.rd()
    print(c)

test(m)



python実行結果



0.5 < 1.0
1
2.0 < 1.0
0


以上。

0
0
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
0
0