PUES AQUI REPORTANDO RESULTADOS DE MIS PROYECTOS QUE GRACIAS A "ELVIC" Y A "YUCARDO" PUDE RESOLVER.
EL PRIMERO ES UN REGISTRO CONDESPLAZAMIENTO A LA IZQUIERDA O A LA DERECHA.
EL SEGUNDO ES UN REGISTRO CON DESPLAZAMIENTO ROTACIONAL
POR ULTIMO UNA MAQUINA DE 8 ESTADOS O CONTADOR INSTANCIADA CON UNA MEMORIA ROM
EL PRIMERO ES UN REGISTRO CONDESPLAZAMIENTO A LA IZQUIERDA O A LA DERECHA.
Código:
--DISENO DE UN REGISTRO CON DESPLAZAMIENTO
ENTITY REG_DESP IS
PORT(
DIN_A, DIN_B: IN BIT_VECTOR(3 DOWNTO 0); --ENTRADAS DE REGISTRO
IN_SERIAL: IN BIT; --ENTRADA DE BIT POR DESPLAZAMIENTO
CHARGE: IN BIT; --CARGADOR DE DATOS EN LOS REGISTROS
SHIFT_LR: IN BIT; --CONTROL DE DESPLAZAMIENTO
CLK: IN BIT; --SEÑAL DE RELOJ
QOUT_A, QOUT_B: OUT BIT_VECTOR(3 DOWNTO 0) --SALIDA DE REGISTROS
);
END ENTITY REG_DESP;
ARCHITECTURE ARC OF REG_DESP IS
SIGNAL REG_B, REG_A: BIT_VECTOR(3 DOWNTO 0);
BEGIN
REG: PROCESS(CLK)
BEGIN
IF CLK'EVENT AND CLK='1' THEN
IF CHARGE='1' THEN REG_B <= DIN_A;
REG_A <= DIN_B;
IF SHIFT_LR='0' THEN
REG_A(0) <= IN_SERIAL;
REG_A(1) <= REG_A(0);
REG_A(2) <= REG_A(1);
REG_A(3) <= REG_A(2);
REG_B(0) <= REG_A(3);
REG_B(1) <= REG_B(0);
REG_B(2) <= REG_B(1);
REG_B(3) <= REG_B(2);
ELSE
REG_B(3) <= IN_SERIAL;
REG_B(2) <= REG_B(3);
REG_B(1) <= REG_B(2);
REG_B(0) <= REG_B(1);
REG_A(3) <= REG_B(0);
REG_A(2) <= REG_A(3);
REG_A(1) <= REG_A(2);
REG_A(0) <= REG_A(1);
END IF;
END IF;
END IF;
END PROCESS REG;
QOUT_A <= REG_B;
QOUT_B <= REG_A;
END ARCHITECTURE ARC;
EL SEGUNDO ES UN REGISTRO CON DESPLAZAMIENTO ROTACIONAL
Código:
--DISENO DE UN REGISTRO ROTACIONAL
ENTITY REG_DESP IS
PORT(
DIN_A, DIN_B: IN BIT_VECTOR(3 DOWNTO 0); --ENTRADAS DE REGISTRO
CHARGE: IN BIT; --CARGADOR DE DATOS EN LOS REGISTROS
SHIFT_LR: IN BIT; --CONTROL DE DESPLAZAMIENTO
CLK: IN BIT; --SEÑAL DE RELOJ
QOUT_A, QOUT_B: OUT BIT_VECTOR(3 DOWNTO 0) --SALIDA DE REGISTROS
);
END ENTITY REG_DESP;
ARCHITECTURE ARC OF REG_DESP IS
SIGNAL REG_B, REG_A: BIT_VECTOR(3 DOWNTO 0);
BEGIN
REG: PROCESS(CLK)
BEGIN
IF CLK'EVENT AND CLK='1' THEN
IF CHARGE='1' THEN REG_B <= DIN_A;
REG_A <= DIN_B;
ELSE
IF SHIFT_LR='0' THEN
REG_A(0) <= REG_B(3);
REG_A(1) <= REG_A(0);
REG_A(2) <= REG_A(1);
REG_A(3) <= REG_A(2);
REG_B(0) <= REG_A(3);
REG_B(1) <= REG_B(0);
REG_B(2) <= REG_B(1);
REG_B(3) <= REG_B(2);
ELSE
REG_B(3) <= REG_A(0);
REG_B(2) <= REG_B(3);
REG_B(1) <= REG_B(2);
REG_B(0) <= REG_B(1);
REG_A(3) <= REG_B(0);
REG_A(2) <= REG_A(3);
REG_A(1) <= REG_A(2);
REG_A(0) <= REG_A(1);
END IF;
END IF;
END IF;
END PROCESS REG;
QOUT_A <= REG_B;
QOUT_B <= REG_A;
END ARCHITECTURE ARC;
Código:
--DISENAR UN CONTADOR HEXADECIMAL ASCENDENTE-DESCENDENTE CON RESET Y CONTADOR DE NUMEROS PRIMOS
ENTITY CNT_8 IS
PORT(
CLK: IN BIT; --FLANCOS DE SUBIDA
X, Y, Z: IN BIT;
RESET: IN BIT; --PONE LA SALIDA EN 0's.
DISPLAY: OUT BIT_VECTOR(6 DOWNTO 0); --SALIDA HEXADECIMAL
BAR_LED: OUT BIT_VECTOR(2 DOWNTO 0) --SALIDA AL BAR LED
);
END ENTITY CNT_8;
------------------------------------
------------------------------------
ARCHITECTURE ARC_CNT OF CNT_8 IS
COMPONENT ROM_MXN IS
PORT(
M: IN BIT_VECTOR(2 DOWNTO 0); --ENTRADA A LA MEMORIA ROM
N: OUT BIT_VECTOR(6 DOWNTO 0) --SALIDA DE MEMORIA ROM
);
END COMPONENT ROM_MXN;
SIGNAL HEX: BIT_VECTOR(2 DOWNTO 0);
TYPE ESTADOS IS (A, B, C, D, E, F, G, H);
SIGNAL EP, ES: ESTADOS;
SIGNAL ADRESS: BIT_VECTOR(2 DOWNTO 0);
BEGIN
--*************PARTE SINCRONA****************
SINC: PROCESS(CLK)
BEGIN
IF CLK'EVENT AND CLK='1' THEN
IF RESET='1' THEN
EP <= A;
ELSE
EP <= ES;
END IF;
END IF;
END PROCESS SINC;
--*********FIN DE LA PARTE SINCRONA**********
--***********PARTE COMBINACIONAL*************
COMB: PROCESS(EP, X, Y, Z)
BEGIN
CASE EP IS
WHEN A => ADRESS <="000";
IF X='0' THEN ES <= A;
ELSIF X='1' AND Y='0' THEN ES <= B;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= H;
ELSE ES <= B;
-- X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN B => ADRESS <="001";
IF X='0' THEN ES <= B;
ELSIF X='1' AND Y='0' THEN ES <= C;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= A;
ELSE ES <= C;
--X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN C => ADRESS <="010";
IF X='0' THEN ES <= C;
ELSIF X='1' AND Y='0' THEN ES <= D;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= B;
ELSE ES <= D;
-- X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN D => ADRESS <="011";
IF X='0' THEN ES <= D;
ELSIF X='1' AND Y='0' THEN ES <= E;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= C;
ELSE ES <= F;
-- X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN E => ADRESS <="100";
IF X='0' THEN ES <= E;
ELSIF X='1' AND Y='0' THEN ES <= F;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= D;
ELSE ES <= B;
-- X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN F => ADRESS <="101";
IF X='0' THEN ES <= F;
ELSIF X='1' AND Y='0' THEN ES <= G;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= E;
ELSE ES <= H;
--X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN G => ADRESS <="110";
IF X='0' THEN ES <= G;
ELSIF X='1' AND Y='0' THEN ES <= H;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= F;
ELSE ES <= B;
-- X='1' AND Y='1' AND Z='1' THEN
END IF;
WHEN H => ADRESS <="111";
IF X='0' THEN ES <= H;
ELSIF X='1' AND Y='0' THEN ES <= A;
ELSIF X='1' AND Y='1' AND Z='0' THEN ES <= G;
ELSE ES <= B;
-- X='1' AND Y='1' AND Z='1' THEN
END IF;
END CASE;
END PROCESS COMB;
--*******FIN DE LA PARTE COMBINACIONAL*******
ROM: ROM_MXN
PORT MAP(
M => ADRESS,
N => DISPLAY
);
BAR_LED <= ADRESS;
--******************************************
END ARCHITECTURE ARC_CNT;
--***************MEMORIA ROM*****************
ENTITY ROM_MXN IS
PORT(
M: IN BIT_VECTOR(2 DOWNTO 0); --ENTRADA A LA MEMORIA ROM
N: OUT BIT_VECTOR(6 DOWNTO 0) --SALIDA DE MEMORIA ROM
);
END ENTITY ROM_MXN;
ARCHITECTURE ARC OF ROM_MXN IS
BEGIN
ROM: PROCESS(M)
BEGIN
CASE M IS
WHEN "000" => N <= "0000001"; --A
WHEN "001" => N <= "1010000"; --b
WHEN "010" => N <= "0011010"; --C
WHEN "011" => N <= "1100000"; --d
WHEN "100" => N <= "0010010"; --E
WHEN "101" => N <= "0010011"; --F
WHEN "110" => N <= "0000100"; --g
WHEN "111" => N <= "1000001"; --H
WHEN OTHERS => N <= (OTHERS=>'0');
END CASE;
END PROCESS ROM;
END ARCHITECTURE ARC;