OpenCores
URL https://opencores.org/ocsvn/c16/c16/trunk

Subversion Repositories c16

[/] [c16/] [trunk/] [vhdl/] [data_core.vhd] - Diff between revs 9 and 26

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 9 Rev 26
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
 
--  Uncomment the following lines to use the declarations that are
--  Uncomment the following lines to use the declarations that are
--  provided for instantiating Xilinx primitive components.
--  provided for instantiating Xilinx primitive components.
--library UNISIM;
--library UNISIM;
--use UNISIM.VComponents.all;
--use UNISIM.VComponents.all;
 
 
use work.cpu_pack.ALL;
use work.cpu_pack.ALL;
 
 
entity data_core is
entity data_core is
        PORT(   CLK_I : in  std_logic;
        PORT(   CLK_I : in  std_logic;
                        T2    : in  std_logic;
                        T2    : in  std_logic;
                        CLR   : in  std_logic;
                        CLR   : in  std_logic;
                        CE    : in  std_logic;
                        CE    : in  std_logic;
 
 
                        -- select signals
                        -- select signals
                        SX    : in  std_logic_vector( 1 downto 0);
                        SX    : in  std_logic_vector( 1 downto 0);
                        SY    : in  std_logic_vector( 3 downto 0);
                        SY    : in  std_logic_vector( 3 downto 0);
                        OP    : in  std_logic_vector( 4 downto 0);               -- alu op
                        OP    : in  std_logic_vector( 4 downto 0);               -- alu op
                        PC    : in  std_logic_vector(15 downto 0);               -- PC
                        PC    : in  std_logic_vector(15 downto 0);               -- PC
                        QU    : in  std_logic_vector( 3 downto 0);                       -- quick operand
                        QU    : in  std_logic_vector( 3 downto 0);                       -- quick operand
                        SA    : in  std_logic_vector(4 downto 0);                        -- select address
                        SA    : in  std_logic_vector(4 downto 0);                        -- select address
                        SMQ   : in  std_logic;                                                  -- select MQ (H/L)
                        SMQ   : in  std_logic;                                                  -- select MQ (H/L)
 
 
                        -- write enable/select signal
                        -- write enable/select signal
                        WE_RR : in  std_logic;
                        WE_RR : in  std_logic;
                        WE_LL : in  std_logic;
                        WE_LL : in  std_logic;
                        WE_SP : in  SP_OP;
                        WE_SP : in  SP_OP;
 
 
                        -- data in signals
                        -- data in signals
                        IMM  : in  std_logic_vector(15 downto 0);                -- immediate data
                        IMM  : in  std_logic_vector(15 downto 0);                -- immediate data
                        RDAT : in  std_logic_vector( 7 downto 0);                -- memory/IO data
                        RDAT : in  std_logic_vector( 7 downto 0);                -- memory/IO data
 
 
                        -- memory control signals
                        -- memory control signals
                        ADR     : out std_logic_vector(15 downto 0);
                        ADR     : out std_logic_vector(15 downto 0);
                        MQ     : out std_logic_vector( 7 downto 0);
                        MQ     : out std_logic_vector( 7 downto 0);
 
 
                        Q_RR   : out std_logic_vector(15 downto 0);
                        Q_RR   : out std_logic_vector(15 downto 0);
                        Q_LL   : out std_logic_vector(15 downto 0);
                        Q_LL   : out std_logic_vector(15 downto 0);
                        Q_SP   : out std_logic_vector(15 downto 0)
                        Q_SP   : out std_logic_vector(15 downto 0)
                );
                );
end data_core;
end data_core;
 
 
architecture Behavioral of data_core is
architecture Behavioral of data_core is
 
 
        function b8(A : std_logic) return std_logic_vector is
        function b8(A : std_logic) return std_logic_vector is
        begin
        begin
                return A & A & A & A & A & A & A & A;
                return A & A & A & A & A & A & A & A;
        end;
        end;
 
 
        COMPONENT alu8
        COMPONENT alu8
        PORT(   CLK_I : in  std_logic;
        PORT(   CLK_I : in  std_logic;
                        T2    : in  std_logic;
                        T2    : in  std_logic;
                        CE    : in  std_logic;
                        CE    : in  std_logic;
                        CLR   : in  std_logic;
                        CLR   : in  std_logic;
 
 
                        ALU_OP : IN  std_logic_vector( 4 downto 0);
                        ALU_OP : IN  std_logic_vector( 4 downto 0);
                        XX     : IN  std_logic_vector(15 downto 0);
                        XX     : IN  std_logic_vector(15 downto 0);
                        YY     : IN  std_logic_vector(15 downto 0);
                        YY     : IN  std_logic_vector(15 downto 0);
                        ZZ     : OUT std_logic_vector(15 downto 0)
                        ZZ     : OUT std_logic_vector(15 downto 0)
                );
                );
        END COMPONENT;
        END COMPONENT;
 
 
        COMPONENT select_yy
        COMPONENT select_yy
        PORT(   SY      : IN  std_logic_vector( 3 downto 0);
        PORT(   SY      : IN  std_logic_vector( 3 downto 0);
                        IMM     : IN  std_logic_vector(15 downto 0);
                        IMM     : IN  std_logic_vector(15 downto 0);
                        QUICK   : IN  std_logic_vector( 3 downto 0);
                        QUICK   : IN  std_logic_vector( 3 downto 0);
                        RDAT    : IN  std_logic_vector( 7 downto 0);
                        RDAT    : IN  std_logic_vector( 7 downto 0);
                        RR      : IN  std_logic_vector(15 downto 0);
                        RR      : IN  std_logic_vector(15 downto 0);
                        YY      : OUT std_logic_vector(15 downto 0)
                        YY      : OUT std_logic_vector(15 downto 0)
                );
                );
        END COMPONENT;
        END COMPONENT;
 
 
        -- cpu registers
        -- cpu registers
        --
        --
        signal RR     : std_logic_vector(15 downto 0);
        signal RR     : std_logic_vector(15 downto 0);
        signal LL     : std_logic_vector(15 downto 0);
        signal LL     : std_logic_vector(15 downto 0);
        signal SP     : std_logic_vector(15 downto 0);
        signal SP     : std_logic_vector(15 downto 0);
 
 
        -- internal buses
        -- internal buses
        --
        --
        signal XX      : std_logic_vector(15 downto 0);
        signal XX      : std_logic_vector(15 downto 0);
        signal YY      : std_logic_vector(15 downto 0);
        signal YY      : std_logic_vector(15 downto 0);
        signal ZZ      : std_logic_vector(15 downto 0);
        signal ZZ      : std_logic_vector(15 downto 0);
        signal ADR_X   : std_logic_vector(15 downto 0);
        signal ADR_X   : std_logic_vector(15 downto 0);
        signal ADR_Z   : std_logic_vector(15 downto 0);
        signal ADR_Z   : std_logic_vector(15 downto 0);
        signal ADR_YZ  : std_logic_vector(15 downto 0);
        signal ADR_YZ  : std_logic_vector(15 downto 0);
        signal ADR_XYZ : std_logic_vector(15 downto 0);
        signal ADR_XYZ : std_logic_vector(15 downto 0);
 
 
begin
begin
 
 
        alu_8: alu8
        alu_8: alu8
        PORT MAP(       CLK_I  => CLK_I,
        PORT MAP(       CLK_I  => CLK_I,
                                T2     => T2,
                                T2     => T2,
                                CE     => CE,
                                CE     => CE,
                                CLR    => CLR,
                                CLR    => CLR,
                                ALU_OP => OP,
                                ALU_OP => OP,
                                XX     => XX,
                                XX     => XX,
                                YY     => YY,
                                YY     => YY,
                                ZZ     => ZZ
                                ZZ     => ZZ
        );
        );
 
 
        selyy: select_yy
        selyy: select_yy
        PORT MAP(       SY      => SY,
        PORT MAP(       SY      => SY,
                                IMM     => IMM,
                                IMM     => IMM,
                                QUICK   => QU,
                                QUICK   => QU,
                                RDAT    => RDAT,
                                RDAT    => RDAT,
                                RR      => RR,
                                RR      => RR,
                                YY      => YY
                                YY      => YY
        );
        );
 
 
        ADR             <= ADR_XYZ;
        ADR             <= ADR_XYZ;
        MQ      <= ZZ(15 downto 8) when SMQ = '1' else ZZ(7 downto 0);
        MQ      <= ZZ(15 downto 8) when SMQ = '1' else ZZ(7 downto 0);
 
 
        Q_RR <= RR;
        Q_RR <= RR;
        Q_LL <= LL;
        Q_LL <= LL;
        Q_SP <= SP;
        Q_SP <= SP;
 
 
        -- memory address
        -- memory address
        --
        --
        sel_ax: process(SA(4 downto 3), IMM)
        sel_ax: process(SA(4 downto 3), IMM)
 
 
                variable SAX : std_logic_vector(4 downto 3);
                variable SAX : std_logic_vector(4 downto 3);
 
 
        begin
        begin
                SAX := SA(4 downto 3);
                SAX := SA(4 downto 3);
 
 
                case SAX is
                case SAX is
 
 
                        when SA_43_I16 =>       ADR_X <= IMM;
                        when SA_43_I16 =>       ADR_X <= IMM;
                        when SA_43_I8S =>       ADR_X <= b8(IMM(7)) & IMM(7 downto 0);
                        when SA_43_I8S =>       ADR_X <= b8(IMM(7)) & IMM(7 downto 0);
                        when others        =>   ADR_X <= b8(SA(3)) & b8(SA(3));
                        when others        =>   ADR_X <= b8(SA(3)) & b8(SA(3));
                end case;
                end case;
        end process;
        end process;
 
 
        sel_az: process(SA(2 downto 1), LL, RR, SP)
        sel_az: process(SA(2 downto 1), LL, RR, SP)
 
 
                variable SAZ : std_logic_vector(2 downto 1);
                variable SAZ : std_logic_vector(2 downto 1);
 
 
        begin
        begin
                SAZ := SA(2 downto 1);
                SAZ := SA(2 downto 1);
 
 
                case SAZ is
                case SAZ is
                        when SA_21_0  =>        ADR_Z <= X"0000";
                        when SA_21_0  =>        ADR_Z <= X"0000";
                        when SA_21_LL =>        ADR_Z <= LL;
                        when SA_21_LL =>        ADR_Z <= LL;
                        when SA_21_RR =>        ADR_Z <= RR;
                        when SA_21_RR =>        ADR_Z <= RR;
                        when others       =>    ADR_Z <= SP;
                        when others       =>    ADR_Z <= SP;
                end case;
                end case;
        end process;
        end process;
 
 
        sel_ayz: process(SA(0), ADR_Z)
        sel_ayz: process(SA(0), ADR_Z)
        begin
        begin
                ADR_YZ <= ADR_Z + (X"000" & "000" & SA(0));
                ADR_YZ <= ADR_Z + (X"000" & "000" & SA(0));
        end process;
        end process;
 
 
        sel_axyz: process(ADR_X, ADR_YZ)
        sel_axyz: process(ADR_X, ADR_YZ)
        begin
        begin
                ADR_XYZ <= ADR_X + ADR_YZ;
                ADR_XYZ <= ADR_X + ADR_YZ;
        end process;
        end process;
 
 
        sel_xx: process(SX, LL, RR, SP, PC)
        sel_xx: process(SX, LL, RR, SP, PC)
        begin
        begin
                case SX is
                case SX is
                        when SX_LL      =>      XX <= LL;
                        when SX_LL      =>      XX <= LL;
                        when SX_RR      =>      XX <= RR;
                        when SX_RR      =>      XX <= RR;
                        when SX_SP      =>      XX <= SP;
                        when SX_SP      =>      XX <= SP;
                        when others     =>      XX <= PC;
                        when others     =>      XX <= PC;
                end case;
                end case;
        end process;
        end process;
 
 
        regs: process(CLK_I)
        regs: process(CLK_I)
        begin
        begin
                if (rising_edge(CLK_I)) then
                if (rising_edge(CLK_I)) then
                        if    (CLR = '1') then
                        if    (CLR = '1') then
                                RR  <= X"0000";
                                RR  <= X"0000";
                                LL  <= X"0000";
                                LL  <= X"0000";
                                SP  <= X"0000";
                                SP  <= X"0000";
                        elsif (CE  = '1' and T2 = '1') then
                        elsif (CE  = '1' and T2 = '1') then
                                if (WE_RR = '1') then           RR  <= ZZ;              end if;
                                if (WE_RR = '1') then           RR  <= ZZ;              end if;
                                if (WE_LL = '1') then           LL  <= ZZ;              end if;
                                if (WE_LL = '1') then           LL  <= ZZ;              end if;
 
 
                                case WE_SP is
                                case WE_SP is
                                        when SP_INC     =>              SP <= ADR_YZ;
                                        when SP_INC     =>              SP <= ADR_YZ;
                                        when SP_LOAD    =>              SP <= ADR_XYZ;
                                        when SP_LOAD    =>              SP <= ADR_XYZ;
                                        when SP_NOP             =>              null;
                                        when SP_NOP             =>              null;
                                end case;
                                end case;
                        end if;
                        end if;
                end if;
                end if;
        end process;
        end process;
 
 
end Behavioral;
end Behavioral;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.