Tutorial
Tutorial
Tutorial
2.1 Contador_4b.vhd
--
--
-- Title : e_cont4b
-- Design : tutorialVHDL
-- Author : carlos garcia
-- Company : instituto tecnologico cuidad guzman
--
--
--
-- File : c:\VHDL\tutorial\tutorialVHDL\src\Contador_4b.vhd
-- Generated : Wed Oct 12 20:51:50 2022
-- From : interface description file
-- By : Itf2Vhdl ver. 1.22
--
--
--
-- Description :
--
--
Active-HDL Student
Active-HDL Student
Qint<= Qint + 1;
end if;
end if;
end if;
end process;
Q<= Qint;
FULL <= '1' when (Qint=9) else '0';
end a_cont4b;
2.2 comp_and.vhd
--
--
-- Title : e_compand
-- Design : tutorialVHDL
-- Author : carlos garcia
-- Company : instituto tecnologico cuidad guzman
--
--
--
-- File : c:\VHDL\tutorial\tutorialVHDL\src\comp_and.vhd
-- Generated : Wed Oct 12 21:15:07 2022
-- From : interface description file
-- By : Itf2Vhdl ver. 1.22
--
--
--
-- Description :
--
--
end a_compand;
2
Active-HDL Student
Active-HDL Student
2.3 cont_bcd.bde
2.3.1 cont_bcd.vhd
--
--
-- Title :
-- Design : tutorialVHDL
-- Author :
-- Company :
--
--
--
-- File : c:\VHDL\tutorial\tutorialVHDL\compile\cont_bcd.vhd
-- Generated : Thu Oct 13 11:48:38 2022
-- From : c:\VHDL\tutorial\tutorialVHDL\..\src\cont_bcd.bde
-- By : Bde2Vhdl ver. 2.6
--
--
3
Active-HDL Student
Active-HDL Student
--
-- Description :
--
--
-- Design unit header --
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_signed.all;
use IEEE.std_logic_unsigned.all;
entity e_bcd is
port(
CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
GATE : in STD_LOGIC;
bcd_a : out STD_LOGIC_VECTOR(3 downto 0);
bcd_b : out STD_LOGIC_VECTOR(3 downto 0);
bcd_c : out STD_LOGIC_VECTOR(3 downto 0);
bcd_d : out STD_LOGIC_VECTOR(3 downto 0)
);
end e_bcd;
architecture a_bcd of e_bcd is
component e_compand
port(
a0 : in STD_LOGIC;
a1 : in STD_LOGIC;
Y : out STD_LOGIC
);
end component;
component e_cont4b
port(
CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
ENABLE : in STD_LOGIC;
FULL : out STD_LOGIC;
Q : out STD_LOGIC_VECTOR(3 downto 0)
);
end component;
---- Constants -----
constant DANGLING_INPUT_CONSTANT : STD_LOGIC := 'Z';
---- Signal declarations used on the diagram ----
4
Active-HDL Student
Active-HDL Student
begin
U1 : e_cont4b
port map(
CLK => Dangling_Input_Signal,
RESET => Dangling_Input_Signal,
ENABLE => GATE,
FULL => NET705,
Q(3) => BUS642(7),
Q(2) => BUS642(6),
Q(1) => BUS642(5),
Q(0) => BUS642(4)
);
U2 : e_cont4b
port map(
CLK => Dangling_Input_Signal,
RESET => Dangling_Input_Signal,
ENABLE => NET731,
FULL => NET734,
Q => bcd_c
);
U3 : e_cont4b
port map(
CLK => Dangling_Input_Signal,
RESET => Dangling_Input_Signal,
ENABLE => NET758,
FULL => NET761,
Q => bcd_b
);
U4 : e_cont4b
port map(
CLK => Dangling_Input_Signal,
RESET => Dangling_Input_Signal,
ENABLE => NET773,
Q(3) => BUS684(7),
Q(2) => BUS684(6),
Q(1) => BUS684(5),
Q(0) => BUS684(4)
);
U5 : e_compand
port map(
a0 =>
NET705, a1
=> GATE, Y
=> NET731
);
U6 : e_compand
port map(
a0 => NET734,
a1 => NET731,
Y => NET758
);
U7 : e_compand
port map(
a0 => NET761,
a1 => NET758,
5
Active-HDL Student
Active-HDL Student
Y => NET773
);
-- Output\buffer terminals
bcd_a(0) <= BUS684(4);
bcd_a(1) <= BUS684(5);
bcd_a(2) <= BUS684(6);
bcd_a(3) <= BUS684(7);
bcd_d(0) <= BUS642(4);
bcd_d(1) <= BUS642(5);
bcd_d(2) <= BUS642(6);
bcd_d(3) <= BUS642(7);
2.4 hex2led.vhd
--HEX-to-seven-segment decoder
-- HEX: in STD_LOGIC_VECTOR (3 downto 0);
-- LED: out STD_LOGIC_VECTOR (6 downto 0);
--
-- segment encoding
-- 0
-- ---
-- 5 | | 1
-- --- <- 6
-- 4 | | 2
-- ---
-- 3
--
-- Title : e_hex2led
-- Design : tutorialVHDL
-- Author : carlos garcia
-- Company : instituto tecnologico cuidad guzman
--
--
--
-- File : c:\VHDL\tutorial\tutorialVHDL\src\hex2led.vhd
-- Generated : Wed Oct 12 22:11:06 2022
-- From : interface description file
-- By : Itf2Vhdl ver. 1.22
--
--
--
-- Description :
--
6
Active-HDL Student
Active-HDL Student
--{{ Section below this comment is automatically maintained
-- and may be overwritten
--{entity {e_hex2led} architecture {a_hex2led}}
library IEEE;
use IEEE.std_logic_1164.all;
entity e_hex2led is
port(
hex : in STD_LOGIC_VECTOR(3 downto 0);
led : out STD_LOGIC_VECTOR(6 downto 0)
);
end e_hex2led;
--}} End of automatically maintained section
end a_hex2led;
2.4.1 Controller.vhd
--
--
-- Title : No Title
-- Design :
-- Author : carlos garcia
-- Company : instituto tecnologico cuidad guzman
--
--
--
-- File : c:/VHDL/tutorial/tutorialVHDL/compile/Controller.vhd
-- Generated : Thu Oct 13 08:33:17 2022
-- From : c:/VHDL/tutorial/tutorialVHDL/src/Controller.asf
-- By : Active-HDL Student Edition FSM Code Generator ver. 6.0
--
--
-
7
Active-HDL Student
Active-HDL Student
-- Description :
--
--
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_signed.all;
entity Controller is
port (
f_pattern: in STD_LOGIC;
reset: in STD_LOGIC;
start: in STD_LOGIC;
gate: out STD_LOGIC;
end_reset: out STD_LOGIC
);
end Controller;
architecture Controller_arch of Controller is
begin
-- Diagram ACTION
-- Machine: Sreg0
8
Active-HDL Student
Active-HDL Student
when idle =>
gate <='0';
end_reset<='1';
case start is
when '1' =>
NextState_Sreg0 <= open_gate;
when '0' =>
NextState_Sreg0 <= idle;
when others =>
null;
end case;
when open_gate =>
gate <='1';
end_reset<='0';
NextState_Sreg0 <= end_cycle;
when end_cycle =>
gate<='0';
end_reset<='0';
case start is
when '0' =>
NextState_Sreg0 <= idle;
when '1' =>
NextState_Sreg0 <= end_cycle;
when others =>
null;
end case;
--vhdl_cover_off
when others =>
null;
--vhdl_cover_on
end case;
end process;
end Controller_arch;
9
Active-HDL Student
Active-HDL Student
2.5 frec_top2.bde
2.5.1 frec_top2.vhd
--
--
-- Title :
-- Design : tutorialVHDL
-- Author :
-- Company :
--
--
--
-- File : c:\VHDL\tutorial\tutorialVHDL\compile\frec_top2.vhd
-- Generated : Thu Oct 13 12:41:15 2022
-- From : c:\VHDL\tutorial\tutorialVHDL\src\frec_top2.bde
-- By : Bde2Vhdl ver. 2.6
--
--
--
-- Description :
1
Active-HDL Student
Active-HDL Student
--
--
-- Design unit header --
library IEEE;
use IEEE.std_logic_1164.all;
-- Included from components --
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_signed.all;
entity e_frec is
port(
f_input : in STD_LOGIC;
f_pattern : in STD_LOGIC;
Reset : in STD_LOGIC;
Start : in STD_LOGIC;
led_d : out STD_LOGIC_VECTOR(6 downto 0);
led_c : out STD_LOGIC_VECTOR(6 downto 0);
led_b : out STD_LOGIC_VECTOR(6 downto 0);
led_a : out STD_LOGIC_VECTOR(6 downto 0)
);
end e_frec;
architecture a_frec of e_frec is
component controller
port(
f_pattern : in std_logic;
reset : in std_logic;
start : in std_logic;
gate : out std_logic;
end_reset : out std_logic
);
end component;
component e_bcd
port(
CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
GATE : in STD_LOGIC;
bcd_a : out STD_LOGIC_VECTOR(3 downto 0);
bcd_b : out STD_LOGIC_VECTOR(3 downto 0);
bcd_c : out STD_LOGIC_VECTOR(3 downto 0);
bcd_d : out STD_LOGIC_VECTOR(3 downto 0)
);
end component;
component e_hex2led
port(
hex : in STD_LOGIC_VECTOR(3 downto 0);
led : out STD_LOGIC_VECTOR(6 downto 0)
);
end component;
---- Signal declarations used on the diagram ----
1
Active-HDL Student
Active-HDL Student
signal BUS1033 : STD_LOGIC_VECTOR(3 downto 0);
begin
U4 : e_bcd
port map(
CLK => f_input,
RESET => NET1041,
GATE => NET1049,
bcd_a => BUS1033,
bcd_b => BUS1025,
bcd_c => BUS1017,
bcd_d => BUS1004
);
U5 : e_hex2led
port map(
hex => BUS1033,
led => led_d
);
U6 : e_hex2led
port map(
hex => BUS1025,
led => led_c
);
U7 : e_hex2led
port map(
hex => BUS1017,
led => led_b
);
U8 : e_hex2led
port map(
hex => BUS1004,
led => led_a
);
end a_frec;
1
Active-HDL Student