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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [core.vhd] - Diff between revs 28 and 29

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 28 Rev 29
Line 141... Line 141...
  signal bankreg1: std_logic_vector(3 downto 0); --these signals have register bank stuff baked in
  signal bankreg1: std_logic_vector(3 downto 0); --these signals have register bank stuff baked in
  signal bankreg2: std_logic_vector(3 downto 0);
  signal bankreg2: std_logic_vector(3 downto 0);
  signal bankreg3: std_logic_vector(3 downto 0);
  signal bankreg3: std_logic_vector(3 downto 0);
  signal FetchMemAddr: std_logic_vector(15 downto 0);
  signal FetchMemAddr: std_logic_vector(15 downto 0);
 
 
 
  signal UsuallySS: std_logic_vector(3 downto 0);
 
  signal UsuallyDS: std_logic_vector(3 downto 0);
begin
begin
  reg: registerfile port map(
  reg: registerfile port map(
    WriteEnable => regWE,
    WriteEnable => regWE,
    DataIn => regIn,
    DataIn => regIn,
    Clock => Clock,
    Clock => Clock,
Line 207... Line 208...
  DebugTR <= TR;
  DebugTR <= TR;
  --register addresses with registerbank baked in
  --register addresses with registerbank baked in
  bankreg1 <= ('1' & opreg1) when (regbank='1' and opreg1(2)='0') else '0' & opreg1;
  bankreg1 <= ('1' & opreg1) when (regbank='1' and opreg1(2)='0') else '0' & opreg1;
  bankreg2 <= ('1' & opreg2) when (regbank='1' and opreg2(2)='0') else '0' & opreg2;
  bankreg2 <= ('1' & opreg2) when (regbank='1' and opreg2(2)='0') else '0' & opreg2;
  bankreg3 <= ('1' & opreg3) when (regbank='1' and opreg3(2)='0') else '0' & opreg3;
  bankreg3 <= ('1' & opreg3) when (regbank='1' and opreg3(2)='0') else '0' & opreg3;
 
  --UsuallySegment shortcuts (only used when not an immediate
 
  UsuallyDS <= "1101" when opseges='0' else "1110";
 
  UsuallySS <= "1111" when opseges='0' else "1110";
 
 
 
 
 
  foo: process(Clock, Hold, state, IR, inreset, reset, regin, regout, IPCarryOut, CSCarryOut)
  decode: process(Clock, Hold, state, IR, inreset, reset, regin, regout, IPCarryOut, CSCarryOut)
 
  begin
  begin
    if rising_edge(Clock) then
    if rising_edge(Clock) then
 
 
    --states
    --states
      if reset='1' and hold='0' then
      if reset='1' and hold='0' then
Line 271... Line 274...
        state <= Execute;
        state <= Execute;
      elsif state=WaitForMemory then
      elsif state=WaitForMemory then
        state <= Execute;
        state <= Execute;
        FetchEn <= '1';
        FetchEn <= '1';
        IpAddend <= x"02";
        IpAddend <= x"02";
 
        SpAddend <= x"00";
      end if;
      end if;
 
 
 
 
      if state=Execute then
      if state=Execute then
        fetchEN <= '1';
        fetchEN <= '1';
Line 306... Line 310...
              state <= WaitForMemory;
              state <= WaitForMemory;
              IPAddend <= x"00"; --disable all this because we have to wait a cycle to write memory
              IPAddend <= x"00"; --disable all this because we have to wait a cycle to write memory
              FetchEN <= '0';
              FetchEN <= '0';
            when "0011" => --group 3 comparisons
            when "0011" => --group 3 comparisons
              AluOp <= "01" & opreg3; --nothing hard here, ALU does it all for us
              AluOp <= "01" & opreg3; --nothing hard here, ALU does it all for us
              AluIn1 <= regOut(to_integer(unsigned(opreg1)));
              AluIn1 <= regOut(to_integer(unsigned(bankreg1)));
              AluIn2 <= regOut(to_integer(unsigned(opreg2)));
              AluIn2 <= regOut(to_integer(unsigned(bankreg2)));
            when "0100" => --group 4 bitwise operations
            when "0100" => --group 4 bitwise operations
              AluOp <= "00" & opreg3; --nothing hard here, ALU does it all for us
              AluOp <= "00" & opreg3; --nothing hard here, ALU does it all for us
              AluIn1 <= regOut(to_integer(unsigned(opreg1)));
              AluIn1 <= regOut(to_integer(unsigned(bankreg1)));
              AluIn2 <= regOut(to_integer(unsigned(opreg2)));
              AluIn2 <= regOut(to_integer(unsigned(bankreg2)));
              regIn(to_integer(unsigned(opreg1))) <= AluOut;
              regIn(to_integer(unsigned(bankreg1))) <= AluOut;
              regWE(to_integer(unsigned(opreg1))) <= '1';
              regWE(to_integer(unsigned(bankreg1))) <= '1';
 
           when "0101" => --group 5
 
              case opreg3 is
 
                when "000" => --subgroup 5-0
 
                  case opreg2 is
 
                    when "000" => --push reg
 
                      SpAddend <= x"02"; --set SP to increment
 
                      OpAddress <= regOut(to_integer(unsigned(UsuallySS))) & regOut(REGSP);
 
                      OpWE <= '1';
 
                      OpData <= x"00" & regOut(to_integer(unsigned(bankreg1)));
 
                      OpWW <= '1';
 
                      state <= WaitForMemory;
 
                      IPAddend <= x"00";
 
                      FetchEN <= '0';
 
                    when "001" => --pop reg
 
                      SPAddend <= x"FE"; --set SP to decrement
 
                      OpAddress <= regOut(to_integer(unsigned(UsuallySS))) & regOut(REGSP);
 
                      OpWE <= '0';
 
                      regIn(to_integer(unsigned(bankreg1))) <= OpData(7 downto 0);
 
                      OpWW <= '0';
 
                      state <= WaitForMemory;
 
                      IPAddend <= x"00";
 
                      FetchEN <= '0';
 
                    when others =>
 
                      --synthesis off
 
                      report "Not implemented subgroup 5-0" severity error;
 
                      --synthesis on
 
                  end case;
 
                when others =>
 
                  --synthesis off
 
                  report "Not implemented group 5" severity error;
 
                  --synthesis on
 
              end case;
            when others =>
            when others =>
              --synthesis off
              --synthesis off
              report "Not implemented" severity error;
              report "Not implemented" severity error;
              --synthesis on
              --synthesis on
          end case;
          end case;
        end if;
        end if;
      end if;
      end if;
 
 
 
    end if;
 
 
 
 
 
 
    end if;
 
  end process;
  end process;
 
 
 
 
 
 
 
 

powered by: WebSVN 2.1.0

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