|
| 1 | +# RUN: %PYTHON% %s | FileCheck %s |
| 2 | + |
| 3 | +from pycde import Module, Clock, Reset, Input, Output |
| 4 | +from pycde.seq import FIFO |
| 5 | +from pycde.testing import unittestmodule |
| 6 | +from pycde.types import Bits, UInt |
| 7 | + |
| 8 | +from pycde.module import generator |
| 9 | + |
| 10 | +# CHECK-LABEL: hw.module @SimpleFIFOTest(in %clk : !seq.clock, in %rst : i1) |
| 11 | +# CHECK-NEXT: %false = hw.constant false |
| 12 | +# CHECK-NEXT: [[R0:%.+]] = hwarith.constant 0 : ui32 |
| 13 | +# CHECK-NEXT: %out, %full, %empty, %almostFull, %almostEmpty = seq.fifo depth 16 in [[R0]] rdEn %false wrEn %false clk %clk rst %rst : ui32 |
| 14 | + |
| 15 | + |
| 16 | +@unittestmodule(run_passes=False) |
| 17 | +class SimpleFIFOTest(Module): |
| 18 | + clk = Clock() |
| 19 | + rst = Reset() |
| 20 | + |
| 21 | + @generator |
| 22 | + def construct(ports): |
| 23 | + c0 = Bits(1)(0) |
| 24 | + ui32 = UInt(32)(0) |
| 25 | + |
| 26 | + fifo = FIFO(type=UInt(32), depth=16, clk=ports.clk, rst=ports.rst) |
| 27 | + fifo.push(ui32, c0) |
| 28 | + fifo.pop(c0) |
| 29 | + |
| 30 | + |
| 31 | +# CHECK-LABEL: hw.module @SimpleFIFOTestRd1(in %clk : !seq.clock, in %rst : i1) |
| 32 | +# CHECK-NEXT: %false = hw.constant false |
| 33 | +# CHECK-NEXT: [[R0:%.+]] = hwarith.constant 0 : ui32 |
| 34 | +# CHECK-NEXT: %out, %full, %empty, %almostFull, %almostEmpty = seq.fifo depth 16 rd_latency 1 in [[R0]] rdEn %false wrEn %false clk %clk rst %rst : ui32 |
| 35 | + |
| 36 | + |
| 37 | +@unittestmodule(run_passes=False) |
| 38 | +class SimpleFIFOTestRd1(Module): |
| 39 | + clk = Clock() |
| 40 | + rst = Reset() |
| 41 | + |
| 42 | + @generator |
| 43 | + def construct(ports): |
| 44 | + c0 = Bits(1)(0) |
| 45 | + ui32 = UInt(32)(0) |
| 46 | + |
| 47 | + fifo = FIFO(type=UInt(32), |
| 48 | + depth=16, |
| 49 | + clk=ports.clk, |
| 50 | + rst=ports.rst, |
| 51 | + rd_latency=1) |
| 52 | + fifo.push(ui32, c0) |
| 53 | + fifo.pop(c0) |
0 commit comments