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

📄 odt_watchdog.v

📁 DDR2 的控制器
💻 V
📖 第 1 页 / 共 4 页
字号:
	    (wr_cmd_counter[i] > add_lat) && (wr_cmd_counter[i] < (cas_lat+add_lat))) begin
            if (!ddr_odt)
	        $display ("ODT ERROR: ddr_odt should be high at time %0t\n",$time);
        end

        // Issue an error message if the ODT signal is asserted when 
	// it should not be
    end

    if (!(|wr_cmd_count_en) && ddr_odt&& ((cas_lat+add_lat) > 4))
	$display ("ODT ERROR: ddr_odt asserted when it should not be at time %0t\n",$time);

end

`endif

`ifdef CS_WIDTH_4
always @ (posedge mem_clk) begin
    if (mem_rd_cmd) begin
   `ifdef USR_SLOT_SIZE_2
	if ((cas_lat + add_lat) == 3) begin
	    if (ddr_cs_n == 4'b1110 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1101 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1011 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b0111 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
   end
  `else
	// edge 0 should sample ODT asserted
	if ((cas_lat + add_lat) == 3) begin
	    if (ddr_cs_n == 4'b0111 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1110 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1101 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1011 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	end
  `endif
    end

    //----------------------------------------------------------
    if (mem_wr_cmd) begin
	// edge 0 should sample ODT asserted
   `ifdef USR_SLOT_SIZE_2
	if ((cas_lat + add_lat) < 5) begin
	    if (ddr_cs_n == 4'b1110 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1101 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1011 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b0111 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	end
   `else
	if ((cas_lat + add_lat) < 5) begin
	    if (ddr_cs_n == 4'b0111 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1110 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1101 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1011 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	end
   `endif

	// edge -1 should have sampled ODT asserted
   `ifdef USR_SLOT_SIZE_2
	if ((cas_lat + add_lat) == 3) begin
	    if (ddr_cs_n == 4'b1110 && !flop_ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should have been high a clock cycle earlier at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1101 && !flop_ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should have been high a clock cycle earlier at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1011 && !flop_ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should have been high a clock cycle earlier at time %0t\n",$time);
	    if (ddr_cs_n == 4'b0111 && !flop_ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should have been high a clock cycle earlier at time %0t\n",$time);
	end
   `else
	if ((cas_lat + add_lat) == 3) begin
	    if (ddr_cs_n == 4'b0111 && !flop_ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should have been high a clock cycle earlier at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1110 && !flop_ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should have been high a clock cycle earlier at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1101 && !flop_ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should have been high a clock cycle earlier at time %0t\n",$time);
	    if (ddr_cs_n == 4'b1011 && !flop_ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should have been high a clock cycle earlier at time %0t\n",$time);
	end
   `endif
    end

    //----------------------------------------------------------
    // ODT detection for read commands
  `ifdef USR_SLOT_SIZE_2
    for (i=0; i<8; i=i+1) begin
        if (cmd_count_en[i] && int_burst_len == 4 && (cas_lat == 3) &&
	    (cmd_counter[i] >= add_lat) && (cmd_counter[i] < (cas_lat+add_lat-1))) begin
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

        else if (cmd_count_en[i] && int_burst_len == 4 && (cas_lat == 4) &&
	    (cmd_counter[i] >= add_lat+1) && (cmd_counter[i] < (cas_lat+add_lat-1))) begin
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

        if (cmd_count_en[i] && int_burst_len == 8 && (cas_lat == 3) &&
	    (cmd_counter[i] >= add_lat) && (cmd_counter[i] < (cas_lat+add_lat+1))) begin
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

        else if (cmd_count_en[i] && int_burst_len == 8 && (cas_lat == 4) &&
	    (cmd_counter[i] >= add_lat+1) && (cmd_counter[i] < (cas_lat+add_lat+1))) begin
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
		$display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

    end
 `else
    for (i=0; i<8; i=i+1) begin
        if (cmd_count_en[i] && int_burst_len == 4 && (cas_lat == 3) &&
	    (cmd_counter[i] >= add_lat) && (cmd_counter[i] < (cas_lat+add_lat-1))) begin
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
        end

        else if (cmd_count_en[i] && int_burst_len == 4 && (cas_lat == 4) &&
	    (cmd_counter[i] >= add_lat+1) && (cmd_counter[i] < (cas_lat+add_lat-1))) begin
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
        end

        if (cmd_count_en[i] && int_burst_len == 8 && (cas_lat == 3) &&
	    (cmd_counter[i] >= add_lat) && (cmd_counter[i] < (cas_lat+add_lat+1))) begin
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
        end

        else if (cmd_count_en[i] && int_burst_len == 8 && (cas_lat == 4) &&
	    (cmd_counter[i] >= add_lat+1) && (cmd_counter[i] < (cas_lat+add_lat+1))) begin
	    if (ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[2])
		$display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
	    if (ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[3])
		$display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
        end

    end
 `endif

    //----------------------------------------------------------
    // ODT detection for write commands
  `ifdef USR_SLOT_SIZE_2
    for (i=0; i<8; i=i+1) begin
        if (wr_cmd_count_en[i] && (int_burst_len == 4) && (cas_lat == 3) &&
	    (wr_cmd_counter[i] >= add_lat-1) && (wr_cmd_counter[i] < (cas_lat+add_lat-2))) begin
            if (wr_ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

        else if (wr_cmd_count_en[i] && (int_burst_len == 4) && (cas_lat == 4) &&
	    (wr_cmd_counter[i] >= add_lat) && (wr_cmd_counter[i] < (cas_lat+add_lat-2))) begin
            if (wr_ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

        if (wr_cmd_count_en[i] && (int_burst_len == 8) && (cas_lat == 3) &&
	    (wr_cmd_counter[i] >= add_lat-1) && (wr_cmd_counter[i] < (cas_lat+add_lat))) begin
            if (wr_ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end

        else if (wr_cmd_count_en[i] && int_burst_len == 8 && (cas_lat == 4) &&
	    (wr_cmd_counter[i] >= add_lat) && (wr_cmd_counter[i] < (cas_lat+add_lat))) begin
            if (wr_ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[0])
	        $display ("ODT ERROR: ddr_odt[0] should be high at time %0t\n",$time);
        end
    end
 `else
    for (i=0; i<8; i=i+1) begin
        if (wr_cmd_count_en[i] && (int_burst_len == 4) && (cas_lat == 3) &&
	    (wr_cmd_counter[i] >= add_lat-1) && (wr_cmd_counter[i] < (cas_lat+add_lat-2))) begin
            if (wr_ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[3])
	        $display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[3])
	        $display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[3])
	        $display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
        end

        else if (wr_cmd_count_en[i] && (int_burst_len == 4) && (cas_lat == 4) &&
	    (wr_cmd_counter[i] >= add_lat) && (wr_cmd_counter[i] < (cas_lat+add_lat-2))) begin
            if (wr_ddr_cs_n_d[i] == 4'b0111 && !ddr_odt[2])
	        $display ("ODT ERROR: ddr_odt[2] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1110 && !ddr_odt[3])
	        $display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1101 && !ddr_odt[3])
	        $display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
            if (wr_ddr_cs_n_d[i] == 4'b1011 && !ddr_odt[3])
	        $display ("ODT ERROR: ddr_odt[3] should be high at time %0t\n",$time);
        end

⌨️ 快捷键说明

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