⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 altcam远程控制存取
💻 TXT
📖 第 1 页 / 共 5 页
字号:
                write0_done <= false;
                write1_done <= false;
                writex_done <= false;
                --------------------
                -- CAM READ MODES --
                --------------------
                -- If pattern changed or mstart asserted again then restart
                -- read cycle.
                if (match_mode = "FAST_MULTIPLE" and mstart_used = false and reset_read = true) 
                    or (mstart = '1' and mstart_rgd1 = '0')
                    or ((ipattern /= pattern_rgd) and (reset_read=false)) then
                    restart_read := true;
                    reset_read := false;
                    get_first_match <= false;
                else
                    restart_read := false;
                end if;
                -------------------------
                -- FAST MULTIPLE: READ --
                -------------------------
                if match_mode = "FAST_MULTIPLE" then
                    if get_first_match = true and restart_read = false then
                        if get_next_match = true then -- start of next read cycle
                            index := next_search; 
                            maddr_fm0: for i in index to numwords-1 loop
                                mword_fm0: for j in 0 to width-1 loop
                                    if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                        ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                        if j = width-1 then 
                                            next_search := i+1;
                                            exit maddr_fm0;
                                        end if;
                                    else 
                                        exit mword_fm0;
                                    end if;
                                end loop mword_fm0;
                            end loop maddr_fm0;
                            if index = next_search then -- no more matches
                                mfound_int <= '0';
                                maddress_int <= (others => '1');
                            else
                                maddress_int <= ieee.std_logic_arith.conv_std_logic_vector(next_search-1, widthad);
                            end if;
                        end if;
                    else -- start of new read cycle
                        count := 0;
                        mbits_tmp := (others => '0');
                        maddr_fm1: for i in 0 to numwords -1 loop
                            mword_fm1: for j in 0 to width-1 loop
                                if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                    ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                    if j = width-1 then 
                                        if (count = 0) and (reset_read = false) and (restart_read = true) then
                                            mfound_int <= '1';
                                            maddress_int <= ieee.std_logic_arith.conv_std_logic_vector(i, widthad);
                                            get_first_match <= true;
                                            next_search := i+1;
                                        end if;
                                        mbits_tmp(i) := '1';
                                        count := count + 1;
                                    end if;
                                else 
                                    exit mword_fm1;
                                end if;
                            end loop mword_fm1;
                        end loop maddr_fm1;
                        mcount_int <= ieee.std_logic_arith.conv_std_logic_vector(count, widthad);
                        mbits_int <= mbits_tmp;
                        if (count = 0) or (reset_read = true) then -- no matches
                            mfound_int <= '0';
                            maddress_int <= (others => '1');
                        end if;
                    end if; -- end of initial read cycle
                end if; -- end of FAST MULTIPLE

                --------------------
                -- MULTIPLE: READ --
                --------------------
                if match_mode = "MULTIPLE" then
                    if get_first_match = true and restart_read = false then
                        if get_next_match = true then -- start of next read cycle
                            index := next_search; 
                            maddr_mm0: for i in index to numwords-1 loop
                                mword_mm0: for j in 0 to width-1 loop
                                    if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                        ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                        if j = width-1 then 
                                            next_search := i+1;
                                            exit maddr_mm0;
                                        end if;
                                    else 
                                        exit mword_mm0;
                                    end if;
                                end loop mword_mm0;
                            end loop maddr_mm0;
                            if index = next_search then
                                mfound_int <= '0';
                                maddress_int <= (others => '1');
                            else
                                maddress_int <= ieee.std_logic_arith.conv_std_logic_vector(next_search-1, widthad);
                            end if;
                        end if;
                    else -- start of 1st match 
                      count := 0;
                      if reset_read=false then -- Not in reset state
                        if first_read_clock = false then 
                            -- 1st cycle: match with even and write to even
                            first_read_clock <= true;
                            maddress_int <= (others => '1');
                            mfound_int <= '0';
                            mbits_tmp := mbits_int;
                            maddr_mm1: for i in 0 to numwords-1 loop
                                if (i mod 2)=0 then
                                    if mbits_int(i) = '1' then
                                        count := count + 1;
                                    end if;
                                    mword_mm1: for j in 0 to width-1 loop
                                        if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                            ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                            if j = width-1 then 
                                                mbits_tmp(i+1) := '1';
                                                count := count + 1;
                                            end if;
                                        else 
                                            mbits_tmp(i+1) := '0';
                                            exit mword_mm1;
                                        end if;
                                    end loop mword_mm1;
                                end if;
                            end loop maddr_mm1;
                        else -- 2nd read cycle
                            -- 2nd cycle: do match 
                            first_read_clock <= false;
                            mbits_tmp := (others => '0');
                            maddr_mm2: for i in 0 to numwords-1 loop
                                mword_mm2: for j in 0 to width-1 loop
                                    if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                        ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                        if j = width-1 then 
                                            if count = 0 then
                                                next_search := i+1;
                                            end if;
                                            mbits_tmp(i) := '1';
                                            count := count + 1;
                                        end if;
                                    else 
                                        exit mword_mm2;
                                    end if;
                                end loop mword_mm2;
                            end loop maddr_mm2;
                            if count = 0 then -- no matches
                                maddress_int <= (others => '1');
                                mfound_int <= '0';
                            else
                                get_first_match <= true;
                                mfound_int <= '1';
                                maddress_int <= ieee.std_logic_arith.conv_std_logic_vector(next_search-1, widthad);
                            end if;
                        end if;
                      else -- In reset state
                           -- Match with even but write to odd
                        maddress_int <= (others => '1');
                        mfound_int <= '0';
                        mbits_tmp := (others => '0');
                        maddr_mm3: for i in 0 to numwords-1 loop
                            if (i mod 2)=0 then
                                mword_mm3: for j in 0 to width-1 loop
                                    if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                        ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                        if j = width-1 then 
                                            mbits_tmp(i+1) := '1';
                                            count := count + 1;
                                        end if;
                                    else 
                                        exit mword_mm3;
                                    end if;
                                end loop mword_mm3;
                            end if;
                        end loop maddr_mm3;
                      end if; -- end of 1st match
                      mcount_int <= ieee.std_logic_arith.conv_std_logic_vector(count, widthad);
                      mbits_int <= mbits_tmp;
                    end if; -- end of initial read cycle
                end if; -- end of MULTIPLE

                ------------------
                -- SINGLE: READ --
                ------------------
                if match_mode = "SINGLE" then
                    mbits_tmp := (others => '0');
                    index := 0;
                    count := 0;
                    maddr_sm0: for i in 0 to numwords-1 loop
                        mword_sm0: for j in 0 to width-1 loop
                               if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                   ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                   if j = width-1 then 
                                       mbits_tmp(i) := '1';
                                       index := i;
                                       count := 1;
                                       exit maddr_sm0;
                                    end if;
                                else
                                    exit mword_sm0;
                                end if;
                        end loop mword_sm0;
                    end loop maddr_sm0;
                    mcount_int <= ieee.std_logic_arith.conv_std_logic_vector(count, widthad);
                    mbits_int <= mbits_tmp;
                    if count = 0 then
                        maddress_int <= (others => '0');
                        mfound_int <= '0';
                    else
                        mfound_int <= '1';
                        maddress_int <= ieee.std_logic_arith.conv_std_logic_vector(index, widthad);
                    end if;
                end if; -- end of SINGLE
            else -- if wren = '1' 
                ----------------------
                -- READ AFTER WRITE --
                ----------------------
                -- Writing to CAM so reset read cycle.
                get_first_match <= false;
                first_read_clock <= false;
                restart_read := false;
                if (mstart_used = true) then
                    reset_read := true;
                end if;
                -------------------------------------
                -- FAST MULTIPLE: READ AFTER WRITE --
                -------------------------------------
                if match_mode = "FAST_MULTIPLE" then
                    mfound_int <= '0';
                    maddress_int <= (others => '1');
                    count := 0;
                    mbits_tmp := (others => '0');
                    if (writex = true) and (iwrxused = '1') then
                        waddr_fm0: for i in 0 to numwords-1 loop
                            wword_fm0: for j in 0 to width-1 loop
                                if (((x_array(i)(j) = '0') and (cam_array(i)(j) = (ipattern(j) xor iwrx(j)))) or 
                                    ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                    if j = width-1 then 
                                        mbits_tmp(i) := '1';
                                        count := count + 1;
                                    end if;
                                else 
                                    exit wword_fm0;
                                end if;
                            end loop wword_fm0;
                        end loop waddr_fm0;
                    else
                        waddr_fm1: for i in 0 to numwords-1 loop
                            wword_fm1: for j in 0 to width-1 loop
                                if (((x_array(i)(j) = '0') and (cam_array(i)(j) = ipattern(j))) or 
                                    ((x_array(i)(j) = '1') and (cam_array(i)(j) = '0'))) then
                                    if j = width-1 then 
                                        mbits_tmp(i) := '1';
                                        count := count + 1;
                                    end if;
                                else 
                                    exit wword_fm1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -