📄 seg7_m8.vhd
字号:
-----------------------------------------------------------------------
-- Seg7_M8.vhd
-- --------------------------------------------------------------------
-- >>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<
-- --------------------------------------------------------------------
-- Copyright (c) 2005 by Lattice Semiconductor Corporation
-- --------------------------------------------------------------------
--
-- Permission:
--
-- Lattice Semiconductor grants permission to use this code for use
-- in synthesis for any Lattice programmable logic product. Other
-- use of this code, including the selling or duplication of any
-- portion is strictly prohibited.
--
-- Disclaimer:
--
-- This VHDL or Verilog source code is intended as a design reference
-- which illustrates how these types of functions can be implemented.
-- It is the user's responsibility to verify their design for
-- consistency and functionality through the use of formal
-- verification methods. Lattice Semiconductor provides no warranty
-- regarding the use or functionality of this code.
--
-- --------------------------------------------------------------------
--
-- Lattice Semiconductor Corporation
-- 5555 NE Moore Court
-- Hillsboro, OR 97214
-- U.S.A
--
-- TEL: 1-800-Lattice (USA and Canada)
-- 408-826-6000 (other locations)
--
-- web: http://www.latticesemi.com/
-- email: techsupport@latticesemi.com
--
-- --------------------------------------------------------------------
--
-- This is a Mico8 peripheral that controls two 7segment displays
-- Address map:
-- 00000011: 7 Segment control register
--
-- The 7 Segments are to be connected like this:
-- "gfedcba"
-- bit 0 = segment 'a'
-- bit 1 = segment 'b'
--
-- --------------------------------------------------------------------
--
-- Revision History :
-- --------------------------------------------------------------------
-- Ver :| Author :| Mod. Date :| Changes Made:
-- V1.1 :| G.M. :| 13/03/08 :| Release
-- --------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity Seg7_M8 is
port (
Clk : in std_logic;
Reset : in std_logic;
WR : in std_logic;
Addr: in std_logic_vector(7 downto 0);
Mico8_Data : in std_logic_vector (7 downto 0);
Segm_Out1: out std_logic_vector(6 downto 0);
Segm_Out2: out std_logic_vector(6 downto 0)
);
end Seg7_M8;
architecture behave of Seg7_M8 is
signal zWR : std_logic;
signal Leds_out: std_logic_vector(7 downto 0);
constant LEDaddress: std_logic_vector (7 downto 0) := "00000011";
attribute pgroup : string;
attribute pgroup of behave : architecture is "Seg7";
begin
write: process (clk, reset, WR)
begin
if reset = '1' then
Leds_out <= (others => '0');
zWR <= WR;
elsif clk'event and clk = '1' then
zWR <= WR;
if (zWR /= WR) and (WR = '0') then
if Addr = LEDaddress then
Leds_out <= Mico8_Data(7 downto 0);
end if;
end if;
end if;
end process;
Segm_Out1 <= "1000000" WHEN Leds_out(3 downto 0) = "0000" ELSE -- H"40"
"1111001" WHEN Leds_out(3 downto 0) = "0001" ELSE -- H"79"
"0100100" WHEN Leds_out(3 downto 0) = "0010" ELSE -- H"24"
"0110000" WHEN Leds_out(3 downto 0) = "0011" ELSE -- H"30"
"0011001" WHEN Leds_out(3 downto 0) = "0100" ELSE -- H"19"
"0010010" WHEN Leds_out(3 downto 0) = "0101" ELSE -- H"12"
"0000010" WHEN Leds_out(3 downto 0) = "0110" ELSE -- H"02"
"1111000" WHEN Leds_out(3 downto 0) = "0111" ELSE -- H"78"
"0000000" WHEN Leds_out(3 downto 0) = "1000" ELSE -- H"00"
"0010000" WHEN Leds_out(3 downto 0) = "1001" ELSE -- H"10"
"0001000" WHEN Leds_out(3 downto 0) = "1010" ELSE -- H"08"
"0000011" WHEN Leds_out(3 downto 0) = "1011" ELSE -- H"03"
"1000110" WHEN Leds_out(3 downto 0) = "1100" ELSE -- H"46"
"0100001" WHEN Leds_out(3 downto 0) = "1101" ELSE -- H"21"
"0000110" WHEN Leds_out(3 downto 0) = "1110" ELSE -- H"06"
"0001110"; -- H"0E"
Segm_Out2 <= "1000000" WHEN Leds_out(7 downto 4) = "0000" ELSE -- H"40"
"1111001" WHEN Leds_out(7 downto 4) = "0001" ELSE -- H"79"
"0100100" WHEN Leds_out(7 downto 4) = "0010" ELSE -- H"24"
"0110000" WHEN Leds_out(7 downto 4) = "0011" ELSE -- H"30"
"0011001" WHEN Leds_out(7 downto 4) = "0100" ELSE -- H"19"
"0010010" WHEN Leds_out(7 downto 4) = "0101" ELSE -- H"12"
"0000010" WHEN Leds_out(7 downto 4) = "0110" ELSE -- H"02"
"1111000" WHEN Leds_out(7 downto 4) = "0111" ELSE -- H"78"
"0000000" WHEN Leds_out(7 downto 4) = "1000" ELSE -- H"00"
"0010000" WHEN Leds_out(7 downto 4) = "1001" ELSE -- H"10"
"0001000" WHEN Leds_out(7 downto 4) = "1010" ELSE -- H"08"
"0000011" WHEN Leds_out(7 downto 4) = "1011" ELSE -- H"03"
"1000110" WHEN Leds_out(7 downto 4) = "1100" ELSE -- H"46"
"0100001" WHEN Leds_out(7 downto 4) = "1101" ELSE -- H"21"
"0000110" WHEN Leds_out(7 downto 4) = "1110" ELSE -- H"06"
"0001110"; -- H"0E"
end behave;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -