Download presentation
Presentation is loading. Please wait.
Published byRandolf Boyd Modified over 8 years ago
1
Lecture 8 Review Combinational Devices –Decoder –Multiplexor (Bhasker p-81) –Shifter –Barrel Shifter (Bhasker p-303)
2
Decoder DEC N inputs 2**N outputs Z(0), …, Z(2**N-1) En Outputs are Zero’s when en=‘0’ X: N-bit vector input or an unsigned integer Only the xth output is a ‘1’ others are ‘0’
3
Decode Code Package dec_pack is constant N: integer := 16; subtype my_input integer range 0 to 2**N-1; End dec_pack; -- compile dec_pack into work library Library ieee; Use work.dec_pack.all; ieee.std_logic_1164.all Entity decoder is Port(x: in my_input; z: out std_logic_vector(0 to (2**N)-1); End decoder;
4
Decoder Architecture behav of decoder is begin Process(x) Begin If en = ‘1’ then for i in 0 to n-1 loop if i = x then z(i) <= ‘1’; else z(i) <= ‘0’; end if; end loop; End if; End process; End behav;
5
A 4-to-1 Mux Code Process(a,b,c,d,ctrl) Variable temp: std_logic; Begin case ctrl is when “00” => temp := a; when “01” => temp := b; when “10” => temp := c; when “11” => temp := d; when others => temp := ‘x’; end case; Z <= temp after mux_delay; End process;
6
Shifter Combinational logic, i.e., not a storage Routing switch Entity my_shifter is Generic(N : natural := 32); Port( x : in std_logic_vector(0 to n-1); sel: in std_logic_vector(0 to 2); z : out std_logic_vector(0 to n-1)); End my_shifter; -- sel: “000” no shift, “001” shift right, --“010” shift left, “011” rotate right, --“100” rotate left, others not used.
7
Barrel Shifter -- Rotate left by a specified number Entity Barrel_shifter is generic(N: positive := 4); port( DATA: in std_logic_vecter(n-1 downto 0); selekt: in integer range 0 to N-1; b_out: out std_logic_vecter(n-1 downto 0)); End barrel_shifter; Architecture concurrent_statement of barrel_shifter is Begin b_out 0 else DATA; End concurrent_statement;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.