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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [rtl/] [vlib/] [rbus/] [rb_mon.vhd] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 wfjm
-- $Id: rb_mon.vhd 599 2014-10-25 13:43:56Z mueller $
2 2 wfjm
--
3 27 wfjm
-- Copyright 2007-2014 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 2 wfjm
--
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 9 wfjm
-- Module Name:    rb_mon - sim
16
-- Description:    rbus monitor (for tb's)
17 2 wfjm
--
18
-- Dependencies:   -
19
-- Test bench:     -
20 27 wfjm
-- Tool versions:  xst 8.2-14.7; ghdl 0.18-0.31
21 9 wfjm
--
22 2 wfjm
-- Revision History: 
23
-- Date         Rev Version  Comment
24 27 wfjm
-- 2014-10-25   599   4.1.1  use writeoptint()
25
-- 2014-09-03   591   4.1    add burst counter; add state checker
26
-- 2014-08-30   589   4.0    use hex for addr; 4 bit STAT; monitor ACK=0
27
-- 2014-08-15   583   3.5    rb_mreq addr now 16 bit
28 17 wfjm
-- 2011-12-23   444   3.1    CLK_CYCLE now integer
29 13 wfjm
-- 2011-11-19   427   3.0.1  now numeric_std clean
30 9 wfjm
-- 2010-12-22   346   3.0    renamed rritb_rbmon -> rb_mon
31 2 wfjm
-- 2010-06-05   301   2.1.1  renamed _rpmon -> _rbmon
32
-- 2010-06-03   299   2.1    new init encoding (WE=0/1 int/ext)
33
-- 2010-05-02   287   2.0.1  rename RP_STAT->RB_STAT,AP_LAM->RB_LAM
34
--                           drop RP_IINT signal from interfaces
35
-- 2008-08-24   162   2.0    with new rb_mreq/rb_sres interface
36
-- 2008-03-24   129   1.2.1  CLK_CYCLE now 31 bits
37
-- 2007-12-23   105   1.2    added AP_LAM display
38
-- 2007-11-24    98   1.1    added RP_IINT support
39
-- 2007-08-27    76   1.0    Initial version 
40
------------------------------------------------------------------------------
41
 
42
library ieee;
43
use ieee.std_logic_1164.all;
44 13 wfjm
use ieee.numeric_std.all;
45 2 wfjm
use ieee.std_logic_textio.all;
46
use std.textio.all;
47
 
48
use work.slvtypes.all;
49
use work.simlib.all;
50 9 wfjm
use work.rblib.all;
51 2 wfjm
 
52 9 wfjm
entity rb_mon is                        -- rbus monitor (for tb's)
53 2 wfjm
  generic (
54
    DBASE : positive :=  2);            -- base for writing data values
55
  port (
56
    CLK  : in slbit;                    -- clock
57 17 wfjm
    CLK_CYCLE : in integer := 0;        -- clock cycle number
58 2 wfjm
    ENA  : in slbit := '1';             -- enable monitor output
59
    RB_MREQ : in rb_mreq_type;          -- rbus: request
60
    RB_SRES : in rb_sres_type;          -- rbus: response
61
    RB_LAM : in slv16 := (others=>'0'); -- rbus: look at me
62 27 wfjm
    RB_STAT : in slv4                   -- rbus: status flags
63 2 wfjm
  );
64 9 wfjm
end rb_mon;
65 2 wfjm
 
66
 
67 9 wfjm
architecture sim of rb_mon is
68 2 wfjm
 
69
begin
70
 
71 9 wfjm
  proc_moni: process
72 2 wfjm
    variable oline : line;
73 27 wfjm
    variable nhold  : integer := 0;
74
    variable nburst : integer := 0;
75 2 wfjm
    variable data : slv16 := (others=>'0');
76
    variable tag : string(1 to 8) := (others=>' ');
77
    variable err : slbit := '0';
78 27 wfjm
    variable r_sel : slbit := '0';
79 2 wfjm
 
80
    procedure write_data(L: inout line;
81
                         tag: in string;
82
                         data: in slv16;
83 27 wfjm
                         nhold:  in integer := 0;
84
                         nburst: in integer := 0;
85 2 wfjm
                         cond: in boolean := false;
86
                         ctxt: in string := " ") is
87
    begin
88
      writetimestamp(L, CLK_CYCLE, tag);
89 27 wfjm
      writehex(L, RB_MREQ.addr, right, 4);
90
      write(L, string'("  "));
91 2 wfjm
      writegen(L, data, right, 0, DBASE);
92 27 wfjm
      write(L, string'("  "));
93 2 wfjm
      write(L, RB_STAT, right, 4);
94 27 wfjm
      writeoptint(L, "  hold=", nhold,  2);
95
      writeoptint(L, "  b=",    nburst, 2);
96 2 wfjm
      if cond then
97
        write(L, ctxt);
98
      end if;
99
      writeline(output, L);
100
    end procedure write_data;
101
 
102
  begin
103
 
104
    loop
105
 
106
      if ENA = '0' then                 -- if disabled
107
        wait until ENA='1';             -- stall process till enabled
108
      end if;
109
 
110 13 wfjm
      wait until rising_edge(CLK);      -- check at end of clock cycle
111 2 wfjm
 
112 27 wfjm
      if RB_MREQ.aval='1' and r_sel='0' then
113
        nburst := 0;
114
      end if;
115
 
116
      if RB_MREQ.re='1' or RB_MREQ.we='1' then
117 2 wfjm
        if RB_SRES.err = '1' then
118
          err := '1';
119
        end if;
120
        if RB_SRES.busy = '1' then
121
          nhold := nhold + 1;
122
        else
123 9 wfjm
          data := (others=>'0');
124
          tag  := ": ????  ";
125
          if RB_MREQ.re = '1' then
126
            data := RB_SRES.dout;
127
            tag  :=  ": rbre  ";
128 2 wfjm
          end if;
129 9 wfjm
          if RB_MREQ.we = '1' then
130
            data := RB_MREQ.din;
131
            tag  :=  ": rbwe  ";
132
          end if;
133 2 wfjm
 
134 27 wfjm
          if RB_SRES.ack = '1' then
135
            write_data(oline, tag, data, nhold, nburst, err='1', "  ERR='1'");
136
          else
137
            write_data(oline, tag, data, nhold, nburst, true,    "  ACK='0'");
138
          end if;
139
          nburst := nburst + 1;
140 2 wfjm
          nhold := 0;
141
        end if;
142
 
143
      else
144
        if nhold > 0 then
145 27 wfjm
          write_data(oline, tag, data, nhold, nburst, true, "  TIMEOUT");
146 2 wfjm
        end if;
147
        nhold := 0;
148
        err := '0';
149
      end if;
150
 
151
      if RB_MREQ.init = '1' then                     -- init
152 27 wfjm
        write_data(oline, ": rbini ", RB_MREQ.din);
153 2 wfjm
      end if;
154
 
155
      if unsigned(RB_LAM) /= 0 then
156 27 wfjm
        write_data(oline, ": rblam ", RB_LAM, 0, 0, true, "  RB_LAM active");
157 2 wfjm
      end if;
158 27 wfjm
 
159
      r_sel := RB_MREQ.aval;
160
 
161 2 wfjm
    end loop;
162 9 wfjm
  end process proc_moni;
163 27 wfjm
 
164
  proc_check: process (CLK)
165
    variable r_sel  : slbit := '0';
166
    variable r_addr : slv16 := (others=>'0');
167
    variable idump  : boolean := false;
168
    variable oline : line;
169
  begin
170
 
171
    if rising_edge(CLK) then
172
      idump := false;
173
 
174
      -- check that addr doesn't change after 1st aval cycle
175
      if r_sel='1' and RB_MREQ.addr /= r_addr then
176
        writetimestamp(oline, CLK_CYCLE,
177
          ": FAIL rb_mon: addr changed after aval; initial addr=");
178
        writehex(oline, r_addr, right, 4);
179
        writeline(output, oline);
180
        idump := true;
181
      end if;
182
 
183
      -- check that we,re don't come together in core select time
184
      --   (aval and r_sel) and not at all outside
185
      if RB_MREQ.aval='1' and r_sel='1' then
186
        if RB_MREQ.we='1' and RB_MREQ.re='1' then
187
          writetimestamp(oline, CLK_CYCLE,
188
            ": FAIL rb_mon: we and re both active");
189
          writeline(output, oline);
190
          idump := true;
191
        end if;
192
        if RB_MREQ.init='1' then
193
          writetimestamp(oline, CLK_CYCLE,
194
            ": FAIL rb_mon: init seen inside select");
195
          writeline(output, oline);
196
          idump := true;
197
        end if;
198
      else
199
        if RB_MREQ.we='1' or RB_MREQ.re='1' then
200
          writetimestamp(oline, CLK_CYCLE,
201
            ": FAIL rb_mon: no select and we,re seen");
202
          writeline(output, oline);
203
          idump := true;
204
        end if;
205
      end if;
206
 
207
      -- check that init not seen when aval or select is active
208
      if RB_MREQ.aval='1' or r_sel='1' then
209
        if RB_MREQ.init='1' then
210
          writetimestamp(oline, CLK_CYCLE,
211
            ": FAIL rb_mon: init seen inside aval or select");
212
          writeline(output, oline);
213
          idump := true;
214
        end if;
215
      end if;
216
 
217
      -- check that SRES isn't touched unless aval or select is active
218
      if RB_MREQ.aval='0' and r_sel='0' then
219
        if RB_SRES.dout/=x"0000" or RB_SRES.busy='1' or
220
           RB_SRES.ack='1' or RB_SRES.err='1' then
221
          writetimestamp(oline, CLK_CYCLE,
222
            ": FAIL rb_mon: SRES driven outside aval or select");
223
          writeline(output, oline);
224
          idump := true;
225
        end if;
226
      end if;
227
 
228
      -- dump rbus state in case of any error seen above
229
      if idump then
230
        write(oline, string'("   FAIL: MREQ aval="));
231
        write(oline, RB_MREQ.aval, right, 1);
232
        write(oline, string'(" re="));
233
        write(oline, RB_MREQ.re  , right, 1);
234
        write(oline, string'(" we="));
235
        write(oline, RB_MREQ.we  , right, 1);
236
        write(oline, string'(" init="));
237
        write(oline, RB_MREQ.init, right, 1);
238
        write(oline, string'(" sel="));
239
        write(oline, r_sel       , right, 1);
240
        write(oline, string'(" addr="));
241
        writehex(oline, RB_MREQ.addr, right, 4);
242
        write(oline, string'(" din="));
243
        writehex(oline, RB_MREQ.din,  right, 4);
244
        writeline(output, oline);
245
 
246
        write(oline, string'("   FAIL: SRES ack="));
247
        write(oline, RB_SRES.ack , right, 1);
248
        write(oline, string'(" busy="));
249
        write(oline, RB_SRES.busy, right, 1);
250
        write(oline, string'(" err="));
251
        write(oline, RB_SRES.err , right, 1);
252
        write(oline, string'(" dout="));
253
        writehex(oline, RB_SRES.dout, right, 4);
254
        writeline(output, oline);
255
      end if;
256
 
257
      -- keep track of select state and latch current addr
258
      if RB_MREQ.aval='1' and r_sel='0' then  -- if 1st cycle of aval
259
        r_addr := RB_MREQ.addr;                     -- latch addr
260
      end if;
261
      -- select simply aval if last cycle (assume all addr are valid)
262
      r_sel := RB_MREQ.aval;
263
    end if;
264
 
265
  end process proc_check;
266 2 wfjm
 
267
end sim;

powered by: WebSVN 2.1.0

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