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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 wfjm
-- $Id: rlink_mon.vhd 609 2014-12-07 19:35:25Z 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:    rlink_mon - sim
16
-- Description:    rlink monitor (for tb's)
17 2 wfjm
--
18
-- Dependencies:   -
19
-- Test bench:     -
20 27 wfjm
-- Tool versions:  xst 8.2-17.7; ghdl 0.18-0.31
21 9 wfjm
--
22 2 wfjm
-- Revision History: 
23
-- Date         Rev Version  Comment
24 27 wfjm
-- 2014-11-08   602   4.0.2  annotate clobber commas
25
-- 2014-10-25   599   4.0.1  use writeoptint()
26
-- 2014-10-12   596   4.0    adopt to new escaping, better 8 bit output
27 17 wfjm
-- 2011-12-23   444   3.1    CLK_CYCLE now integer
28 13 wfjm
-- 2011-11-19   427   3.0.2  now numeric_std clean
29 9 wfjm
-- 2010-12-24   347   3.0.1  rename: CP_*->RL->*
30
-- 2010-12-22   346   3.0    renamed rritb_cpmon -> rlink_mon
31 2 wfjm
-- 2010-06-11   303   2.5.1  fix data9 assignment, always proper width now
32
-- 2010-06-07   302   2.5    use sop/eop framing instead of soc+chaining
33
-- 2008-03-24   129   1.0.1  CLK_CYCLE now 31 bits
34
-- 2007-09-09    81   1.0    Initial version 
35
------------------------------------------------------------------------------
36
 
37
library ieee;
38
use ieee.std_logic_1164.all;
39 13 wfjm
use ieee.numeric_std.all;
40 2 wfjm
use ieee.std_logic_textio.all;
41
use std.textio.all;
42
 
43
use work.slvtypes.all;
44
use work.simlib.all;
45 9 wfjm
use work.rlinklib.all;
46 27 wfjm
use work.comlib.all;
47 2 wfjm
 
48 9 wfjm
entity rlink_mon is                     -- rlink monitor
49 2 wfjm
  generic (
50
    DWIDTH : positive :=  9);           -- data port width (8 or 9)
51
  port (
52
    CLK  : in slbit;                    -- clock
53 17 wfjm
    CLK_CYCLE : in integer := 0;        -- clock cycle number
54 2 wfjm
    ENA  : in slbit := '1';             -- enable monitor output
55 9 wfjm
    RL_DI : in slv(DWIDTH-1 downto 0);  -- rlink: data in
56
    RL_ENA : in slbit;                  -- rlink: data enable
57
    RL_BUSY : in slbit;                 -- rlink: data busy
58
    RL_DO : in slv(DWIDTH-1 downto 0);  -- rlink: data out
59
    RL_VAL : in slbit;                  -- rlink: data valid
60
    RL_HOLD : in slbit                  -- rlink: data hold
61 2 wfjm
  );
62 9 wfjm
end rlink_mon;
63 2 wfjm
 
64
 
65 9 wfjm
architecture sim of rlink_mon is
66 2 wfjm
 
67
begin
68
 
69
  assert DWIDTH=8 or DWIDTH=9
70
    report "assert(DWIDTH=8 or DWIDTH=9)" severity failure;
71
 
72 9 wfjm
  proc_moni: process
73 2 wfjm
    variable oline : line;
74
    variable nbusy : integer := 0;
75
    variable nhold : integer := 0;
76 27 wfjm
    variable edatarx : boolean := false;
77
    variable edatatx : boolean := false;
78
 
79 2 wfjm
    procedure write_val(L: inout line;
80
                        data: in slv(DWIDTH-1 downto 0);
81
                        nwait: in integer;
82 27 wfjm
                        txt1: in string(1 to 2);
83
                        txt2: in string;
84
                        edata: in boolean) is
85 2 wfjm
      variable data9 : slv9 := (others=>'0');
86 27 wfjm
      variable optxt : string(1 to 8) := ": ??rx  ";
87 2 wfjm
    begin
88
 
89 27 wfjm
      if DWIDTH = 9 then
90
        optxt(3 to 4) := "rl";
91
      else
92
        optxt(3 to 4) := "r8";
93
      end if;
94
      optxt(5 to 6) := txt1;
95
      writetimestamp(L, CLK_CYCLE, optxt);
96 2 wfjm
 
97
      if DWIDTH = 9 then
98
        write(L, data(data'left), right, 1);
99
      else
100
        write(L, string'(" "));
101
      end if;
102
 
103
      write(L, data(7 downto 0), right, 9);
104 27 wfjm
      writeoptint(L, txt2, nwait);
105 2 wfjm
 
106
      if DWIDTH=9 and data(data'left)='1' then
107
        -- a copy to data9 needed to allow following case construct
108
        -- using data directly gives a 'subtype is not locally static' error
109
        data9 := (others=>'0');
110
        data9(data'range) := data;
111
        write(L, string'("  comma"));
112
        case data9 is
113 9 wfjm
          when c_rlink_dat_sop  => write(L, string'(" sop"));
114
          when c_rlink_dat_eop  => write(L, string'(" eop"));
115
          when c_rlink_dat_nak  => write(L, string'(" nak"));
116
          when c_rlink_dat_attn => write(L, string'(" attn"));
117 27 wfjm
          when others           => write(L, string'(" clobber|oob"));
118 2 wfjm
        end case;
119
      end if;
120
 
121 27 wfjm
      if DWIDTH = 8 then
122
 
123
        if edata then
124
          write(L, string'("  edata"));
125
          if data(c_cdata_edf_pref) /= c_cdata_ed_pref or
126
             (not data(c_cdata_edf_eci)) /= data(c_cdata_edf_ec) then
127
            write(L, string'(" FAIL: bad format"));
128
          else
129
            write(L, string'(" ec="));
130
            write(L, data(c_cdata_edf_ec));
131
            data9 := (others=>'0');
132
            data9(8) := '1';
133
            data9(c_cdata_edf_ec) := data(c_cdata_edf_ec);
134
            case data9 is
135
              when c_rlink_dat_sop  => write(L, string'(" (sop)"));
136
              when c_rlink_dat_eop  => write(L, string'(" (eop)"));
137
              when c_rlink_dat_nak  => write(L, string'(" (nak)"));
138
              when c_rlink_dat_attn => write(L, string'(" (attn)"));
139
              when "100000" & c_cdata_ec_xon  => write(L, string'(" (xon)"));
140
              when "100000" & c_cdata_ec_xoff => write(L, string'(" (xoff)"));
141
              when "100000" & c_cdata_ec_fill => write(L, string'(" (fill)"));
142
              when "100000" & c_cdata_ec_esc  => write(L, string'(" (esc)"));
143
              when others =>
144
                write(L, string'(" FAIL: bad ec"));
145
            end case;
146
          end if;
147
        end if;
148
 
149
        if data = c_cdata_escape then
150
          write(L, string'("  escape"));
151
        end if;
152
      end if;
153
 
154 2 wfjm
      writeline(output, L);
155
    end procedure write_val;
156
 
157
  begin
158
 
159
    loop
160
 
161
      if ENA='0' then                   -- if disabled
162
        wait until ENA='1';             -- stall process till enabled
163
      end if;
164
 
165 13 wfjm
      wait until rising_edge(CLK); -- check at end of clock cycle
166 2 wfjm
 
167 9 wfjm
      if RL_ENA = '1' then
168
        if RL_BUSY = '1' then
169 2 wfjm
          nbusy := nbusy + 1;
170
        else
171 27 wfjm
          write_val(oline, RL_DI, nbusy, "rx", "  nbusy=", edatarx);
172
          edatarx := RL_DI=c_cdata_escape;
173
          nbusy   := 0;
174 2 wfjm
        end if;
175
      else
176
        nbusy := 0;
177
      end if;
178
 
179 9 wfjm
      if RL_VAL = '1' then
180
        if RL_HOLD = '1' then
181 2 wfjm
          nhold := nhold + 1;
182
        else
183 27 wfjm
          write_val(oline, RL_DO, nhold, "tx", "  nhold=", edatatx);
184
          edatatx := RL_DO=c_cdata_escape;
185
          nhold   := 0;
186 2 wfjm
        end if;
187
      else
188
        nhold := 0;
189
      end if;
190
 
191
    end loop;
192 9 wfjm
  end process proc_moni;
193 2 wfjm
 
194
end sim;

powered by: WebSVN 2.1.0

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