Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -------------------------------------------------------------------------------
- --
- -- Entity Name: ledbargraph
- -- Entity Description: Entity has an 8-bit data input bus (inp),
- -- Entity also has 1 8-bit data output bus (leds)
- -- Architecture Name: loop_arch
- -- Description: Led bargraph
- -- Outputs number of 1s determined by input switch
- -- For each switch that is set to 1, another led on the led bargraph lights up
- -- If one switch is set to 1, the bottom led lights, if two switches are set to 1, the bottom two leds light and so on
- -- Implemented using dataflow style selectors
- --
- -- Lab 04
- -- Section 1, Bench 8
- -- Author: Brian Chen and Greg Parker
- --
- -------------------------------------------------------------------------------
- library ieee;
- use ieee.std_logic_1164.all;
- entity ones_bar_graph is
- port(inp : in std_logic_vector(7 downto 0);
- leds : out std_logic_vector(7 downto 0));
- end ones_bar_graph;
- architecture loop_arch of ones_bar_graph is
- begin
- process (inp)
- begin
- variable led_count : integer := 0;
- for i in 7 downto 0 loop
- if (inp(i)) = '1' then
- led_count <= led_count + 1;
- end if;
- end loop;
- for j in 0 to led_count loop
- leds(i) <= '1';
- end loop;
- end process;
- end loop_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement