OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [rtl/] [vlib/] [simlib/] [simbididly.vhd] - Blame information for rev 37

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 wfjm
-- $Id: simbididly.vhd 793 2016-07-23 19:38:55Z mueller $
2
--
3
-- Copyright 2016- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    simbididly - sim
16
-- Description:    Bi-directional bus delay for test benches
17
--
18
-- Dependencies:   -
19
-- Test bench:     tb_simbididly
20
-- Target Devices: generic
21
-- Tool versions:  xst 14.7; viv 2016.2; ghdl 0.33
22
-- Revision History: 
23
-- Date         Rev Version  Comment
24
-- 2016-07-23   793   1.0.1  ensure non-zero DELAY
25
-- 2016-07-17   789   1.0    Initial version (use separate driver regs now)
26
-- 2016-07-16   787   0.1    First draft
27
------------------------------------------------------------------------------
28
 
29
library ieee;
30
use ieee.std_logic_1164.all;
31
use ieee.numeric_std.all;
32
use work.slvtypes.all;
33
 
34
entity simbididly is                  -- test bench bi-directional bus delay
35
  generic (
36
    DELAY : Delay_length;             -- transport delay between A and B (>0ns!)
37
    DWIDTH : positive := 16);         -- data port width
38
   port (
39
    A : inout slv(DWIDTH-1 downto 0); -- port A
40
    B : inout slv(DWIDTH-1 downto 0)  -- port B
41
  );
42
end entity simbididly;
43
 
44
 
45
architecture sim of simbididly is
46
 
47
  type state_type is (
48
    s_idle,                             -- s_idle: both ports high-z
49
    s_a2b,                              -- s_a2b: A drives, B listens
50
    s_b2a                               -- s_b2a: B drives, A listens
51
  );
52
 
53
  constant all_z : slv(DWIDTH-1 downto 0) := (others=>'Z');
54
 
55
  signal R_STATE : state_type := s_idle;
56
  signal R_A     : slv(DWIDTH-1 downto 0) := (others=>'Z');
57
  signal R_B     : slv(DWIDTH-1 downto 0) := (others=>'Z');
58
 
59
begin
60
 
61
  process
62
 
63
    variable istate : state_type := s_idle;
64
 
65
  begin
66
 
67
    -- the delay model can enter into a delta cycle oszillation mode
68
    -- when DELAY is 0 ns. So ensure the delay is non-zero
69
    assert DELAY > 0 ns report "DELAY > 0 ns" severity failure;
70
 
71
    while true loop
72
 
73
      -- if idle check whether A or B port starts to drive bus
74
      -- Note: both signal R_STATE and variable istate is updated
75
      --   istate is needed to control the driver section below in the
76
      --   same delta cycle based on the most recent state state
77
      istate := R_STATE;
78
 
79
      if now > 0 ns then                -- to avoid startup problems
80
        if R_STATE = s_idle then
81
          if A /= all_z then
82
            R_STATE <= s_a2b;
83
            istate  := s_a2b;
84
          elsif B /= all_z then
85
            R_STATE <= s_b2a;
86
            istate  := s_b2a;
87
          end if;
88
        end if;
89
      end if;
90
 
91
      case istate is
92
        when s_a2b =>
93
          R_B <= transport A after DELAY;
94
          if A = all_z then R_STATE <= s_idle after DELAY; end if;
95
        when s_b2a =>
96
          R_A <= transport B after DELAY;
97
          if B = all_z then R_STATE <= s_idle after DELAY; end if;
98
        when others => null;
99
      end case;
100
 
101
      -- Note: the driver clash check is done by comparing an internal signal
102
      --   with the external signal. If they differ this indicates a clash.
103
      --   Just checking for 'x' gives false alarms when the bus is driven
104
      --   with 'x', which can for example come from a memory model before
105
      --   valid data is available.
106
      if now > 0 ns then                -- to avoid startup problems
107
        case istate is
108
          when s_a2b =>
109
            assert B = R_B report "driver clash B port" severity error;
110
          when s_b2a =>
111
            assert A = R_A report "driver clash A port" severity error;
112
          when others => null;
113
        end case;
114
      end if;
115
 
116
      wait on A,B;
117
    end loop;
118
 
119
  end process;
120
 
121
  A <= R_A;
122
  B <= R_B;
123
 
124
end sim;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.