summaryrefslogtreecommitdiff
path: root/2004/n/fpga/src/portserie/rxserie.vhd
diff options
context:
space:
mode:
Diffstat (limited to '2004/n/fpga/src/portserie/rxserie.vhd')
-rw-r--r--2004/n/fpga/src/portserie/rxserie.vhd206
1 files changed, 206 insertions, 0 deletions
diff --git a/2004/n/fpga/src/portserie/rxserie.vhd b/2004/n/fpga/src/portserie/rxserie.vhd
new file mode 100644
index 0000000..c44536b
--- /dev/null
+++ b/2004/n/fpga/src/portserie/rxserie.vhd
@@ -0,0 +1,206 @@
+-- -------------------------------------------
+-- Port série RX pour le fpga robot
+-- -------------------------------------------
+--
+-- * Prend 3 adresses mémoire :
+-- 0 - Rxdata
+-- 1 - Flag : (x ! x ! x ! x ! FNE ! FFull ! 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(adr : integer);
+constant adr_w : integer :=10;
+port(
+ adrbus: in std_logic_vector((adr_w - 1) downto 0);
+ databus: inout std_logic_vector(7 downto 0);
+ rw: in std_logic;
+ busck: in std_logic;
+ rst: in std_logic;
+ masterck: in std_logic;
+ rxin: in std_logic;
+ FNEIout: out std_logic;
+ FFIout: out std_logic;
+ );
+end rxserie;
+
+architecture rtl of rxserie is
+
+component registre
+ generic(adr : integer);
+ port(
+ adrbus: in std_logic_vector((adr_w - 1) downto 0);
+ databus: inout std_logic_vector(7 downto 0);
+ input: in std_logic_vector(7 downto 0);
+ output: out std_logic_vector(7 downto 0);
+ rw: in std_logic;
+ load: in std_logic;
+ ck: in std_logic;
+ rst: in std_logic
+ );
+end component;
+
+component fifo
+ port(
+ data_in: in std_logic_vector(7 downto 0);
+ data_out: in std_logic_vector(7 downto 0);
+ ck_in: in std_logic;
+ ck_out: in std_logic;
+ f0: out std_logic;
+ f1: out std_logic;
+ f2: out std_logic;
+ f3: out std_logic;
+ 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(
+ ck_in: in std_logic;
+ ck_out: in std_logic;
+ param: in std_logic_vector(1 downto 0)
+ );
+end component;
+
+component decoder
+ generic(adr : integer);
+ port(
+ adrbus: in std_logic_vector((adr_w - 1) downto 0);
+ 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: std_logic_vector((adr_w - 1) downto 0);
+signal databus: std_logic_vector(7 downto 0);
+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;
+
+