summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprot2004-02-23 14:28:44 +0000
committerprot2004-02-23 14:28:44 +0000
commit0a1f5ed5b441501c01dbf94f80828952f091c433 (patch)
tree19f3092563728fe39bde9b06ff9661fe6bb894fb
parent35a62b404da36bf239aa8954c286efa6c2bb925d (diff)
Ajout des fichiers vhdl des vacances
-rw-r--r--2004/n/fpga/src/portserie/REGISTRE.VHD82
-rw-r--r--2004/n/fpga/src/portserie/RXSERIE.TEX145
-rw-r--r--2004/n/fpga/src/portserie/RXSERIE.VHD206
-rw-r--r--2004/n/fpga/src/portserie/TEST_REG.VHD69
-rw-r--r--2004/n/fpga/src/portserie/TXSERIE.TEX139
-rw-r--r--2004/n/fpga/src/portserie/TXSERIE.VHD201
-rw-r--r--2004/n/fpga/src/portserie/modele.vhd603
7 files changed, 1445 insertions, 0 deletions
diff --git a/2004/n/fpga/src/portserie/REGISTRE.VHD b/2004/n/fpga/src/portserie/REGISTRE.VHD
new file mode 100644
index 0000000..c927f8b
--- /dev/null
+++ b/2004/n/fpga/src/portserie/REGISTRE.VHD
@@ -0,0 +1,82 @@
+-- -------------------------------------------
+-- Registre générique à brancher sur un bus
+-- -------------------------------------------
+--
+-- * on peut écrire ou lire dans le registre depuis le bus :
+-- . Positionner l'adresse
+-- . Mettre 'rw' à 1=>read 0=>write
+-- . Front montant sur 'ck'
+-- Remarque : on ne peut pas écrire via le bus si 'load' est activé
+-- * on peut lire la valeur en permanence sur 'output'
+-- * on peut écrire dans le registre en permanence grâce à 'load'. Cette
+-- action est prioritaire sur l'écriture via le bus
+-- . Mettre 'load' à 1
+-- . Ecrire dans 'input' (actualisation immédiate)
+-- . Mettre 'load' à 0 pour latcher
+
+library ieee;
+library ieee.std_logic_1164.all;
+
+entity registre is
+generic(adr : integer);
+constant adr_w : integer :=10;
+constant data_w : integer :=8;
+port(
+ adrbus: in std_logic_vector((adr_w - 1) downto 0);
+ databus: inout std_logic_vector((data_w - 1) downto 0);
+ input: in std_logic_vector((data_w - 1) downto 0);
+ output: out std_logic_vector((data_w - 1) downto 0);
+ rw: in std_logic;
+ load: in std_logic;
+ ck: in std_logic;
+ rst: in std_logic
+ );
+end registre;
+
+architecture rtl of registre is
+signal REG : std_logic_vector((data_w - 1) downto 0);
+
+begin
+ p_w:process(ck)
+ begin
+ if(ck'event and ck='1') then
+ if(bvtoi(To_bitvector(adrbus))=adr) then
+ if(rw='0') then
+ if(load='0') then
+ REG<=databus;
+ end if;
+ end if;
+ end if;
+ end if;
+ end process p_w;
+
+ p_r : process(adr,rw)
+ begin
+ if(bvtoi(To_bitvector(adrbus))=adr and rw='1') then
+ databus<=REG;
+ else
+ databus<='ZZZZZZZZ';
+ end if;
+ end process p_r;
+
+ p_load : process(load,input)
+ begin
+ if(load='1') then
+ REG<=input;
+ end if;
+ end process p_load;
+
+ p_reset : process(rst)
+ begin
+ if(rst'event and rst='1') then
+ REG='00000000';
+ databus='ZZZZZZZZ';
+ end if;
+
+ output<=REG;
+end rtl;
+
+
+
+
+
diff --git a/2004/n/fpga/src/portserie/RXSERIE.TEX b/2004/n/fpga/src/portserie/RXSERIE.TEX
new file mode 100644
index 0000000..ae840f6
--- /dev/null
+++ b/2004/n/fpga/src/portserie/RXSERIE.TEX
@@ -0,0 +1,145 @@
+\section{Cahier des charges}
+Le cahier des charges du récepteur série est le suivant :
+
+\begin{itemize}
+\item Réception série 8 bits, 1 start, 2 stop
+\item Vitesse : paramétrable 9600 et 115200 bauds
+\item Fifo de stockage des données reçues
+\item Interruption activable signalant que la fifo est pleine
+\item Interruption activable signalant qu'on a reçu une donnée
+\end{itemize}
+
+\section{Architecture globale}
+Voici le schéma modulaire du récepteur :
+
+\section{Utilisation}
+Ce port série utilise 3 adresses mémoire :
+\subsection{Rxdata}
+Ce registre 8 bits permet de récupérer les données reçues. On les lit
+séquentiellement, et chaque lecture dans ce registre dépile la donnée en bas
+de la fifo.
+
+Adresse : \textit{adresse\_module} + 0
+
+\subsection{Flag}
+C'est le registre d'état. Il donne essentiellement des informations sur l'état
+de remplissage de la pile de réception.
+
+Adresse : \textit{adresse\_module} + 1
+
+Structure :
+\begin{tabular}
+bit ! 7 ! 6 ! 5 ! 4 ! 3 ! 2 ! 1 ! 0
+nom ! x ! x ! x ! x ! FNE ! FFull ! FL1 ! FL0
+\end{tabular}
+
+Signification des bits :
+\begin{description}
+\item [FL1/FL0] : Fifo Level 1/0. Ces bits donnent le niveau de remplissage de
+la fifo.
+ \begin{tabular}
+ FL1/FL0 ! Tx de remplissage
+ 00 ! < 25\%
+ 01 ! 25\% < Tx < 50\%
+ 10 ! 20\% < Tx < 75\%
+ 11 ! 75\% < Tx
+ \end{tabular}
+\item [FFull] : indique que la pile est pleine. Chaque front montant de ce
+bit déclenche l'interruption FifoFullInt
+\item [FNE] : FifoNonEmpty. Indique que la fifo n'est pas vide, et donc qu'une
+donnée est arrivée dans le récepteur. Chaque front montant de ce bit déclenche
+l'interruption FifiNonEmptyInt
+\end{description}
+
+\subsection{Config}
+Ce registre sert de configuration pour la transmission.
+
+Adresse : \textit{adresse\_module} + 2
+
+Structure
+\begin{tabular}
+bit ! 7 ! 6 ! 5 ! 4 ! 3 ! 2 ! 1 ! 0
+nom ! x ! x ! x ! On/Off ! FNEIE ! FFIE ! BdR1 ! BdR0
+\end{tabular}
+
+Signification des bits :
+\begin{description}
+\item [BdR1/BdR0] : BaudRate1/0. Ces bits paramètrent la vitesse de
+transmission.
+ \begin{tabular}
+ BdR1/BdR0 ! Vitessse
+ 00 ! 9600
+ 01 ! 19200
+ 10 ! 57600
+ 11 ! 115200
+ \end{tabular}
+\item [FFIF] : FifoFull-Int-Enable. Active ou non l'interruption FifoFull
+(actif à 1)
+\item [FNEIE] : FifiNonEmpty-Int-Enable. Active ou non l'interruption
+FifiNonEmpty (actif à 1)
+\item [On/Off] : active ou non la réception de données
+\end{description}
+
+\subsection{Utilisation}
+\begin{itemize}
+\item Mettre le bit On/Off à 1 pour activer la réception des données.
+\item Paramétrer la vitesse à l'aide des bits BdR1/0
+\item Il est conseillé d'activer l'interruption de fifo pleine (FFInt) en
+mettant à 1 le bit FFIE.
+\item On peut également activer l'interruption de donnée reçue FNEInt en
+mettant à 1 le bit FNEIE.
+\item Tester si une donnée est présente dans le buffer en testant le bit FNE.
+S'il est à 1, lire la donnée dans rxdata. La donnée est alors automatiquement
+dépilée de la fifo.
+\item On peut lire en permanence l'état de la fifo grâce aux bits FL1/0.
+\item Quand la fifo est pleine, le flag FFI passe à 1, et le front
+montant de ce bit génère une interruption. Il faut alors lire les 512 octets
+de la fifo pour la vider.
+\end{itemize}
+
+
+\section{Interfaçage}
+
+Voici le schéma de l'entité txserie :
+
+Voici le code vhdl de l'entité rxserie :
+\begin{verbatim}
+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;
+\end{verbatim}
+
+\begin{description}
+\item [adr : integer] : paramètre générique entier définissant l'adresse du
+module (notée \textit{adress\_module})
+\item [adr\_w] : largeur du bus d'adresse. le code peut ainsi être modifié
+pour s'adapter à plusieurs largeurs de bus d'adresse.
+\item [adrbus] : bus d'adresse
+\item [databus] : bus de données
+\item [rw] : ligne Read/Write\_
+\item [busck] : horloge bus
+\item [rst] : patte de reset
+\item [masterck] : horloge générale du fpga
+\item [rxin] : patte de sortie série
+\item [FNEIout] : sortie d'interruption FNEInt
+\item [FFIout] : sortie d'interruption FFInt
+\end{description}
+
+
+\section{Conclusion}
+Ce récepteur est polyvalent, il intègre les fonctions les plus utilisées,
+et permet de les utiliser facilement.
+
+
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;
+
+
diff --git a/2004/n/fpga/src/portserie/TEST_REG.VHD b/2004/n/fpga/src/portserie/TEST_REG.VHD
new file mode 100644
index 0000000..91157d2
--- /dev/null
+++ b/2004/n/fpga/src/portserie/TEST_REG.VHD
@@ -0,0 +1,69 @@
+-- testbench pour le registre
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.all;
+use work.mypack.all;
+
+entity testreg is
+constant adr_w : integer :=10;
+constant data_w : integer :=8;
+end testreg;
+
+architecture sim1 of testreg is
+component registre
+ port(
+ adrbus: in std_logic_vector((adr_w - 1) downto 0);
+ databus:inout std_logic_vector((data_w - 1) downto 0);
+ input: in std_logic_vector((data_w - 1) downto 0);
+ output: out std_logic_vector((data_w - 1) downto 0);
+ rw: in std_logic;
+ load: in std_logic;
+ ck: in std_logic;
+ rst: in std_logic
+ );
+end component;
+
+signal adrbus: std_logic_vector((adr_w - 1) downto 0);
+signal databus: std_logic_vector((data_w - 1) downto 0);
+signal input: std_logic_vector((data_w - 1) downto 0);
+signal put: std_logic_vector((data_w - 1) downto 0);
+signal rw: std_logic;
+signal load: std_logic;
+signal ck: std_logic;
+signal rst: std_logic;
+
+begin
+ R0: registre
+ generic map(adr => 12)
+ port map(
+ adrbus=> adrbus,
+ databus=> databus,
+ input=> input := '00000001',
+ output=> output,
+ rw=> rw :='0',
+ load=> load :='0',
+ ck=> ck :='0',
+ rst=> rst
+ );
+
+ adrbus <= '0000001100' ,
+ '0100001100' after 40 ns,
+ '0000001101' after 60 ns;
+ '0000001100' after 100 ns,
+
+ databus <= databus + 1 after 2 ns;
+ input <= not input after 3 ns;
+ rw <= not rw after 11 ns;
+ load <= not load after 7 ns;
+ ck <= not ck after 5 ns;
+ rst <= '1','0' after 2 ns;
+
+end sim1;
+
+
+configuration cf1 of testreg is
+ for sim1
+ for all : registre use entity work.registre(rtl); end for;
+ end for;
+end cf1;
+
diff --git a/2004/n/fpga/src/portserie/TXSERIE.TEX b/2004/n/fpga/src/portserie/TXSERIE.TEX
new file mode 100644
index 0000000..20648fd
--- /dev/null
+++ b/2004/n/fpga/src/portserie/TXSERIE.TEX
@@ -0,0 +1,139 @@
+\section{Cahier des charges}
+Le cahier des charges du transmetteur série est le suivant :
+
+\begin{itemize}
+\item Transmission série 8 bits, 1 start, 2 stop
+\item Vitesse : paramétrable 9600 et 115200 bauds
+\item Fifo de stockage avant transmision
+\item Interruption activable signalant que la pile est pleine
+\end{itemize}
+
+\section{Architecture globale}
+Voici le schéma modulaire du transmetteur :
+
+\section{Utilisation}
+Ce port série utilise 3 adresses mémoire :
+\subsection{Txdata}
+Ce registre 8 bits sert à recevoir les données à envoyer. On les écrit
+séquentiellement, et chaque écriture dans ce registre empile la donnée en haut
+de la fifo.
+
+Adresse : \textit{adresse\_module} + 0
+
+\subsection{Flag}
+C'est le registre d'état. il donne essentiellement des informations sur l'état
+de remplissage de la pile de transmision.
+
+Adresse : \textit{adresse\_module} + 1
+
+Structure :
+\begin{tabular}
+bit ! 7 ! 6 ! 5 ! 4 ! 3 ! 2 ! 1 ! 0
+nom ! x ! x ! x ! x ! Empty ! Full/Int ! FLI1 ! FLI0
+\end{tabular}
+
+Signification des bits :
+\begin{description}
+\item [FL1/FL0] : Fifo Level 1/0. Ces bits donnent le niveau de remplissage de
+la fifo.
+ \begin{tabular}
+ FL1/FL0 ! Tx de remplissage
+ 00 ! < 25\%
+ 01 ! 25\% < Tx < 50\%
+ 10 ! 20\% < Tx < 75\%
+ 11 ! 75\% < Tx
+ \end{tabular}
+\item [Full/Int] : indique que la pile est pleine, ce qui déclenche une
+interruption
+\item [Empty] : indique que la pile ET le transmetteur sont vides, que la
+transmission est donc terminée.
+\end{description}
+
+\subsection{Config}
+Ce registre sert de configuration pour la transmission.
+
+Adresse : \textit{adresse\_module} + 2
+
+Structure
+\begin{tabular}
+bit ! 7 ! 6 ! 5 ! 4 ! 3 ! 2 ! 1 ! 0
+nom ! x ! x ! x ! On/Off ! Purge ! IntEn ! BdR1 ! BdR0
+\end{tabular}
+
+Signification des bits :
+\begin{description}
+\item [BdR1/BdR0] : BaudRate1/0. Ces bits paramètrent la vitesse de
+transmission.
+ \begin{tabular}
+ BdR1/BdR0 ! Vitessse
+ 00 ! 9600
+ 01 ! 19200
+ 10 ! 57600
+ 11 ! 115200
+ \end{tabular}
+\item [Int/En] : active ou non l'interruption de fifo pleine
+\item [Purge] : vide la fifo de toutes ses données
+\item [On/Off] : active ou non la transmission
+\end{description}
+
+\subsection{Utilisation}
+\begin{itemize}
+\item Mettre le bit On/Off à 1 pour activer la transmission
+\item Paramétrer la vitesse à l'aide des bits BdR1/0
+\item Il est conseillé d'activer l'interruption de fifo pleine en mettant à 1
+le bit IntEn.
+\item Ecriture dans txdata pour charger les données dans la fifo. Elles sont
+alors automatiquement transférées, au plus tôt. Dès que le registre à décalage
+est vide, il dépile le dernier élément de la fifo et le transmet à nouveau.
+\item On peut lire en permanence l'état de la fifo grâce aux bits FL1/0.
+\item Quand la fifo est pleine, le flag Full/Int passe à 1, et le front
+montant de ce bit génère une interruption.
+\item Il est possible de vider la fifo en mettant Purge à 1. Il faut le
+remettre à 0 pour qu'il puisse être à nouveau actif, car la purge de la fifo
+ne s'effectue que sur front montant de ce bit.
+\end{itemize}
+
+
+\section{Interfaçage}
+
+Voici le schéma de l'entité txserie :
+
+Voici le code vhdl de l'entité txserie :
+\begin{verbatim}
+entity txserie 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;
+ txout: out std_logic;
+ intout: out std_logic;
+ );
+end txserie;
+\end{verbatim}
+
+\begin{description}
+\item [adr : integer] : paramètre générique entier définissant l'adresse du
+module (notée \textit{adress\_module})
+\item [adr\_w] : largeur du bus d'adresse. le code peut ainsi être modifié
+pour s'adapter à plusieurs largeurs de bus d'adresse.
+\item [adrbus] : bus d'adresse
+\item [databus] : bus de données
+\item [rw] : ligne Read/Write\_
+\item [busck] : horloge bus
+\item [rst] : patte de reset
+\item [masterck] : horloge générale du fpga
+\item [txout] : patte de sortie série
+\item [intout] : sortie d'interruption
+\end{description}
+
+
+\section{Conclusion}
+Ce transmetteur est polyvalent, il intègre les fonctions les plus utilisées,
+et permet de les utiliser facilement.
+
+
diff --git a/2004/n/fpga/src/portserie/TXSERIE.VHD b/2004/n/fpga/src/portserie/TXSERIE.VHD
new file mode 100644
index 0000000..acd91a3
--- /dev/null
+++ b/2004/n/fpga/src/portserie/TXSERIE.VHD
@@ -0,0 +1,201 @@
+-- -------------------------------------------
+-- Port série TX pour le fpga robot
+-- -------------------------------------------
+--
+-- * Prend 3 adresses mémoire :
+-- 0 - Txdata
+-- 1 - Flag : (x ! x ! x ! x ! Empty ! Full/Int ! FLI1 ! FLI0)
+-- 2 - Config : (x ! x ! x ! On/Off ! Purge ! IntEn ! BdR1 ! BdR0)
+-- * Mettre le bit On/Off à 1 pour activer la transmission
+-- * Chaque écriture dans txdata charge la donnée dans la fifo
+-- * Dès que le registre à décalage est vide, il enlève le dernier élément de
+-- la fifo et le transmet
+-- * Deux bits de stop
+-- * Quand la fifo est pleine, met le flag Full/Int à 1 et génère une
+-- interruption. Il faut alors mettre à 0 le bit IntEn, qui sera remis à 1 à
+-- la prochaine écriture dans la fifo
+-- * On peut lire l'état de la pile dans le registre de flags
+-- * On peut vider la pile en mettant Purge à 1
+-- * Baudrate disponible :
+-- BdR1/0 ! Baudrate
+-- 00 ! 9600
+-- 01 ! 19200
+-- 10 ! 57600
+-- 11 ! 115200
+
+
+library ieee;
+library ieee.std_logic_1164.all;
+
+entity txserie 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;
+ txout: out std_logic;
+ intout: out std_logic;
+ );
+end txserie;
+
+architecture rtl of txserie 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 transmitter
+ 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;
+
+
diff --git a/2004/n/fpga/src/portserie/modele.vhd b/2004/n/fpga/src/portserie/modele.vhd
new file mode 100644
index 0000000..3186341
--- /dev/null
+++ b/2004/n/fpga/src/portserie/modele.vhd
@@ -0,0 +1,603 @@
+-- txserie.vhd
+-- Eurobot 2004 : APB Team
+-- Auteur : Pierre Prot
+
+-- -------------------------------------------
+-- Port série TX pour le fpga robot
+-- -------------------------------------------
+--
+-- * Prend 3 adresses mémoire :
+-- 0 - Txdata
+-- 1 - Flag : (x ! x ! x ! x ! Empty ! Full/Int ! FLI1 ! FLI0)
+-- 2 - Config : (x ! x ! x ! On/Off ! Purge ! IntEn ! BdR1 ! BdR0)
+-- * Mettre le bit On/Off à 1 pour activer la transmission
+-- * Chaque écriture dans txdata charge la donnée dans la fifo
+-- * Dès que le registre à décalage est vide, il enlève le dernier élément de
+-- la fifo et le transmet
+-- * Deux bits de stop
+-- * Quand la fifo est pleine, met le flag Full/Int à 1 et génère une
+-- interruption. Il faut alors mettre à 0 le bit IntEn, qui sera remis à 1 à
+-- la prochaine écriture dans la fifo
+-- * On peut lire l'état de la pile dans le registre de flags
+-- * On peut vider la pile en mettant Purge à 1
+-- * Baudrate disponible :
+-- BdR1/0 ! Baudrate
+-- 00 ! 9600
+-- 01 ! 19200
+-- 10 ! 57600
+-- 11 ! 115200
+
+
+
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.std_logic_arith.all;
+use ieee.std_logic_unsigned.all;
+
+use work.nono_const.all;
+
+entity txserie is
+ generic (
+ -- adresses des différents registres du module.
+ A_DATA : T_ADDRESS ;
+ A_CONFIG : T_ADDRESS ;
+ A_FLAG : T_ADDRESS
+ -- si autre choses à déclarer...
+ );
+ port (
+ rst : in std_logic;
+ clk : in std_logic;
+
+ -- XXX : savoir si read = 0 ou 1 !!
+ rw : in std_logic; -- read (0) / write (1)
+
+ bus_data : inout unsigned ((NB_BIT_DATA - 1) downto 0);
+ bus_address : in unsigned ((NB_BIT_ADDRESS - 1) downto 0)
+ );
+end entity;
+
+
+entity txserie 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;
+ txout: out std_logic;
+ intout: out std_logic;
+ );
+end txserie;
+
+architecture rtl of txserie 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 transmitter
+ 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;
+
+
+
+library ieee;
+library ieee.std_logic_1164.all;
+
+entity txserie 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;
+ txout: out std_logic;
+ intout: out std_logic;
+ );
+end txserie;
+
+architecture rtl of txserie 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 transmitter
+ 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;
+
+library ieee;
+library ieee.std_logic_1164.all;
+
+entity txserie 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;
+ txout: out std_logic;
+ intout: out std_logic;
+ );
+end txserie;
+
+architecture rtl of txserie 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 transmitter
+ 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;
+
+
+
+
+
+architecture test_modele of modele is
+begin
+ process (rst, clk)
+ begin
+ if (rst = '1') then
+ bus_data <= x"00";
+ elsif (clk'event and clk = '1') then
+ if (bus_address = A_REG1) then
+ bus_data <= x"01";
+ else
+ if (bus_address = A_REG2) then
+ bus_data <= x"02";
+ elsif (bus_address = A_REG3) then
+ bus_data <= x"03";
+ end if;
+ end if;
+ end if;
+ end process;
+end test_modele;