ПТСиПЦУвСБ/Лекция 4 — различия между версиями
Материал из Wiki
ANA (обсуждение | вклад) (Новая страница: «{{ПТСиПЦУвСБ TOC}} <slideshow style="custis" headingmark="Слайд:" incmark=":step" scaled="true"> ;title: Типы данных языка VHDL ;au…») |
ANA (обсуждение | вклад) м (→Слайд: Содержание) |
||
Строка 12: | Строка 12: | ||
* [[ПЦУСБ/Лекция 3|Описание комбинационных схем на языке VHDL]] | * [[ПЦУСБ/Лекция 3|Описание комбинационных схем на языке VHDL]] | ||
* оператор generic и generate | * оператор generic и generate | ||
+ | |||
+ | |||
+ | == Слайд: Формальный синтаксис декларации generic == | ||
+ | |||
+ | entity_declaration ⇐ | ||
+ | '''entity''' identifier '''is''' | ||
+ | [ '''generic''' ( ''generic''_interface_list ) ; ] | ||
+ | [ '''port''' ( ''port''_interface_list ) ; ] | ||
+ | { entity_declarative_item } | ||
+ | [ '''begin''' | ||
+ | { concurrent_assertion_statement | ||
+ | | ''passive''_concurrent_procedure_call_statement | ||
+ | | ''passive''_process_statement } ] | ||
+ | '''end''' [ '''entity''' ] [ identifier ] ; | ||
+ | |||
+ | interface_list ⇐ interface_declaration { ; ... } | ||
+ | |||
+ | interface_declaration ⇐ | ||
+ | identifier { , ... } : subtype_indication [ := expression ] | ||
+ | |||
+ | |||
+ | === Слайд: Пример 1 (generic) === | ||
+ | |||
+ | '''entity''' and2 '''is''' | ||
+ | '''generic''' ( {{Кр|Tpd}} : time ); | ||
+ | '''port''' ( a, b : in std_logic; y : out std_logic ); | ||
+ | '''end entity''' and2; | ||
+ | |||
+ | '''architecture''' simple '''of''' and2 '''is''' | ||
+ | '''begin''' | ||
+ | and2_function : | ||
+ | y <= a '''and''' b '''after''' {{Кр|Tpd}}; | ||
+ | '''end architecture''' simple; | ||
+ | |||
+ | |||
+ | === Оператор [[Синтаксис_языка_VHDL-2008#component_instantiation_statement|port map]] === | ||
+ | |||
+ | ''instantiation_label'' ''':''' ''component_name'' '''port map''' (''port list''); | ||
+ | |||
+ | ''instantiation_label'' : | ||
+ | [ '''component''' ] ''component_name'' | ||
+ | | '''entity''' ''entity_name'' [ ( ''architecture_identifier'' ) ] | ||
+ | | '''configuration''' ''configuration_name'' | ||
+ | [ '''generic map''' ( ''generic_association_list'' ) ] | ||
+ | [ '''port map''' ( [ port_name => ] signal_name [, [ port_name => ] signal_name]... ) ] ; | ||
+ | |||
+ | Пример: | ||
+ | |||
+ | gate1 : and2 -- [ '''component''' ] ''component_name'' | ||
+ | '''generic map''' ( {{Кр|Tpd}} => 2 ns ) | ||
+ | '''port map''' ( a => sig1, | ||
+ | b => sig2, | ||
+ | y => sig_out ); | ||
+ | |||
+ | gate2 : '''entity''' work.and2(simple) -- '''entity''' ''entity_name'' [ ( ''architecture_identifier'' ) ] | ||
+ | '''generic map''' ( {{Кр|Tpd}} => 3 ns ) | ||
+ | '''port map''' ( a => a1, b => b1, y => sig1 ); | ||
+ | |||
+ | |||
+ | === Слайд: Пример 2 (generic) === | ||
+ | |||
+ | '''entity''' control_unit '''is''' | ||
+ | '''generic''' ( Tpd_clk_out, Tpw_clk : delay_length; | ||
+ | debug : boolean := false ); | ||
+ | '''port''' ( clk : in std_logic; | ||
+ | ready : in std_logic; | ||
+ | control1, control2 : out std_logic ); | ||
+ | '''end entity''' control_unit; | ||
+ | . . . | ||
+ | '''generic map''' ( 200 ps, 1500 ps, false ) | ||
+ | '''generic map''' ( Tpd_clk_out => 200 ps, Tpw_clk => 1500 ps ) | ||
+ | '''generic map''' ( 200 ps, 1500 ps, debug => open ) | ||
+ | |||
+ | |||
+ | === Слайд: Пример 3 (generic) === | ||
+ | |||
+ | '''entity''' reg '''is''' | ||
+ | '''generic''' ( {{Кр|width}} : positive ); | ||
+ | '''port''' ( d : in std_logic_vector({{Кр|width}} - 1 '''downto''' 0); | ||
+ | q : out std_logic_vector({{Кр|width}} - 1 '''downto''' 0); | ||
+ | clk, reset : in std_logic ); | ||
+ | '''end entity''' reg; | ||
+ | |||
+ | '''architecture''' behavioral '''of''' reg '''is''' | ||
+ | '''begin''' | ||
+ | behavior : '''process''' (clk, reset) '''is''' | ||
+ | '''constant''' zero : std_logic_vector({{Кр|width}} - 1 '''downto''' 0) := (others => '0'); | ||
+ | '''begin''' | ||
+ | '''if''' reset = '1' '''then''' | ||
+ | q <= zero; | ||
+ | '''elsif''' rising_edge(clk) '''then''' | ||
+ | q <= d; | ||
+ | '''end if'''; | ||
+ | '''end process''' behavior; | ||
+ | '''end architecture''' behavioral; | ||
+ | |||
+ | |||
+ | === Слайд: Расширение VHDL-2008 Generic Types === | ||
+ | |||
+ | '''entity''' generic_mux2 '''is''' | ||
+ | '''generic''' ( type {{Кр|data_type}} ); | ||
+ | '''port''' | ||
+ | ( sel : in bit; | ||
+ | a, b : in {{Кр|data_type}}; | ||
+ | z : out {{Кр|data_type}} ); | ||
+ | '''end entity''' generic_mux2; | ||
+ | |||
+ | '''architecture''' rtl '''of''' mux2 '''is''' | ||
+ | '''begin''' | ||
+ | z <= a '''when''' not sel '''else''' b; | ||
+ | '''end architecture''' rtl; | ||
+ | |||
+ | . . . | ||
+ | |||
+ | '''signal''' sel_bit, a_bit, b_bit, z_bit : std_logic; | ||
+ | . . . | ||
+ | bit_mux : '''entity''' work.generic_mux2(rtl) | ||
+ | '''generic map''' ( {{Кр|data_type}} => std_logic ) | ||
+ | '''port map''' | ||
+ | ( sel => sel_bit, a => a_bit, b => b_bit, | ||
+ | z => z_bit ); | ||
+ | |||
+ | |||
+ | === Слайд: NEW === |
Версия 18:45, 11 марта 2014
- Заголовок
- Типы данных языка VHDL
- Автор
- Авдеев Н.А.
- Нижний колонтитул
- ПТСиПЦУвСБ/Лекция 4
- Дополнительный нижний колонтитул
- Авдеев Н.А., 18:45, 25 марта 2014
Содержание |
Слайд: Содержание
- Тип [un]signed пакета numeric_std
- Описание комбинационных схем на языке VHDL
- оператор generic и generate
Слайд: Формальный синтаксис декларации generic
entity_declaration ⇐ entity identifier is [ generic ( generic_interface_list ) ; ] [ port ( port_interface_list ) ; ] { entity_declarative_item } [ begin { concurrent_assertion_statement | passive_concurrent_procedure_call_statement | passive_process_statement } ] end [ entity ] [ identifier ] ; interface_list ⇐ interface_declaration { ; ... } interface_declaration ⇐ identifier { , ... } : subtype_indication [ := expression ]
Слайд: Пример 1 (generic)
entity and2 is generic ( Tpd : time ); port ( a, b : in std_logic; y : out std_logic ); end entity and2; architecture simple of and2 is begin and2_function : y <= a and b after Tpd; end architecture simple;
Оператор port map
instantiation_label : component_name port map (port list);
instantiation_label : [ component ] component_name | entity entity_name [ ( architecture_identifier ) ] | configuration configuration_name [ generic map ( generic_association_list ) ] [ port map ( [ port_name => ] signal_name [, [ port_name => ] signal_name]... ) ] ;
Пример:
gate1 : and2 -- [ component ] component_name
generic map ( Tpd => 2 ns )
port map ( a => sig1,
b => sig2,
y => sig_out );
gate2 : entity work.and2(simple) -- entity entity_name [ ( architecture_identifier ) ]
generic map ( Tpd => 3 ns )
port map ( a => a1, b => b1, y => sig1 );
Слайд: Пример 2 (generic)
entity control_unit is generic ( Tpd_clk_out, Tpw_clk : delay_length; debug : boolean := false ); port ( clk : in std_logic; ready : in std_logic; control1, control2 : out std_logic ); end entity control_unit; . . . generic map ( 200 ps, 1500 ps, false ) generic map ( Tpd_clk_out => 200 ps, Tpw_clk => 1500 ps ) generic map ( 200 ps, 1500 ps, debug => open )
Слайд: Пример 3 (generic)
entity reg is generic ( width : positive ); port ( d : in std_logic_vector(width - 1 downto 0); q : out std_logic_vector(width - 1 downto 0); clk, reset : in std_logic ); end entity reg; architecture behavioral of reg is begin behavior : process (clk, reset) is constant zero : std_logic_vector(width - 1 downto 0) := (others => '0'); begin if reset = '1' then q <= zero; elsif rising_edge(clk) then q <= d; end if; end process behavior; end architecture behavioral;
Слайд: Расширение VHDL-2008 Generic Types
entity generic_mux2 is generic ( type data_type ); port ( sel : in bit; a, b : in data_type; z : out data_type ); end entity generic_mux2; architecture rtl of mux2 is begin z <= a when not sel else b; end architecture rtl; . . . signal sel_bit, a_bit, b_bit, z_bit : std_logic; . . . bit_mux : entity work.generic_mux2(rtl) generic map ( data_type => std_logic ) port map ( sel => sel_bit, a => a_bit, b => b_bit, z => z_bit );