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

Subversion Repositories w11

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

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

Line No. Rev Author Line
1 27 wfjm
-- $Id: byte2cdata.vhd 596 2014-10-17 19:50:07Z 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:    byte2cdata - syn
16
-- Description:    Byte stream to 9 bit comma,data converter
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21 27 wfjm
-- Tool versions:  xst 8.2-14.7; ghdl 0.18-0.31
22 9 wfjm
--
23 2 wfjm
-- Revision History: 
24
-- Date         Rev Version  Comment
25 27 wfjm
-- 2014-10-17   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-08-27    76   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 byte2cdata is                    -- byte stream -> 9bit comma,data
39
  port (
40
    CLK : in slbit;                     -- clock
41
    RESET : in slbit;                   -- reset
42
    DI : in slv8;                       -- input data
43 27 wfjm
    ENA : in slbit;                     -- input data enable
44
    ERR : in slbit;                     -- input data error
45
    BUSY : out slbit;                   -- input data busy
46 9 wfjm
    DO : out slv9;                      -- output data; bit 8 = comma flag
47 27 wfjm
    VAL : out slbit;                    -- output data valid
48
    HOLD : in slbit                     -- output data hold
49 2 wfjm
  );
50
end byte2cdata;
51
 
52
 
53
architecture syn of byte2cdata is
54
 
55
  type regs_type is record
56 27 wfjm
    data : slv9;                        -- data
57
    dataval : slbit;                    -- data valid
58
    edpend : slbit;                     -- edata pending
59 2 wfjm
  end record regs_type;
60
 
61
  constant regs_init : regs_type := (
62 27 wfjm
    (others=>'0'),                      -- data
63
    '0','0'                             -- dataval,edpend
64 2 wfjm
  );
65
 
66
  signal R_REGS : regs_type := regs_init;  -- state registers
67
  signal N_REGS : regs_type := regs_init;  -- next value state regs
68
 
69
begin
70
 
71
  proc_regs: process (CLK)
72
  begin
73
 
74 13 wfjm
    if rising_edge(CLK) then
75 2 wfjm
      if RESET = '1' then
76
        R_REGS <= regs_init;
77
      else
78
        R_REGS <= N_REGS;
79
      end if;
80
    end if;
81
 
82
  end process proc_regs;
83
 
84 27 wfjm
  proc_next: process (R_REGS, DI, ENA, ERR, HOLD)
85 2 wfjm
 
86
    variable r : regs_type := regs_init;
87
    variable n : regs_type := regs_init;
88
 
89 27 wfjm
    variable idata : slv9 := (others=>'0');
90
    variable iesc :  slbit := '0';
91 2 wfjm
    variable ibusy : slbit := '0';
92
 
93
  begin
94
 
95
    r := R_REGS;
96
    n := R_REGS;
97
 
98 27 wfjm
    -- data path logic
99
    idata := '1' & "00000" & "100";   -- clobber
100
    iesc  := '0';
101
 
102
    if r.edpend = '1' then
103
      if DI(c_cdata_edf_pref) = c_cdata_ed_pref and
104
         (not DI(c_cdata_edf_eci)) = DI(c_cdata_edf_ec) then
105
        case DI(c_cdata_edf_ec) is
106
          when c_cdata_ec_xon =>
107
            idata := '0' & c_cdata_xon;
108
          when c_cdata_ec_xoff =>
109
            idata := '0' & c_cdata_xoff;
110
          when c_cdata_ec_fill =>
111
            idata := '0' & c_cdata_fill;
112
          when c_cdata_ec_esc =>
113
            idata := '0' & c_cdata_escape;
114
          when others =>
115
            idata := '1' &  "00000" & DI(c_cdata_edf_ec);
116
        end case;
117
      end if;
118
    else
119
      idata := '0' & DI;
120
      if DI = c_cdata_escape then
121
        iesc := '1';
122
      end if;
123
    end if;
124
 
125
    -- control path logic
126 2 wfjm
    ibusy := '1';
127 27 wfjm
    if HOLD = '0' then
128
      ibusy     := '0';
129
      n.dataval := '0';
130
      n.data    := idata;
131
      if ENA = '1' then
132
        if r.edpend = '0' then
133
          if iesc = '0' then
134
            n.dataval := '1';
135
          else
136
            n.edpend  := '1';
137 2 wfjm
          end if;
138 27 wfjm
        else
139
          n.dataval := '1';
140
          n.edpend  := '0';
141 2 wfjm
        end if;
142 27 wfjm
      elsif ERR = '1' then
143
        n.dataval := '1';
144
      end if;
145
    end if;
146 2 wfjm
 
147
    N_REGS <= n;
148
 
149 27 wfjm
    DO   <= r.data;
150
    VAL  <= r.dataval;
151 2 wfjm
    BUSY <= ibusy;
152
 
153
  end process proc_next;
154
 
155
 
156
end syn;

powered by: WebSVN 2.1.0

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