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