⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 top_avr_core.vhd

📁 avr core porocesssor vhdl source code
💻 VHD
📖 第 1 页 / 共 2 页
字号:
--************************************************************************************************
-- Top entity for AVR core
-- Version 2.0
-- Designed by Ruslan Lepetenok 20.01.2002
--************************************************************************************************

library IEEE;
use IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;

--library altera;
--use altera.maxplus2.all;

use work.mux_type_package.all;

entity top_avr_core is port
(
     nrst  : in std_logic;
     clk   : in std_logic;

     porta : inout std_logic_vector(7 downto 0);
     portb : inout std_logic_vector(7 downto 0);
	 
	 -- UART 
	 rxd   : in  std_logic;
	 txd   : out std_logic
	 );

end top_avr_core;

architecture struct of top_avr_core is

component cpuwait is port (
          clk       : in std_logic;
          nrst      : in std_logic;

		  cpuwait  : out std_logic;		  
	      ramwe	   : in  std_logic;
		  ramre	   : in  std_logic);

end component;

component pport is 
	generic(PORTX_Adr : integer ;DDRX_Adr : integer ; PINX_Adr :integer);
	port(
	                   -- AVR Control
               ireset     : in std_logic;
               cp2	      : in std_logic;
               adr        : in std_logic_vector(5 downto 0);
               dbus_in    : in std_logic_vector(7 downto 0);
               dbus_out   : out std_logic_vector(7 downto 0);
               iore       : in std_logic;
               iowe       : in std_logic;
               out_en     : out std_logic; 
			            -- External connection
			   pinx       : inout std_logic_vector(7 downto 0));
end component;


component prom is port (
address_in : in  std_logic_vector (15 downto 0);
data_out   : out std_logic_vector (15 downto 0));
end component;

component ram is 
		  generic(ram_size :positive; address_width : positive);
	      port (
          cp2         : in std_logic;
  	      address     : in  std_logic_vector (address_width-1 downto 0);
		  ramwe		  : in  std_logic;
		  din         : in  std_logic_vector (7 downto 0);
		  dout        : out	std_logic_vector (7 downto 0));
end component;


component external_mux is port (
		  ramre              : in  std_logic;
		  dbus_out           : out std_logic_vector (7 downto 0);
		  ram_data_out       : in  std_logic_vector (7 downto 0);
		  io_port_bus        : in  ext_mux_din_type;
		  io_port_en_bus     : in  ext_mux_en_type;
          irqack             : in  std_logic;
          irqackad           : in  std_logic_vector(4 downto 0);		  
		  ind_irq_ack        : out std_logic_vector(22 downto 0)		  
		  );
end component;

component Service_Module is port(
	                   -- AVR Control
               ireset         : in  std_logic;
               cp2	          : in  std_logic;
               adr            : in  std_logic_vector(5 downto 0);
               dbus_in        : in  std_logic_vector(7 downto 0);
               dbus_out       : out std_logic_vector(7 downto 0);
               iore           : in  std_logic;
               iowe           : in  std_logic;
               out_en         : out std_logic; 
			        -- SLEEP mode signals
			   sleep_en       : out std_logic;
		   	        -- SRAM control signals
			   ESRAM_en       : out std_logic;
			   ESRAM_WS       : out std_logic;
			   	    --IRQ
               ExtInt_IRQ     : out std_logic_vector(7 downto 0);
			   ExtInt_IRQ_Ack : in  std_logic_vector(3 downto 0);
			   
			   -- External interrupts (inputs)
			   Ext_Int_In     : in  std_logic_vector(7 downto 0));
end component;

-- SIMPLE TIMER **********************************
component simple_timer is port(
ireset        : in std_logic;
cp2           : in std_logic;
irqline       : out std_logic;
timer_irqack  : in std_logic
							  );
end component;
-- ***********************************************


component Timer_Counter is port(
	                   -- AVR Control
               ireset         : in std_logic;
               cp2	          : in std_logic;
               adr            : in std_logic_vector(5 downto 0);
               dbus_in        : in std_logic_vector(7 downto 0);
               dbus_out       : out std_logic_vector(7 downto 0);
               iore           : in std_logic;
               iowe           : in std_logic;
               out_en         : out std_logic; 

                       --Timer/Counters
               EXT1           : in std_logic;
               EXT2           : in std_logic;
			   Tosc1	      : in std_logic;
			   OC0_PWM0       : out std_logic;
			   OC1A_PWM1A     : out std_logic;
			   OC1B_PWM1B     : out std_logic;
			   OC2_PWM2       : out std_logic;
			   		   
			           --IRQ
               TC0OvfIRQ      : out std_logic;
			   TC0OvfIRQ_Ack  : in std_logic;
			   TC0CmpIRQ      : out std_logic;
			   TC0CmpIRQ_Ack  : in std_logic;
			   TC2OvfIRQ      : out std_logic;
			   TC2OvfIRQ_Ack  : in std_logic;
			   TC2CmpIRQ      : out std_logic;
			   TC2CmpIRQ_Ack  : in std_logic;
			   TC1OvfIRQ      : out std_logic;
			   TC1OvfIRQ_Ack  : in std_logic;
			   TC1CmpAIRQ     : out std_logic;
			   TC1CmpAIRQ_Ack : in std_logic;
			   TC1CmpBIRQ     : out std_logic;
			   TC1CmpBIRQ_Ack : in std_logic;			   
			   TC1ICIRQ       : out std_logic;
			   TC1ICIRQ_Ack   : in std_logic);
end component;


--*************** UART ***************************
component uart is port(
	                   -- AVR Control
               ireset     : in std_logic;
               cp2	      : in std_logic;
               adr        : in std_logic_vector(5 downto 0);
               dbus_in    : in std_logic_vector(7 downto 0);
               dbus_out   : out std_logic_vector(7 downto 0);
               iore       : in std_logic;
               iowe       : in std_logic;
               out_en     : out std_logic; 

                       --UART
               rxd        : in std_logic;
               rx_en      : out std_logic;
               txd        : out std_logic;
               tx_en      : out std_logic;

                       --IRQ
               txcirq     : out std_logic;
               txc_irqack : in std_logic;
               udreirq    : out std_logic;
			   rxcirq     : out std_logic);
end component;


-- Core itself
component avr_core is port
(

cp2      : in std_logic;
ireset   : in std_logic;
cpuwait  : in std_logic;

-- PROGRAM MEMORY PORTS
pc       : out std_logic_vector (15 downto 0);   
inst     : in std_logic_vector (15 downto 0);	

-- I/O REGISTERS PORTS
adr      : out std_logic_vector (5 downto 0); 	
iore     : out std_logic;                       
iowe     : out std_logic;						

-- DATA MEMORY PORTS
ramadr   : out std_logic_vector (15 downto 0);
ramre    : out std_logic;
ramwe    : out std_logic;

dbusin   : in std_logic_vector (7 downto 0);
dbusout  : out std_logic_vector (7 downto 0);

-- INTERRUPTS PORT
irqlines : in std_logic_vector (22 downto 0);
irqack   : out std_logic;
irqackad : out std_logic_vector(4 downto 0)

);

end component;

-- ############################## Signals connected directly to the core ##########################################

-- Global signals
signal sg_core_cp2      : std_logic :='0';                    
signal sg_core_ireset   : std_logic :='0';                    

signal sg_core_cpuwait  : std_logic :='0';                    

-- Program memory
signal sg_core_pc   : std_logic_vector (15 downto 0):=(others=>'0'); -- PROM address
signal sg_core_inst : std_logic_vector (15 downto 0):=(others=>'0'); -- PROM data

-- I/O registers
signal sg_core_adr  : std_logic_vector (5 downto 0):=(others=>'0');
signal sg_core_iore : std_logic :='0';                    
signal sg_core_iowe : std_logic :='0';

-- Data memery
signal sg_core_ramadr : std_logic_vector (15 downto 0):=(others=>'0');
signal sg_core_ramre  : std_logic :='0';
signal sg_core_ramwe  : std_logic :='0';

signal sg_core_dbusin   : std_logic_vector (7 downto 0):=(others=>'0');
signal sg_core_dbusout  : std_logic_vector (7 downto 0):=(others=>'0');

-- Interrupts
signal sg_core_irqlines : std_logic_vector(22 downto 0) :=(others=>'0');
signal sg_core_irqack   : std_logic :='0';
signal sg_core_irqackad : std_logic_vector(4 downto 0) :=(others=>'0');

-- ###############################################################################################################

-- ############################## Signals connected directly to the RAM ##########################################

signal sg_ram_din       : std_logic_vector (7 downto 0):=(others=>'0');
signal sg_ram_din_comb  : std_logic_vector (7 downto 0):=(others=>'0'); -- COMBINATORIAL OUTPUT (FOR FLEX IMPLEMENTATION)
signal sg_ram_dout      : std_logic_vector (7 downto 0):=(others=>'0');
	
-- ###############################################################################################################


-- ############################## Signals connected directly to the I/O registers ################################
-- PortA
signal sg_porta_dbusout : std_logic_vector (7 downto 0) := (others => '0');
signal sg_porta_out_en  : std_logic := '0';

-- PortB
signal sg_portb_dbusout : std_logic_vector (7 downto 0) := (others => '0');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -