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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [core.vhd] - Diff between revs 30 and 31

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

Rev 30 Rev 31
Line 113... Line 113...
  --alu signals
  --alu signals
  signal AluOp: std_logic_vector(4 downto 0);
  signal AluOp: std_logic_vector(4 downto 0);
  signal AluIn1: std_logic_vector(7 downto 0);
  signal AluIn1: std_logic_vector(7 downto 0);
  signal AluIn2: std_logic_vector(7 downto 0);
  signal AluIn2: std_logic_vector(7 downto 0);
  signal AluOut: std_logic_vector(7 downto 0);
  signal AluOut: std_logic_vector(7 downto 0);
 
  signal AluTR: std_logic;
  signal TR: std_logic;
  signal TR: std_logic;
 
  signal TRData: std_logic;
 
  signal UseAluTR: std_logic;
 
 
  --control signals
  --control signals
  signal InReset: std_logic;
  signal InReset: std_logic;
  signal OpAddress: std_logic_vector(15 downto 0); --memory address to use for operation of an instruction
  signal OpAddress: std_logic_vector(15 downto 0); --memory address to use for operation of an instruction
  signal OpData: std_logic_vector(15 downto 0); --data to write or will load to here
  signal OpData: std_logic_vector(15 downto 0); --data to write or will load to here
Line 183... Line 186...
  cpualu: alu port map(
  cpualu: alu port map(
    Op => AluOp,
    Op => AluOp,
    DataIn1 => AluIn1,
    DataIn1 => AluIn1,
    DataIn2 => AluIn2,
    DataIn2 => AluIn2,
    DataOut => AluOut,
    DataOut => AluOut,
    TR => TR
    TR => AluTR
  );
  );
  fetcheraddress <= regIn(REGCS) & regIn(REGIP);
  fetcheraddress <= regIn(REGCS) & regIn(REGIP);
  MemAddr <= OpAddress when state=WaitForMemory else FetchMemAddr;
  MemAddr <= OpAddress when state=WaitForMemory else FetchMemAddr;
  MemOut <= OpData when (state=WaitForMemory and OpWE='1') else "ZZZZZZZZZZZZZZZZ" when state=HoldMemory else x"0000";
  MemOut <= OpData when (state=WaitForMemory and OpWE='1') else "ZZZZZZZZZZZZZZZZ" when state=HoldMemory else x"0000";
  MemWE <= OpWE when state=WaitForMemory else 'Z' when state=HoldMemory else '0';
  MemWE <= OpWE when state=WaitForMemory else 'Z' when state=HoldMemory else '0';
Line 213... Line 216...
  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
  --UsuallySegment shortcuts (only used when not an immediate
  UsuallyDS <= "1101" when opseges='0' else "1110";
  UsuallyDS <= "1101" when opseges='0' else "1110";
  UsuallySS <= "1111" when opseges='0' else "1110";
  UsuallySS <= "1111" when opseges='0' else "1110";
 
  TR <= TRData when UseAluTR='0' else AluTR;
 
 
  foo: process(Clock, Hold, state, IR, inreset, reset, regin, regout, IPCarryOut, CSCarryOut)
  foo: process(Clock, Hold, state, IR, inreset, reset, regin, regout, IPCarryOut, CSCarryOut)
  begin
  begin
    if rising_edge(Clock) then
    if rising_edge(Clock) then
 
 
Line 238... Line 241...
        fetchEN <= '1';
        fetchEN <= '1';
        OpData <= "ZZZZZZZZZZZZZZZZ";
        OpData <= "ZZZZZZZZZZZZZZZZ";
        OpAddress <= x"0000";
        OpAddress <= x"0000";
        OpWE <= '0';
        OpWE <= '0';
        opWW <= '0';
        opWW <= '0';
 
        TRData <= '0';
 
        UseAluTR <= '0';
        --finish up
        --finish up
      elsif InReset='1' and reset='0' and Hold='0' then --reset is done, start executing
      elsif InReset='1' and reset='0' and Hold='0' then --reset is done, start executing
        InReset <= '0';
        InReset <= '0';
        fetchEN <= '1';
        fetchEN <= '1';
        state <= FirstFetch1;
        state <= FirstFetch1;
Line 302... Line 307...
        regIn(REGSP) <= SPCarryOut; --with addend being 0, it'll just write SP to SP so it won't change, but this makes code easier for me
        regIn(REGSP) <= SPCarryOut; --with addend being 0, it'll just write SP to SP so it won't change, but this makes code easier for me
        regIn(REGSS) <= SSCarryOut;
        regIn(REGSS) <= SSCarryOut;
        regWE(REGSP) <= '1';
        regWE(REGSP) <= '1';
        regWE(REGSS) <= '1';
        regWE(REGSS) <= '1';
        OpAddress <= "ZZZZZZZZZZZZZZZZ";
        OpAddress <= "ZZZZZZZZZZZZZZZZ";
 
        if UseAluTR='1' then
 
          UseAluTR<='0';
 
        end if;
        --actual decoding
        --actual decoding
        if opcond1='0' or (opcond1='1' and TR='1') then
        if opcond1='0' or (opcond1='1' and TR='1') then
          case opmain is
          case opmain is
            when "0000" => --mov reg,imm
            when "0000" => --mov reg,imm
              regIn(to_integer(unsigned(bankreg1))) <= opimmd;
              regIn(to_integer(unsigned(bankreg1))) <= opimmd;
Line 318... Line 325...
              OpWW <= '0';
              OpWW <= '0';
              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
 
              TRData <= AluTR;
 
              UseAluTR <= '1';
              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(bankreg1)));
              AluIn1 <= regOut(to_integer(unsigned(bankreg1)));
              AluIn2 <= regOut(to_integer(unsigned(bankreg2)));
              AluIn2 <= regOut(to_integer(unsigned(bankreg2)));
            when "0100" => --group 4 bitwise operations
            when "0100" => --group 4 bitwise operations
              --setup wait state
              --setup wait state

powered by: WebSVN 2.1.0

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