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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 2 wfjm
-- $Id: rritb_cpmon.vhd 314 2010-07-09 17:38:41Z mueller $
2
--
3
-- Copyright 2007-2010 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:    rritb_cpmon - sim
16
-- Description:    rritb: rri comm port monitor
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Tool versions:  xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
21
-- Revision History: 
22
-- Date         Rev Version  Comment
23
-- 2010-06-11   303   2.5.1  fix data9 assignment, always proper width now
24
-- 2010-06-07   302   2.5    use sop/eop framing instead of soc+chaining
25
-- 2008-03-24   129   1.0.1  CLK_CYCLE now 31 bits
26
-- 2007-09-09    81   1.0    Initial version 
27
------------------------------------------------------------------------------
28
 
29
library ieee;
30
use ieee.std_logic_1164.all;
31
use ieee.std_logic_arith.all;
32
use ieee.std_logic_textio.all;
33
use std.textio.all;
34
 
35
use work.slvtypes.all;
36
use work.simlib.all;
37
use work.rrilib.all;
38
 
39
entity rritb_cpmon is                   -- rritb, rri comm port monitor
40
  generic (
41
    DWIDTH : positive :=  9);           -- data port width (8 or 9)
42
  port (
43
    CLK  : in slbit;                    -- clock
44
    CLK_CYCLE : in slv31 := (others=>'0');  -- clock cycle number
45
    ENA  : in slbit := '1';             -- enable monitor output
46
    CP_DI : in slv(DWIDTH-1 downto 0);  -- comm port: data in
47
    CP_ENA : in slbit;                  -- comm port: data enable
48
    CP_BUSY : in slbit;                 -- comm port: data busy
49
    CP_DO : in slv(DWIDTH-1 downto 0);  -- comm port: data out
50
    CP_VAL : in slbit;                  -- comm port: data valid
51
    CP_HOLD : in slbit                  -- comm port: data hold
52
  );
53
end rritb_cpmon;
54
 
55
 
56
architecture sim of rritb_cpmon is
57
 
58
begin
59
 
60
  assert DWIDTH=8 or DWIDTH=9
61
    report "assert(DWIDTH=8 or DWIDTH=9)" severity failure;
62
 
63
  proc_cpmoni: process
64
    variable oline : line;
65
    variable nbusy : integer := 0;
66
    variable nhold : integer := 0;
67
 
68
    procedure write_val(L: inout line;
69
                        data: in slv(DWIDTH-1 downto 0);
70
                        nwait: in integer;
71
                        txt1: in string;
72
                        txt2: in string) is
73
      variable data9 : slv9 := (others=>'0');
74
    begin
75
 
76
      writetimestamp(L, CLK_CYCLE, txt1);
77
 
78
      if DWIDTH = 9 then
79
        write(L, data(data'left), right, 1);
80
      else
81
        write(L, string'(" "));
82
      end if;
83
 
84
      write(L, data(7 downto 0), right, 9);
85
      if nwait > 0 then
86
        write(L, txt2);
87
        write(L, nwait);
88
      end if;
89
 
90
      if DWIDTH=9 and data(data'left)='1' then
91
        -- a copy to data9 needed to allow following case construct
92
        -- using data directly gives a 'subtype is not locally static' error
93
        data9 := (others=>'0');
94
        data9(data'range) := data;
95
        write(L, string'("  comma"));
96
        case data9 is
97
          when c_rri_dat_idle => write(L, string'(" idle"));
98
          when c_rri_dat_sop  => write(L, string'(" sop"));
99
          when c_rri_dat_eop  => write(L, string'(" eop"));
100
          when c_rri_dat_nak  => write(L, string'(" nak"));
101
          when c_rri_dat_attn => write(L, string'(" attn"));
102
          when others => null;
103
        end case;
104
      end if;
105
 
106
      writeline(output, L);
107
    end procedure write_val;
108
 
109
  begin
110
 
111
    loop
112
 
113
      if ENA='0' then                   -- if disabled
114
        wait until ENA='1';             -- stall process till enabled
115
      end if;
116
 
117
      wait until CLK'event and CLK='1'; -- check at end of clock cycle
118
 
119
      if CP_ENA = '1' then
120
        if CP_BUSY = '1' then
121
          nbusy := nbusy + 1;
122
        else
123
          write_val(oline, CP_DI, nbusy, ": cprx  ", "  nbusy=");
124
          nbusy := 0;
125
        end if;
126
      else
127
        nbusy := 0;
128
      end if;
129
 
130
      if CP_VAL = '1' then
131
        if CP_HOLD = '1' then
132
          nhold := nhold + 1;
133
        else
134
          write_val(oline, CP_DO, nhold, ": cptx  ", "  nhold=");
135
          nhold := 0;
136
        end if;
137
      else
138
        nhold := 0;
139
      end if;
140
 
141
    end loop;
142
  end process proc_cpmoni;
143
 
144
end sim;

powered by: WebSVN 2.1.0

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