The Muffin Boy
The Muffin Boy

Reputation: 314

= can not have such operands in this context

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;

Upvotes: 0

Views: 2801

Answers (1)

user1155120
user1155120

Reputation:

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.

Upvotes: 1

Related Questions