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