📄 新建 文本文档.txt
字号:
REPORT "[Line "& int_to_str(lineno) & "]:Illegal Intel Hex Format! "
SEVERITY ERROR;
end if;
ibase := ibase * 256 + hex_str_to_int(base);
check_sum_vec := unsigned(check_sum_vec) + unsigned(CONV_STD_LOGIC_VECTOR(hex_str_to_int(base), 8));
end loop;
ibase := ibase * 16; -- because std load addr is 2 bytes.
when OTHERS =>
ASSERT FALSE
REPORT "[Line "& int_to_str(lineno) & "]:Illegal record type in Intel Hex File! "
SEVERITY ERROR;
end case;
READ(L=>buf, VALUE=>checksum,good=>booval);
if not (booval) then
ASSERT FALSE
REPORT "[Line "& int_to_str(lineno) & "]:Checksum is missing! "
SEVERITY ERROR;
end if;
check_sum_vec := unsigned(not (check_sum_vec)) + 1;
check_sum_vec_tmp := CONV_STD_LOGIC_VECTOR(hex_str_to_int(checksum),8);
if (check_sum_vec /= check_sum_vec_tmp) then
ASSERT FALSE
REPORT "[Line "& int_to_str(lineno) & "]:Incorrect checksum!"
SEVERITY ERROR;
end if;
end loop;
return mem_data;
end;
end altcam;
architecture behave of altcam is
signal pattern_rgd: std_logic_vector(width-1 downto 0) := (others => '0'); -- registered input
signal pattern_int: std_logic_vector(width-1 downto 0) := (others => '0'); -- internal input
signal wrx_rgd: std_logic_vector(width-1 downto 0) := (others => '0'); -- registered input
signal wrx_int: std_logic_vector(width-1 downto 0) := (others => '0'); -- internal input
signal wrxused_rgd : std_logic := '0'; -- registered input
signal wrxused_int : std_logic := '0'; -- internal input
signal wraddress_rgd: std_logic_vector(widthad-1 downto 0) := (others => '0'); -- registered input
signal wren_rgd: std_logic := '0'; -- registered input
signal wrdelete_rgd: std_logic := '0'; -- internally registered input
signal maddress_rgd: std_logic_vector(widthad-1 downto 0) := (others => '0'); -- registered output
signal maddress_int: std_logic_vector(widthad-1 downto 0) := (others => '0'); -- internal output
signal mbits_rgd: std_logic_vector(numwords-1 downto 0) := (others => '0'); -- registered output
signal mbits_int: std_logic_vector(numwords-1 downto 0) := (others => '0'); -- internal output
signal mfound_rgd: std_logic := '0'; -- registered output
signal mfound_int: std_logic := '0'; -- internal output
signal mcount_rgd: std_logic_vector(widthad-1 downto 0) := (others => '0'); -- registered output
signal mcount_int: std_logic_vector(widthad-1 downto 0) := (others => '0'); -- internal output
signal wrbusy_int : std_logic := '0'; -- internal output
signal rdbusy_int : std_logic := '0'; -- internal output
signal outclock_int: std_logic; -- internal outclock
signal outaclr_int: std_logic; -- internal outaclr
-- CAM signals
signal cam_init: integer := 1;
signal cam_array: lpm_memory;
signal x_array: lpm_memory;
-- Read control signals
signal get_first_match : boolean := false;
signal get_next_match : boolean := true;
signal first_read_clock : boolean := false;
signal mstart_rgd1: std_logic := '0';
signal mstart_rgd2: std_logic := '0';
signal rdbusy_delayed : std_logic;
signal first_read_in_write: boolean := false;
signal mstart_used: boolean := false;
-- Write control signals
signal write_start : std_logic;
signal write_start_rgd: std_logic := '0';
signal write_start_1: std_logic := '0';
signal write0: boolean := true;
signal write1: boolean := false;
signal writex: boolean := false;
signal write0_done: boolean := false;
signal write1_done: boolean := false;
signal writex_done: boolean := false;
signal write_incomplete: std_logic := '0';
begin
msg: process (wraddress_rgd, wrdelete_rgd, wren_rgd,
wrxused_int, pattern_int, mstart_rgd1)
begin
if wren_rgd'event and wren_rgd = '0' and write_incomplete = '1' then
ASSERT FALSE
REPORT "Insufficient write cycle time, write maybe invalid! "
SEVERITY WARNING;
elsif pattern_int'event and write_incomplete = '1' then
ASSERT FALSE
REPORT "Insufficient pattern hold time, write maybe invalid! "
SEVERITY WARNING;
elsif wraddress_rgd'event and write_incomplete = '1' then
ASSERT FALSE
REPORT "Insufficient address hold time, write maybe invalid! "
SEVERITY WARNING;
elsif wrdelete_rgd'event and wrdelete_rgd = '0' and
write_incomplete = '1' then
ASSERT FALSE
REPORT "Insufficient delete cycle time, delete failed! "
SEVERITY WARNING;
elsif wrdelete_rgd'event and wrdelete_rgd = '1' and
write_incomplete = '1' then
ASSERT FALSE
REPORT "Insufficient write cycle time, write maybe invalid! "
SEVERITY WARNING;
elsif wrxused_int'event and write_incomplete = '1' and
wrdelete_rgd = '0' then
ASSERT FALSE
REPORT "wrxused signal changed during write! "
SEVERITY WARNING;
elsif mstart_rgd1'event and write_incomplete = '1' and
mstart_rgd1 = '1' then
ASSERT FALSE
REPORT "Incorrect read attempt during write! "
SEVERITY WARNING;
end if;
if pattern_int'event then
if rdbusy_delayed = '1' then
ASSERT FALSE
REPORT "Insufficient read time, read failed! "
SEVERITY WARNING;
elsif rdbusy_delayed = '0' and mnext = '1' then
ASSERT FALSE
REPORT "Illegal pattern change during read, read failed! "
SEVERITY WARNING;
end if;
end if;
end process msg;
-- Evaluate parameters
pattern_int <= pattern when pattern_reg = "UNREGISTERED" else pattern_rgd;
wrx_int <= wrx when wrx_reg = "UNREGISTERED" else wrx_rgd;
wrxused_int <= wrxused when wrx_reg = "UNREGISTERED" else wrxused_rgd;
maddress <= maddress_int when output_reg = "UNREGISTERED" else maddress_rgd;
mbits <= mbits_int when output_reg = "UNREGISTERED" else mbits_rgd;
mcount <= mcount_int when output_reg = "UNREGISTERED" else mcount_rgd;
mfound <= mfound_int when output_reg = "UNREGISTERED" else mfound_rgd;
wrbusy <= wrbusy_int;
rdbusy <= rdbusy_int;
outclock_int <= outclock when output_reg = "OUTCLOCK" else inclock;
outaclr_int <= outaclr when output_aclr = "ON" else inaclr;
rdbusy_delayed <= rdbusy_int after 2 ns;
mstart_update: process (mstart)
begin
mstart_used <= true;
end process mstart_update;
-----------------------------------------
-- Evaluate ALTCAM reading and writing --
-----------------------------------------
read_write: process (inaclr, inclock, pattern)
variable count : natural := 0;
variable index : natural :=0;
variable addr : natural :=0;
variable next_search : natural := 0;
variable restart_read : boolean := false;
variable reset_read : boolean := true;
variable ipattern: std_logic_vector(width-1 downto 0);
variable iwraddress: std_logic_vector(widthad-1 downto 0);
variable iwrx: std_logic_vector(width-1 downto 0);
variable iwren: std_logic;
variable iwrxused : std_logic;
variable mbits_tmp: std_logic_vector(numwords-1 downto 0);
variable cam_array_tmp: lpm_memory;
variable x_array_tmp: lpm_memory;
begin
-- Initialise the CAM at startup.
if cam_init = 1 then
if lpm_file = "UNUSED" then
for i in 0 to numwords-1 loop
cam_array(i) <= (others => '1');
x_array(i) <= (others => '1');
end loop;
elsif lpm_filex = "UNUSED" then
cam_array <= hex_to_stdlogicarray(lpm_file);
for i in 0 to numwords-1 loop
x_array(i) <= (others => '0');
end loop;
else
cam_array <= hex_to_stdlogicarray(lpm_file);
x_array <= hex_to_stdlogicarray(lpm_filex);
end if;
if match_mode /= "SINGLE" then
maddress_int <= (others => '1');
end if;
end if;
cam_init <= 0;
ipattern := pattern;
iwrx := wrx;
iwraddress := wraddress;
iwren := wren;
if (wrx_reg = "UNUSED") or (wrx_aclr = "UNUSED") then
iwrxused := '0'; -- must be unconnected
else
iwrxused := wrxused;
end if;
if inaclr = '1' then
if (mstart_used = true) then
reset_read := true;
end if;
first_read_clock <= false;
get_first_match <= false;
if pattern_aclr = "ON" then
pattern_rgd <= (others => '0');
ipattern := (others => '0');
end if;
if wrx_aclr = "ON" then
wrx_rgd <= (others => '0');
iwrx := (others => '0');
wrxused_rgd <= '0';
iwrxused := '0';
end if;
if wraddress_aclr = "ON" then
wraddress_rgd <= (others => '0');
iwraddress := (others => '0');
end if;
if wrcontrol_aclr = "ON" then
wren_rgd <= '0';
iwren := '0';
write0_done <= false;
write1_done <= false;
writex_done <= false;
end if;
if (pattern_aclr = "ON") then
mbits_int <= (others => '0');
mcount_int <= (others => '0');
mfound_int <= '0';
if (match_mode = "SINGLE") then
maddress_int <= (others => '0');
else
maddress_int <= (others => '1');
end if;
end if;
end if;
if inclock'event and (inclocken = '1') then
if inclock = '1' then
pattern_rgd <= ipattern;
wrx_rgd <= iwrx;
wrxused_rgd <= iwrxused;
wraddress_rgd <= iwraddress;
wren_rgd <= iwren;
write_start_rgd <= write_start;
write_incomplete <= wrbusy_int;
mstart_rgd1 <= mstart;
mstart_rgd2 <= mstart_rgd1;
wrdelete_rgd <= wrdelete;
if iwren = '0' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -