Вы находитесь на странице: 1из 9

Proyecto Final - Tecnicas Digitales I

Bosse - Miranda - Malerba


12 de febrero de 2015

1.

Introducci
on

Como conclusi
on del a
no, y utilizando los contenidos aprendidos, proponemos la realizaci
on de un proyecto en el que integraremos conceptos tales como
M
aquinas de Estado, comunicacion por Puerto Serie, Divisores de Frecuencia, y
dem
as, mediante su implementacion en VHDL describiendo una estructura de
hardware corriendo en una plataforma FPGA.

2.

Ante - Proyecto

El proyecto se basa en la comunicacion de dos estaciones por medio de un


protocolo serie de com
un acuerdo. Para ello, proponemos la utilizacion del mundialmente conocido C
odigo Morse.
Componiendo la trama de enlace utilizaremos 2 FPGA, las cuales estaran
comunicadas entre si mediante el protocolo serie mecionado anteriormente. A
su vez, estas estar
an enlazadas a una computadora cada una. Mediante la PC
se le comunicar
a al dispositivo el mensaje a enviar utilizando protocolo serie y
la interfaz UART de la pc.
Como interprete de la comunicacion PC-FPGA escribiremos un programa
para tal fin, mediante la utilizacion de C++ con entorno grafico en Qt4.

3.

Adaptaci
on

Al momento del planteo del proyecto se presupuso de muy alta dificultad la


posibilidad de reemplazar uno de los extremos de la comunicacion por un operario capacitado, quien transmitira a una estacion el mensaje en codigo Morse
y all la FPGA se encargara de recibirlo y decodificarlo. Se creyo complicada la tarea de sincronizaci
on entre el operario y la maquina, debido a la poca
uniformidad del mensaje enviado y la complejidad de su modelado.
A la hora de realizar el proyecto nos vimos capaces de dise
nar un sistema que
guiara al operario y facilitara enormemente su uso. Es por eso que decidimos
modificar tal aspecto del proyecto volviendolo altamente mas aplicable a un uso
real.

Bosse - Miranda - Malerba

Tecnicas Digitales I - 2014 - Trabajo Final

Figura 1: M
odulo de interpretacion del codigo Morse.

4.

Realizaci
on

La construcci
on en VHDL se descompone en 2 modulos: la lectura de la
trama del mensaje y el envo por protocolo UART a la PC.
1. Para la interpretaci
on de la trama del mensaje construmos una maquina
de Mealy (Figura 1) cuya finalidad fue determinar si la se
nal que ingresaba
corresponda a un punto (.) o a una raya (-), componentes fundamentales del c
odigo Morse. Ademas de los puntos y rayas, la maquina deba
discriminar 2 lapsos de tiempo de diferente longitud, para poder, luego,
determinar cuales puntos y rayas deben ir juntos para simbolizar una letra
y cuales deben ir separados porque pertenecen a palabras diferentes.
2. Por otro lado, una vez realizada la identificacion del smbolo recibido, es
necesario enviarlo a la PC donde se realizara la vinculacion con los caracteres correspondientes -indicados por el modulo anterior- a fin de formar
el mensaje. Para esto, el modulo de transmision utiliza el protocolo UART
a 115200 baudios mediante el cual enva los paquetes con el mensaje.

4.1.

Problemas

Durante el desarrollo nos encontramos con diversos problemas. El mayor de


ellos fue el dise
no de un sistema intuitivo para proveer la mejor experiencia al
momento de ingresar el mensaje.
Para resolver esto, utilizamos un sistema de codigos visuales que comunican al operador cuando el sistema ha detectado el ingreso de cada uno de los

Bosse - Miranda - Malerba

Tecnicas Digitales I - 2014 - Trabajo Final

smbolos. Cremos -y luego comprobamos- que mediante la utilizacion de tres indicadores se logra un dictado fluido. Dos de ellos se encargan de indicar cuando
se ha detectado un punto o una raya respectivamente y el tercero se
nala cuando
ha transcurrido el tiempo suficiente para indicar un espacio.
Otro imprevisto que se nos presento fue la sobrecarga del canal de comunicaciones, debido a que el sistema estaba dise
nado para enviar un codigo equivalente
a un espacio cada cierto intervalo de tiempo definido. Al estar el receptor en
estado IDLE, a la espera del ingreso del mensaje por parte del operador, este
enviaba constantemente espacios utilizando ociosamente la linea. Para solucio
narlo, limitamos la cantidad de envos a 2 espacios seguidos. Esta
es la mayor
separaci
on necesaria ya que es utilizada para denotar el desacople entre palabras.

5.

Conclusi
on

Una vez concluido el proyecto y alcanzado el objetivo de describir un sistema


capaz de interpretar el dictado humano logramos un producto estable y bien
formado capaz de utilizarse sin mayores problemas en cualquier otro ambiente.
Como mejora al sistema se podran realizar pruebas con un circuito de tiempo
como entrada, con el cual se regulara la barrera que separa al punto de la raya,
pudiendo ajustarse la detecci
on para operarios mas o menos veloces, mejorando
el rendimiendo.

Bosse - Miranda - Malerba

6.

Tecnicas Digitales I - 2014 - Trabajo Final

Code

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
entity receptor is
generic(
frequency
baud
);
Port (

I,rst
clkCS
txd,clkCM
txd_busy

E1, E2, E3, E4


cada estado
);
end receptor;

: integer := 25000000;
: integer := 115200

:
:
:
:

in STD_LOGIC;
in std_logic;
out std_logic;
out std_logic;

: out std_logic; -- led para

architecture Behavioral of receptor is


-- DEFINICION DE TIPOS
-- CODIGO MORSE
type state_typeCM is ( reposo,
espacio,
punto,
ralla
);
-- COMUNICACION SERIE
type state_typeCS is (idle, start, bit0, bit1, bit2, bit3, bit4, bit5,
bit6, bit7, stop1, stop2);
-- DEFINICION DE SENALES
-- CODIGO MORSE
signal stateCM, next_stateCM : state_typeCM;
signal S_i : std_logic_vector(1 DOWNTO 0);
signal SSclkCM : std_logic := 0;
signal clock_div : integer range 0 to 12500000 := 0;
signal clock_temp : integer range 0 to 12500000 := 0;
signal CONT : integer range 0 to 3 := 0;
-- COMUNICACION SERIE
signal stateCS : state_typeCS := idle;
signal data, txd_data : std_logic_vector(7 downto 0);
signal baud_tick : std_logic;
signal busy : std_logic := 0;
signal baud_divider : integer range 0 to (frequency/100 + baud/100 - 1)
:= 0;

Bosse - Miranda - Malerba

Tecnicas Digitales I - 2014 - Trabajo Final

signal txd0,txd1,txd2,txd3,txd4,txd5,txd6,txd7,txd_start : std_logic;


begin
-- CODIGO MORSE
SYNC_PROC: process (clkCS)
begin
if (clkCSevent and clkCS = 1) then
if (rst = 1) then
clock_div <= 0;
else
clock_div <= clock_div + 1;
if clock_div = 100 and SSclkCM = 0 and txd_data /=
"00000000" and CONT < 3 then
txd_start <= 1;
end if;
if clock_div = 2100 and SSclkCM = 0 and txd_data /=
"00000000" and CONT < 3 then
txd_start <= 0;
end if;
if clock_div = 12500000 then
SSclkCM <= not SSclkCM;
clkCM <= SSclkCM;
clock_div <= 0;
end if;
end if;
end if;
end process;
process (SSclkCM)
begin
if (SSclkCMevent and SSclkCM = 1) then
if (rst = 1) then
stateCM <= reposo;
txd_data <= "00000000";
else
stateCM <= next_stateCM;
if (stateCM = espacio) then
if (CONT < 3) then
CONT <= CONT + 1;
end if;
else
CONT <= 0;
end if;
txd_data <= S_i(0) & S_i(1) & "000000" ;
end if;
end if;
end process;
OUTPUT_DECODE: process (stateCM, I)
begin

Bosse - Miranda - Malerba

if (stateCM = reposo) then


E1
E2
E3
E4

<=
<=
<=
<=

1;
0;
0;
0;

if (I = 0) then
S_i <= "00";
else
S_i <= "00";
end if;
end if;
if (stateCM = espacio) then
E1
E2
E3
E4

<=
<=
<=
<=

0;
1;
0;
0;

if (I = 0) then
S_i <= "11";
else
S_i <= "00";
end if;
end if;
if (stateCM = punto) then
E1
E2
E3
E4

<=
<=
<=
<=

0;
0;
1;
0;

if (I = 0) then
S_i <= "01";
else
S_i <= "10";
end if;
end if;
if (stateCM = ralla) then
E1
E2
E3
E4

<=
<=
<=
<=

0;
0;
0;
1;

if (I = 0) then
S_i <= "00";
else
S_i <= "00";
end if;

Tecnicas Digitales I - 2014 - Trabajo Final

Bosse - Miranda - Malerba

Tecnicas Digitales I - 2014 - Trabajo Final

end if;
end process;
NEXT_STATE_DECODE: process (stateCM, I)
begin
next_stateCM <= stateCM; --default is to stay in current state
case (stateCM) is
when reposo =>
if I = 1 then
next_stateCM <= punto;
else
next_stateCM <= espacio;
end if;
when espacio =>
if I = 1 then
next_stateCM <= punto;
else
next_stateCM <= espacio;
end if;
when punto =>
if I = 1 then
next_stateCM <= ralla;
else
next_stateCM <= reposo;
end if;
when ralla =>
if I = 1 then
next_stateCM <= ralla;
else
next_stateCM <= reposo;
end if;
when others =>
next_stateCM <= reposo;
end case;
end process;
-- COMUNICACION SERIE
-- DEFINICIONES
txd_busy <= busy; busy <= 0 when stateCS = idle else 1;
-- PROCESOS
baud_gen : process(clkCS)
begin
if clkCSevent and clkCS = 1 then
if busy = 1 then
baud_divider <= baud_divider + (baud/100);
if baud_divider > (frequency/100) then
baud_tick <= 1;
baud_divider <= 0;
else
baud_tick <= 0;
end if;

Bosse - Miranda - Malerba

Tecnicas Digitales I - 2014 - Trabajo Final

end if;
end if;
end process baud_gen;
-state_proc : process(clkCS)
begin
if clkCSevent and clkCS = 1 then
case stateCS is
when idle =>
if txd_start = 1 then
stateCS <= start;
end if;
when start =>
if baud_tick = 1 then
stateCS <= bit0;
end if;
when bit0 =>
if baud_tick = 1 then
stateCS <= bit1;
end if;
when bit1 =>
if baud_tick = 1 then
stateCS <= bit2;
end if;
when bit2 =>
if baud_tick = 1 then
stateCS <= bit3;
end if;
when bit3 =>
if baud_tick = 1 then
stateCS <= bit4;
end if;
when bit4 =>
if baud_tick = 1 then
stateCS <= bit5;
end if;
when bit5 =>
if baud_tick = 1 then
stateCS <= bit6;
end if;
when bit6 =>
if baud_tick = 1 then
stateCS <= bit7;
end if;
when bit7 =>
if baud_tick = 1 then
stateCS <= stop1;
end if;
when stop1 =>
if baud_tick = 1 then
stateCS <= stop2;
end if;
when stop2 =>
if baud_tick = 1 then

Bosse - Miranda - Malerba

Tecnicas Digitales I - 2014 - Trabajo Final

stateCS <= idle;


end if;
end case;
end if;
end process state_proc;
-data_load_proc : process(clkCS)
begin
if clkCSevent and clkCS = 1 then
if txd_start = 1 then
data <= txd_data;
end if;
end if;
end process data_load_proc;
-txd_proc : process(clkCS)
begin
if clkCSevent and clkCS = 1 then
case stateCS is
when idle => txd <= 1;
when start => txd <= 0;
when bit0 => txd <= data(0);
when bit1 => txd <= data(1);
when bit2 => txd <= data(2);
when bit3 => txd <= data(3);
when bit4 => txd <= data(4);
when bit5 => txd <= data(5);
when bit6 => txd <= data(6);
when bit7 => txd <= data(7);
when stop1 => txd <= 1;
when stop2 => txd <= 1;
end case;
end if;
end process txd_proc;

end Behavioral;

Вам также может понравиться