File: perf_inferWaiter.py

package info (click to toggle)
myhdl 0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,728 kB
  • sloc: python: 25,033; ansic: 2,203; makefile: 243; sh: 206
file content (72 lines) | stat: -rw-r--r-- 1,997 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#  This file is part of the myhdl library, a Python package for using
#  Python as a Hardware Description Language.
#
#  Copyright (C) 2003-2008 Jan Decaluwe
#
#  The myhdl library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation; either version 2.1 of the
#  License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.

#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

""" Run the unit tests for inferWaiter """
from __future__ import absolute_import


import random
from random import randrange
random.seed(1) # random, but deterministic

import myhdl
from myhdl import *
from myhdl._Waiter import _SignalWaiter,_SignalTupleWaiter, _DelayWaiter, \
                          _EdgeWaiter, _EdgeTupleWaiter, _Waiter
from test_inferWaiter import *



QUIET=1


N=10

def bench(genFunc, waiterType):

    a, b, c, d, r, s = [Signal(intbv()) for i in range(6)]

    s = [Signal(intbv()) for i in range(N)]
    gen_inst_s = []

    for i in range(N):
        gen_inst_s.append(waiterType(genFunc(a, b, c, d, s[i])))

    def stimulus():
        for i in range(5000):
            yield delay(randrange(1, 10))
            if randrange(2):
                a.next = randrange(32)
            if randrange(2):
                b.next = randrange(32)
            c.next = randrange(2)
            d.next = randrange(2)
        raise StopSimulation()

    return gen_inst_s, _Waiter(stimulus())


gen = SignalGen2

waiter = _Waiter

sim = Simulation(bench(gen, waiter))
sim.run()