aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/deb573721/573721_deb.vhd
blob: de8fe0bc4fa00b159b68d78539d8397d7ac89efa (plain)
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
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity test is end entity;

architecture a_test of test is
    signal a, b : std_logic;
    signal i1 : integer := 1;
    constant i2 : integer := 1;
    signal t1 : time := 1 ns;
    constant t2 : time := 1 ns;
begin
    process
        variable m : boolean;
        variable ip1 : integer := 1;
        constant ip2 : integer := 1;
        variable tp1 : time := 1 ns;
        constant tp2 : time := 1 ns;
    begin
        m := a'stable(1 ns);        --works ... literal
        m := a'stable(i1 * ns);     --works ... signal * unit
        m := a'stable(i2 * ns);     --works ... constant * unit
        m := a'stable(t1);          --works ... signal (time)
        m := a'stable(t2);          --works ... constant (time)
        m := a'stable(ip1 * ns);    --crashs ... LOCAL variable * unit
        m := a'stable(ip2 * ns);    --works ...  LOCAL constant * unit
        m := a'stable(tp1);         --crashs ... LOCAL variable (time)
        m := a'stable(tp2);         --crashs ... LOCAL constant (time)
        --
        m := a'quiet(1 ns);        --works
        m := a'quiet(i1 * ns);     --works
        m := a'quiet(i2 * ns);     --works
        m := a'quiet(t1);          --works
        m := a'quiet(t2);          --works
        m := a'quiet(ip1 * ns);    --crashs
        m := a'quiet(ip2 * ns);    --works
        m := a'quiet(tp1);         --crashs
        m := a'quiet(tp2);         --crashs
        --
        b <= a'delayed(1 ns);        --works
        b <= a'delayed(i1 * ns);     --works
        b <= a'delayed(i2 * ns);     --works
        b <= a'delayed(t1);          --works
        b <= a'delayed(t2);          --works
        b <= a'delayed(ip1 * ns);    --crashs
        b <= a'delayed(ip2 * ns);    --works
        b <= a'delayed(tp1);         --crashs
        b <= a'delayed(tp2);         --crashs
    end process;
end architecture;
, "%s\n", msg); exit(1); } void gfxSleepMilliseconds(delaytime_t ms) { struct timespec ts; switch(ms) { case TIME_IMMEDIATE: linuxyield(); return; case TIME_INFINITE: while(1) sleep(60); return; default: ts.tv_sec = ms / 1000; ts.tv_nsec = (ms % 1000) * 1000000; nanosleep(&ts, 0); return; } } void gfxSleepMicroseconds(delaytime_t us) { struct timespec ts; switch(us) { case TIME_IMMEDIATE: linuxyield(); return; case TIME_INFINITE: while(1) sleep(60); return; default: ts.tv_sec = us / 1000000; ts.tv_nsec = (us % 1000000) * 1000; nanosleep(&ts, 0); return; } } systemticks_t gfxSystemTicks(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; } gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) { gfxThreadHandle th; (void) stackarea; (void) stacksz; (void) prio; // Implementing priority with pthreads is a rats nest that is also pthreads implementation dependent. // Only some pthreads schedulers support it, some implementations use the operating system process priority mechanisms. // Even those that do support it can have different ranges of priority and "normal" priority is an undefined concept. // Across different UNIX style operating systems things can be very different (let alone OS's such as Windows). // Even just Linux changes the way priority works with different kernel schedulers and across kernel versions. // For these reasons we ignore the priority. if (pthread_create(&th, 0, fn, param)) return 0; return th; } threadreturn_t gfxThreadWait(gfxThreadHandle thread) { threadreturn_t retval; if (pthread_join(thread, &retval)) return 0; return retval; } #if GFX_USE_POSIX_SEMAPHORES void gfxSemInit(gfxSem *pSem, semcount_t val, semcount_t limit) { pSem->max = limit; sem_init(&pSem->sem, 0, val); } void gfxSemDestroy(gfxSem *pSem) { sem_destroy(&pSem->sem); } bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) { switch (ms) { case TIME_INFINITE: return sem_wait(&pSem->sem) ? FALSE : TRUE; case TIME_IMMEDIATE: return sem_trywait(&pSem->sem) ? FALSE : TRUE; default: { struct timespec tm; clock_gettime(CLOCK_REALTIME, &tm); tm.tv_sec += ms / 1000; tm.tv_nsec += (ms % 1000) * 1000000; return sem_timedwait(&pSem->sem, &tm) ? FALSE : TRUE; } } } void gfxSemSignal(gfxSem *pSem) { int res; res = 0; sem_getvalue(&pSem->sem, &res); if (res < pSem->max) sem_post(&pSem->sem); } #else void gfxSemInit(gfxSem *pSem, semcount_t val, semcount_t limit) { pthread_mutex_init(&pSem->mtx, 0); pthread_cond_init(&pSem->cond, 0); pthread_mutex_lock(&pSem->mtx); pSem->cnt = val; pSem->max = limit; pthread_mutex_unlock(&pSem->mtx); } void gfxSemDestroy(gfxSem *pSem) { pthread_mutex_destroy(&pSem->mtx); pthread_cond_destroy(&pSem->cond); } bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) { pthread_mutex_lock(&pSem->mtx); switch (ms) { case TIME_INFINITE: while (!pSem->cnt) pthread_cond_wait(&pSem->cond, &pSem->mtx); break; case TIME_IMMEDIATE: if (!pSem->cnt) { pthread_mutex_unlock(&pSem->mtx); return FALSE; } break; default: { struct timespec tm; clock_gettime(CLOCK_REALTIME, &tm); tm.tv_sec += ms / 1000; tm.tv_nsec += (ms % 1000) * 1000000; while (!pSem->cnt) { // We used to test the return value for ETIMEDOUT. This doesn't // work in some current pthread libraries which return -1 instead // and set errno to ETIMEDOUT. So, we will return FALSE on any error // including a ETIMEDOUT. if (pthread_cond_timedwait(&pSem->cond, &pSem->mtx, &tm)) { pthread_mutex_unlock(&pSem->mtx); return FALSE; } } } break; } pSem->cnt--; pthread_mutex_unlock(&pSem->mtx); return TRUE; } void gfxSemSignal(gfxSem *pSem) { pthread_mutex_lock(&pSem->mtx); if (pSem->cnt < pSem->max) { pSem->cnt++; pthread_cond_signal(&pSem->cond); } pthread_mutex_unlock(&pSem->mtx); } #endif // GFX_USE_POSIX_SEMAPHORES #endif /* GFX_USE_OS_LINUX */