0

Here's the full error: ERROR:HDLParsers:808 - "C:/Users/vROG/Desktop/.../CacheController.vhd" Line 72. = can not have such operands in this context.

I'd understand how to fix this if I was used '+' or '*', but equal sign?

As you can tell, the code isn't nearly being close to completely, but I can't understand why my second nested if isn't working. I've tried turning dirtyBIT to type int, but it still gives me the same error, which leads me to believe that I made a trivial error somewhere.

FIXED (Using user1155120's advice) However how do I resolve the issue with offset and tag?

architecture Behavioral of CacheController is

signal tagFROMCPU :  STD_LOGIC_VECTOR(7 downto 0) := CPU_addr(15 downto 8);
signal indexFROMCPU: STD_LOGIC_VECTOR(2 downto 0) := CPU_addr(7 downto 5);
signal offsetFROMCPU: STD_LOGIC_VECTOR(4 downto 0) := CPU_addr(4 downto 0);

TYPE STATETYPE IS (state_0, state_1, state_2, state_3);
SIGNAL present_state    : STATETYPE;

--Variables
signal dirtyBIT: std_logic_vector (7 downto 0);
signal validBIT: std_logic_vector (7 downto 0);

TYPE tag is array (7 downto 0) of STD_LOGIC_VECTOR(7 downto 0);
TYPE offset is array (7 downto 0) of STD_LOGIC_VECTOR(4 downto 0);

signal myTag: tag;
signal myOFFSET : offset;
    begin

--STATE MACHINE
process(clk)    
begin
    if (present_state = state_0) then --Start State : Checks for HIT or MISS, PERFORMS HIT OPERATION or MOVES TO STATE_1
        if ((myTag(to_integer(unsigned(indexFROMCPU)) = tagFROMCPU)) then
        --HIT
        else
            present_state <= state_1;
        end if;
    elsIF (present_state = state_1) then --CHECKS DIRTY BIT. IF 0, LOADS DATA, MOVES TO STATE_0 ELSE move to state_2

        if (dirtyBit(to_integer(unsigned(indexFROMCPU))) = '0') then
            present_state <= state_0;
        else
            present_state <= state_2;
        end if;

    elsIF(present_state = state_2) then -- DIRTY BIT IS 1, SAVES DATA, goes back to STATE_1
            present_state <= state_1;
    end if;
end process;


end Behavioral;

OLD CODE

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;


entity CacheController is
Port (
        clk         : in  STD_LOGIC;
        CPU_addr    : in  STD_LOGIC_VECTOR (15 downto 0);
        CPU_WR_RD   : in  STD_LOGIC;
        CPU_CS      : in  STD_LOGIC;

        CPU_RDY     : out STD_LOGIC;

        SDRAM_Addr  : out  STD_LOGIC_VECTOR (15 downto 0);
        SDRAM_WR_RD : out  STD_LOGIC;
        SDRAM_MSTRB : out  STD_LOGIC;

        MUX1,MUX2   : out STD_LOGIC;

        SRAM_Addr   : out  STD_LOGIC_VECTOR (7 downto 0);
        SRAM_WEN    : out  STD_LOGIC

);

end CacheController;

architecture Behavioral of CacheController is

signal tagFROMCPU :  STD_LOGIC_VECTOR(7 downto 0) := CPU_addr(15 downto 8);
signal indexFROMCPU: STD_LOGIC_VECTOR(2 downto 0) := CPU_addr(7 downto 5);
signal offsetFROMCPU: STD_LOGIC_VECTOR(4 downto 0) := CPU_addr(4 downto 0);

TYPE STATETYPE IS (state_0, state_1, state_2, state_3);
SIGNAL present_state    : STATETYPE;

--Variables to emulate SRAM
TYPE dirtyBIT is array (7 downto 0) of std_logic;
TYPE validBIT is array (7 downto 0) of std_logic;
TYPE tag is array (7 downto 0,7 downto 0) of std_logic;
TYPE offset is array (7 downto 0,4 downto 0) of std_logic;

begin

--STATE MACHINE
process(clk)    
begin
    if (present_state = state_0) then --Start State : Checks for HIT or MISS, PERFORMS HIT OPERATION or MOVES TO STATE_1

    elsIF (present_state = state_1) then --CHECKS DIRTY BIT. IF 0, LOADS DATA, MOVES TO STATE_0 ELSE move to state_2

        if (dirtyBit(to_integer(unsigned(indexFROMCPU))) = '0') then
            present_state <= state_0;
        else
            present_state <= state_2;
        end if;

    elsIF(present_state = state_2) then -- DIRTY BIT IS 1, SAVES DATA, goes back to STATE_1
            present_state <= state_1;
    end if;
end process;


end Behavioral;
The Muffin Boy
  • 314
  • 4
  • 14
  • The code that you pasted only consists of 64 lines. Which one is supposed to be the offending line number 72? – mkrieger1 Oct 10 '15 at 21:11
  • This is an XST error. @mkrieger1 - line 52. `dirtyBit` is the name of a type. Perhaps you want to declare it as a signal object? I'd suspect that will hold true for all four of the `-- Variables` you show as types. –  Oct 10 '15 at 21:54
  • @user1155120 Is correct. Replacing Dirtybit with any of the --Variables will give the same error. Will try declaring them as signals – The Muffin Boy Oct 10 '15 at 21:59
  • Don't ruined the value of your question/answer to third parties by making it unclear. Consider rolling your edit back here and asking another question. I answered and can't tell what *issue with offset and tag* you're asking about now. Unclear can lead to down votes and closure, accepted answers can block further interest. You're not asking for debug help now. See [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask). There may be issues suited for different tags or other Stack Exchange sites. Good direct questions get good answers. –  Oct 11 '15 at 02:05

1 Answers1

1

Operator overload resolution (for the "=" operator) requires a function be declared with a matching signature (types of the left and right inputs and the return type).

        if (dirtyBit(to_integer(unsigned(indexFROMCPU))) = '0') then

Change the declaration for dirtyBit:

--Variables to emulate SRAM
-- TYPE dirtyBIT is array (7 downto 0) of std_logic;
signal dirtyBIT: std_logic_vector (7 downto 0);

And your code analyzes. I'd suggest the other type declaration (validBIT, tag and offset) should be similarly treated.

It looks like there should be an array type where offset is used. The type name might be changed to preserve offset as a signal name.