1 |
8 |
bjoerno |
---====================== Start Software License ========================---
|
2 |
|
|
--== ==--
|
3 |
|
|
--== This license governs the use of this software, and your use of ==--
|
4 |
|
|
--== this software constitutes acceptance of this license. Agreement ==--
|
5 |
|
|
--== with all points is required to use this software. ==--
|
6 |
|
|
--== ==--
|
7 |
|
|
--== 1. This source file may be used and distributed without ==--
|
8 |
|
|
--== restriction provided that this software license statement is not ==--
|
9 |
|
|
--== removed from the file and that any derivative work contains the ==--
|
10 |
|
|
--== original software license notice and the associated disclaimer. ==--
|
11 |
|
|
--== ==--
|
12 |
|
|
--== 2. This source file is free software; you can redistribute it ==--
|
13 |
|
|
--== and/or modify it under the restriction that UNDER NO CIRCUMTANCES ==--
|
14 |
|
|
--== this Software is to be used to CONSTRUCT a SPACEWIRE INTERFACE ==--
|
15 |
|
|
--== This implies modification and/or derivative work of this Software. ==--
|
16 |
|
|
--== ==--
|
17 |
|
|
--== 3. This source is distributed in the hope that it will be useful, ==--
|
18 |
|
|
--== but WITHOUT ANY WARRANTY; without even the implied warranty of ==--
|
19 |
|
|
--== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ==--
|
20 |
|
|
--== ==--
|
21 |
|
|
--== Your rights under this license are terminated immediately if you ==--
|
22 |
|
|
--== breach it in any way. ==--
|
23 |
|
|
--== ==--
|
24 |
|
|
---======================= End Software License =========================---
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
---====================== Start Copyright Notice ========================---
|
28 |
|
|
--== ==--
|
29 |
|
|
--== Filename ..... transmitter.vhd ==--
|
30 |
|
|
--== Download ..... http://www.ida.ing.tu-bs.de ==--
|
31 |
|
|
--== Company ...... IDA TU Braunschweig, Prof. Dr.-Ing. Harald Michalik ==--
|
32 |
|
|
--== Authors ...... Björn Osterloh, Karel Kotarowski ==--
|
33 |
|
|
--== Contact ...... Björn Osterloh (b.osterloh@tu-bs.de) ==--
|
34 |
|
|
--== Copyright .... Copyright (c) 2008 IDA ==--
|
35 |
|
|
--== Project ...... SoCWire CODEC ==--
|
36 |
|
|
--== Version ...... 1.00 ==--
|
37 |
|
|
--== Conception ... 11 November 2008 ==--
|
38 |
|
|
--== Modified ..... N/A ==--
|
39 |
|
|
--== ==--
|
40 |
|
|
---======================= End Copyright Notice =========================---
|
41 |
|
|
|
42 |
|
|
LIBRARY IEEE;
|
43 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
44 |
|
|
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
|
45 |
|
|
USE WORK.ALL;
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
ENTITY transmitter IS
|
49 |
|
|
GENERIC(
|
50 |
|
|
|
51 |
|
|
datawidth : NATURAL RANGE 8 TO 8192
|
52 |
|
|
);
|
53 |
|
|
PORT(
|
54 |
|
|
--== General Interface (Sync Rst, 50MHz Clock) ==--
|
55 |
|
|
|
56 |
|
|
rst : IN STD_LOGIC;
|
57 |
|
|
clk : IN STD_LOGIC;
|
58 |
|
|
|
59 |
|
|
--== SoCWire Interface ==--
|
60 |
|
|
|
61 |
|
|
state : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
|
62 |
|
|
|
63 |
|
|
--== External Transmit Interface ==--
|
64 |
|
|
|
65 |
|
|
tx : OUT STD_LOGIC_VECTOR(datawidth+1 DOWNTO 0);
|
66 |
|
|
tx_valid : OUT STD_LOGIC;
|
67 |
|
|
|
68 |
|
|
--== Data Input Interface ==--
|
69 |
|
|
|
70 |
|
|
dat_full : OUT STD_LOGIC;
|
71 |
|
|
dat_nwrite : IN STD_LOGIC;
|
72 |
|
|
dat_din : IN STD_LOGIC_VECTOR(datawidth DOWNTO 0);
|
73 |
|
|
|
74 |
|
|
--== FCT Input Interface ==--
|
75 |
|
|
|
76 |
|
|
fct_full : OUT STD_LOGIC;
|
77 |
|
|
fct_nwrite : IN STD_LOGIC
|
78 |
|
|
);
|
79 |
|
|
END transmitter;
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
ARCHITECTURE rtl OF transmitter IS
|
83 |
|
|
|
84 |
|
|
---==========================---
|
85 |
|
|
--== Constants Declarations ==--
|
86 |
|
|
---==========================---
|
87 |
|
|
|
88 |
|
|
CONSTANT st_error_reset : STD_LOGIC_VECTOR(2 DOWNTO 0) := "000";
|
89 |
|
|
CONSTANT st_error_wait : STD_LOGIC_VECTOR(2 DOWNTO 0) := "001";
|
90 |
|
|
CONSTANT st_ready : STD_LOGIC_VECTOR(2 DOWNTO 0) := "010";
|
91 |
|
|
CONSTANT st_started : STD_LOGIC_VECTOR(2 DOWNTO 0) := "011";
|
92 |
|
|
CONSTANT st_connecting : STD_LOGIC_VECTOR(2 DOWNTO 0) := "100";
|
93 |
|
|
CONSTANT st_run : STD_LOGIC_VECTOR(2 DOWNTO 0) := "101";
|
94 |
|
|
CONSTANT st_unknown_1 : STD_LOGIC_VECTOR(2 DOWNTO 0) := "110";
|
95 |
|
|
CONSTANT st_unknown_2 : STD_LOGIC_VECTOR(2 DOWNTO 0) := "111";
|
96 |
|
|
CONSTANT zeros : STD_LOGIC_VECTOR(datawidth DOWNTO 5) := (others => '0');
|
97 |
|
|
|
98 |
|
|
---=======================---
|
99 |
|
|
--== Signal Declarations ==--
|
100 |
|
|
---=======================---
|
101 |
|
|
|
102 |
|
|
SIGNAL tx_rst : STD_LOGIC;
|
103 |
|
|
SIGNAL clk_en : STD_LOGIC;
|
104 |
|
|
SIGNAL load_d : STD_LOGIC;
|
105 |
|
|
SIGNAL load : STD_LOGIC;
|
106 |
|
|
SIGNAL bit_array_d : STD_LOGIC_VECTOR(datawidth DOWNTO 0);
|
107 |
|
|
SIGNAL bit_array : STD_LOGIC_VECTOR(datawidth DOWNTO 0);
|
108 |
|
|
SIGNAL parity_d : STD_LOGIC;
|
109 |
|
|
SIGNAL parity : STD_LOGIC;
|
110 |
|
|
SIGNAL fct_en : STD_LOGIC;
|
111 |
|
|
SIGNAL dat_en : STD_LOGIC;
|
112 |
|
|
SIGNAL fct_full_i : STD_LOGIC;
|
113 |
|
|
SIGNAL dat_full_i : STD_LOGIC;
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
BEGIN
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
---=========================================================---
|
121 |
|
|
--== Generate Tx Reset Signal to hold Transmitter in Reset ==--
|
122 |
|
|
---=========================================================---
|
123 |
|
|
|
124 |
|
|
tx_rst <= '1' WHEN ((state /= st_Started) AND (state /= st_connecting) AND
|
125 |
|
|
(state /= st_run)) OR (rst = '1') ELSE '0';
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
---=====================---
|
130 |
|
|
--== Synchronous Logic ==--
|
131 |
|
|
---=====================---
|
132 |
|
|
|
133 |
|
|
PROCESS (clk)
|
134 |
|
|
BEGIN
|
135 |
|
|
IF RISING_EDGE(clk) THEN
|
136 |
|
|
IF tx_rst = '0' THEN
|
137 |
|
|
clk_en <= NOT clk_en;
|
138 |
|
|
load <= load_d;
|
139 |
|
|
IF load = '1' THEN
|
140 |
|
|
parity <= parity_d;
|
141 |
|
|
bit_array <= bit_array_d;
|
142 |
|
|
END IF;
|
143 |
|
|
ELSE
|
144 |
|
|
clk_en <= '0';
|
145 |
|
|
load <= '0';
|
146 |
|
|
parity <= '1';
|
147 |
|
|
bit_array <= (others => '0');
|
148 |
|
|
END IF;
|
149 |
|
|
END IF;
|
150 |
|
|
END PROCESS;
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
---===========================================================---
|
154 |
|
|
--== Generate pulse for cycle where shift register is loaded ==--
|
155 |
|
|
---===========================================================---
|
156 |
|
|
|
157 |
|
|
load_d <= NOT tx_rst;
|
158 |
|
|
|
159 |
|
|
---===========================================================---
|
160 |
|
|
--== FCT & NChar Input Interfaces (pre-sniff then handshake) ==--
|
161 |
|
|
---===========================================================---
|
162 |
|
|
|
163 |
|
|
PROCESS(load_d, state, fct_nwrite, dat_nwrite)
|
164 |
|
|
BEGIN
|
165 |
|
|
IF (load_d = '1') THEN
|
166 |
|
|
IF ((state = st_connecting) OR (state = st_run)) AND (fct_nwrite = '0') THEN
|
167 |
|
|
fct_full_i <= '0';
|
168 |
|
|
dat_full_i <= '1';
|
169 |
|
|
ELSIF (state = st_run) AND (dat_nwrite = '0') THEN
|
170 |
|
|
fct_full_i <= '1';
|
171 |
|
|
dat_full_i <= '0';
|
172 |
|
|
ELSE
|
173 |
|
|
fct_full_i <= '1';
|
174 |
|
|
dat_full_i <= '1';
|
175 |
|
|
END IF;
|
176 |
|
|
ELSE
|
177 |
|
|
fct_full_i <= '1';
|
178 |
|
|
dat_full_i <= '1';
|
179 |
|
|
END IF;
|
180 |
|
|
END PROCESS;
|
181 |
|
|
|
182 |
|
|
fct_en <= NOT(fct_full_i) AND NOT(fct_nwrite);
|
183 |
|
|
dat_en <= NOT(dat_full_i) AND NOT(dat_nwrite);
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
---==================================---
|
187 |
|
|
--== Character Priority Multiplexor ==--
|
188 |
|
|
---==================================---
|
189 |
|
|
|
190 |
|
|
PROCESS(load, bit_array, fct_en, dat_en, parity, dat_din)
|
191 |
|
|
BEGIN
|
192 |
|
|
IF (load = '1') THEN
|
193 |
|
|
IF (fct_en = '1') THEN
|
194 |
|
|
bit_array_d <= zeros & "00001";
|
195 |
|
|
ELSIF (dat_en = '1') THEN
|
196 |
|
|
IF (dat_din(datawidth) = '1') THEN
|
197 |
|
|
bit_array_d <= zeros & "00" & NOT(dat_din(0)) & dat_din(0) & '1';
|
198 |
|
|
ELSE
|
199 |
|
|
bit_array_d <= dat_din(datawidth-1 DOWNTO 0) & '0';
|
200 |
|
|
END IF;
|
201 |
|
|
ELSE
|
202 |
|
|
bit_array_d <= zeros & "10111";
|
203 |
|
|
END IF;
|
204 |
|
|
ELSE
|
205 |
|
|
bit_array_d <= (others => '0');
|
206 |
|
|
END IF;
|
207 |
|
|
END PROCESS;
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
PROCESS(bit_array_d, bit_array)
|
211 |
|
|
VARIABLE temp : STD_LOGIC;
|
212 |
|
|
BEGIN
|
213 |
|
|
temp := '0' XOR bit_array_d(0);
|
214 |
|
|
FOR i IN 1 TO datawidth LOOP
|
215 |
|
|
temp := temp XOR bit_array(i);
|
216 |
|
|
END LOOP;
|
217 |
|
|
parity_d <= NOT temp;
|
218 |
|
|
END PROCESS;
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
---===================================---
|
222 |
|
|
--== Drive Tx Data Output (NONE-TMR) ==--
|
223 |
|
|
---===================================---
|
224 |
|
|
|
225 |
|
|
tx <= bit_array & parity;
|
226 |
|
|
tx_valid <= load;
|
227 |
|
|
|
228 |
|
|
---======================================---
|
229 |
|
|
--== Shared Internal & External Signals ==--
|
230 |
|
|
---======================================---
|
231 |
|
|
|
232 |
|
|
fct_full <= fct_full_i;
|
233 |
|
|
dat_full <= dat_full_i;
|
234 |
|
|
|
235 |
|
|
END rtl;
|