summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/portserie/rxserie.vhd
blob: 2b906d5ed75c2027ca2e99d4611576e083c79d17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
-- -------------------------------------------
-- Port s�rie RX pour le fpga robot
-- -------------------------------------------
-- 
-- * Prend 3 adresses m�moire :
--    0 - Rxdata 
--    1 - Flag :   (x ! x ! FNE ! FFull  !  FL3  ! FL2  ! FL1  ! FL0 )
--    2 - Config : (x ! x !  x  ! On/Off ! FNEIF ! FFIF ! BdR1 ! BdR0)
-- * Mettre le bit On/Off � 1 pour activer la reception
-- * Chaque lecture dans rxdata d�pile la donn�e de la fifo
-- * D�s que le registre � d�calage est plein, il empile la donn�e dans la
--   fifo.
-- * Deux bits de stop
-- * Quand la fifo est pleine, met le flag FifoFull (FF) � 1. Chaque front
--   montant du flag FF met � 1 le flag d'interruption FFIF et g�n�re une
--   interruption. Il faut alors mettre � 0 FFIF, qui sera remis � 1 au
--   prochain front montant de FF
-- * Quand il y a au moins une donn�e dans la pile, le bit FifiNonEmpty (FNE) 
--   est � 1. Quand FNE passe de 0 � 1, le flag FNEIF passe � 1 et g�n�re une
--   interruption. Il faut alors mettre � 0 FNEIF, qui repassera � 1 au 
--   prochain front montant de FNE
-- * On peut lire l'�tat de la pile dans le registre de flags (FifoLevel1/0)
-- * Baudrate disponible : 
--	BdR1/0 	! Baudrate
--	00	! 9600
--	01	! 19200
--	10	! 57600
--	11	! 115200


library ieee;
library ieee.std_logic_1164.all;

entity rxserie is
    generic (
	-- adresses des diff�rents registres du module.
	A_DATA : T_ADDRESS;
	A_CONFIG : T_ADDRESS;
	A_FLAG : T_ADDRESS
    );
    port (
	rst : in std_logic;
	clk : in std_logic;
	rw  : in std_logic; -- read (0) / write (1)
	bus_data : inout T_DATA;
	bus_address : in T_ADDRESS;
	masterck: in std_logic;
	rxin: in std_logic;
	FNEIout: out std_logic;
	FFIout:	out std_logic
    );
end rxserie;

architecture rtl of rxserie is

component regIO
    generic(adr : T_ADDRESS);
    port(
	bus_address: in T_ADDRESS;
	bus_data: inout T_DATA;
	input: 	in   T_DATA;
	output: out  T_DATA;
	rw:	in std_logic;
	load:	in std_logic;
	ck:	in std_logic;
	rst:	in std_logic
	);
end component;

component fifo is
    port(
	data_in: in T_DATA;
	data_out: out T_DATA;
	ck: 	in std_logic;
	ck_in: 	in std_logic;
	ck_out:	in std_logic;
	flags:	out std_logic_vector(5 downto 0);
	purge:	in std_logic
	);
end component;

component receiver
    port(
	data_in: in std_logic_vector(7 downto 0);
	ck:	in std_logic;
	flag:	out std_logic;
	txout: 	out std_logic
	);
end component;

component clockgene
    port(
	ckin:	in std_logic;
	ckout:	out std_logic;
	param:	in std_logic_vector(1 downto 0)
	);
end component;

component decoder
    generic(adr : T_ADDRESS);
    port(
	bus_address: in T_DATA;
	cs:	out   std_logic
	);
end component;



--signal fifoEmpty: std_logic;
--signal fifoFull: std_logic;
--signal fifoLI1: std_logic;
--signal fifoLI0: std_logic;
--signal BdR1: std_logic;
--signal BdR0: std_logic;
signal purge: std_logic;
signal geneck: std_logic;
signal txck: std_logic;
signal busck: std_logic;
signal adrbus: T_DATA;
signal databus: T_DATA;
signal rw: std_logic;
signal rst: std_logic;
signal txdata: std_logic;
signal txempty: std_logic;
signal csFifo: std_logic;
signal fifockin: std_logic;
signal fifockout: std_logic;

FIFO1: fifo
    port map(
	data_in=>databus,
	data_out=>txdata,
	ck_in=>fifockin,
	ck_out=>fifockout
	f0=>fifoEmpty,
	f1=>fifoLI0,
	f2=>fifoLI1,
	f3=>fifoFull,
	purge=>confreg(3)
	);

fifockin<=csFifo and not rw and busck;
fifockout<=txempty;	-- � v�rifier !!! Cette ligne est valable pour
			-- txempty=1 quand le tx est vide
	
TX1 : transmitter
    port map(
	data_in=>txdata,
	ck=>txck,
	flag=>txempty,
	txout=>txout,
	);

CLOCK1 : clockgene
     port map(
	ck_in=>geneck,
	ck_out=>txck,
	param=>confreg(1 downto 0)
	);
geneck<=confreg(4) and masterck; -- On/Off et masterck


-- Config : (x ! x ! x ! On/Off ! Purge ! IntEn ! BdR1 ! BdR0)
RCONF : registre
    generic map(adr=>adr+1)
    port map(
	adrbus=>adrbus,
	databus=>databus,
	input=>(others => '0'),
	output=>confreg,
	rw=>rw,
	load=>'0',
	ck=>busck,
	rst=>'0'
	);

-- Flag : (x ! x ! x ! x ! Empty ! Full/Int ! FLI1 ! FLI0)
RFLAG : registre
    generic map(adr=>adr+2)
    port map(
	adrbus=>adrbus,
	databus=>databus,
	input=>flagreg,
	output=>open,
	rw=>rw,
	load=>'1',
	ck=>busck,
	rst=>'0'
	);
    
flagreg(7 downto 3)<=(others => '0');
flagreg(3)<=txempty;
flagreg(2)<=fifoFull;
flagreg(1)<=fifoLI1;
flagreg(0)<=fifoLI0;

-- la sortie intout est active si la pile est pleine ET si le bit de conf est
-- activ�
intout<=fifoFull and confreg(2); -- IntEn et fifoFull

DECOD : decoder
    generic map(adr=>adr)
    port map(
	adrbus=>adrbus,
	cs=>csFifo
	);
end rtl;