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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [rtl/] [vlib/] [comlib/] [cdata2byte.vhd] - Blame information for rev 40

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

Line No. Rev Author Line
1 29 wfjm
-- $Id: cdata2byte.vhd 641 2015-02-01 22:12:15Z 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
-- Module Name:    cdata2byte - syn
16
-- Description:    9 bit comma,data to Byte stream converter
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21 29 wfjm
-- Tool versions:  ise 8.2-14.7; viv 2014.4; ghdl 0.18-0.31
22 9 wfjm
--
23 2 wfjm
-- Revision History: 
24
-- Date         Rev Version  Comment
25 27 wfjm
-- 2014-10-12   596   2.0    re-write, commas now 2 byte sequences
26 13 wfjm
-- 2011-11-19   427   1.0.2  now numeric_std clean
27 2 wfjm
-- 2007-10-12    88   1.0.1  avoid ieee.std_logic_unsigned, use cast to unsigned
28
-- 2007-06-30    62   1.0    Initial version 
29
------------------------------------------------------------------------------
30
 
31
library ieee;
32
use ieee.std_logic_1164.all;
33 13 wfjm
use ieee.numeric_std.all;
34 2 wfjm
 
35
use work.slvtypes.all;
36 27 wfjm
use work.comlib.all;
37 2 wfjm
 
38
entity cdata2byte is                    -- 9bit comma,data -> byte stream
39
  port (
40
    CLK : in slbit;                     -- clock
41
    RESET : in slbit;                   -- reset
42 27 wfjm
    ESCXON : in slbit;                  -- enable xon/xoff escaping
43
    ESCFILL : in slbit;                 -- enable fill escaping
44 9 wfjm
    DI : in slv9;                       -- input data; bit 8 = comma flag
45 27 wfjm
    ENA : in slbit;                     -- input data enable
46
    BUSY : out slbit;                   -- input data busy    
47 2 wfjm
    DO : out slv8;                      -- output data
48 27 wfjm
    VAL : out slbit;                    -- output data valid
49
    HOLD : in slbit                     -- output data hold
50 2 wfjm
  );
51
end cdata2byte;
52
 
53
 
54
architecture syn of cdata2byte is
55
 
56
  type regs_type is record
57 27 wfjm
    data : slv8;                        -- data
58
    ecode : slv3;                       -- ecode
59
    dataval : slbit;                    -- data valid
60
    ecodeval : slbit;                   -- ecode valid
61 2 wfjm
  end record regs_type;
62
 
63
  constant regs_init : regs_type := (
64 27 wfjm
    (others=>'0'),                      -- data
65
    (others=>'0'),                      -- ecode
66
    '0','0'                             -- dataval,ecodeval
67 2 wfjm
  );
68
 
69
  signal R_REGS : regs_type := regs_init;  -- state registers
70
  signal N_REGS : regs_type := regs_init;  -- next value state regs
71
 
72
begin
73
 
74
  proc_regs: process (CLK)
75
  begin
76
 
77 13 wfjm
    if rising_edge(CLK) then
78 2 wfjm
      if RESET = '1' then
79
        R_REGS <= regs_init;
80
      else
81
        R_REGS <= N_REGS;
82
      end if;
83
    end if;
84
 
85
  end process proc_regs;
86
 
87 27 wfjm
  proc_next: process (R_REGS, DI, ENA, HOLD, ESCXON, ESCFILL)
88 2 wfjm
 
89
    variable r : regs_type := regs_init;
90
    variable n : regs_type := regs_init;
91
 
92 27 wfjm
    variable idata  : slv8 := (others=>'0');
93
    variable iecode : slv3 := (others=>'0');
94
    variable iesc   : slbit := '0';
95
    variable ibusy  : slbit := '0';
96 2 wfjm
 
97
  begin
98
 
99
    r := R_REGS;
100
    n := R_REGS;
101
 
102 27 wfjm
    -- data path logic
103
    iesc   := '0';
104
    iecode := '0' & DI(1 downto 0);
105
    if DI(8) = '1' then
106
      iesc   := '1';
107
    else
108
      case DI(7 downto 0) is
109
        when c_cdata_xon =>
110
          if ESCXON = '1' then
111
            iesc   := '1';
112
            iecode := c_cdata_ec_xon;
113
          end if;
114
        when c_cdata_xoff =>
115
          if ESCXON = '1' then
116
            iesc   := '1';
117
            iecode := c_cdata_ec_xoff;
118
          end if;
119
        when c_cdata_fill =>
120
          if ESCFILL = '1' then
121
            iesc   := '1';
122
            iecode := c_cdata_ec_fill;
123
          end if;
124
        when c_cdata_escape =>
125
          iesc   := '1';
126
          iecode := c_cdata_ec_esc;
127
        when others => null;
128
      end case;
129
    end if;
130
 
131
    if iesc = '0' then
132
      idata := DI(7 downto 0);
133
    else
134
      idata := c_cdata_escape;
135
    end if;
136
 
137
    -- control path logic
138 2 wfjm
    ibusy := '1';
139 27 wfjm
    if HOLD = '0' then
140
      n.dataval := '0';
141
      if r.ecodeval = '1' then
142
        n.data(c_cdata_edf_pref) := c_cdata_ed_pref;
143
        n.data(c_cdata_edf_eci)  := not r.ecode;
144
        n.data(c_cdata_edf_ec )  := r.ecode;
145
        n.dataval  := '1';
146
        n.ecodeval := '0';
147
      else
148 2 wfjm
        ibusy := '0';
149
        if ENA = '1' then
150 27 wfjm
          n.data     := idata;
151
          n.dataval  := '1';
152
          n.ecode    := iecode;
153
          n.ecodeval := iesc;
154 2 wfjm
        end if;
155 27 wfjm
      end if;
156
    end if;
157 2 wfjm
 
158
    N_REGS <= n;
159
 
160 27 wfjm
    DO   <= r.data;
161
    VAL  <= r.dataval;
162 2 wfjm
    BUSY <= ibusy;
163
 
164
  end process proc_next;
165
 
166
end syn;

powered by: WebSVN 2.1.0

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