Created
December 11, 2015 16:33
-
-
Save forflo/f0266d7b54b61b58ddb0 to your computer and use it in GitHub Desktop.
This is a addon entity for the picoblaze. It adds an seven segment multiplexer with integrated registers for the segments bit patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------------------------- | |
-- Company: | |
-- Author: Florian Mayer | |
-- | |
-- Create Date: 16:18:13 12/09/2015 | |
-- Design Name: | |
-- Module Name: seven_segment - Behavioral | |
-- Project Name: | |
-- Target Devices: | |
-- Tool versions: | |
-- Description: | |
-- | |
-- Dependencies: | |
-- | |
-- Revision: | |
-- Revision 0.01 - File Created | |
-- Additional Comments: | |
-- | |
---- | |
library ieee; | |
use ieee.std_logic_1164.all; | |
use ieee.std_logic_arith.all; | |
use ieee.std_logic_unsigned.all; | |
entity seven_segment is | |
port ( | |
reset: in std_logic; | |
write_enable: in std_logic; | |
bit_pattern: in std_logic_vector(7 downto 0); | |
address: in std_logic_vector(1 downto 0); | |
segment_output: out std_logic_vector(7 downto 0); | |
segment_address_out: out std_logic_vector(3 downto 0); | |
clock: in std_logic); | |
end seven_segment; | |
architecture Behavioral of seven_segment is | |
type segment_data_t is array(3 downto 0) of std_logic_vector(7 downto 0); | |
signal segment_data: segment_data_t; | |
signal counter: unsigned(1 downto 0); | |
begin | |
segment_output_driver: process(clock, reset) | |
begin | |
if reset = '1' then | |
segment_output <= (others => '0'); | |
elsif rising_edge(clock) then | |
segment_output <= segment_data(conv_integer(counter)); | |
end if; | |
end process segment_output_driver; | |
counter_proc: process(clock, reset) | |
variable divider: unsigned(8 downto 0); | |
begin | |
if reset = '1' then | |
divider := (others => '0'); | |
counter <= (others => '0'); | |
elsif rising_edge(clock) then | |
if divider = 2**divider'length-1 then | |
counter <= counter + 1; | |
divider := (others => '0'); | |
else | |
divider := divider + 1; | |
end if; | |
end if; | |
end process counter_proc; | |
round_robin: process(clock, reset) | |
begin | |
if reset = '1' then | |
segment_address_out <= (others => '0'); | |
elsif rising_edge(clock) then | |
case counter is | |
when "00" => segment_address_out <= "0001"; | |
when "01" => segment_address_out <= "0010"; | |
when "10" => segment_address_out <= "0100"; | |
when "11" => segment_address_out <= "1000"; | |
when others => segment_address_out <= "0000"; | |
end case; | |
end if; | |
end process round_robin; | |
picoblaze_interface: process(clock, reset) | |
begin | |
if reset = '1' then | |
segment_data <= (others => (others => '0')); | |
elsif rising_edge(clock) then | |
if write_enable = '1' then | |
segment_data(conv_integer(unsigned(address))) <= bit_pattern; | |
end if; | |
end if; | |
end process picoblaze_interface; | |
end Behavioral; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment