##// END OF EJS Templates
Se saca comando x"08" de la implementación. Este comando estaba indicado en la descripción y dejaba colgado al equipo en el momento de su configuración porque el pulsedesign genera este comando.
imanay -
r45:46
parent child
Show More
@@ -1,182 +1,182
1 library IEEE; No newline at end of file
1 library IEEE;
2 use IEEE.STD_LOGIC_1164.ALL; No newline at end of file
2 use IEEE.STD_LOGIC_1164.ALL;
3 use IEEE.STD_LOGIC_ARITH.ALL; No newline at end of file
3 use IEEE.STD_LOGIC_ARITH.ALL;
4 use IEEE.STD_LOGIC_UNSIGNED.ALL; No newline at end of file
4 use IEEE.STD_LOGIC_UNSIGNED.ALL;
5 --Entidad de detector de comandos No newline at end of file
5 --Entidad de detector de comandos
6 ---Contiene un SIPO (Serial Input Parallel Output) interno proveniente de rs232_module para obtener en un registro los datos seriales. No newline at end of file
6 ---Contiene un SIPO (Serial Input Parallel Output) interno proveniente de rs232_module para obtener en un registro los datos seriales.
7 ---Devuelve el comando codificado ("funcion") con una se�al de aviso de comando listo("func_data_sel") muy usada en muchos modulos. No newline at end of file
7 ---Devuelve el comando codificado ("funcion") con una se�al de aviso de comando listo("func_data_sel") muy usada en muchos modulos.
8 ---Asimismo, devuelve el dato recibido ("data_out") con una se�al de aviso de dato listo ("ready_div_clk") que sera recibida por wr_memory_block_module. No newline at end of file
8 ---Asimismo, devuelve el dato recibido ("data_out") con una se�al de aviso de dato listo ("ready_div_clk") que sera recibida por wr_memory_block_module.
9 ---Una vez de dar aviso mediante ambas se�ales de aviso se espera "ACK" para regresar a espera de otro comando � dato. No newline at end of file
9 ---Una vez de dar aviso mediante ambas se�ales de aviso se espera "ACK" para regresar a espera de otro comando � dato.
10 entity commands_detector is No newline at end of file
10 entity commands_detector is
11 Port ( clk : in STD_LOGIC; No newline at end of file
11 Port ( clk : in STD_LOGIC;
12 RST : in STD_LOGIC; No newline at end of file
12 RST : in STD_LOGIC;
13 RX : in STD_LOGIC; No newline at end of file
13 RX : in STD_LOGIC;
14 ACK : in std_logic; No newline at end of file
14 ACK : in std_logic;
15 funcion : out STD_LOGIC_VECTOR (7 downto 0); No newline at end of file
15 funcion : out STD_LOGIC_VECTOR (7 downto 0);
16 func_data_sel : out std_logic; No newline at end of file
16 func_data_sel : out std_logic;
17 data_out : out std_LOGIC_VECTOR(7 downto 0); No newline at end of file
17 data_out : out std_LOGIC_VECTOR(7 downto 0);
18 ready_div_clk : out STD_LOGIC); No newline at end of file
18 ready_div_clk : out STD_LOGIC);
19 end commands_detector; No newline at end of file
19 end commands_detector;
20 No newline at end of file
20
21 architecture Behavioral of commands_detector is No newline at end of file
21 architecture Behavioral of commands_detector is
22 component rs232_module No newline at end of file
22 component rs232_module
23 Port ( CLK : in STD_LOGIC; No newline at end of file
23 Port ( CLK : in STD_LOGIC;
24 RST : in STD_LOGIC; No newline at end of file
24 RST : in STD_LOGIC;
25 RX : in STD_LOGIC; No newline at end of file
25 RX : in STD_LOGIC;
26 ACK : in STD_LOGIC; No newline at end of file
26 ACK : in STD_LOGIC;
27 READY : out STD_LOGIC; No newline at end of file
27 READY : out STD_LOGIC;
28 DATA : out STD_LOGIC_VECTOR (7 downto 0)); No newline at end of file
28 DATA : out STD_LOGIC_VECTOR (7 downto 0));
29 end component; No newline at end of file
29 end component;
30 --Definiciones para m�quina de estado No newline at end of file
30 --Definiciones para m�quina de estado
31 type command_func_fsm is (IDLE, COMMAND_VAL, DATA_VAL,WAIT_ACK); No newline at end of file
31 type command_func_fsm is (IDLE, COMMAND_VAL, DATA_VAL,WAIT_ACK);
32 signal com_func_fsm : command_func_fsm:=IDLE; No newline at end of file
32 signal com_func_fsm : command_func_fsm:=IDLE;
33 attribute com_fsm_attribute : STRING; No newline at end of file
33 attribute com_fsm_attribute : STRING;
34 attribute com_fsm_attribute of command_func_fsm: TYPE is "00 01 10 11"; No newline at end of file
34 attribute com_fsm_attribute of command_func_fsm: TYPE is "00 01 10 11";
35 --Se�ales internas para enlazar se�ales rs232_module_1 No newline at end of file
35 --Se�ales internas para enlazar se�ales rs232_module_1
36 signal READY : std_logic:='0'; No newline at end of file
36 signal READY : std_logic:='0';
37 signal data : std_logic_vector(7 downto 0):=(others=>'0'); No newline at end of file
37 signal data : std_logic_vector(7 downto 0):=(others=>'0');
38 begin No newline at end of file
38 begin
39 No newline at end of file
39
40 --Instanciaci�n de rs232_module_1 para detectar datos formato RS232 a 9600 baudios No newline at end of file
40 --Instanciaci�n de rs232_module_1 para detectar datos formato RS232 a 9600 baudios
41 ---depositando dato recibido en registro "data". No newline at end of file
41 ---depositando dato recibido en registro "data".
42 ---Se�al interna "READY" sirve para indicar que se tiene un dato listo en la bandeja "data". Dura 1 ciclo de clk_sys. No newline at end of file
42 ---Se�al interna "READY" sirve para indicar que se tiene un dato listo en la bandeja "data". Dura 1 ciclo de clk_sys.
43 rs232_module_1 : rs232_module No newline at end of file
43 rs232_module_1 : rs232_module
44 Port map ( CLK => CLK, No newline at end of file
44 Port map ( CLK => CLK,
45 RST => RST, No newline at end of file
45 RST => RST,
46 RX => RX, No newline at end of file
46 RX => RX,
47 ACK => READY, No newline at end of file
47 ACK => READY,
48 READY => READY, No newline at end of file
48 READY => READY,
49 DATA => data); No newline at end of file
49 DATA => data);
50 --Proceso de M�quina de Estado No newline at end of file
50 --Proceso de M�quina de Estado
51 ---IDLE: estado de espera a recepci�n de dato listo en bandeja "data" mediante "ready" que viene de rs232_module_1 No newline at end of file
51 ---IDLE: estado de espera a recepci�n de dato listo en bandeja "data" mediante "ready" que viene de rs232_module_1
52 --- y de decisi�n entre recepci�n de COMANDO � DATO No newline at end of file
52 --- y de decisi�n entre recepci�n de COMANDO � DATO
53 ---COMMAND_VAL: estado que reconoce comandos estandar y pasa a WAIT_ACK, caso contrario regresa a IDLE. No newline at end of file
53 ---COMMAND_VAL: estado que reconoce comandos estandar y pasa a WAIT_ACK, caso contrario regresa a IDLE.
54 ---DATA_VAL: estado de transicion a WAIT_ACK. No newline at end of file
54 ---DATA_VAL: estado de transicion a WAIT_ACK.
55 ---WAIT_ACK: espera se�al acknowledge externo, que indica recepci�n externa de dato codificado � registro paralelo para regresar a IDLE. No newline at end of file
55 ---WAIT_ACK: espera se�al acknowledge externo, que indica recepci�n externa de dato codificado � registro paralelo para regresar a IDLE.
56 Process(clk) No newline at end of file
56 Process(clk)
57 begin No newline at end of file
57 begin
58 if rising_edge(clk) then No newline at end of file
58 if rising_edge(clk) then
59 if RST = '1' then No newline at end of file
59 if RST = '1' then
60 com_func_fsm <= IDLE; No newline at end of file
60 com_func_fsm <= IDLE;
61 else No newline at end of file
61 else
62 case com_func_fsm is No newline at end of file
62 case com_func_fsm is
63 ------------------------------------ No newline at end of file
63 ------------------------------------
64 when IDLE => No newline at end of file
64 when IDLE =>
65 case ready is No newline at end of file
65 case ready is
66 when '1' => No newline at end of file
66 when '1' =>
67 if data = X"FF" then No newline at end of file
67 if data = X"FF" then
68 com_func_fsm <= COMMAND_VAL; No newline at end of file
68 com_func_fsm <= COMMAND_VAL;
69 elsif data = X"FE" then No newline at end of file
69 elsif data = X"FE" then
70 com_func_fsm <= DATA_VAL; No newline at end of file
70 com_func_fsm <= DATA_VAL;
71 end if; No newline at end of file
71 end if;
72 when others => null; No newline at end of file
72 when others => null;
73 end case; No newline at end of file
73 end case;
74 ------------------------------------ No newline at end of file
74 ------------------------------------
75 when DATA_VAL => No newline at end of file
75 when DATA_VAL =>
76 if ready = '1' then No newline at end of file
76 if ready = '1' then
77 com_func_fsm <= WAIT_ACK; No newline at end of file
77 com_func_fsm <= WAIT_ACK;
78 end if; No newline at end of file
78 end if;
79 ------------------------------------ No newline at end of file
79 ------------------------------------
80 when COMMAND_VAL => No newline at end of file
80 when COMMAND_VAL =>
81 if ready = '1' then No newline at end of file
81 if ready = '1' then
82 case data is
82 case data is
No newline at end of file
83 when X"78" | X"48" | X"58" | X"68" | X"70" | X"5C"| X"18" | X"00" | X"28" | X"30" | X"40" | X"43" | X"09" | X"16" | X"59" | X"45"=> No newline at end of file
83 when X"78" | X"48" | X"58" | X"68" | X"70" | X"5C"| X"18" | X"00" | X"28" | X"30" | X"40" | X"43" | X"09" | X"08" | X"59" | X"45"=> No newline at end of file
84 com_func_fsm <= WAIT_ACK; No newline at end of file
84 com_func_fsm <= WAIT_ACK;
85 when others => com_func_fsm <= IDLE; No newline at end of file
85 when others => com_func_fsm <= IDLE;
86 end case; No newline at end of file
86 end case;
87 end if; No newline at end of file
87 end if;
88 ------------------------------------ No newline at end of file
88 ------------------------------------
89 when OTHERS => No newline at end of file
89 when OTHERS =>
90 if ACK = '1' then No newline at end of file
90 if ACK = '1' then
91 com_func_fsm <= IDLE; No newline at end of file
91 com_func_fsm <= IDLE;
92 end if; No newline at end of file
92 end if;
93 ------------------------------------ No newline at end of file
93 ------------------------------------
94 end case; No newline at end of file
94 end case;
95 end if; No newline at end of file
95 end if;
96 end if; No newline at end of file
96 end if;
97 end process; No newline at end of file
97 end process;
98 --Proceso que, dentro del estado COMMAND_VAL, diferencia los comandos recibidos y los codifica en un registro "funcion" No newline at end of file
98 --Proceso que, dentro del estado COMMAND_VAL, diferencia los comandos recibidos y los codifica en un registro "funcion"
99 ---Al recibir un "ACK" por parte de un m�dulo externo (acknowledge de recepci�n) se resetea. No newline at end of file
99 ---Al recibir un "ACK" por parte de un m�dulo externo (acknowledge de recepci�n) se resetea.
100 Process(clk) No newline at end of file
100 Process(clk)
101 variable temp : std_logic_vector(7 downto 0); No newline at end of file
101 variable temp : std_logic_vector(7 downto 0);
102 begin No newline at end of file
102 begin
103 if rising_edge(clk) then No newline at end of file
103 if rising_edge(clk) then
104 if rst = '1' or ACK = '1' then No newline at end of file
104 if rst = '1' or ACK = '1' then
105 temp := (others=>'0'); No newline at end of file
105 temp := (others=>'0');
106 elsif com_func_fsm = COMMAND_VAL and ready = '1' then No newline at end of file
106 elsif com_func_fsm = COMMAND_VAL and ready = '1' then
107 --RESET(X"78") RESET por comando No newline at end of file
107 --RESET(X"78") RESET por comando
108 --TX_ON(X"48"), TX_OFF(X"58") Habilitador TX No newline at end of file
108 --TX_ON(X"48"), TX_OFF(X"58") Habilitador TX
109 --SW_ON(X"68"), SW_OFF(X"70") Habilitador SW No newline at end of file
109 --SW_ON(X"68"), SW_OFF(X"70") Habilitador SW
110 --BW_ON(X"09"), BW_OFF(X"5C") Habilitador BW No newline at end of file
110 --BW_ON(X"09"), BW_OFF(X"5C") Habilitador BW
111 --DISABLE(X"00"), ENABLE(X"18") [cmds borrados: X"50" | X"20"] Tipo de Funcionamiento de CR (Deshabilitar Salidas X"00" | Free Running X"18") No newline at end of file
111 --DISABLE(X"00"), ENABLE(X"18") [cmds borrados: X"50" | X"20"] Tipo de Funcionamiento de CR (Deshabilitar Salidas X"00" | Free Running X"18")
112 --WR_DELAY(X"28"),WR_ESTADOS(X"30"), Escritura en MEM. RETARDOS, MEM. ESTADOS y NEXT_SEQ para MULTIPP No newline at end of file
112 --WR_DELAY(X"28"),WR_ESTADOS(X"30"), Escritura en MEM. RETARDOS, MEM. ESTADOS y NEXT_SEQ para MULTIPP
113 --FRECUENCIA SAMPLING(X"40") , ACTIVAR SAMPLING(X"43") SAMPLING Activable y con Frecuencia Programable No newline at end of file
113 --FRECUENCIA SAMPLING(X"40") , ACTIVAR SAMPLING(X"43") SAMPLING Activable y con Frecuencia Programable
114 --DIVISOR FREC. PROGRAMABLE (X"08"), DIVISOR POR DEFECTO = 60 Divisor de Frecuencia Programable para generaci�n de Pulsos de Salida de CR. No newline at end of file
114 --DIVISOR FREC. PROGRAMABLE (X"08"), DIVISOR POR DEFECTO = 60 Divisor de Frecuencia Programable para generaci�n de Pulsos de Salida de CR.
115 --GENERADOR DE RF VARIABLE (X"45") No newline at end of file
115 --GENERADOR DE RF VARIABLE (X"45")
116 case data is No newline at end of file
116 case data is
117 -- when X"09" | X"5C" => temp:="10000000"; No newline at end of file
117 -- when X"09" | X"5C" => temp:="10000000";
118 when X"45" => temp:="10000000"; No newline at end of file
118 when X"45" => temp:="10000000";
119 when X"78" => temp:="01000000"; No newline at end of file
119 when X"78" => temp:="01000000";
120 when X"48" | X"58" => temp:="00100000"; No newline at end of file
120 when X"48" | X"58" => temp:="00100000";
121 when X"68" | X"70" => temp:="00010000"; No newline at end of file
121 when X"68" | X"70" => temp:="00010000";
122 when X"18" | X"00" | X"59" => temp:="00001000"; No newline at end of file
122 when X"18" | X"00" | X"59" => temp:="00001000";
123 when X"28" | X"30" => temp:="00000100"; No newline at end of file
123 when X"28" | X"30" => temp:="00000100";
124 when X"40" | X"43" => temp:="00000010"; No newline at end of file
124 when X"40" | X"43" => temp:="00000010";
125 when X"16" => temp:="00000001"; No newline at end of file
125 when X"16" => temp:="00000001";
126 when others => temp:=(others=>'0'); No newline at end of file
126 when others => temp:=(others=>'0');
127 end case; No newline at end of file
127 end case;
128 end if; No newline at end of file
128 end if;
129 end if; No newline at end of file
129 end if;
130 funcion <= temp; No newline at end of file
130 funcion <= temp;
131 end process; No newline at end of file
131 end process;
132 --Proceso que genera "ready_div_clk". No newline at end of file
132 --Proceso que genera "ready_div_clk".
133 ---"ready_div_clk" indica que un dato(no comando) ha sido le�do correctamente y se encuentra disponible en el registro "data_out" No newline at end of file
133 ---"ready_div_clk" indica que un dato(no comando) ha sido le�do correctamente y se encuentra disponible en el registro "data_out"
134 ---Al recibir un "ACK" por parte de un m�dulo externo (acknowledge de recepci�n) se resetea. No newline at end of file
134 ---Al recibir un "ACK" por parte de un m�dulo externo (acknowledge de recepci�n) se resetea.
135 Process(clk) No newline at end of file
135 Process(clk)
136 begin No newline at end of file
136 begin
137 if rising_edge(clk) then No newline at end of file
137 if rising_edge(clk) then
138 if rst = '1' or ACK = '1' then No newline at end of file
138 if rst = '1' or ACK = '1' then
139 ready_div_clk <= '0'; No newline at end of file
139 ready_div_clk <= '0';
140 elsif ready = '1' then No newline at end of file
140 elsif ready = '1' then
141 case com_func_fsm is No newline at end of file
141 case com_func_fsm is
142 when DATA_VAL => No newline at end of file
142 when DATA_VAL =>
143 ready_div_clk <= '1'; No newline at end of file
143 ready_div_clk <= '1';
144 when others => null; No newline at end of file
144 when others => null;
145 end case; No newline at end of file
145 end case;
146 end if; No newline at end of file
146 end if;
147 end if; No newline at end of file
147 end if;
148 end Process; No newline at end of file
148 end Process;
149 --Proceso que extrae el dato � comando mostrado por rs232_module_1 No newline at end of file
149 --Proceso que extrae el dato � comando mostrado por rs232_module_1
150 ---Al recibir un "ACK" por parte de un m�dulo externo (acknowledge de recepci�n) se resetea. No newline at end of file
150 ---Al recibir un "ACK" por parte de un m�dulo externo (acknowledge de recepci�n) se resetea.
151 Process(clk) No newline at end of file
151 Process(clk)
152 begin No newline at end of file
152 begin
153 if rising_edge(clk) then No newline at end of file
153 if rising_edge(clk) then
154 if rst = '1' or ACK = '1' then No newline at end of file
154 if rst = '1' or ACK = '1' then
155 data_out <= (others=>'0'); No newline at end of file
155 data_out <= (others=>'0');
156 elsif ready = '1' then No newline at end of file
156 elsif ready = '1' then
157 case com_func_fsm is No newline at end of file
157 case com_func_fsm is
158 when DATA_VAL | COMMAND_VAL => data_out <= data; No newline at end of file
158 when DATA_VAL | COMMAND_VAL => data_out <= data;
159 when others => null; No newline at end of file
159 when others => null;
160 end case; No newline at end of file
160 end case;
161 end if; No newline at end of file
161 end if;
162 end if; No newline at end of file
162 end if;
163 end process; No newline at end of file
163 end process;
164 --Proceso que genera "func_data_sel". No newline at end of file
164 --Proceso que genera "func_data_sel".
165 ---Muestra un pulso luego de 2 ciclos de clk_sys de haber entrado al estado COMMAND_VAL. No newline at end of file
165 ---Muestra un pulso luego de 2 ciclos de clk_sys de haber entrado al estado COMMAND_VAL.
166 ---Tiene una duraci�n de 1 ciclo de clk_sys. No newline at end of file
166 ---Tiene una duraci�n de 1 ciclo de clk_sys.
167 process(clk) No newline at end of file
167 process(clk)
168 variable retardo : std_logic_vector(1 downto 0):=(others=>'0'); No newline at end of file
168 variable retardo : std_logic_vector(1 downto 0):=(others=>'0');
169 begin No newline at end of file
169 begin
170 if rising_edge(clk) then No newline at end of file
170 if rising_edge(clk) then
171 if rst = '1' or com_func_fsm /= COMMAND_VAL then No newline at end of file
171 if rst = '1' or com_func_fsm /= COMMAND_VAL then
172 func_data_sel <= '0'; No newline at end of file
172 func_data_sel <= '0';
173 retardo:=(others=>'0'); No newline at end of file
173 retardo:=(others=>'0');
174 elsif com_func_fsm = COMMAND_VAL then No newline at end of file
174 elsif com_func_fsm = COMMAND_VAL then
175 func_data_sel <= not(retardo(1)) and retardo(0); No newline at end of file
175 func_data_sel <= not(retardo(1)) and retardo(0);
176 retardo(1):=retardo(0); No newline at end of file
176 retardo(1):=retardo(0);
177 retardo(0) :='1'; No newline at end of file
177 retardo(0) :='1';
178 end if; No newline at end of file
178 end if;
179 end if; No newline at end of file
179 end if;
180 end process; No newline at end of file
180 end process;
181 end Behavioral; No newline at end of file
181 end Behavioral;
182 No newline at end of file
182
General Comments 0
You need to be logged in to leave comments. Login now