Advertisement
Guest User

CU

a guest
Mar 30th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.63 KB | None | 0 0
  1. -------------------------------------------------------------------------
  2. -- Design unit:
  3. -- Description:            
  4. -------------------------------------------------------------------------
  5.  
  6. library IEEE;
  7. use IEEE.std_logic_1164.all;
  8. use IEEE.std_logic_unsigned.all;      
  9. use work.R8_pkg.all;
  10.  
  11. entity uC_R8 is
  12.     port (
  13.         clk     : in std_logic;
  14.         rst     : in std_logic;
  15.         port_a  : inout std_logic_vector(15 downto 0);
  16.         port_b  : inout std_logic_vector(15 downto 0)
  17.     );
  18. end uC_R8;
  19.  
  20. architecture structural of uC_R8 is
  21.  
  22.     signal clk_aux, rst_aux :  std_logic;
  23.     signal rw, ce, ce_n, we_n, oe_n, ce_ports, ce_memo : std_logic;
  24.     signal dataR8, dataBus, addressR8, address : std_logic_vector(15 downto 0);    
  25.    
  26. begin  
  27.        
  28.         MICROCONTROLADOR: entity work.R8
  29.         port map (
  30.             clk         => clk_aux,
  31.             rst         => rst_aux,
  32.             data_in     => dataBus,
  33.             data_out    => dataR8,
  34.             address     => addressR8,
  35.             ce          => ce,
  36.             rw          => rw
  37.         );
  38.        
  39.         RAM : entity work.Memory  
  40.         generic map (
  41.            SIZE         => 1024,    -- 1024 words (2KB)
  42.            imageFileName => "teste1.txt"--"../sim/Todas_Instrucoes_R8.txt"
  43.         )
  44.         port map (
  45.             clk     => clk_aux,
  46.             ce_n    => ce_memo,
  47.             we_n    => we_n,
  48.             oe_n    => oe_n,
  49.             data    => dataBus,
  50.             address => addressR8
  51.         );
  52.        
  53.        
  54.         BIDIRECTIONAL_PORT_A: entity work.BidirectionalPort
  55.         generic map(
  56.             DATA_DIRECTION_ADDR => x"FFF0",
  57.             OUTPUT_DATA_ADDR    => x"FFF1",
  58.             INPUT_DATA_ADDR     => x"FFF2"
  59.         )
  60.         port map (
  61.             clk         => clk_aux,
  62.             rst         => rst_aux,
  63.             address     => addressR8,
  64.             data        => dataBus,
  65.             port_io     => port_a,
  66.             ce          => ce_ports,
  67.             rw          => rw
  68.         );
  69.          
  70.         BIDIRECTIONAL_PORT_B: entity work.BidirectionalPort
  71.         generic map(
  72.             DATA_DIRECTION_ADDR => x"FFF3",
  73.             OUTPUT_DATA_ADDR    => x"FFF4",
  74.             INPUT_DATA_ADDR     => x"FFF5"
  75.         )
  76.         port map (
  77.             clk         => clk_aux,
  78.             rst         => rst_aux,
  79.             address     => addressR8,
  80.             data        => dataBus,
  81.             port_io     => port_b,
  82.             ce          => ce_ports,
  83.             rw          => rw
  84.         );
  85.          
  86.  
  87.     -- Memory access control signals      
  88.     ce_n <= '0' when (ce='1') else '1';
  89.     oe_n <= '0' when (ce='1' and rw='1') else '1';      
  90.     we_n <= '0' when (ce='1' and rw='0') else '1';    
  91.        
  92.     ce_ports <= ce when addressR8 > x"FFEF" else '0';
  93.     ce_memo <= ce_n when addressR8 < x"FFF0" else '0';
  94.    
  95.     dataBus <= dataR8 when ce = '1' and rw='0' else     -- Writing access              
  96.             (others => 'Z');    
  97.     clk_aux <= clk;
  98.     rst_aux <= rst;
  99. end structural;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement