1 |
19 |
wfjm |
-- $Id: tst_serloop_hiomap.vhd 476 2013-01-26 22:23:53Z mueller $
|
2 |
16 |
wfjm |
--
|
3 |
|
|
-- Copyright 2011- 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: tst_serloop_hiomap - syn
|
16 |
|
|
-- Description: default human I/O mapper
|
17 |
|
|
--
|
18 |
|
|
-- Dependencies: -
|
19 |
|
|
-- Test bench: -
|
20 |
|
|
--
|
21 |
|
|
-- Target Devices: generic
|
22 |
|
|
-- Tool versions: xst 13.1; ghdl 0.29
|
23 |
|
|
--
|
24 |
|
|
-- Revision History:
|
25 |
|
|
-- Date Rev Version Comment
|
26 |
|
|
-- 2011-12-09 437 1.0.2 rename serport stat->moni port
|
27 |
|
|
-- 2011-11-16 426 1.0.1 setup leds and dps
|
28 |
|
|
-- 2011-11-05 420 1.0 Initial version
|
29 |
|
|
------------------------------------------------------------------------------
|
30 |
|
|
--
|
31 |
|
|
-- Usage of Switches, Buttons, LEDs:
|
32 |
|
|
--
|
33 |
|
|
-- BTN(3): -- unused --
|
34 |
|
|
-- (2): -- unused --
|
35 |
|
|
-- (1): load enables from SWI(7:4)
|
36 |
|
|
-- SWI(7) -> ENAFTDI
|
37 |
|
|
-- SWI(6) -> ENATHROTTLE
|
38 |
|
|
-- SWI(5) -> ENAESC
|
39 |
|
|
-- SWI(4) -> ENAXON
|
40 |
|
|
-- (0): reset state [!! decoded by top level design !!]
|
41 |
|
|
--
|
42 |
|
|
-- SWI(7:4) select display or enable pattern (when BTN(1) pressed)
|
43 |
|
|
-- (3) -- unused --
|
44 |
|
|
-- (2:1): mode 00 idle
|
45 |
|
|
-- 01 rxblast
|
46 |
|
|
-- 10 txblast
|
47 |
|
|
-- 11 loop
|
48 |
|
|
-- SWI(0) 0 -> main board RS232 port
|
49 |
|
|
-- 1 -> Pmod1 RS232 port
|
50 |
|
|
--
|
51 |
|
|
-- LED(7) enaesc
|
52 |
|
|
-- (6) enaxon
|
53 |
|
|
-- (5) rxfecnt > 0 (frame error)
|
54 |
|
|
-- (4) rxoecnt > 0 (overrun error)
|
55 |
|
|
-- (3) rxsecnt > 0 (sequence error)
|
56 |
|
|
-- (2) abact (shows ab activity)
|
57 |
|
|
-- (1) (not rxok) or (not txok) (shows back preasure)
|
58 |
|
|
-- (0) rxact or txact (shows activity)
|
59 |
|
|
--
|
60 |
|
|
-- DSP data as selected by SWI(7:4)
|
61 |
|
|
-- 0000 -> rxfecnt
|
62 |
|
|
-- 0001 -> rxoecnt
|
63 |
|
|
-- 0010 -> rxsecnt
|
64 |
|
|
-- 0100 -> rxcnt.l
|
65 |
|
|
-- 0101 -> rxcnt.h
|
66 |
|
|
-- 0110 -> txcnt.l
|
67 |
|
|
-- 0111 -> txcnt.h
|
68 |
|
|
-- 1000 -> rxokcnt
|
69 |
|
|
-- 1001 -> txokcnt
|
70 |
|
|
-- 1010 -> rxuicnt,rxuidat
|
71 |
|
|
-- 1111 -> abclkdiv
|
72 |
|
|
--
|
73 |
|
|
-- DP(3): not SER_MONI.txok (shows tx back preasure)
|
74 |
|
|
-- (2): SER_MONI.txact (shows tx activity)
|
75 |
|
|
-- (1): not SER_MONI.rxok (shows rx back preasure)
|
76 |
|
|
-- (0): SER_MONI.rxact (shows rx activity)
|
77 |
|
|
--
|
78 |
|
|
|
79 |
|
|
library ieee;
|
80 |
|
|
use ieee.std_logic_1164.all;
|
81 |
|
|
use ieee.numeric_std.all;
|
82 |
|
|
|
83 |
|
|
use work.slvtypes.all;
|
84 |
19 |
wfjm |
use work.serportlib.all;
|
85 |
16 |
wfjm |
use work.tst_serlooplib.all;
|
86 |
|
|
|
87 |
|
|
-- ----------------------------------------------------------------------------
|
88 |
|
|
|
89 |
|
|
entity tst_serloop_hiomap is -- default human I/O mapper
|
90 |
|
|
port (
|
91 |
|
|
CLK : in slbit; -- clock
|
92 |
|
|
RESET : in slbit; -- reset
|
93 |
|
|
HIO_CNTL : out hio_cntl_type; -- tester controls from hio
|
94 |
|
|
HIO_STAT : in hio_stat_type; -- tester status to diaplay by hio
|
95 |
|
|
SER_MONI : in serport_moni_type; -- serport monitor to display by hio
|
96 |
|
|
SWI : in slv8; -- switch settings
|
97 |
|
|
BTN : in slv4; -- button settings
|
98 |
|
|
LED : out slv8; -- led data
|
99 |
|
|
DSP_DAT : out slv16; -- display data
|
100 |
|
|
DSP_DP : out slv4 -- display decimal points
|
101 |
|
|
);
|
102 |
|
|
end tst_serloop_hiomap;
|
103 |
|
|
|
104 |
|
|
architecture syn of tst_serloop_hiomap is
|
105 |
|
|
|
106 |
|
|
type regs_type is record
|
107 |
|
|
enaxon : slbit; -- enable xon/xoff handling
|
108 |
|
|
enaesc : slbit; -- enable xon/xoff escaping
|
109 |
|
|
enathrottle : slbit; -- enable 1 msec tx throttling
|
110 |
|
|
enaftdi : slbit; -- enable ftdi flush handling
|
111 |
|
|
dspdat : slv16; -- display data
|
112 |
|
|
end record regs_type;
|
113 |
|
|
|
114 |
|
|
constant regs_init : regs_type := (
|
115 |
|
|
'0','0','0','0', -- enaxon,enaesc,enathrottle,enaftdi
|
116 |
|
|
(others=>'0') -- dspdat
|
117 |
|
|
|
118 |
|
|
);
|
119 |
|
|
|
120 |
|
|
signal R_REGS : regs_type := regs_init; -- state registers
|
121 |
|
|
signal N_REGS : regs_type := regs_init; -- next value state regs
|
122 |
|
|
|
123 |
|
|
begin
|
124 |
|
|
|
125 |
|
|
proc_regs: process (CLK)
|
126 |
|
|
begin
|
127 |
|
|
|
128 |
|
|
if rising_edge(CLK) then
|
129 |
|
|
if RESET = '1' then
|
130 |
|
|
R_REGS <= regs_init;
|
131 |
|
|
else
|
132 |
|
|
R_REGS <= N_REGS;
|
133 |
|
|
end if;
|
134 |
|
|
end if;
|
135 |
|
|
|
136 |
|
|
end process proc_regs;
|
137 |
|
|
|
138 |
|
|
proc_next: process (R_REGS, HIO_STAT, SER_MONI, SWI, BTN)
|
139 |
|
|
|
140 |
|
|
variable r : regs_type := regs_init;
|
141 |
|
|
variable n : regs_type := regs_init;
|
142 |
|
|
|
143 |
|
|
variable icntl : hio_cntl_type := hio_cntl_init;
|
144 |
|
|
variable iled : slv8 := (others=>'0');
|
145 |
|
|
variable idat : slv16 := (others=>'0');
|
146 |
|
|
variable idp : slv4 := (others=>'0');
|
147 |
|
|
|
148 |
|
|
begin
|
149 |
|
|
|
150 |
|
|
r := R_REGS;
|
151 |
|
|
n := R_REGS;
|
152 |
|
|
|
153 |
|
|
icntl := hio_cntl_init;
|
154 |
|
|
iled := (others=>'0');
|
155 |
|
|
idat := (others=>'0');
|
156 |
|
|
idp := (others=>'0');
|
157 |
|
|
|
158 |
|
|
-- handle BTN(1) "load enables" press
|
159 |
|
|
|
160 |
|
|
if BTN(1) = '1' then
|
161 |
|
|
n.enaxon := SWI(4);
|
162 |
|
|
n.enaesc := SWI(5);
|
163 |
|
|
n.enathrottle := SWI(6);
|
164 |
|
|
n.enaftdi := SWI(7);
|
165 |
|
|
end if;
|
166 |
|
|
|
167 |
|
|
-- setup tester controls
|
168 |
|
|
|
169 |
|
|
icntl.mode := SWI(2 downto 1);
|
170 |
|
|
icntl.enaxon := r.enaxon;
|
171 |
|
|
icntl.enaesc := r.enaesc;
|
172 |
|
|
icntl.enathrottle := r.enathrottle;
|
173 |
|
|
icntl.enaftdi := r.enaftdi;
|
174 |
|
|
|
175 |
|
|
-- setup leds
|
176 |
|
|
iled(7) := icntl.enaesc;
|
177 |
|
|
iled(6) := icntl.enaxon;
|
178 |
|
|
if unsigned(HIO_STAT.rxfecnt) > 0 then iled(5) := '1'; end if;
|
179 |
|
|
if unsigned(HIO_STAT.rxoecnt) > 0 then iled(4) := '1'; end if;
|
180 |
|
|
if unsigned(HIO_STAT.rxsecnt) > 0 then iled(3) := '1'; end if;
|
181 |
|
|
iled(2) := SER_MONI.abact;
|
182 |
|
|
iled(1) := (not SER_MONI.rxok) or (not SER_MONI.txok);
|
183 |
|
|
iled(0) := SER_MONI.rxact or SER_MONI.txact;
|
184 |
|
|
|
185 |
|
|
-- setup display data
|
186 |
|
|
|
187 |
|
|
case SWI(7 downto 4) is
|
188 |
|
|
when "0000" => idat := HIO_STAT.rxfecnt;
|
189 |
|
|
when "0001" => idat := HIO_STAT.rxoecnt;
|
190 |
|
|
when "0010" => idat := HIO_STAT.rxsecnt;
|
191 |
|
|
when "0100" => idat := HIO_STAT.rxcnt(15 downto 0);
|
192 |
|
|
when "0101" => idat := HIO_STAT.rxcnt(31 downto 16);
|
193 |
|
|
when "0110" => idat := HIO_STAT.txcnt(15 downto 0);
|
194 |
|
|
when "0111" => idat := HIO_STAT.txcnt(31 downto 16);
|
195 |
|
|
when "1000" => idat := HIO_STAT.rxokcnt;
|
196 |
|
|
when "1001" => idat := HIO_STAT.txokcnt;
|
197 |
|
|
when "1010" => idat := HIO_STAT.rxuicnt & HIO_STAT.rxuidat;
|
198 |
|
|
when "1111" => idat := SER_MONI.abclkdiv;
|
199 |
|
|
when others => null;
|
200 |
|
|
end case;
|
201 |
|
|
n.dspdat := idat;
|
202 |
|
|
|
203 |
|
|
-- setup display decimal points
|
204 |
|
|
|
205 |
|
|
idp(3) := not SER_MONI.txok; -- tx back preasure
|
206 |
|
|
idp(2) := SER_MONI.txact; -- tx activity
|
207 |
|
|
idp(1) := not SER_MONI.rxok; -- rx back preasure
|
208 |
|
|
idp(0) := SER_MONI.rxact; -- rx activity
|
209 |
|
|
|
210 |
|
|
N_REGS <= n;
|
211 |
|
|
|
212 |
|
|
HIO_CNTL <= icntl;
|
213 |
|
|
LED <= iled;
|
214 |
|
|
DSP_DAT <= r.dspdat;
|
215 |
|
|
DSP_DP <= idp;
|
216 |
|
|
|
217 |
|
|
end process proc_next;
|
218 |
|
|
|
219 |
|
|
end syn;
|