module_content
stringlengths
18
1.05M
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [7:0] crc; genvar g; wire [7:0] out_p1; wire [15:0] out_p2; wire [7:0] out_p3; wire [7:0] out_p4; paramed #(.WIDTH(8), .MODE(0)) p1 (.in(crc), .out(out_p1)); paramed #(.WIDTH(16), .MODE(1)) p2 (.in({crc,crc}), .out(out_p2)); paramed #(.WIDTH(8), .MODE(2)) p3 (.in(crc), .out(out_p3)); gencase #(.MODE(3)) p4 (.in(crc), .out(out_p4)); wire [7:0] out_ef; enflop #(.WIDTH(8)) enf (.a(crc), .q(out_ef), .oe_e1(1'b1), .clk(clk)); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%b %x %x %x %x %x\n",$time, cyc, crc, out_p1, out_p2, out_p3, out_p4, out_ef); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin // Setup crc <= 8'hed; end else if (cyc==1) begin end else if (cyc==3) begin if (out_p1 !== 8'h2d) $stop; if (out_p2 !== 16'h2d2d) $stop; if (out_p3 !== 8'h78) $stop; if (out_p4 !== 8'h44) $stop; if (out_ef !== 8'hda) $stop; end else if (cyc==9) begin $write("*-* All Finished *-*\n"); $finish; end end endmodule
module gencase (/*AUTOARG*/ // Outputs out, // Inputs in ); parameter MODE = 0; input [7:0] in; output [7:0] out; generate // : genblk1 begin case (MODE) 2: mbuf mc [7:0] (.q(out[7:0]), .a({in[5:0],in[7:6]})); default: mbuf mc [7:0] (.q(out[7:0]), .a({in[3:0],in[3:0]})); endcase end endgenerate endmodule
module paramed (/*AUTOARG*/ // Outputs out, // Inputs in ); parameter WIDTH = 1; parameter MODE = 0; input [WIDTH-1:0] in; output [WIDTH-1:0] out; generate if (MODE==0) initial $write("Mode=0\n"); // No else endgenerate `ifndef NC // for(genvar) unsupported `ifndef ATSIM // for(genvar) unsupported generate // Empty loop body, local genvar for (genvar j=0; j<3; j=j+1) begin end // Ditto to make sure j has new scope for (genvar j=0; j<5; j=j+1) begin end endgenerate `endif `endif generate endgenerate genvar i; generate if (MODE==0) begin // Flip bitorder, direct assign method for (i=0; i<WIDTH; i=i+1) begin assign out[i] = in[WIDTH-i-1]; end end else if (MODE==1) begin // Flip using instantiation for (i=0; i<WIDTH; i=i+1) begin integer from = WIDTH-i-1; if (i==0) begin // Test if's within a for mbuf m0 (.q(out[i]), .a(in[from])); end else begin mbuf ma (.q(out[i]), .a(in[from])); end end end else begin for (i=0; i<WIDTH; i=i+1) begin mbuf ma (.q(out[i]), .a(in[i^1])); end end endgenerate endmodule
module mbuf ( input a, output q ); assign q = a; endmodule
module enflop (clk, oe_e1, a,q); parameter WIDTH=1; input clk; input oe_e1; input [WIDTH-1:0] a; output [WIDTH-1:0] q; reg [WIDTH-1:0] oe_r; reg [WIDTH-1:0] q_r; genvar i; generate for (i = 0; i < WIDTH; i = i + 1) begin : datapath_bits enflop_one enflop_one (.clk (clk), .d (a[i]), .q_r (q_r[i])); always @(posedge clk) oe_r[i] <= oe_e1; assign q[i] = oe_r[i] ? q_r[i] : 1'bx; end endgenerate endmodule
module enflop_one ( input clk, input d, output reg q_r ); always @(posedge clk) q_r <= d; endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [7:0] crc; genvar g; wire [7:0] out_p1; wire [15:0] out_p2; wire [7:0] out_p3; wire [7:0] out_p4; paramed #(.WIDTH(8), .MODE(0)) p1 (.in(crc), .out(out_p1)); paramed #(.WIDTH(16), .MODE(1)) p2 (.in({crc,crc}), .out(out_p2)); paramed #(.WIDTH(8), .MODE(2)) p3 (.in(crc), .out(out_p3)); gencase #(.MODE(3)) p4 (.in(crc), .out(out_p4)); wire [7:0] out_ef; enflop #(.WIDTH(8)) enf (.a(crc), .q(out_ef), .oe_e1(1'b1), .clk(clk)); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%b %x %x %x %x %x\n",$time, cyc, crc, out_p1, out_p2, out_p3, out_p4, out_ef); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin // Setup crc <= 8'hed; end else if (cyc==1) begin end else if (cyc==3) begin if (out_p1 !== 8'h2d) $stop; if (out_p2 !== 16'h2d2d) $stop; if (out_p3 !== 8'h78) $stop; if (out_p4 !== 8'h44) $stop; if (out_ef !== 8'hda) $stop; end else if (cyc==9) begin $write("*-* All Finished *-*\n"); $finish; end end endmodule
module gencase (/*AUTOARG*/ // Outputs out, // Inputs in ); parameter MODE = 0; input [7:0] in; output [7:0] out; generate // : genblk1 begin case (MODE) 2: mbuf mc [7:0] (.q(out[7:0]), .a({in[5:0],in[7:6]})); default: mbuf mc [7:0] (.q(out[7:0]), .a({in[3:0],in[3:0]})); endcase end endgenerate endmodule
module paramed (/*AUTOARG*/ // Outputs out, // Inputs in ); parameter WIDTH = 1; parameter MODE = 0; input [WIDTH-1:0] in; output [WIDTH-1:0] out; generate if (MODE==0) initial $write("Mode=0\n"); // No else endgenerate `ifndef NC // for(genvar) unsupported `ifndef ATSIM // for(genvar) unsupported generate // Empty loop body, local genvar for (genvar j=0; j<3; j=j+1) begin end // Ditto to make sure j has new scope for (genvar j=0; j<5; j=j+1) begin end endgenerate `endif `endif generate endgenerate genvar i; generate if (MODE==0) begin // Flip bitorder, direct assign method for (i=0; i<WIDTH; i=i+1) begin assign out[i] = in[WIDTH-i-1]; end end else if (MODE==1) begin // Flip using instantiation for (i=0; i<WIDTH; i=i+1) begin integer from = WIDTH-i-1; if (i==0) begin // Test if's within a for mbuf m0 (.q(out[i]), .a(in[from])); end else begin mbuf ma (.q(out[i]), .a(in[from])); end end end else begin for (i=0; i<WIDTH; i=i+1) begin mbuf ma (.q(out[i]), .a(in[i^1])); end end endgenerate endmodule
module mbuf ( input a, output q ); assign q = a; endmodule
module enflop (clk, oe_e1, a,q); parameter WIDTH=1; input clk; input oe_e1; input [WIDTH-1:0] a; output [WIDTH-1:0] q; reg [WIDTH-1:0] oe_r; reg [WIDTH-1:0] q_r; genvar i; generate for (i = 0; i < WIDTH; i = i + 1) begin : datapath_bits enflop_one enflop_one (.clk (clk), .d (a[i]), .q_r (q_r[i])); always @(posedge clk) oe_r[i] <= oe_e1; assign q[i] = oe_r[i] ? q_r[i] : 1'bx; end endgenerate endmodule
module enflop_one ( input clk, input d, output reg q_r ); always @(posedge clk) q_r <= d; endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; logic use_AnB; logic [1:0] active_command [8:0]; logic [1:0] command_A [8:0]; logic [1:0] command_B [8:0]; logic [1:0] active_command2 [8:0]; logic [1:0] command_A2 [7:0]; logic [1:0] command_B2 [8:0]; logic [1:0] active_command3 [1:0][2:0][3:0]; logic [1:0] command_A3 [1:0][2:0][3:0]; logic [1:0] command_B3 [1:0][2:0][3:0]; logic [1:0] active_command4 [8:0]; logic [1:0] command_A4 [7:0]; logic [1:0] active_command5 [8:0]; logic [1:0] command_A5 [7:0]; // Single dimension assign assign active_command[3:0] = (use_AnB) ? command_A[7:0] : command_B[7:0]; // Assignment of entire arrays assign active_command2 = (use_AnB) ? command_A2 : command_B2; // Multi-dimension assign assign active_command3[1:0][2:0][3:0] = (use_AnB) ? command_A3[1:0][2:0][3:0] : command_B3[1:0][1:0][3:0]; // Supported: Delayed assigment with RHS Var == LHS Var logic [7:0] arrd [7:0]; always_ff @(posedge clk) arrd[7:4] <= arrd[3:0]; // Unsupported: Non-delayed assigment with RHS Var == LHS Var logic [7:0] arr [7:0]; assign arr[7:4] = arr[3:0]; // Delayed assign always @(posedge clk) begin active_command4[7:0] <= command_A4[8:0]; end // Combinational assign always_comb begin active_command5[8:0] = command_A5[7:0]; end endmodule
module outputs) wire [7:0] m_from_clk_lev1_r; // From a of t_order_a.v wire [7:0] n_from_clk_lev2; // From a of t_order_a.v wire [7:0] o_from_com_levs11; // From a of t_order_a.v wire [7:0] o_from_comandclk_levs12;// From a of t_order_a.v wire [7:0] o_subfrom_clk_lev2; // From b of t_order_b.v // End of automatics reg [7:0] cyc; initial cyc=0; t_order_a a ( .one (8'h1), /*AUTOINST*/ // Outputs .m_from_clk_lev1_r (m_from_clk_lev1_r[7:0]), .n_from_clk_lev2 (n_from_clk_lev2[7:0]), .o_from_com_levs11 (o_from_com_levs11[7:0]), .o_from_comandclk_levs12(o_from_comandclk_levs12[7:0]), // Inputs .clk (clk), .a_to_clk_levm3 (a_to_clk_levm3[7:0]), .b_to_clk_levm1 (b_to_clk_levm1[7:0]), .c_com_levs10 (c_com_levs10[7:0]), .d_to_clk_levm2 (d_to_clk_levm2[7:0])); t_order_b b ( /*AUTOINST*/ // Outputs .o_subfrom_clk_lev2 (o_subfrom_clk_lev2[7:0]), // Inputs .m_from_clk_lev1_r (m_from_clk_lev1_r[7:0])); reg [7:0] o_from_com_levs12; reg [7:0] o_from_com_levs13; always @ (/*AS*/o_from_com_levs11) begin o_from_com_levs12 = o_from_com_levs11 + 8'h1; o_from_com_levs12 = o_from_com_levs12 + 8'h1; // Test we can add to self and optimize o_from_com_levs13 = o_from_com_levs12; end reg sepassign_in; // verilator lint_off UNOPTFLAT wire [3:0] sepassign; // verilator lint_on UNOPTFLAT // verilator lint_off UNOPT assign #0.1 sepassign[0] = 0, sepassign[1] = sepassign[2], sepassign[2] = sepassign[3], sepassign[3] = sepassign_in; wire [7:0] o_subfrom_clk_lev3 = o_subfrom_clk_lev2; // verilator lint_on UNOPT always @ (posedge clk) begin cyc <= cyc+8'd1; sepassign_in <= 0; if (cyc == 8'd1) begin a_to_clk_levm3 <= 0; d_to_clk_levm2 <= 1; b_to_clk_levm1 <= 1; c_com_levs10 <= 2; sepassign_in <= 1; end if (cyc == 8'd2) begin if (sepassign !== 4'b1110) $stop; end if (cyc == 8'd3) begin $display("%d %d %d %d",m_from_clk_lev1_r, n_from_clk_lev2, o_from_com_levs11, o_from_comandclk_levs12); if (m_from_clk_lev1_r !== 8'h2) $stop; if (o_subfrom_clk_lev3 !== 8'h2) $stop; if (n_from_clk_lev2 !== 8'h2) $stop; if (o_from_com_levs11 !== 8'h3) $stop; if (o_from_com_levs13 !== 8'h5) $stop; if (o_from_comandclk_levs12 !== 8'h5) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module outputs) wire [7:0] m_from_clk_lev1_r; // From a of t_order_a.v wire [7:0] n_from_clk_lev2; // From a of t_order_a.v wire [7:0] o_from_com_levs11; // From a of t_order_a.v wire [7:0] o_from_comandclk_levs12;// From a of t_order_a.v wire [7:0] o_subfrom_clk_lev2; // From b of t_order_b.v // End of automatics reg [7:0] cyc; initial cyc=0; t_order_a a ( .one (8'h1), /*AUTOINST*/ // Outputs .m_from_clk_lev1_r (m_from_clk_lev1_r[7:0]), .n_from_clk_lev2 (n_from_clk_lev2[7:0]), .o_from_com_levs11 (o_from_com_levs11[7:0]), .o_from_comandclk_levs12(o_from_comandclk_levs12[7:0]), // Inputs .clk (clk), .a_to_clk_levm3 (a_to_clk_levm3[7:0]), .b_to_clk_levm1 (b_to_clk_levm1[7:0]), .c_com_levs10 (c_com_levs10[7:0]), .d_to_clk_levm2 (d_to_clk_levm2[7:0])); t_order_b b ( /*AUTOINST*/ // Outputs .o_subfrom_clk_lev2 (o_subfrom_clk_lev2[7:0]), // Inputs .m_from_clk_lev1_r (m_from_clk_lev1_r[7:0])); reg [7:0] o_from_com_levs12; reg [7:0] o_from_com_levs13; always @ (/*AS*/o_from_com_levs11) begin o_from_com_levs12 = o_from_com_levs11 + 8'h1; o_from_com_levs12 = o_from_com_levs12 + 8'h1; // Test we can add to self and optimize o_from_com_levs13 = o_from_com_levs12; end reg sepassign_in; // verilator lint_off UNOPTFLAT wire [3:0] sepassign; // verilator lint_on UNOPTFLAT // verilator lint_off UNOPT assign #0.1 sepassign[0] = 0, sepassign[1] = sepassign[2], sepassign[2] = sepassign[3], sepassign[3] = sepassign_in; wire [7:0] o_subfrom_clk_lev3 = o_subfrom_clk_lev2; // verilator lint_on UNOPT always @ (posedge clk) begin cyc <= cyc+8'd1; sepassign_in <= 0; if (cyc == 8'd1) begin a_to_clk_levm3 <= 0; d_to_clk_levm2 <= 1; b_to_clk_levm1 <= 1; c_com_levs10 <= 2; sepassign_in <= 1; end if (cyc == 8'd2) begin if (sepassign !== 4'b1110) $stop; end if (cyc == 8'd3) begin $display("%d %d %d %d",m_from_clk_lev1_r, n_from_clk_lev2, o_from_com_levs11, o_from_comandclk_levs12); if (m_from_clk_lev1_r !== 8'h2) $stop; if (o_subfrom_clk_lev3 !== 8'h2) $stop; if (n_from_clk_lev2 !== 8'h2) $stop; if (o_from_com_levs11 !== 8'h3) $stop; if (o_from_com_levs13 !== 8'h5) $stop; if (o_from_comandclk_levs12 !== 8'h5) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module ddr3_model ( rst_n, ck, ck_n, cke, cs_n, ras_n, cas_n, we_n, dm_tdqs, ba, addr, dq, dqs, dqs_n, tdqs_n, odt ); `include "ddr3_model_parameters.vh" parameter check_strict_mrbits = 1; parameter check_strict_timing = 1; parameter feature_pasr = 1; parameter feature_truebl4 = 0; // text macros `define DQ_PER_DQS DQ_BITS/DQS_BITS `define BANKS (1<<BA_BITS) `define MAX_BITS (BA_BITS+ROW_BITS+COL_BITS-BL_BITS) `define MAX_SIZE (1<<(BA_BITS+ROW_BITS+COL_BITS-BL_BITS)) `define MEM_SIZE (1<<MEM_BITS) `define MAX_PIPE 4*CL_MAX // Declare Ports input rst_n; input ck; input ck_n; input cke; input cs_n; input ras_n; input cas_n; input we_n; inout [DM_BITS-1:0] dm_tdqs; input [BA_BITS-1:0] ba; input [ADDR_BITS-1:0] addr; inout [DQ_BITS-1:0] dq; inout [DQS_BITS-1:0] dqs; inout [DQS_BITS-1:0] dqs_n; output [DQS_BITS-1:0] tdqs_n; input odt; // clock jitter real tck_avg; time tck_sample [TDLLK-1:0]; time tch_sample [TDLLK-1:0]; time tcl_sample [TDLLK-1:0]; time tck_i; time tch_i; time tcl_i; real tch_avg; real tcl_avg; time tm_ck_pos; time tm_ck_neg; real tjit_per_rtime; integer tjit_cc_time; real terr_nper_rtime; //DDR3 clock jitter variables real tjit_ch_rtime; real duty_cycle; // clock skew real out_delay; integer dqsck [DQS_BITS-1:0]; integer dqsck_min; integer dqsck_max; integer dqsq_min; integer dqsq_max; integer seed; // Mode Registers reg [ADDR_BITS-1:0] mode_reg [`BANKS-1:0]; reg burst_order; reg [BL_BITS:0] burst_length; reg blotf; reg truebl4; integer cas_latency; reg dll_reset; reg dll_locked; integer write_recovery; reg low_power; reg dll_en; reg [2:0] odt_rtt_nom; reg [1:0] odt_rtt_wr; reg odt_en; reg dyn_odt_en; reg [1:0] al; integer additive_latency; reg write_levelization; reg duty_cycle_corrector; reg tdqs_en; reg out_en; reg [2:0] pasr; integer cas_write_latency; reg asr; // auto self refresh reg srt; // self refresh temperature range reg [1:0] mpr_select; reg mpr_en; reg odts_readout; integer read_latency; integer write_latency; // cmd encoding parameter // {cs, ras, cas, we} LOAD_MODE = 4'b0000, REFRESH = 4'b0001, PRECHARGE = 4'b0010, ACTIVATE = 4'b0011, WRITE = 4'b0100, READ = 4'b0101, ZQ = 4'b0110, NOP = 4'b0111, // DESEL = 4'b1xxx, PWR_DOWN = 4'b1000, SELF_REF = 4'b1001 ; reg [8*9-1:0] cmd_string [9:0]; initial begin cmd_string[LOAD_MODE] = "Load Mode"; cmd_string[REFRESH ] = "Refresh "; cmd_string[PRECHARGE] = "Precharge"; cmd_string[ACTIVATE ] = "Activate "; cmd_string[WRITE ] = "Write "; cmd_string[READ ] = "Read "; cmd_string[ZQ ] = "ZQ "; cmd_string[NOP ] = "No Op "; cmd_string[PWR_DOWN ] = "Pwr Down "; cmd_string[SELF_REF ] = "Self Ref "; end // command state reg [`BANKS-1:0] active_bank; reg [`BANKS-1:0] auto_precharge_bank; reg [`BANKS-1:0] write_precharge_bank; reg [`BANKS-1:0] read_precharge_bank; reg [ROW_BITS-1:0] active_row [`BANKS-1:0]; reg in_power_down; reg in_self_refresh; reg [3:0] init_mode_reg; reg init_dll_reset; reg init_done; integer init_step; reg zq_set; reg er_trfc_max; reg odt_state; reg odt_state_dly; reg dyn_odt_state; reg dyn_odt_state_dly; reg prev_odt; wire [7:0] calibration_pattern = 8'b10101010; // value returned during mpr pre-defined pattern readout wire [7:0] temp_sensor = 8'h01; // value returned during mpr temp sensor readout reg [1:0] mr_chk; reg rd_bc; integer banki; // cmd timers/counters integer ref_cntr; integer odt_cntr; integer ck_cntr; integer ck_txpr; integer ck_load_mode; integer ck_refresh; integer ck_precharge; integer ck_activate; integer ck_write; integer ck_read; integer ck_zqinit; integer ck_zqoper; integer ck_zqcs; integer ck_power_down; integer ck_slow_exit_pd; integer ck_self_refresh; integer ck_freq_change; integer ck_odt; integer ck_odth8; integer ck_dll_reset; integer ck_cke_cmd; integer ck_bank_write [`BANKS-1:0]; integer ck_bank_read [`BANKS-1:0]; integer ck_group_activate [1:0]; integer ck_group_write [1:0]; integer ck_group_read [1:0]; time tm_txpr; time tm_load_mode; time tm_refresh; time tm_precharge; time tm_activate; time tm_write_end; time tm_power_down; time tm_slow_exit_pd; time tm_self_refresh; time tm_freq_change; time tm_cke_cmd; time tm_ttsinit; time tm_bank_precharge [`BANKS-1:0]; time tm_bank_activate [`BANKS-1:0]; time tm_bank_write_end [`BANKS-1:0]; time tm_bank_read_end [`BANKS-1:0]; time tm_group_activate [1:0]; time tm_group_write_end [1:0]; // pipelines reg [`MAX_PIPE:0] al_pipeline; reg [`MAX_PIPE:0] wr_pipeline; reg [`MAX_PIPE:0] rd_pipeline; reg [`MAX_PIPE:0] odt_pipeline; reg [`MAX_PIPE:0] dyn_odt_pipeline; reg [BL_BITS:0] bl_pipeline [`MAX_PIPE:0]; reg [BA_BITS-1:0] ba_pipeline [`MAX_PIPE:0]; reg [ROW_BITS-1:0] row_pipeline [`MAX_PIPE:0]; reg [COL_BITS-1:0] col_pipeline [`MAX_PIPE:0]; reg prev_cke; // data state reg [BL_MAX*DQ_BITS-1:0] memory_data; reg [BL_MAX*DQ_BITS-1:0] bit_mask; reg [BL_BITS-1:0] burst_position; reg [BL_BITS:0] burst_cntr; reg [DQ_BITS-1:0] dq_temp; reg [31:0] check_write_postamble; reg [31:0] check_write_preamble; reg [31:0] check_write_dqs_high; reg [31:0] check_write_dqs_low; reg [15:0] check_dm_tdipw; reg [63:0] check_dq_tdipw; // data timers/counters time tm_rst_n; time tm_cke; time tm_odt; time tm_tdqss; time tm_dm [15:0]; time tm_dqs [15:0]; time tm_dqs_pos [31:0]; time tm_dqss_pos [31:0]; time tm_dqs_neg [31:0]; time tm_dq [63:0]; time tm_cmd_addr [22:0]; reg [8*7-1:0] cmd_addr_string [22:0]; initial begin cmd_addr_string[ 0] = "CS_N "; cmd_addr_string[ 1] = "RAS_N "; cmd_addr_string[ 2] = "CAS_N "; cmd_addr_string[ 3] = "WE_N "; cmd_addr_string[ 4] = "BA 0 "; cmd_addr_string[ 5] = "BA 1 "; cmd_addr_string[ 6] = "BA 2 "; cmd_addr_string[ 7] = "ADDR 0"; cmd_addr_string[ 8] = "ADDR 1"; cmd_addr_string[ 9] = "ADDR 2"; cmd_addr_string[10] = "ADDR 3"; cmd_addr_string[11] = "ADDR 4"; cmd_addr_string[12] = "ADDR 5"; cmd_addr_string[13] = "ADDR 6"; cmd_addr_string[14] = "ADDR 7"; cmd_addr_string[15] = "ADDR 8"; cmd_addr_string[16] = "ADDR 9"; cmd_addr_string[17] = "ADDR 10"; cmd_addr_string[18] = "ADDR 11"; cmd_addr_string[19] = "ADDR 12"; cmd_addr_string[20] = "ADDR 13"; cmd_addr_string[21] = "ADDR 14"; cmd_addr_string[22] = "ADDR 15"; end reg [8*5-1:0] dqs_string [1:0]; initial begin dqs_string[0] = "DQS "; dqs_string[1] = "DQS_N"; end // Memory Storage `ifdef MAX_MEM parameter RFF_BITS = DQ_BITS*BL_MAX; // %z format uses 8 bytes for every 32 bits or less. parameter RFF_CHUNK = 8 * (RFF_BITS/32 + (RFF_BITS%32 ? 1 : 0)); reg [1024:1] tmp_model_dir; integer memfd[`BANKS-1:0]; initial begin : file_io_open integer bank; if (!$value$plusargs("model_data+%s", tmp_model_dir)) begin tmp_model_dir = "/tmp"; $display( "%m: at time %t WARNING: no +model_data option specified, using /tmp.", $time ); end for (bank = 0; bank < `BANKS; bank = bank + 1) memfd[bank] = open_bank_file(bank); end `else reg [BL_MAX*DQ_BITS-1:0] memory [0:`MEM_SIZE-1]; reg [`MAX_BITS-1:0] address [0:`MEM_SIZE-1]; reg [MEM_BITS:0] memory_index; reg [MEM_BITS:0] memory_used = 0; `endif // receive reg rst_n_in; reg ck_in; reg ck_n_in; reg cke_in; reg cs_n_in; reg ras_n_in; reg cas_n_in; reg we_n_in; reg [15:0] dm_in; reg [2:0] ba_in; reg [15:0] addr_in; reg [63:0] dq_in; reg [31:0] dqs_in; reg odt_in; reg [15:0] dm_in_pos; reg [15:0] dm_in_neg; reg [63:0] dq_in_pos; reg [63:0] dq_in_neg; reg dq_in_valid; reg dqs_in_valid; integer wdqs_cntr; integer wdq_cntr; integer wdqs_pos_cntr [31:0]; reg b2b_write; reg [BL_BITS:0] wr_burst_length; reg [31:0] prev_dqs_in; reg diff_ck; always @(rst_n ) rst_n_in <= #BUS_DELAY rst_n; always @(ck ) ck_in <= #BUS_DELAY ck; always @(ck_n ) ck_n_in <= #BUS_DELAY ck_n; always @(cke ) cke_in <= #BUS_DELAY cke; always @(cs_n ) cs_n_in <= #BUS_DELAY cs_n; always @(ras_n ) ras_n_in <= #BUS_DELAY ras_n; always @(cas_n ) cas_n_in <= #BUS_DELAY cas_n; always @(we_n ) we_n_in <= #BUS_DELAY we_n; always @(dm_tdqs) dm_in <= #BUS_DELAY dm_tdqs; always @(ba ) ba_in <= #BUS_DELAY ba; always @(addr ) addr_in <= #BUS_DELAY addr; always @(dq ) dq_in <= #BUS_DELAY dq; always @(dqs or dqs_n) dqs_in <= #BUS_DELAY (dqs_n<<16) | dqs; always @(odt ) odt_in <= #BUS_DELAY odt; // create internal clock always @(posedge ck_in) diff_ck <= ck_in; always @(posedge ck_n_in) diff_ck <= ~ck_n_in; wire [15:0] dqs_even = dqs_in[15:0]; wire [15:0] dqs_odd = dqs_in[31:16]; wire [3:0] cmd_n_in = !cs_n_in ? {ras_n_in, cas_n_in, we_n_in} : NOP; //deselect = nop // transmit reg dqs_out_en; reg [DQS_BITS-1:0] dqs_out_en_dly; reg dqs_out; reg [DQS_BITS-1:0] dqs_out_dly; reg dq_out_en; reg [DQ_BITS-1:0] dq_out_en_dly; reg [DQ_BITS-1:0] dq_out; reg [DQ_BITS-1:0] dq_out_dly; integer rdqsen_cntr; integer rdqs_cntr; integer rdqen_cntr; integer rdq_cntr; bufif1 buf_dqs [DQS_BITS-1:0] (dqs, dqs_out_dly, dqs_out_en_dly & {DQS_BITS{out_en}}); bufif1 buf_dqs_n [DQS_BITS-1:0] (dqs_n, ~dqs_out_dly, dqs_out_en_dly & {DQS_BITS{out_en}}); bufif1 buf_dq [DQ_BITS-1:0] (dq, dq_out_dly, dq_out_en_dly & {DQ_BITS {out_en}}); assign tdqs_n = {DQS_BITS{1'bz}}; initial begin if (BL_MAX < 2) $display("%m ERROR: BL_MAX parameter must be >= 2. \nBL_MAX = %d", BL_MAX); if ((1<<BO_BITS) > BL_MAX) $display("%m ERROR: 2^BO_BITS cannot be greater than BL_MAX parameter."); $timeformat (-12, 1, " ps", 1); seed = RANDOM_SEED; ck_cntr = 0; end function integer get_rtt_wr; input [1:0] rtt; begin get_rtt_wr = RZQ/{rtt[0], rtt[1], 1'b0}; end endfunction function integer get_rtt_nom; input [2:0] rtt; begin case (rtt) 1: get_rtt_nom = RZQ/4; 2: get_rtt_nom = RZQ/2; 3: get_rtt_nom = RZQ/6; 4: get_rtt_nom = RZQ/12; 5: get_rtt_nom = RZQ/8; default : get_rtt_nom = 0; endcase end endfunction // calculate the absolute value of a real number function real abs_value; input arg; real arg; begin if (arg < 0.0) abs_value = -1.0 * arg; else abs_value = arg; end endfunction function integer ceil; input number; real number; // LMR 4.1.7 // When either operand of a relational expression is a real operand then the other operand shall be converted // to an equivalent real value, and the expression shall be interpreted as a comparison between two real values. if (number > $rtoi(number)) ceil = $rtoi(number) + 1; else ceil = number; endfunction function integer floor; input number; real number; // LMR 4.1.7 // When either operand of a relational expression is a real operand then the other operand shall be converted // to an equivalent real value, and the expression shall be interpreted as a comparison between two real values. if (number < $rtoi(number)) floor = $rtoi(number) - 1; else floor = number; endfunction `ifdef MAX_MEM function integer open_bank_file( input integer bank ); integer fd; reg [2048:1] filename; begin $sformat( filename, "%0s/%m.%0d", tmp_model_dir, bank ); fd = $fopen(filename, "w+"); if (fd == 0) begin $display("%m: at time %0t ERROR: failed to open %0s.", $time, filename); $finish; end else begin if (DEBUG) $display("%m: at time %0t INFO: opening %0s.", $time, filename); open_bank_file = fd; end end endfunction function [RFF_BITS:1] read_from_file( input integer fd, input integer index ); integer code; integer offset; reg [1024:1] msg; reg [RFF_BITS:1] read_value; begin offset = index * RFF_CHUNK; code = $fseek( fd, offset, 0 ); // $fseek returns 0 on success, -1 on failure if (code != 0) begin $display("%m: at time %t ERROR: fseek to %d failed", $time, offset); $finish; end code = $fscanf(fd, "%z", read_value); // $fscanf returns number of items read if (code != 1) begin if ($ferror(fd,msg) != 0) begin $display("%m: at time %t ERROR: fscanf failed at %d", $time, index); $display(msg); $finish; end else read_value = 'hx; end /* when reading from unwritten portions of the file, 0 will be returned. * Use 0 in bit 1 as indicator that invalid data has been read. * A true 0 is encoded as Z. */ if (read_value[1] === 1'bz) // true 0 encoded as Z, data is valid read_value[1] = 1'b0; else if (read_value[1] === 1'b0) // read from file section that has not been written read_value = 'hx; read_from_file = read_value; end endfunction task write_to_file( input integer fd, input integer index, input [RFF_BITS:1] data ); integer code; integer offset; begin offset = index * RFF_CHUNK; code = $fseek( fd, offset, 0 ); if (code != 0) begin $display("%m: at time %t ERROR: fseek to %d failed", $time, offset); $finish; end // encode a valid data if (data[1] === 1'bz) data[1] = 1'bx; else if (data[1] === 1'b0) data[1] = 1'bz; $fwrite( fd, "%z", data ); end endtask `else function get_index; input [`MAX_BITS-1:0] addr; begin : index get_index = 0; for (memory_index=0; memory_index<memory_used; memory_index=memory_index+1) begin if (address[memory_index] == addr) begin get_index = 1; disable index; end end end endfunction `endif task memory_write; input [BA_BITS-1:0] bank; input [ROW_BITS-1:0] row; input [COL_BITS-1:0] col; input [BL_MAX*DQ_BITS-1:0] data; reg [`MAX_BITS-1:0] addr; begin `ifdef MAX_MEM addr = {row, col}/BL_MAX; write_to_file( memfd[bank], addr, data ); `else // chop off the lowest address bits addr = {bank, row, col}/BL_MAX; if (get_index(addr)) begin address[memory_index] = addr; memory[memory_index] = data; end else if (memory_used == `MEM_SIZE) begin $display ("%m: at time %t ERROR: Memory overflow. Write to Address %h with Data %h will be lost.\nYou must increase the MEM_BITS parameter or define MAX_MEM.", $time, addr, data); if (STOP_ON_ERROR) $stop(0); end else begin address[memory_used] = addr; memory[memory_used] = data; memory_used = memory_used + 1; end `endif end endtask task memory_read; input [BA_BITS-1:0] bank; input [ROW_BITS-1:0] row; input [COL_BITS-1:0] col; output [BL_MAX*DQ_BITS-1:0] data; reg [`MAX_BITS-1:0] addr; begin `ifdef MAX_MEM addr = {row, col}/BL_MAX; data = read_from_file( memfd[bank], addr ); `else // chop off the lowest address bits addr = {bank, row, col}/BL_MAX; if (get_index(addr)) begin data = memory[memory_index]; end else begin data = {BL_MAX*DQ_BITS{1'bx}}; end `endif end endtask task set_latency; begin if (al == 0) begin additive_latency = 0; end else begin additive_latency = cas_latency - al; end read_latency = cas_latency + additive_latency; write_latency = cas_write_latency + additive_latency; end endtask // this task will erase the contents of 0 or more banks task erase_banks; input [`BANKS-1:0] banks; //one select bit per bank reg [BA_BITS-1:0] ba; reg [`MAX_BITS-1:0] i; integer bank; begin `ifdef MAX_MEM for (bank = 0; bank < `BANKS; bank = bank + 1) if (banks[bank] === 1'b1) begin $fclose(memfd[bank]); memfd[bank] = open_bank_file(bank); end `else memory_index = 0; i = 0; // remove the selected banks for (memory_index=0; memory_index<memory_used; memory_index=memory_index+1) begin ba = (address[memory_index]>>(ROW_BITS+COL_BITS-BL_BITS)); if (!banks[ba]) begin //bank is selected to keep address[i] = address[memory_index]; memory[i] = memory[memory_index]; i = i + 1; end end // clean up the unused banks for (memory_index=i; memory_index<memory_used; memory_index=memory_index+1) begin address[memory_index] = 'bx; memory[memory_index] = {8*DQ_BITS{1'bx}}; end memory_used = i; `endif end endtask // Before this task runs, the model must be in a valid state for precharge power down and out of reset. // After this task runs, NOP commands must be issued until TZQINIT has been met task initialize; input [ADDR_BITS-1:0] mode_reg0; input [ADDR_BITS-1:0] mode_reg1; input [ADDR_BITS-1:0] mode_reg2; input [ADDR_BITS-1:0] mode_reg3; begin if (DEBUG) $display ("%m: at time %t INFO: Performing Initialization Sequence", $time); cmd_task(1, NOP, 'bx, 'bx); cmd_task(1, ZQ, 'bx, 'h400); //ZQCL cmd_task(1, LOAD_MODE, 3, mode_reg3); cmd_task(1, LOAD_MODE, 2, mode_reg2); cmd_task(1, LOAD_MODE, 1, mode_reg1); cmd_task(1, LOAD_MODE, 0, mode_reg0 | 'h100); // DLL Reset cmd_task(0, NOP, 'bx, 'bx); end endtask task reset_task; integer i; begin // disable inputs dq_in_valid = 0; dqs_in_valid <= 0; wdqs_cntr = 0; wdq_cntr = 0; for (i=0; i<31; i=i+1) begin wdqs_pos_cntr[i] <= 0; end b2b_write <= 0; // disable outputs out_en = 0; dq_out_en = 0; rdq_cntr = 0; dqs_out_en = 0; rdqs_cntr = 0; // disable ODT odt_en = 0; dyn_odt_en = 0; odt_state = 0; dyn_odt_state = 0; // reset bank state active_bank = 0; auto_precharge_bank = 0; read_precharge_bank = 0; write_precharge_bank = 0; // require initialization sequence init_done = 0; mpr_en = 0; init_step = 0; init_mode_reg = 0; init_dll_reset = 0; zq_set = 0; // reset DLL dll_en = 0; dll_reset = 0; dll_locked = 0; // exit power down and self refresh prev_cke = 1'bx; in_power_down = 0; in_self_refresh = 0; // clear pipelines al_pipeline = 0; wr_pipeline = 0; rd_pipeline = 0; odt_pipeline = 0; dyn_odt_pipeline = 0; end endtask parameter SAME_BANK = 2'd0; // same bank, same group parameter DIFF_BANK = 2'd1; // different bank, same group parameter DIFF_GROUP = 2'd2; // different bank, different group task chk_err; input [1:0] relationship; input [BA_BITS-1:0] bank; input [3:0] fromcmd; input [3:0] cmd; reg err; begin // $display ("truebl4 = %d, relationship = %d, fromcmd = %h, cmd = %h", truebl4, relationship, fromcmd, cmd); casex ({truebl4, relationship, fromcmd, cmd}) // load mode {1'bx, DIFF_BANK , LOAD_MODE, LOAD_MODE} : begin if (ck_cntr - ck_load_mode < TMRD) $display ("%m: at time %t ERROR: tMRD violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , LOAD_MODE, READ } : begin if (($time - tm_load_mode < TMOD) || (ck_cntr - ck_load_mode < TMOD_TCK)) $display ("%m: at time %t ERROR: tMOD violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , LOAD_MODE, REFRESH } , {1'bx, DIFF_BANK , LOAD_MODE, PRECHARGE} , {1'bx, DIFF_BANK , LOAD_MODE, ACTIVATE } , {1'bx, DIFF_BANK , LOAD_MODE, ZQ } , {1'bx, DIFF_BANK , LOAD_MODE, PWR_DOWN } , {1'bx, DIFF_BANK , LOAD_MODE, SELF_REF } : begin if (($time - tm_load_mode < TMOD) || (ck_cntr - ck_load_mode < TMOD_TCK)) $display ("%m: at time %t ERROR: tMOD violation during %s", $time, cmd_string[cmd]); end // refresh {1'bx, DIFF_BANK , REFRESH , LOAD_MODE} , {1'bx, DIFF_BANK , REFRESH , REFRESH } , {1'bx, DIFF_BANK , REFRESH , PRECHARGE} , {1'bx, DIFF_BANK , REFRESH , ACTIVATE } , {1'bx, DIFF_BANK , REFRESH , ZQ } , {1'bx, DIFF_BANK , REFRESH , SELF_REF } : begin if ($time - tm_refresh < TRFC_MIN) $display ("%m: at time %t ERROR: tRFC violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , REFRESH , PWR_DOWN } : begin if (ck_cntr - ck_refresh < TREFPDEN) $display ("%m: at time %t ERROR: tREFPDEN violation during %s", $time, cmd_string[cmd]); end // precharge {1'bx, SAME_BANK , PRECHARGE, ACTIVATE } : begin if ($time - tm_bank_precharge[bank] < TRP) $display ("%m: at time %t ERROR: tRP violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'bx, DIFF_BANK , PRECHARGE, LOAD_MODE} , {1'bx, DIFF_BANK , PRECHARGE, REFRESH } , {1'bx, DIFF_BANK , PRECHARGE, ZQ } , {1'bx, DIFF_BANK , PRECHARGE, SELF_REF } : begin if ($time - tm_precharge < TRP) $display ("%m: at time %t ERROR: tRP violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , PRECHARGE, PWR_DOWN } : ; //tPREPDEN = 1 tCK, can be concurrent with auto precharge // activate {1'bx, SAME_BANK , ACTIVATE , PRECHARGE} : begin if ($time - tm_bank_activate[bank] > TRAS_MAX) $display ("%m: at time %t ERROR: tRAS maximum violation during %s to bank %d", $time, cmd_string[cmd], bank); if ($time - tm_bank_activate[bank] < TRAS_MIN) $display ("%m: at time %t ERROR: tRAS minimum violation during %s to bank %d", $time, cmd_string[cmd], bank);end {1'bx, SAME_BANK , ACTIVATE , ACTIVATE } : begin if ($time - tm_bank_activate[bank] < TRC) $display ("%m: at time %t ERROR: tRC violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'bx, SAME_BANK , ACTIVATE , WRITE } , {1'bx, SAME_BANK , ACTIVATE , READ } : ; // tRCD is checked outside this task {1'b0, DIFF_BANK , ACTIVATE , ACTIVATE } : begin if (($time - tm_activate < TRRD) || (ck_cntr - ck_activate < TRRD_TCK)) $display ("%m: at time %t ERROR: tRRD violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_BANK , ACTIVATE , ACTIVATE } : begin if (($time - tm_group_activate[bank[1]] < TRRD) || (ck_cntr - ck_group_activate[bank[1]] < TRRD_TCK)) $display ("%m: at time %t ERROR: tRRD violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_GROUP, ACTIVATE , ACTIVATE } : begin if (($time - tm_activate < TRRD_DG) || (ck_cntr - ck_activate < TRRD_DG_TCK)) $display ("%m: at time %t ERROR: tRRD_DG violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'bx, DIFF_BANK , ACTIVATE , REFRESH } : begin if ($time - tm_activate < TRC) $display ("%m: at time %t ERROR: tRC violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , ACTIVATE , PWR_DOWN } : begin if (ck_cntr - ck_activate < TACTPDEN) $display ("%m: at time %t ERROR: tACTPDEN violation during %s", $time, cmd_string[cmd]); end // write {1'bx, SAME_BANK , WRITE , PRECHARGE} : begin if (($time - tm_bank_write_end[bank] < TWR) || (ck_cntr - ck_bank_write[bank] <= write_latency + burst_length/2)) $display ("%m: at time %t ERROR: tWR violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b0, DIFF_BANK , WRITE , WRITE } : begin if (ck_cntr - ck_write < TCCD) $display ("%m: at time %t ERROR: tCCD violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_BANK , WRITE , WRITE } : begin if (ck_cntr - ck_group_write[bank[1]] < TCCD) $display ("%m: at time %t ERROR: tCCD violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b0, DIFF_BANK , WRITE , READ } : begin if (ck_cntr - ck_write < write_latency + burst_length/2 + TWTR_TCK - additive_latency) $display ("%m: at time %t ERROR: tWTR violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_BANK , WRITE , READ } : begin if (ck_cntr - ck_group_write[bank[1]] < write_latency + burst_length/2 + TWTR_TCK - additive_latency) $display ("%m: at time %t ERROR: tWTR violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_GROUP, WRITE , WRITE } : begin if (ck_cntr - ck_write < TCCD_DG) $display ("%m: at time %t ERROR: tCCD_DG violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_GROUP, WRITE , READ } : begin if (ck_cntr - ck_write < write_latency + burst_length/2 + TWTR_DG_TCK - additive_latency) $display ("%m: at time %t ERROR: tWTR_DG violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'bx, DIFF_BANK , WRITE , PWR_DOWN } : begin if (($time - tm_write_end < TWR) || (ck_cntr - ck_write < write_latency + burst_length/2)) $display ("%m: at time %t ERROR: tWRPDEN violation during %s", $time, cmd_string[cmd]); end // read {1'bx, SAME_BANK , READ , PRECHARGE} : begin if (($time - tm_bank_read_end[bank] < TRTP) || (ck_cntr - ck_bank_read[bank] < additive_latency + TRTP_TCK)) $display ("%m: at time %t ERROR: tRTP violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b0, DIFF_BANK , READ , WRITE } : ; // tRTW is checked outside this task {1'b1, DIFF_BANK , READ , WRITE } : ; // tRTW is checked outside this task {1'b0, DIFF_BANK , READ , READ } : begin if (ck_cntr - ck_read < TCCD) $display ("%m: at time %t ERROR: tCCD violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_BANK , READ , READ } : begin if (ck_cntr - ck_group_read[bank[1]] < TCCD) $display ("%m: at time %t ERROR: tCCD violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'b1, DIFF_GROUP, READ , WRITE } : ; // tRTW is checked outside this task {1'b1, DIFF_GROUP, READ , READ } : begin if (ck_cntr - ck_read < TCCD_DG) $display ("%m: at time %t ERROR: tCCD_DG violation during %s to bank %d", $time, cmd_string[cmd], bank); end {1'bx, DIFF_BANK , READ , PWR_DOWN } : begin if (ck_cntr - ck_read < read_latency + 5) $display ("%m: at time %t ERROR: tRDPDEN violation during %s", $time, cmd_string[cmd]); end // zq {1'bx, DIFF_BANK , ZQ , LOAD_MODE} : ; // 1 tCK {1'bx, DIFF_BANK , ZQ , REFRESH } , {1'bx, DIFF_BANK , ZQ , PRECHARGE} , {1'bx, DIFF_BANK , ZQ , ACTIVATE } , {1'bx, DIFF_BANK , ZQ , ZQ } , {1'bx, DIFF_BANK , ZQ , PWR_DOWN } , {1'bx, DIFF_BANK , ZQ , SELF_REF } : begin if (ck_cntr - ck_zqinit < TZQINIT) $display ("%m: at time %t ERROR: tZQinit violation during %s", $time, cmd_string[cmd]); if (ck_cntr - ck_zqoper < TZQOPER) $display ("%m: at time %t ERROR: tZQoper violation during %s", $time, cmd_string[cmd]); if (ck_cntr - ck_zqcs < TZQCS) $display ("%m: at time %t ERROR: tZQCS violation during %s", $time, cmd_string[cmd]); end // power down {1'bx, DIFF_BANK , PWR_DOWN , LOAD_MODE} , {1'bx, DIFF_BANK , PWR_DOWN , REFRESH } , {1'bx, DIFF_BANK , PWR_DOWN , PRECHARGE} , {1'bx, DIFF_BANK , PWR_DOWN , ACTIVATE } , {1'bx, DIFF_BANK , PWR_DOWN , WRITE } , {1'bx, DIFF_BANK , PWR_DOWN , ZQ } : begin if (($time - tm_power_down < TXP) || (ck_cntr - ck_power_down < TXP_TCK)) $display ("%m: at time %t ERROR: tXP violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , PWR_DOWN , READ } : begin if (($time - tm_power_down < TXP) || (ck_cntr - ck_power_down < TXP_TCK)) $display ("%m: at time %t ERROR: tXP violation during %s", $time, cmd_string[cmd]); else if (($time - tm_slow_exit_pd < TXPDLL) || (ck_cntr - ck_slow_exit_pd < TXPDLL_TCK)) $display ("%m: at time %t ERROR: tXPDLL violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , PWR_DOWN , PWR_DOWN } , {1'bx, DIFF_BANK , PWR_DOWN , SELF_REF } : begin if (($time - tm_power_down < TXP) || (ck_cntr - ck_power_down < TXP_TCK)) $display ("%m: at time %t ERROR: tXP violation during %s", $time, cmd_string[cmd]); if ((tm_power_down > tm_refresh) && ($time - tm_refresh < TRFC_MIN)) $display ("%m: at time %t ERROR: tRFC violation during %s", $time, cmd_string[cmd]); if ((tm_refresh > tm_power_down) && (($time - tm_power_down < TXPDLL) || (ck_cntr - ck_power_down < TXPDLL_TCK))) $display ("%m: at time %t ERROR: tXPDLL violation during %s", $time, cmd_string[cmd]); if (($time - tm_cke_cmd < TCKE) || (ck_cntr - ck_cke_cmd < TCKE_TCK)) $display ("%m: at time %t ERROR: tCKE violation on CKE", $time); end // self refresh {1'bx, DIFF_BANK , SELF_REF , LOAD_MODE} , {1'bx, DIFF_BANK , SELF_REF , REFRESH } , {1'bx, DIFF_BANK , SELF_REF , PRECHARGE} , {1'bx, DIFF_BANK , SELF_REF , ACTIVATE } , {1'bx, DIFF_BANK , SELF_REF , WRITE } , {1'bx, DIFF_BANK , SELF_REF , ZQ } : begin if (($time - tm_self_refresh < TXS) || (ck_cntr - ck_self_refresh < TXS_TCK)) $display ("%m: at time %t ERROR: tXS violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , SELF_REF , READ } : begin if (ck_cntr - ck_self_refresh < TXSDLL) $display ("%m: at time %t ERROR: tXSDLL violation during %s", $time, cmd_string[cmd]); end {1'bx, DIFF_BANK , SELF_REF , PWR_DOWN } , {1'bx, DIFF_BANK , SELF_REF , SELF_REF } : begin if (($time - tm_self_refresh < TXS) || (ck_cntr - ck_self_refresh < TXS_TCK)) $display ("%m: at time %t ERROR: tXS violation during %s", $time, cmd_string[cmd]); if (($time - tm_cke_cmd < TCKE) || (ck_cntr - ck_cke_cmd < TCKE_TCK)) $display ("%m: at time %t ERROR: tCKE violation on CKE", $time); end endcase end endtask task cmd_task; input cke; input [2:0] cmd; input [BA_BITS-1:0] bank; input [ADDR_BITS-1:0] addr; reg [`BANKS:0] i; integer j; reg [`BANKS:0] tfaw_cntr; reg [COL_BITS-1:0] col; reg group; begin // tRFC max check if (!er_trfc_max && !in_self_refresh) begin if ($time - tm_refresh > TRFC_MAX && check_strict_timing) begin $display ("%m: at time %t ERROR: tRFC maximum violation during %s", $time, cmd_string[cmd]); er_trfc_max = 1; end end if (cke) begin if ((cmd < NOP) && (cmd != PRECHARGE)) begin if (($time - tm_txpr < TXPR) || (ck_cntr - ck_txpr < TXPR_TCK)) $display ("%m: at time %t ERROR: tXPR violation during %s", $time, cmd_string[cmd]); for (j=0; j<=SELF_REF; j=j+1) begin chk_err(SAME_BANK , bank, j, cmd); chk_err(DIFF_BANK , bank, j, cmd); chk_err(DIFF_GROUP, bank, j, cmd); end end case (cmd) LOAD_MODE : begin if (|odt_pipeline) $display ("%m: at time %t ERROR: ODTL violation during %s", $time, cmd_string[cmd]); if (odt_state) $display ("%m: at time %t ERROR: ODT must be off prior to %s", $time, cmd_string[cmd]); if (|active_bank) begin $display ("%m: at time %t ERROR: %s Failure. All banks must be Precharged.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) $display ("%m: at time %t INFO: %s %d", $time, cmd_string[cmd], bank); if (bank>>2) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved bank bits must be programmed to zero", $time, cmd_string[cmd], bank); end case (bank) 0 : begin // Burst Length if (addr[1:0] == 2'b00) begin burst_length = 8; blotf = 0; truebl4 = 0; if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Length = %d", $time, cmd_string[cmd], bank, burst_length); end else if (addr[1:0] == 2'b01) begin burst_length = 8; blotf = 1; truebl4 = 0; if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Length = Select via A12", $time, cmd_string[cmd], bank); end else if (addr[1:0] == 2'b10) begin burst_length = 4; blotf = 0; truebl4 = 0; if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Length = Fixed %d (chop)", $time, cmd_string[cmd], bank, burst_length); end else if (feature_truebl4 && (addr[1:0] == 2'b11)) begin burst_length = 4; blotf = 0; truebl4 = 1; if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Length = True %d", $time, cmd_string[cmd], bank, burst_length); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Burst Length = %d", $time, cmd_string[cmd], bank, addr[1:0]); end // Burst Order burst_order = addr[3]; if (!burst_order) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Order = Sequential", $time, cmd_string[cmd], bank); end else if (burst_order) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Burst Order = Interleaved", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Burst Order = %d", $time, cmd_string[cmd], bank, burst_order); end // CAS Latency cas_latency = {addr[2],addr[6:4]} + 4; set_latency; if ((cas_latency >= CL_MIN) && (cas_latency <= CL_MAX)) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d CAS Latency = %d", $time, cmd_string[cmd], bank, cas_latency); end else begin $display ("%m: at time %t ERROR: %s %d Illegal CAS Latency = %d", $time, cmd_string[cmd], bank, cas_latency); end // Reserved if (addr[7] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end // DLL Reset dll_reset = addr[8]; if (!dll_reset) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Reset = Normal", $time, cmd_string[cmd], bank); end else if (dll_reset) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Reset = Reset DLL", $time, cmd_string[cmd], bank); dll_locked = 0; init_dll_reset = 1; ck_dll_reset <= ck_cntr; end else begin $display ("%m: at time %t ERROR: %s %d Illegal DLL Reset = %d", $time, cmd_string[cmd], bank, dll_reset); end // Write Recovery if (addr[11:9] == 0) begin write_recovery = 16; end else if (addr[11:9] < 4) begin write_recovery = addr[11:9] + 4; end else begin write_recovery = 2*addr[11:9]; end if ((write_recovery >= WR_MIN) && (write_recovery <= WR_MAX)) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Write Recovery = %d", $time, cmd_string[cmd], bank, write_recovery); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Write Recovery = %d", $time, cmd_string[cmd], bank, write_recovery); end // Power Down Mode low_power = !addr[12]; if (!low_power) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Power Down Mode = DLL on", $time, cmd_string[cmd], bank); end else if (low_power) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Power Down Mode = DLL off", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Power Down Mode = %d", $time, cmd_string[cmd], bank, low_power); end // Reserved if (ADDR_BITS>13 && addr[13] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end end 1 : begin // DLL Enable dll_en = !addr[0]; if (!dll_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Enable = Disabled", $time, cmd_string[cmd], bank); if (check_strict_mrbits) $display ("%m: at time %t WARNING: %s %d DLL off mode is not modeled", $time, cmd_string[cmd], bank); end else if (dll_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d DLL Enable = Enabled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal DLL Enable = %d", $time, cmd_string[cmd], bank, dll_en); end // Output Drive Strength if ({addr[5], addr[1]} == 2'b00) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Drive Strength = %d Ohm", $time, cmd_string[cmd], bank, RZQ/6); end else if ({addr[5], addr[1]} == 2'b01) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Drive Strength = %d Ohm", $time, cmd_string[cmd], bank, RZQ/7); end else if ({addr[5], addr[1]} == 2'b11) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Output Drive Strength = %d Ohm", $time, cmd_string[cmd], bank, RZQ/5); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Output Drive Strength = %d", $time, cmd_string[cmd], bank, {addr[5], addr[1]}); end // ODT Rtt (Rtt_NOM) odt_rtt_nom = {addr[9], addr[6], addr[2]}; if (odt_rtt_nom == 3'b000) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d ODT Rtt = Disabled", $time, cmd_string[cmd], bank); odt_en = 0; end else if ((odt_rtt_nom < 4) || ((!addr[7] || (addr[7] && addr[12])) && (odt_rtt_nom < 6))) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d ODT Rtt = %d Ohm", $time, cmd_string[cmd], bank, get_rtt_nom(odt_rtt_nom)); odt_en = 1; end else begin $display ("%m: at time %t ERROR: %s %d Illegal ODT Rtt = %d", $time, cmd_string[cmd], bank, odt_rtt_nom); odt_en = 0; end // Report the additive latency value al = addr[4:3]; set_latency; if (al == 0) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Additive Latency = %d", $time, cmd_string[cmd], bank, al); end else if ((al >= AL_MIN) && (al <= AL_MAX)) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Additive Latency = CL - %d", $time, cmd_string[cmd], bank, al); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Additive Latency = %d", $time, cmd_string[cmd], bank, al); end // Write Levelization write_levelization = addr[7]; if (!write_levelization) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Write Levelization = Disabled", $time, cmd_string[cmd], bank); end else if (write_levelization) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Write Levelization = Enabled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Write Levelization = %d", $time, cmd_string[cmd], bank, write_levelization); end // Reserved if (addr[8] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end // Reserved if (addr[10] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end // TDQS Enable tdqs_en = addr[11]; if (!tdqs_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d TDQS Enable = Disabled", $time, cmd_string[cmd], bank); end else if (tdqs_en) begin if (8 == DQ_BITS) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d TDQS Enable = Enabled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t WARNING: %s %d Illegal TDQS Enable. TDQS only exists on a x8 part", $time, cmd_string[cmd], bank); tdqs_en = 0; end end else begin $display ("%m: at time %t ERROR: %s %d Illegal TDQS Enable = %d", $time, cmd_string[cmd], bank, tdqs_en); end // Output Enable out_en = !addr[12]; if (!out_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Qoff = Disabled", $time, cmd_string[cmd], bank); end else if (out_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Qoff = Enabled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Qoff = %d", $time, cmd_string[cmd], bank, out_en); end // Reserved if (ADDR_BITS>13 && addr[13] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end end 2 : begin if (feature_pasr) begin // Partial Array Self Refresh pasr = addr[2:0]; case (pasr) 3'b000 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 0-7", $time, cmd_string[cmd], bank); 3'b001 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 0-3", $time, cmd_string[cmd], bank); 3'b010 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 0-1", $time, cmd_string[cmd], bank); 3'b011 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 0", $time, cmd_string[cmd], bank); 3'b100 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 2-7", $time, cmd_string[cmd], bank); 3'b101 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 4-7", $time, cmd_string[cmd], bank); 3'b110 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 6-7", $time, cmd_string[cmd], bank); 3'b111 : if (DEBUG) $display ("%m: at time %t INFO: %s %d Partial Array Self Refresh = Bank 7", $time, cmd_string[cmd], bank); default : $display ("%m: at time %t ERROR: %s %d Illegal Partial Array Self Refresh = %d", $time, cmd_string[cmd], bank, pasr); endcase end else if (addr[2:0] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end // CAS Write Latency cas_write_latency = addr[5:3]+5; set_latency; if ((cas_write_latency >= CWL_MIN) && (cas_write_latency <= CWL_MAX)) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d CAS Write Latency = %d", $time, cmd_string[cmd], bank, cas_write_latency); end else begin $display ("%m: at time %t ERROR: %s %d Illegal CAS Write Latency = %d", $time, cmd_string[cmd], bank, cas_write_latency); end // Auto Self Refresh Method asr = addr[6]; if (!asr) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Auto Self Refresh = Disabled", $time, cmd_string[cmd], bank); end else if (asr) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Auto Self Refresh = Enabled", $time, cmd_string[cmd], bank); if (check_strict_mrbits) $display ("%m: at time %t WARNING: %s %d Auto Self Refresh is not modeled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Auto Self Refresh = %d", $time, cmd_string[cmd], bank, asr); end // Self Refresh Temperature srt = addr[7]; if (!srt) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Self Refresh Temperature = Normal", $time, cmd_string[cmd], bank); end else if (srt) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Self Refresh Temperature = Extended", $time, cmd_string[cmd], bank); if (check_strict_mrbits) $display ("%m: at time %t WARNING: %s %d Self Refresh Temperature is not modeled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal Self Refresh Temperature = %d", $time, cmd_string[cmd], bank, srt); end if (asr && srt) $display ("%m: at time %t ERROR: %s %d SRT must be set to 0 when ASR is enabled.", $time, cmd_string[cmd], bank); // Reserved if (addr[8] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end // Dynamic ODT (Rtt_WR) odt_rtt_wr = addr[10:9]; if (odt_rtt_wr == 2'b00) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Dynamic ODT = Disabled", $time, cmd_string[cmd], bank); dyn_odt_en = 0; end else if ((odt_rtt_wr > 0) && (odt_rtt_wr < 3)) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d Dynamic ODT Rtt = %d Ohm", $time, cmd_string[cmd], bank, get_rtt_wr(odt_rtt_wr)); dyn_odt_en = 1; end else begin $display ("%m: at time %t ERROR: %s %d Illegal Dynamic ODT = %d", $time, cmd_string[cmd], bank, odt_rtt_wr); dyn_odt_en = 0; end // Reserved if (ADDR_BITS>13 && addr[13:11] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end end 3 : begin mpr_select = addr[1:0]; // MultiPurpose Register Select if (mpr_select == 2'b00) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d MultiPurpose Register Select = Pre-defined pattern", $time, cmd_string[cmd], bank); end else begin if (check_strict_mrbits) $display ("%m: at time %t ERROR: %s %d Illegal MultiPurpose Register Select = %d", $time, cmd_string[cmd], bank, mpr_select); end // MultiPurpose Register Enable mpr_en = addr[2]; if (!mpr_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d MultiPurpose Register Enable = Disabled", $time, cmd_string[cmd], bank); end else if (mpr_en) begin if (DEBUG) $display ("%m: at time %t INFO: %s %d MultiPurpose Register Enable = Enabled", $time, cmd_string[cmd], bank); end else begin $display ("%m: at time %t ERROR: %s %d Illegal MultiPurpose Register Enable = %d", $time, cmd_string[cmd], bank, mpr_en); end // Reserved if (ADDR_BITS>13 && addr[13:3] !== 0 && check_strict_mrbits) begin $display ("%m: at time %t ERROR: %s %d Illegal value. Reserved address bits must be programmed to zero", $time, cmd_string[cmd], bank); end end endcase if (dyn_odt_en && write_levelization) $display ("%m: at time %t ERROR: Dynamic ODT is not available during Write Leveling mode.", $time); init_mode_reg[bank] = 1; mode_reg[bank] = addr; tm_load_mode <= $time; ck_load_mode <= ck_cntr; end end REFRESH : begin if (mpr_en) begin $display ("%m: at time %t ERROR: %s Failure. Multipurpose Register must be disabled.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (|active_bank) begin $display ("%m: at time %t ERROR: %s Failure. All banks must be Precharged.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) $display ("%m: at time %t INFO: %s", $time, cmd_string[cmd]); er_trfc_max = 0; ref_cntr = ref_cntr + 1; tm_refresh <= $time; ck_refresh <= ck_cntr; end end PRECHARGE : begin if (addr[AP]) begin if (DEBUG) $display ("%m: at time %t INFO: %s All", $time, cmd_string[cmd]); end // PRECHARGE command will be treated as a NOP if there is no open row in that bank (idle state), // or if the previously open row is already in the process of precharging if (|active_bank) begin if (($time - tm_txpr < TXPR) || (ck_cntr - ck_txpr < TXPR_TCK)) $display ("%m: at time %t ERROR: tXPR violation during %s", $time, cmd_string[cmd]); if (mpr_en) begin $display ("%m: at time %t ERROR: %s Failure. Multipurpose Register must be disabled.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else begin for (i=0; i<`BANKS; i=i+1) begin if (active_bank[i]) begin if (addr[AP] || (i == bank)) begin for (j=0; j<=SELF_REF; j=j+1) begin chk_err(SAME_BANK, i, j, cmd); chk_err(DIFF_BANK, i, j, cmd); end if (auto_precharge_bank[i]) begin $display ("%m: at time %t ERROR: %s Failure. Auto Precharge is scheduled to bank %d.", $time, cmd_string[cmd], i); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) $display ("%m: at time %t INFO: %s bank %d", $time, cmd_string[cmd], i); active_bank[i] = 1'b0; tm_bank_precharge[i] <= $time; tm_precharge <= $time; ck_precharge <= ck_cntr; end end end end end end end ACTIVATE : begin tfaw_cntr = 0; for (i=0; i<`BANKS; i=i+1) begin if ($time - tm_bank_activate[i] < TFAW) begin tfaw_cntr = tfaw_cntr + 1; end end if (tfaw_cntr > 3) begin $display ("%m: at time %t ERROR: tFAW violation during %s to bank %d", $time, cmd_string[cmd], bank); end if (mpr_en) begin $display ("%m: at time %t ERROR: %s Failure. Multipurpose Register must be disabled.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (!init_done) begin $display ("%m: at time %t ERROR: %s Failure. Initialization sequence is not complete.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (active_bank[bank]) begin $display ("%m: at time %t ERROR: %s Failure. Bank %d must be Precharged.", $time, cmd_string[cmd], bank); if (STOP_ON_ERROR) $stop(0); end else begin if (addr >= 1<<ROW_BITS) begin $display ("%m: at time %t WARNING: row = %h does not exist. Maximum row = %h", $time, addr, (1<<ROW_BITS)-1); end if (DEBUG) $display ("%m: at time %t INFO: %s bank %d row %h", $time, cmd_string[cmd], bank, addr); active_bank[bank] = 1'b1; active_row[bank] = addr; tm_group_activate[bank[1]] <= $time; tm_activate <= $time; tm_bank_activate[bank] <= $time; ck_group_activate[bank[1]] <= ck_cntr; ck_activate <= ck_cntr; end end WRITE : begin if ((!rd_bc && blotf) || (burst_length == 4)) begin // BL=4 if (truebl4) begin if (ck_cntr - ck_group_read[bank[1]] < read_latency + TCCD/2 + 2 - write_latency) $display ("%m: at time %t ERROR: tRTW violation during %s to bank %d", $time, cmd_string[cmd], bank); if (ck_cntr - ck_read < read_latency + TCCD_DG/2 + 2 - write_latency) $display ("%m: at time %t ERROR: tRTW_DG violation during %s to bank %d", $time, cmd_string[cmd], bank); end else begin if (ck_cntr - ck_read < read_latency + TCCD/2 + 2 - write_latency) $display ("%m: at time %t ERROR: tRTW violation during %s to bank %d", $time, cmd_string[cmd], bank); end end else begin // BL=8 if (ck_cntr - ck_read < read_latency + TCCD + 2 - write_latency) $display ("%m: at time %t ERROR: tRTW violation during %s to bank %d", $time, cmd_string[cmd], bank); end if (mpr_en) begin $display ("%m: at time %t ERROR: %s Failure. Multipurpose Register must be disabled.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (!init_done) begin $display ("%m: at time %t ERROR: %s Failure. Initialization sequence is not complete.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (!active_bank[bank]) begin if (check_strict_timing) $display ("%m: at time %t ERROR: %s Failure. Bank %d must be Activated.", $time, cmd_string[cmd], bank); if (STOP_ON_ERROR) $stop(0); end else if (auto_precharge_bank[bank]) begin $display ("%m: at time %t ERROR: %s Failure. Auto Precharge is scheduled to bank %d.", $time, cmd_string[cmd], bank); if (STOP_ON_ERROR) $stop(0); end else if (ck_cntr - ck_write < burst_length/2) begin $display ("%m: at time %t ERROR: %s Failure. Illegal burst interruption.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else begin if (addr[AP]) begin auto_precharge_bank[bank] = 1'b1; write_precharge_bank[bank] = 1'b1; end col = {addr[BC-1:AP+1], addr[AP-1:0]}; // assume BC > AP if (col >= 1<<COL_BITS) begin $display ("%m: at time %t WARNING: col = %h does not exist. Maximum col = %h", $time, col, (1<<COL_BITS)-1); end if ((!addr[BC] && blotf) || (burst_length == 4)) begin // BL=4 col = col & -4; end else begin // BL=8 col = col & -8; end if (DEBUG) $display ("%m: at time %t INFO: %s bank %d col %h, auto precharge %d", $time, cmd_string[cmd], bank, col, addr[AP]); wr_pipeline[2*write_latency + 1] = 1; ba_pipeline[2*write_latency + 1] = bank; row_pipeline[2*write_latency + 1] = active_row[bank]; col_pipeline[2*write_latency + 1] = col; if ((!addr[BC] && blotf) || (burst_length == 4)) begin // BL=4 bl_pipeline[2*write_latency + 1] = 4; if (mpr_en && col%4) begin $display ("%m: at time %t WARNING: col[1:0] must be set to 2'b00 during a BL4 Multipurpose Register read", $time); end end else begin // BL=8 bl_pipeline[2*write_latency + 1] = 8; if (odt_in) begin ck_odth8 <= ck_cntr; end end for (j=0; j<(burst_length + 4); j=j+1) begin dyn_odt_pipeline[2*(write_latency - 2) + j] = 1'b1; // ODTLcnw = WL - 2, ODTLcwn = BL/2 + 2 end ck_bank_write[bank] <= ck_cntr; ck_group_write[bank[1]] <= ck_cntr; ck_write <= ck_cntr; end end READ : begin if (!dll_locked) $display ("%m: at time %t WARNING: tDLLK violation during %s.", $time, cmd_string[cmd]); if (mpr_en && (addr[1:0] != 2'b00)) begin $display ("%m: at time %t ERROR: %s Failure. addr[1:0] must be zero during Multipurpose Register Read.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (!init_done) begin $display ("%m: at time %t ERROR: %s Failure. Initialization sequence is not complete.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (!active_bank[bank] && !mpr_en) begin if (check_strict_timing) $display ("%m: at time %t ERROR: %s Failure. Bank %d must be Activated.", $time, cmd_string[cmd], bank); if (STOP_ON_ERROR) $stop(0); end else if (auto_precharge_bank[bank]) begin $display ("%m: at time %t ERROR: %s Failure. Auto Precharge is scheduled to bank %d.", $time, cmd_string[cmd], bank); if (STOP_ON_ERROR) $stop(0); end else if (ck_cntr - ck_read < burst_length/2) begin $display ("%m: at time %t ERROR: %s Failure. Illegal burst interruption.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else begin if (addr[AP] && !mpr_en) begin auto_precharge_bank[bank] = 1'b1; read_precharge_bank[bank] = 1'b1; end col = {addr[BC-1:AP+1], addr[AP-1:0]}; // assume BC > AP if (col >= 1<<COL_BITS) begin $display ("%m: at time %t WARNING: col = %h does not exist. Maximum col = %h", $time, col, (1<<COL_BITS)-1); end if (DEBUG) $display ("%m: at time %t INFO: %s bank %d col %h, auto precharge %d", $time, cmd_string[cmd], bank, col, addr[AP]); rd_pipeline[2*read_latency - 1] = 1; ba_pipeline[2*read_latency - 1] = bank; row_pipeline[2*read_latency - 1] = active_row[bank]; col_pipeline[2*read_latency - 1] = col; if ((!addr[BC] && blotf) || (burst_length == 4)) begin // BL=4 bl_pipeline[2*read_latency - 1] = 4; if (mpr_en && col%4) begin $display ("%m: at time %t WARNING: col[1:0] must be set to 2'b00 during a BL4 Multipurpose Register read", $time); end end else begin // BL=8 bl_pipeline[2*read_latency - 1] = 8; if (mpr_en && col%8) begin $display ("%m: at time %t WARNING: col[2:0] must be set to 3'b000 during a BL8 Multipurpose Register read", $time); end end rd_bc = addr[BC]; ck_bank_read[bank] <= ck_cntr; ck_group_read[bank[1]] <= ck_cntr; ck_read <= ck_cntr; end end ZQ : begin if (mpr_en) begin $display ("%m: at time %t ERROR: %s Failure. Multipurpose Register must be disabled.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else if (|active_bank) begin $display ("%m: at time %t ERROR: %s Failure. All banks must be Precharged.", $time, cmd_string[cmd]); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) $display ("%m: at time %t INFO: %s long = %d", $time, cmd_string[cmd], addr[AP]); if (addr[AP]) begin zq_set = 1; if (init_done) begin ck_zqoper <= ck_cntr; end else begin ck_zqinit <= ck_cntr; end end else begin ck_zqcs <= ck_cntr; end end end NOP: begin if (in_power_down) begin if (($time - tm_freq_change < TCKSRX) || (ck_cntr - ck_freq_change < TCKSRX_TCK)) $display ("%m: at time %t ERROR: tCKSRX violation during Power Down Exit", $time); if ($time - tm_cke_cmd > TPD_MAX) $display ("%m: at time %t ERROR: tPD maximum violation during Power Down Exit", $time); if (DEBUG) $display ("%m: at time %t INFO: Power Down Exit", $time); in_power_down = 0; if ((active_bank == 0) && low_power) begin // precharge power down with dll off if (ck_cntr - ck_odt < write_latency - 1) $display ("%m: at time %t WARNING: tANPD violation during Power Down Exit. Synchronous or asynchronous change in termination resistance is possible.", $time); tm_slow_exit_pd <= $time; ck_slow_exit_pd <= ck_cntr; end tm_power_down <= $time; ck_power_down <= ck_cntr; end if (in_self_refresh) begin if (($time - tm_freq_change < TCKSRX) || (ck_cntr - ck_freq_change < TCKSRX_TCK)) $display ("%m: at time %t ERROR: tCKSRX violation during Self Refresh Exit", $time); if (ck_cntr - ck_cke_cmd < TCKESR_TCK) $display ("%m: at time %t ERROR: tCKESR violation during Self Refresh Exit", $time); if ($time - tm_cke < TISXR) $display ("%m: at time %t ERROR: tISXR violation during Self Refresh Exit", $time); if (DEBUG) $display ("%m: at time %t INFO: Self Refresh Exit", $time); in_self_refresh = 0; ck_dll_reset <= ck_cntr; ck_self_refresh <= ck_cntr; tm_self_refresh <= $time; tm_refresh <= $time; end end endcase if ((prev_cke !== 1) && (cmd !== NOP)) begin $display ("%m: at time %t ERROR: NOP or Deselect is required when CKE goes active.", $time); end if (!init_done) begin case (init_step) 0 : begin if ($time - tm_rst_n < 500000000 && check_strict_timing) $display ("%m at time %t WARNING: 500 us is required after RST_N goes inactive before CKE goes active.", $time); tm_txpr <= $time; ck_txpr <= ck_cntr; init_step = init_step + 1; end 1 : if (dll_en) init_step = init_step + 1; 2 : begin if (&init_mode_reg && init_dll_reset && zq_set) begin if (DEBUG) $display ("%m: at time %t INFO: Initialization Sequence is complete", $time); init_done = 1; end end endcase end end else if (prev_cke) begin if ((!init_done) && (init_step > 1)) begin $display ("%m: at time %t ERROR: CKE must remain active until the initialization sequence is complete.", $time); if (STOP_ON_ERROR) $stop(0); end case (cmd) REFRESH : begin if ($time - tm_txpr < TXPR) $display ("%m: at time %t ERROR: tXPR violation during %s", $time, cmd_string[SELF_REF]); for (j=0; j<=SELF_REF; j=j+1) begin chk_err(DIFF_BANK, bank, j, SELF_REF); end if (mpr_en) begin $display ("%m: at time %t ERROR: Self Refresh Failure. Multipurpose Register must be disabled.", $time); if (STOP_ON_ERROR) $stop(0); end else if (|active_bank) begin $display ("%m: at time %t ERROR: Self Refresh Failure. All banks must be Precharged.", $time); if (STOP_ON_ERROR) $stop(0); end else if (odt_state) begin $display ("%m: at time %t ERROR: Self Refresh Failure. ODT must be off prior to entering Self Refresh", $time); if (STOP_ON_ERROR) $stop(0); end else if (!init_done) begin $display ("%m: at time %t ERROR: Self Refresh Failure. Initialization sequence is not complete.", $time); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) $display ("%m: at time %t INFO: Self Refresh Enter", $time); if (feature_pasr) // Partial Array Self Refresh case (pasr) 3'b000 : ;//keep Bank 0-7 3'b001 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 4-7 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'hF0); end 3'b010 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 2-7 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'hFC); end 3'b011 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 1-7 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'hFE); end 3'b100 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 0-1 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'h03); end 3'b101 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 0-3 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'h0F); end 3'b110 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 0-5 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'h3F); end 3'b111 : begin if (DEBUG) $display("%m: at time %t INFO: Banks 0-6 will be lost due to Partial Array Self Refresh", $time); erase_banks(8'h7F); end endcase in_self_refresh = 1; dll_locked = 0; end end NOP : begin // entering precharge power down with dll off and tANPD has not been satisfied if (low_power && (active_bank == 0) && |odt_pipeline) $display ("%m: at time %t WARNING: tANPD violation during %s. Synchronous or asynchronous change in termination resistance is possible.", $time, cmd_string[PWR_DOWN]); if ($time - tm_txpr < TXPR) $display ("%m: at time %t ERROR: tXPR violation during %s", $time, cmd_string[PWR_DOWN]); for (j=0; j<=SELF_REF; j=j+1) begin chk_err(DIFF_BANK, bank, j, PWR_DOWN); end if (mpr_en) begin $display ("%m: at time %t ERROR: Power Down Failure. Multipurpose Register must be disabled.", $time); if (STOP_ON_ERROR) $stop(0); end else if (!init_done) begin $display ("%m: at time %t ERROR: Power Down Failure. Initialization sequence is not complete.", $time); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) begin if (|active_bank) begin $display ("%m: at time %t INFO: Active Power Down Enter", $time); end else begin $display ("%m: at time %t INFO: Precharge Power Down Enter", $time); end end in_power_down = 1; end end default : begin $display ("%m: at time %t ERROR: NOP, Deselect, or Refresh is required when CKE goes inactive.", $time); end endcase end else if (in_self_refresh || in_power_down) begin if ((ck_cntr - ck_cke_cmd <= TCPDED) && (cmd !== NOP)) $display ("%m: at time %t ERROR: tCPDED violation during Power Down or Self Refresh Entry. NOP or Deselect is required.", $time); end prev_cke = cke; end endtask task data_task; reg [BA_BITS-1:0] bank; reg [ROW_BITS-1:0] row; reg [COL_BITS-1:0] col; integer i; integer j; begin if (diff_ck) begin for (i=0; i<32; i=i+1) begin if (dq_in_valid && dll_locked && ($time - tm_dqs_neg[i] < $rtoi(TDSS*tck_avg))) $display ("%m: at time %t ERROR: tDSS violation on %s bit %d", $time, dqs_string[i/16], i%16); if (check_write_dqs_high[i]) $display ("%m: at time %t ERROR: %s bit %d latching edge required during the preceding clock period.", $time, dqs_string[i/16], i%16); end check_write_dqs_high <= 0; end else begin for (i=0; i<32; i=i+1) begin if (dll_locked && dq_in_valid) begin tm_tdqss = abs_value(1.0*tm_ck_pos - tm_dqss_pos[i]); if ((tm_tdqss < tck_avg/2.0) && (tm_tdqss > TDQSS*tck_avg)) $display ("%m: at time %t ERROR: tDQSS violation on %s bit %d", $time, dqs_string[i/16], i%16); end if (check_write_dqs_low[i]) $display ("%m: at time %t ERROR: %s bit %d latching edge required during the preceding clock period", $time, dqs_string[i/16], i%16); end check_write_preamble <= 0; check_write_postamble <= 0; check_write_dqs_low <= 0; end if (wr_pipeline[0] || rd_pipeline[0]) begin bank = ba_pipeline[0]; row = row_pipeline[0]; col = col_pipeline[0]; burst_cntr = 0; memory_read(bank, row, col, memory_data); end // burst counter if (burst_cntr < burst_length) begin burst_position = col ^ burst_cntr; if (!burst_order) begin burst_position[BO_BITS-1:0] = col + burst_cntr; end burst_cntr = burst_cntr + 1; end // write dqs counter if (wr_pipeline[WDQS_PRE + 1]) begin wdqs_cntr = WDQS_PRE + bl_pipeline[WDQS_PRE + 1] + WDQS_PST - 1; end // write dqs if ((wr_pipeline[2]) && (wdq_cntr == 0)) begin //write preamble check_write_preamble <= ({DQS_BITS{1'b1}}<<16) | {DQS_BITS{1'b1}}; end if (wdqs_cntr > 1) begin // write data if ((wdqs_cntr - WDQS_PST)%2) begin check_write_dqs_high <= ({DQS_BITS{1'b1}}<<16) | {DQS_BITS{1'b1}}; end else begin check_write_dqs_low <= ({DQS_BITS{1'b1}}<<16) | {DQS_BITS{1'b1}}; end end if (wdqs_cntr == WDQS_PST) begin // write postamble check_write_postamble <= ({DQS_BITS{1'b1}}<<16) | {DQS_BITS{1'b1}}; end if (wdqs_cntr > 0) begin wdqs_cntr = wdqs_cntr - 1; end // write dq if (dq_in_valid) begin // write data bit_mask = 0; if (diff_ck) begin for (i=0; i<DM_BITS; i=i+1) begin bit_mask = bit_mask | ({`DQ_PER_DQS{~dm_in_neg[i]}}<<(burst_position*DQ_BITS + i*`DQ_PER_DQS)); end memory_data = (dq_in_neg<<(burst_position*DQ_BITS) & bit_mask) | (memory_data & ~bit_mask); end else begin for (i=0; i<DM_BITS; i=i+1) begin bit_mask = bit_mask | ({`DQ_PER_DQS{~dm_in_pos[i]}}<<(burst_position*DQ_BITS + i*`DQ_PER_DQS)); end memory_data = (dq_in_pos<<(burst_position*DQ_BITS) & bit_mask) | (memory_data & ~bit_mask); end dq_temp = memory_data>>(burst_position*DQ_BITS); if (DEBUG) $display ("%m: at time %t INFO: WRITE @ DQS= bank = %h row = %h col = %h data = %h",$time, bank, row, (-1*BL_MAX & col) + burst_position, dq_temp); if (burst_cntr%BL_MIN == 0) begin memory_write(bank, row, col, memory_data); end end if (wr_pipeline[1]) begin wdq_cntr = bl_pipeline[1]; end if (wdq_cntr > 0) begin wdq_cntr = wdq_cntr - 1; dq_in_valid = 1'b1; end else begin dq_in_valid = 1'b0; dqs_in_valid <= 1'b0; for (i=0; i<31; i=i+1) begin wdqs_pos_cntr[i] <= 0; end end if (wr_pipeline[0]) begin b2b_write <= 1'b0; end if (wr_pipeline[2]) begin if (dqs_in_valid) begin b2b_write <= 1'b1; end dqs_in_valid <= 1'b1; wr_burst_length = bl_pipeline[2]; end // read dqs enable counter if (rd_pipeline[RDQSEN_PRE]) begin rdqsen_cntr = RDQSEN_PRE + bl_pipeline[RDQSEN_PRE] + RDQSEN_PST - 1; end if (rdqsen_cntr > 0) begin rdqsen_cntr = rdqsen_cntr - 1; dqs_out_en = 1'b1; end else begin dqs_out_en = 1'b0; end // read dqs counter if (rd_pipeline[RDQS_PRE]) begin rdqs_cntr = RDQS_PRE + bl_pipeline[RDQS_PRE] + RDQS_PST - 1; end // read dqs if (((rd_pipeline>>1 & {RDQS_PRE{1'b1}}) > 0) && (rdq_cntr == 0)) begin //read preamble dqs_out = 1'b0; end else if (rdqs_cntr > RDQS_PST) begin // read data dqs_out = rdqs_cntr - RDQS_PST; end else if (rdqs_cntr > 0) begin // read postamble dqs_out = 1'b0; end else begin dqs_out = 1'b1; end if (rdqs_cntr > 0) begin rdqs_cntr = rdqs_cntr - 1; end // read dq enable counter if (rd_pipeline[RDQEN_PRE]) begin rdqen_cntr = RDQEN_PRE + bl_pipeline[RDQEN_PRE] + RDQEN_PST; end if (rdqen_cntr > 0) begin rdqen_cntr = rdqen_cntr - 1; dq_out_en = 1'b1; end else begin dq_out_en = 1'b0; end // read dq if (rd_pipeline[0]) begin rdq_cntr = bl_pipeline[0]; end if (rdq_cntr > 0) begin // read data if (mpr_en) begin `ifdef MPR_DQ0 // DQ0 output MPR data, other DQ low if (mpr_select == 2'b00) begin // Calibration Pattern dq_temp = {DQS_BITS{{`DQ_PER_DQS-1{1'b0}}, calibration_pattern[burst_position]}}; end else if (odts_readout && (mpr_select == 2'b11)) begin // Temp Sensor (ODTS) dq_temp = {DQS_BITS{{`DQ_PER_DQS-1{1'b0}}, temp_sensor[burst_position]}}; end else begin // Reserved dq_temp = {DQS_BITS{{`DQ_PER_DQS-1{1'b0}}, 1'bx}}; end `else // all DQ output MPR data if (mpr_select == 2'b00) begin // Calibration Pattern dq_temp = {DQS_BITS{{`DQ_PER_DQS{calibration_pattern[burst_position]}}}}; end else if (odts_readout && (mpr_select == 2'b11)) begin // Temp Sensor (ODTS) dq_temp = {DQS_BITS{{`DQ_PER_DQS{temp_sensor[burst_position]}}}}; end else begin // Reserved dq_temp = {DQS_BITS{{`DQ_PER_DQS{1'bx}}}}; end `endif if (DEBUG) $display ("%m: at time %t READ @ DQS MultiPurpose Register %d, col = %d, data = %b", $time, mpr_select, burst_position, dq_temp[0]); end else begin dq_temp = memory_data>>(burst_position*DQ_BITS); if (DEBUG) $display ("%m: at time %t INFO: READ @ DQS= bank = %h row = %h col = %h data = %h",$time, bank, row, (-1*BL_MAX & col) + burst_position, dq_temp); end dq_out = dq_temp; rdq_cntr = rdq_cntr - 1; end else begin dq_out = {DQ_BITS{1'b1}}; end // delay signals prior to output if (RANDOM_OUT_DELAY && (dqs_out_en || (|dqs_out_en_dly) || dq_out_en || (|dq_out_en_dly))) begin for (i=0; i<DQS_BITS; i=i+1) begin // DQSCK requirements // 1.) less than tDQSCK // 2.) greater than -tDQSCK // 3.) cannot change more than tQH + tDQSQ from previous DQS edge dqsck_max = TDQSCK; if (dqsck_max > dqsck[i] + TQH*tck_avg + TDQSQ) begin dqsck_max = dqsck[i] + TQH*tck_avg + TDQSQ; end dqsck_min = -1*TDQSCK; if (dqsck_min < dqsck[i] - TQH*tck_avg - TDQSQ) begin dqsck_min = dqsck[i] - TQH*tck_avg - TDQSQ; end // DQSQ requirements // 1.) less than tDQSQ // 2.) greater than 0 // 3.) greater than tQH from the previous DQS edge dqsq_min = 0; if (dqsq_min < dqsck[i] - TQH*tck_avg) begin dqsq_min = dqsck[i] - TQH*tck_avg; end if (dqsck_min == dqsck_max) begin dqsck[i] = dqsck_min; end else begin dqsck[i] = $dist_uniform(seed, dqsck_min, dqsck_max); end dqsq_max = TDQSQ + dqsck[i]; dqs_out_en_dly[i] <= #(tck_avg/2) dqs_out_en; dqs_out_dly[i] <= #(tck_avg/2 + dqsck[i]) dqs_out; if (!write_levelization) begin for (j=0; j<`DQ_PER_DQS; j=j+1) begin dq_out_en_dly[i*`DQ_PER_DQS + j] <= #(tck_avg/2) dq_out_en; if (dqsq_min == dqsq_max) begin dq_out_dly [i*`DQ_PER_DQS + j] <= #(tck_avg/2 + dqsq_min) dq_out[i*`DQ_PER_DQS + j]; end else begin dq_out_dly [i*`DQ_PER_DQS + j] <= #(tck_avg/2 + $dist_uniform(seed, dqsq_min, dqsq_max)) dq_out[i*`DQ_PER_DQS + j]; end end end end end else begin out_delay = tck_avg/2; dqs_out_en_dly <= #(out_delay) {DQS_BITS{dqs_out_en}}; dqs_out_dly <= #(out_delay) {DQS_BITS{dqs_out }}; if (write_levelization !== 1'b1) begin dq_out_en_dly <= #(out_delay) {DQ_BITS {dq_out_en }}; dq_out_dly <= #(out_delay) {DQ_BITS {dq_out }}; end end end endtask always @ (posedge rst_n_in) begin : reset integer i; if (rst_n_in) begin if ($time < 200000000 && check_strict_timing) $display ("%m at time %t WARNING: 200 us is required before RST_N goes inactive.", $time); if (cke_in !== 1'b0) $display ("%m: at time %t ERROR: CKE must be inactive when RST_N goes inactive.", $time); if ($time - tm_cke < 10000) $display ("%m: at time %t ERROR: CKE must be maintained inactive for 10 ns before RST_N goes inactive.", $time); // clear memory `ifdef MAX_MEM // verification group does not erase memory // for (banki = 0; banki < `BANKS; banki = banki + 1) begin // $fclose(memfd[banki]); // memfd[banki] = open_bank_file(banki); // end `else memory_used <= 0; //erase memory `endif end end always @(negedge rst_n_in or posedge diff_ck or negedge diff_ck) begin : main integer i; if (!rst_n_in) begin reset_task; end else begin if (!in_self_refresh && (diff_ck !== 1'b0) && (diff_ck !== 1'b1)) $display ("%m: at time %t ERROR: CK and CK_N are not allowed to go to an unknown state.", $time); data_task; // Clock Frequency Change is legal: // 1.) During Self Refresh // 2.) During Precharge Power Down (DLL on or off) if (in_self_refresh || (in_power_down && (active_bank == 0))) begin if (diff_ck) begin tjit_per_rtime = $time - tm_ck_pos - tck_avg; end else begin tjit_per_rtime = $time - tm_ck_neg - tck_avg; end if (dll_locked && (abs_value(tjit_per_rtime) > TJIT_PER)) begin if ((tm_ck_pos - tm_cke_cmd < TCKSRE) || (ck_cntr - ck_cke_cmd < TCKSRE_TCK)) $display ("%m: at time %t ERROR: tCKSRE violation during Self Refresh or Precharge Power Down Entry", $time); if (odt_state) begin $display ("%m: at time %t ERROR: Clock Frequency Change Failure. ODT must be off prior to Clock Frequency Change.", $time); if (STOP_ON_ERROR) $stop(0); end else begin if (DEBUG) $display ("%m: at time %t INFO: Clock Frequency Change detected. DLL Reset is Required.", $time); tm_freq_change <= $time; ck_freq_change <= ck_cntr; dll_locked = 0; end end end if (diff_ck) begin // check setup of command signals if ($time > TIS) begin if ($time - tm_cke < TIS) $display ("%m: at time %t ERROR: tIS violation on CKE by %t", $time, tm_cke + TIS - $time); if (cke_in) begin for (i=0; i<22; i=i+1) begin if ($time - tm_cmd_addr[i] < TIS) $display ("%m: at time %t ERROR: tIS violation on %s by %t", $time, cmd_addr_string[i], tm_cmd_addr[i] + TIS - $time); end end end // update current state if (dll_locked) begin if (mr_chk == 0) begin mr_chk = 1; end else if (init_mode_reg[0] && (mr_chk == 1)) begin // check CL value against the clock frequency if (cas_latency*tck_avg < CL_TIME && check_strict_timing) $display ("%m: at time %t ERROR: CAS Latency = %d is illegal @tCK(avg) = %f", $time, cas_latency, tck_avg); // check WR value against the clock frequency if (ceil(write_recovery*tck_avg) < TWR) $display ("%m: at time %t ERROR: Write Recovery = %d is illegal @tCK(avg) = %f", $time, write_recovery, tck_avg); // check the CWL value against the clock frequency if (check_strict_timing) begin case (cas_write_latency) 5 : if (tck_avg < 2500.0) $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); 6 : if ((tck_avg < 1875.0) || (tck_avg >= 2500.0)) $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); 7 : if ((tck_avg < 1500.0) || (tck_avg >= 1875.0)) $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); 8 : if ((tck_avg < 1250.0) || (tck_avg >= 1500.0)) $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); 9 : if ((tck_avg < 15e3/14) || (tck_avg >= 1250.0)) $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); 10: if ((tck_avg < 937.5) || (tck_avg >= 15e3/14)) $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); default : $display ("%m: at time %t ERROR: CWL = %d is illegal @tCK(avg) = %f", $time, cas_write_latency, tck_avg); endcase // check the CL value against the clock frequency if (!valid_cl(cas_latency, cas_write_latency)) $display ("%m: at time %t ERROR: CAS Latency = %d is not valid when CAS Write Latency = %d", $time, cas_latency, cas_write_latency); end mr_chk = 2; end end else if (!in_self_refresh) begin mr_chk = 0; if (ck_cntr - ck_dll_reset == TDLLK) begin dll_locked = 1; end end if (|auto_precharge_bank) begin for (i=0; i<`BANKS; i=i+1) begin // Write with Auto Precharge Calculation // 1. Meet minimum tRAS requirement // 2. Write Latency PLUS BL/2 cycles PLUS WR after Write command if (write_precharge_bank[i]) begin if ($time - tm_bank_activate[i] >= TRAS_MIN) begin if (ck_cntr - ck_bank_write[i] >= write_latency + burst_length/2 + write_recovery) begin if (DEBUG) $display ("%m: at time %t INFO: Auto Precharge bank %d", $time, i); write_precharge_bank[i] = 0; active_bank[i] = 0; auto_precharge_bank[i] = 0; tm_bank_precharge[i] = $time; tm_precharge = $time; ck_precharge = ck_cntr; end end end // Read with Auto Precharge Calculation // 1. Meet minimum tRAS requirement // 2. Additive Latency plus 4 cycles after Read command // 3. tRTP after the last 8-bit prefetch if (read_precharge_bank[i]) begin if (($time - tm_bank_activate[i] >= TRAS_MIN) && (ck_cntr - ck_bank_read[i] >= additive_latency + TRTP_TCK)) begin read_precharge_bank[i] = 0; // In case the internal precharge is pushed out by tRTP, tRP starts at the point where // the internal precharge happens (not at the next rising clock edge after this event). if ($time - tm_bank_read_end[i] < TRTP) begin if (DEBUG) $display ("%m: at time %t INFO: Auto Precharge bank %d", tm_bank_read_end[i] + TRTP, i); active_bank[i] <= #(tm_bank_read_end[i] + TRTP - $time) 0; auto_precharge_bank[i] <= #(tm_bank_read_end[i] + TRTP - $time) 0; tm_bank_precharge[i] <= #(tm_bank_read_end[i] + TRTP - $time) tm_bank_read_end[i] + TRTP; tm_precharge <= #(tm_bank_read_end[i] + TRTP - $time) tm_bank_read_end[i] + TRTP; ck_precharge = ck_cntr; end else begin if (DEBUG) $display ("%m: at time %t INFO: Auto Precharge bank %d", $time, i); active_bank[i] = 0; auto_precharge_bank[i] = 0; tm_bank_precharge[i] = $time; tm_precharge = $time; ck_precharge = ck_cntr; end end end end end // respond to incoming command if (cke_in ^ prev_cke) begin tm_cke_cmd <= $time; ck_cke_cmd <= ck_cntr; end cmd_task(cke_in, cmd_n_in, ba_in, addr_in); if ((cmd_n_in == WRITE) || (cmd_n_in == READ)) begin al_pipeline[2*additive_latency] = 1'b1; end if (al_pipeline[0]) begin // check tRCD after additive latency if ((rd_pipeline[2*cas_latency - 1]) && ($time - tm_bank_activate[ba_pipeline[2*cas_latency - 1]] < TRCD)) $display ("%m: at time %t ERROR: tRCD violation during %s", $time, cmd_string[READ]); if ((wr_pipeline[2*cas_write_latency + 1]) && ($time - tm_bank_activate[ba_pipeline[2*cas_write_latency + 1]] < TRCD)) $display ("%m: at time %t ERROR: tRCD violation during %s", $time, cmd_string[WRITE]); // check tWTR after additive latency if (rd_pipeline[2*cas_latency - 1]) begin //{ if (truebl4) begin //{ i = ba_pipeline[2*cas_latency - 1]; if ($time - tm_group_write_end[i[1]] < TWTR) $display ("%m: at time %t ERROR: tWTR violation during %s", $time, cmd_string[READ]); if ($time - tm_write_end < TWTR_DG) $display ("%m: at time %t ERROR: tWTR_DG violation during %s", $time, cmd_string[READ]); end else begin if ($time - tm_write_end < TWTR) $display ("%m: at time %t ERROR: tWTR violation during %s", $time, cmd_string[READ]); end end end if (rd_pipeline) begin if (rd_pipeline[2*cas_latency - 1]) begin tm_bank_read_end[ba_pipeline[2*cas_latency - 1]] <= $time; end end for (i=0; i<`BANKS; i=i+1) begin if ((ck_cntr - ck_bank_write[i] > write_latency) && (ck_cntr - ck_bank_write[i] <= write_latency + burst_length/2)) begin tm_bank_write_end[i] <= $time; tm_group_write_end[i[1]] <= $time; tm_write_end <= $time; end end // clk pin is disabled during self refresh if (!in_self_refresh && tm_ck_pos ) begin tjit_cc_time = $time - tm_ck_pos - tck_i; tck_i = $time - tm_ck_pos; tck_avg = tck_avg - tck_sample[ck_cntr%TDLLK]/$itor(TDLLK); tck_avg = tck_avg + tck_i/$itor(TDLLK); tck_sample[ck_cntr%TDLLK] = tck_i; tjit_per_rtime = tck_i - tck_avg; if (dll_locked && check_strict_timing) begin // check accumulated error terr_nper_rtime = 0; for (i=0; i<12; i=i+1) begin terr_nper_rtime = terr_nper_rtime + tck_sample[i] - tck_avg; terr_nper_rtime = abs_value(terr_nper_rtime); case (i) 0 :; 1 : if (terr_nper_rtime - TERR_2PER >= 1.0) $display ("%m: at time %t ERROR: tERR(2per) violation by %f ps.", $time, terr_nper_rtime - TERR_2PER); 2 : if (terr_nper_rtime - TERR_3PER >= 1.0) $display ("%m: at time %t ERROR: tERR(3per) violation by %f ps.", $time, terr_nper_rtime - TERR_3PER); 3 : if (terr_nper_rtime - TERR_4PER >= 1.0) $display ("%m: at time %t ERROR: tERR(4per) violation by %f ps.", $time, terr_nper_rtime - TERR_4PER); 4 : if (terr_nper_rtime - TERR_5PER >= 1.0) $display ("%m: at time %t ERROR: tERR(5per) violation by %f ps.", $time, terr_nper_rtime - TERR_5PER); 5 : if (terr_nper_rtime - TERR_6PER >= 1.0) $display ("%m: at time %t ERROR: tERR(6per) violation by %f ps.", $time, terr_nper_rtime - TERR_6PER); 6 : if (terr_nper_rtime - TERR_7PER >= 1.0) $display ("%m: at time %t ERROR: tERR(7per) violation by %f ps.", $time, terr_nper_rtime - TERR_7PER); 7 : if (terr_nper_rtime - TERR_8PER >= 1.0) $display ("%m: at time %t ERROR: tERR(8per) violation by %f ps.", $time, terr_nper_rtime - TERR_8PER); 8 : if (terr_nper_rtime - TERR_9PER >= 1.0) $display ("%m: at time %t ERROR: tERR(9per) violation by %f ps.", $time, terr_nper_rtime - TERR_9PER); 9 : if (terr_nper_rtime - TERR_10PER >= 1.0) $display ("%m: at time %t ERROR: tERR(10per) violation by %f ps.", $time, terr_nper_rtime - TERR_10PER); 10 : if (terr_nper_rtime - TERR_11PER >= 1.0) $display ("%m: at time %t ERROR: tERR(11per) violation by %f ps.", $time, terr_nper_rtime - TERR_11PER); 11 : if (terr_nper_rtime - TERR_12PER >= 1.0) $display ("%m: at time %t ERROR: tERR(12per) violation by %f ps.", $time, terr_nper_rtime - TERR_12PER); endcase end // check tCK min/max/jitter if (abs_value(tjit_per_rtime) - TJIT_PER >= 1.0) $display ("%m: at time %t ERROR: tJIT(per) violation by %f ps.", $time, abs_value(tjit_per_rtime) - TJIT_PER); if (abs_value(tjit_cc_time) - TJIT_CC >= 1.0) $display ("%m: at time %t ERROR: tJIT(cc) violation by %f ps.", $time, abs_value(tjit_cc_time) - TJIT_CC); if (TCK_MIN - tck_avg >= 1.0) $display ("%m: at time %t ERROR: tCK(avg) minimum violation by %f ps.", $time, TCK_MIN - tck_avg); if (tck_avg - TCK_MAX >= 1.0) $display ("%m: at time %t ERROR: tCK(avg) maximum violation by %f ps.", $time, tck_avg - TCK_MAX); // check tCL if (tm_ck_neg - $time < TCL_ABS_MIN*tck_avg) $display ("%m: at time %t ERROR: tCL(abs) minimum violation on CLK by %t", $time, TCL_ABS_MIN*tck_avg - tm_ck_neg + $time); if (tcl_avg < TCL_AVG_MIN*tck_avg) $display ("%m: at time %t ERROR: tCL(avg) minimum violation on CLK by %t", $time, TCL_AVG_MIN*tck_avg - tcl_avg); if (tcl_avg > TCL_AVG_MAX*tck_avg) $display ("%m: at time %t ERROR: tCL(avg) maximum violation on CLK by %t", $time, tcl_avg - TCL_AVG_MAX*tck_avg); end // calculate the tch avg jitter tch_avg = tch_avg - tch_sample[ck_cntr%TDLLK]/$itor(TDLLK); tch_avg = tch_avg + tch_i/$itor(TDLLK); tch_sample[ck_cntr%TDLLK] = tch_i; tjit_ch_rtime = tch_i - tch_avg; duty_cycle = tch_avg/tck_avg; // update timers/counters tcl_i <= $time - tm_ck_neg; end prev_odt <= odt_in; // update timers/counters ck_cntr <= ck_cntr + 1; tm_ck_pos = $time; end else begin // clk pin is disabled during self refresh if (!in_self_refresh) begin if (dll_locked && check_strict_timing) begin if ($time - tm_ck_pos < TCH_ABS_MIN*tck_avg) $display ("%m: at time %t ERROR: tCH(abs) minimum violation on CLK by %t", $time, TCH_ABS_MIN*tck_avg - $time + tm_ck_pos); if (tch_avg < TCH_AVG_MIN*tck_avg) $display ("%m: at time %t ERROR: tCH(avg) minimum violation on CLK by %t", $time, TCH_AVG_MIN*tck_avg - tch_avg); if (tch_avg > TCH_AVG_MAX*tck_avg) $display ("%m: at time %t ERROR: tCH(avg) maximum violation on CLK by %t", $time, tch_avg - TCH_AVG_MAX*tck_avg); end // calculate the tcl avg jitter tcl_avg = tcl_avg - tcl_sample[ck_cntr%TDLLK]/$itor(TDLLK); tcl_avg = tcl_avg + tcl_i/$itor(TDLLK); tcl_sample[ck_cntr%TDLLK] = tcl_i; // update timers/counters tch_i <= $time - tm_ck_pos; end tm_ck_neg = $time; end // on die termination if (odt_en || dyn_odt_en) begin // odt pin is disabled during self refresh if (!in_self_refresh && diff_ck) begin if ($time - tm_odt < TIS) $display ("%m: at time %t ERROR: tIS violation on ODT by %t", $time, tm_odt + TIS - $time); if (prev_odt ^ odt_in) begin if (!dll_locked) $display ("%m: at time %t WARNING: tDLLK violation during ODT transition.", $time); if (($time - tm_load_mode < TMOD) || (ck_cntr - ck_load_mode < TMOD_TCK)) $display ("%m: at time %t ERROR: tMOD violation during ODT transition", $time); if (ck_cntr - ck_zqinit < TZQINIT) $display ("%m: at time %t ERROR: TZQinit violation during ODT transition", $time); if (ck_cntr - ck_zqoper < TZQOPER) $display ("%m: at time %t ERROR: TZQoper violation during ODT transition", $time); if (ck_cntr - ck_zqcs < TZQCS) $display ("%m: at time %t ERROR: tZQcs violation during ODT transition", $time); // if (($time - tm_slow_exit_pd < TXPDLL) || (ck_cntr - ck_slow_exit_pd < TXPDLL_TCK)) // $display ("%m: at time %t ERROR: tXPDLL violation during ODT transition", $time); if (ck_cntr - ck_self_refresh < TXSDLL) $display ("%m: at time %t ERROR: tXSDLL violation during ODT transition", $time); if (in_self_refresh) $display ("%m: at time %t ERROR: Illegal ODT transition during Self Refresh.", $time); if (!odt_in && (ck_cntr - ck_odt < ODTH4)) $display ("%m: at time %t ERROR: ODTH4 violation during ODT transition", $time); if (!odt_in && (ck_cntr - ck_odth8 < ODTH8)) $display ("%m: at time %t ERROR: ODTH8 violation during ODT transition", $time); if (($time - tm_slow_exit_pd < TXPDLL) || (ck_cntr - ck_slow_exit_pd < TXPDLL_TCK)) $display ("%m: at time %t WARNING: tXPDLL during ODT transition. Synchronous or asynchronous change in termination resistance is possible.", $time); // async ODT mode applies: // 1.) during precharge power down with DLL off // 2.) if tANPD has not been satisfied // 3.) until tXPDLL has been satisfied if ((in_power_down && low_power && (active_bank == 0)) || ($time - tm_slow_exit_pd < TXPDLL) || (ck_cntr - ck_slow_exit_pd < TXPDLL_TCK)) begin odt_state = odt_in; if (DEBUG && odt_en) $display ("%m: at time %t INFO: Async On Die Termination Rtt_NOM = %d Ohm", $time, {32{odt_state}} & get_rtt_nom(odt_rtt_nom)); if (odt_state) begin odt_state_dly <= #(TAONPD) odt_state; end else begin odt_state_dly <= #(TAOFPD) odt_state; end // sync ODT mode applies: // 1.) during normal operation // 2.) during active power down // 3.) during precharge power down with DLL on end else begin odt_pipeline[2*(write_latency - 2)] = 1'b1; // ODTLon, ODTLoff end ck_odt <= ck_cntr; end end if (odt_pipeline[0]) begin odt_state = ~odt_state; if (DEBUG && odt_en) $display ("%m: at time %t INFO: Sync On Die Termination Rtt_NOM = %d Ohm", $time, {32{odt_state}} & get_rtt_nom(odt_rtt_nom)); if (odt_state) begin odt_state_dly <= #(TAON) odt_state; end else begin odt_state_dly <= #(TAOF*tck_avg) odt_state; end end if (rd_pipeline[RDQSEN_PRE]) begin odt_cntr = 1 + RDQSEN_PRE + bl_pipeline[RDQSEN_PRE] + RDQSEN_PST - 1; end if (odt_cntr > 0) begin if (odt_state) begin $display ("%m: at time %t ERROR: On Die Termination must be OFF during Read data transfer.", $time); end odt_cntr = odt_cntr - 1; end if (dyn_odt_en && odt_state) begin if (DEBUG && (dyn_odt_state ^ dyn_odt_pipeline[0])) $display ("%m: at time %t INFO: Sync On Die Termination Rtt_WR = %d Ohm", $time, {32{dyn_odt_pipeline[0]}} & get_rtt_wr(odt_rtt_wr)); dyn_odt_state = dyn_odt_pipeline[0]; end dyn_odt_state_dly <= #(TADC*tck_avg) dyn_odt_state; end if (cke_in && write_levelization) begin for (i=0; i<DQS_BITS; i=i+1) begin if ($time - tm_dqs_pos[i] < TWLH) $display ("%m: at time %t WARNING: tWLH violation on DQS bit %d positive edge. Indeterminate CK capture is possible.", $time, i); end end // shift pipelines if (|wr_pipeline || |rd_pipeline || |al_pipeline) begin al_pipeline = al_pipeline>>1; wr_pipeline = wr_pipeline>>1; rd_pipeline = rd_pipeline>>1; for (i=0; i<`MAX_PIPE; i=i+1) begin bl_pipeline[i] = bl_pipeline[i+1]; ba_pipeline[i] = ba_pipeline[i+1]; row_pipeline[i] = row_pipeline[i+1]; col_pipeline[i] = col_pipeline[i+1]; end end if (|odt_pipeline || |dyn_odt_pipeline) begin odt_pipeline = odt_pipeline>>1; dyn_odt_pipeline = dyn_odt_pipeline>>1; end end end // receiver(s) task dqs_even_receiver; input [3:0] i; reg [63:0] bit_mask; begin bit_mask = {`DQ_PER_DQS{1'b1}}<<(i*`DQ_PER_DQS); if (dqs_even[i]) begin if (tdqs_en) begin // tdqs disables dm dm_in_pos[i] = 1'b0; end else begin dm_in_pos[i] = dm_in[i]; end dq_in_pos = (dq_in & bit_mask) | (dq_in_pos & ~bit_mask); end end endtask always @(posedge dqs_even[ 0]) dqs_even_receiver( 0); always @(posedge dqs_even[ 1]) dqs_even_receiver( 1); always @(posedge dqs_even[ 2]) dqs_even_receiver( 2); always @(posedge dqs_even[ 3]) dqs_even_receiver( 3); always @(posedge dqs_even[ 4]) dqs_even_receiver( 4); always @(posedge dqs_even[ 5]) dqs_even_receiver( 5); always @(posedge dqs_even[ 6]) dqs_even_receiver( 6); always @(posedge dqs_even[ 7]) dqs_even_receiver( 7); always @(posedge dqs_even[ 8]) dqs_even_receiver( 8); always @(posedge dqs_even[ 9]) dqs_even_receiver( 9); always @(posedge dqs_even[10]) dqs_even_receiver(10); always @(posedge dqs_even[11]) dqs_even_receiver(11); always @(posedge dqs_even[12]) dqs_even_receiver(12); always @(posedge dqs_even[13]) dqs_even_receiver(13); always @(posedge dqs_even[14]) dqs_even_receiver(14); always @(posedge dqs_even[15]) dqs_even_receiver(15); task dqs_odd_receiver; input [3:0] i; reg [63:0] bit_mask; begin bit_mask = {`DQ_PER_DQS{1'b1}}<<(i*`DQ_PER_DQS); if (dqs_odd[i]) begin if (tdqs_en) begin // tdqs disables dm dm_in_neg[i] = 1'b0; end else begin dm_in_neg[i] = dm_in[i]; end dq_in_neg = (dq_in & bit_mask) | (dq_in_neg & ~bit_mask); end end endtask always @(posedge dqs_odd[ 0]) dqs_odd_receiver( 0); always @(posedge dqs_odd[ 1]) dqs_odd_receiver( 1); always @(posedge dqs_odd[ 2]) dqs_odd_receiver( 2); always @(posedge dqs_odd[ 3]) dqs_odd_receiver( 3); always @(posedge dqs_odd[ 4]) dqs_odd_receiver( 4); always @(posedge dqs_odd[ 5]) dqs_odd_receiver( 5); always @(posedge dqs_odd[ 6]) dqs_odd_receiver( 6); always @(posedge dqs_odd[ 7]) dqs_odd_receiver( 7); always @(posedge dqs_odd[ 8]) dqs_odd_receiver( 8); always @(posedge dqs_odd[ 9]) dqs_odd_receiver( 9); always @(posedge dqs_odd[10]) dqs_odd_receiver(10); always @(posedge dqs_odd[11]) dqs_odd_receiver(11); always @(posedge dqs_odd[12]) dqs_odd_receiver(12); always @(posedge dqs_odd[13]) dqs_odd_receiver(13); always @(posedge dqs_odd[14]) dqs_odd_receiver(14); always @(posedge dqs_odd[15]) dqs_odd_receiver(15); // Processes to check hold and pulse width of control signals always @(posedge rst_n_in) begin if ($time > 100000) begin if (tm_rst_n + 100000 > $time) $display ("%m: at time %t ERROR: RST_N pulse width violation by %t", $time, tm_rst_n + 100000 - $time); end tm_rst_n = $time; end always @(cke_in) begin if (rst_n_in) begin if ($time > TIH) begin if ($time - tm_ck_pos < TIH) $display ("%m: at time %t ERROR: tIH violation on CKE by %t", $time, tm_ck_pos + TIH - $time); end if ($time - tm_cke < TIPW) $display ("%m: at time %t ERROR: tIPW violation on CKE by %t", $time, tm_cke + TIPW - $time); end tm_cke = $time; end always @(odt_in) begin if (rst_n_in && odt_en && !in_self_refresh) begin if ($time - tm_ck_pos < TIH) $display ("%m: at time %t ERROR: tIH violation on ODT by %t", $time, tm_ck_pos + TIH - $time); if ($time - tm_odt < TIPW) $display ("%m: at time %t ERROR: tIPW violation on ODT by %t", $time, tm_odt + TIPW - $time); end tm_odt = $time; end task cmd_addr_timing_check; input i; reg [4:0] i; begin if (rst_n_in && prev_cke) begin if ((i == 0) && ($time - tm_ck_pos < TIH)) // always check tIH for CS# $display ("%m: at time %t ERROR: tIH violation on %s by %t", $time, cmd_addr_string[i], tm_ck_pos + TIH - $time); if ((i > 0) && (cs_n_in == 0) &&($time - tm_ck_pos < TIH)) // Only check tIH for cmd_addr if CS# is low $display ("%m: at time %t ERROR: tIH violation on %s by %t", $time, cmd_addr_string[i], tm_ck_pos + TIH - $time); if ($time - tm_cmd_addr[i] < TIPW) $display ("%m: at time %t ERROR: tIPW violation on %s by %t", $time, cmd_addr_string[i], tm_cmd_addr[i] + TIPW - $time); end tm_cmd_addr[i] = $time; end endtask always @(cs_n_in ) cmd_addr_timing_check( 0); always @(ras_n_in ) cmd_addr_timing_check( 1); always @(cas_n_in ) cmd_addr_timing_check( 2); always @(we_n_in ) cmd_addr_timing_check( 3); always @(ba_in [ 0]) cmd_addr_timing_check( 4); always @(ba_in [ 1]) cmd_addr_timing_check( 5); always @(ba_in [ 2]) cmd_addr_timing_check( 6); always @(addr_in[ 0]) cmd_addr_timing_check( 7); always @(addr_in[ 1]) cmd_addr_timing_check( 8); always @(addr_in[ 2]) cmd_addr_timing_check( 9); always @(addr_in[ 3]) cmd_addr_timing_check(10); always @(addr_in[ 4]) cmd_addr_timing_check(11); always @(addr_in[ 5]) cmd_addr_timing_check(12); always @(addr_in[ 6]) cmd_addr_timing_check(13); always @(addr_in[ 7]) cmd_addr_timing_check(14); always @(addr_in[ 8]) cmd_addr_timing_check(15); always @(addr_in[ 9]) cmd_addr_timing_check(16); always @(addr_in[10]) cmd_addr_timing_check(17); always @(addr_in[11]) cmd_addr_timing_check(18); always @(addr_in[12]) cmd_addr_timing_check(19); always @(addr_in[13]) cmd_addr_timing_check(20); always @(addr_in[14]) cmd_addr_timing_check(21); always @(addr_in[15]) cmd_addr_timing_check(22); // Processes to check setup and hold of data signals task dm_timing_check; input i; reg [3:0] i; begin if (dqs_in_valid) begin if ($time - tm_dqs[i] < TDH) $display ("%m: at time %t ERROR: tDH violation on DM bit %d by %t", $time, i, tm_dqs[i] + TDH - $time); if (check_dm_tdipw[i]) begin if ($time - tm_dm[i] < TDIPW) $display ("%m: at time %t ERROR: tDIPW violation on DM bit %d by %t", $time, i, tm_dm[i] + TDIPW - $time); end end check_dm_tdipw[i] <= 1'b0; tm_dm[i] = $time; end endtask always @(dm_in[ 0]) dm_timing_check( 0); always @(dm_in[ 1]) dm_timing_check( 1); always @(dm_in[ 2]) dm_timing_check( 2); always @(dm_in[ 3]) dm_timing_check( 3); always @(dm_in[ 4]) dm_timing_check( 4); always @(dm_in[ 5]) dm_timing_check( 5); always @(dm_in[ 6]) dm_timing_check( 6); always @(dm_in[ 7]) dm_timing_check( 7); always @(dm_in[ 8]) dm_timing_check( 8); always @(dm_in[ 9]) dm_timing_check( 9); always @(dm_in[10]) dm_timing_check(10); always @(dm_in[11]) dm_timing_check(11); always @(dm_in[12]) dm_timing_check(12); always @(dm_in[13]) dm_timing_check(13); always @(dm_in[14]) dm_timing_check(14); always @(dm_in[15]) dm_timing_check(15); task dq_timing_check; input i; reg [5:0] i; begin if (dqs_in_valid) begin if ($time - tm_dqs[i/`DQ_PER_DQS] < TDH) $display ("%m: at time %t ERROR: tDH violation on DQ bit %d by %t", $time, i, tm_dqs[i/`DQ_PER_DQS] + TDH - $time); if (check_dq_tdipw[i]) begin if ($time - tm_dq[i] < TDIPW) $display ("%m: at time %t ERROR: tDIPW violation on DQ bit %d by %t", $time, i, tm_dq[i] + TDIPW - $time); end end check_dq_tdipw[i] <= 1'b0; tm_dq[i] = $time; end endtask always @(dq_in[ 0]) dq_timing_check( 0); always @(dq_in[ 1]) dq_timing_check( 1); always @(dq_in[ 2]) dq_timing_check( 2); always @(dq_in[ 3]) dq_timing_check( 3); always @(dq_in[ 4]) dq_timing_check( 4); always @(dq_in[ 5]) dq_timing_check( 5); always @(dq_in[ 6]) dq_timing_check( 6); always @(dq_in[ 7]) dq_timing_check( 7); always @(dq_in[ 8]) dq_timing_check( 8); always @(dq_in[ 9]) dq_timing_check( 9); always @(dq_in[10]) dq_timing_check(10); always @(dq_in[11]) dq_timing_check(11); always @(dq_in[12]) dq_timing_check(12); always @(dq_in[13]) dq_timing_check(13); always @(dq_in[14]) dq_timing_check(14); always @(dq_in[15]) dq_timing_check(15); always @(dq_in[16]) dq_timing_check(16); always @(dq_in[17]) dq_timing_check(17); always @(dq_in[18]) dq_timing_check(18); always @(dq_in[19]) dq_timing_check(19); always @(dq_in[20]) dq_timing_check(20); always @(dq_in[21]) dq_timing_check(21); always @(dq_in[22]) dq_timing_check(22); always @(dq_in[23]) dq_timing_check(23); always @(dq_in[24]) dq_timing_check(24); always @(dq_in[25]) dq_timing_check(25); always @(dq_in[26]) dq_timing_check(26); always @(dq_in[27]) dq_timing_check(27); always @(dq_in[28]) dq_timing_check(28); always @(dq_in[29]) dq_timing_check(29); always @(dq_in[30]) dq_timing_check(30); always @(dq_in[31]) dq_timing_check(31); always @(dq_in[32]) dq_timing_check(32); always @(dq_in[33]) dq_timing_check(33); always @(dq_in[34]) dq_timing_check(34); always @(dq_in[35]) dq_timing_check(35); always @(dq_in[36]) dq_timing_check(36); always @(dq_in[37]) dq_timing_check(37); always @(dq_in[38]) dq_timing_check(38); always @(dq_in[39]) dq_timing_check(39); always @(dq_in[40]) dq_timing_check(40); always @(dq_in[41]) dq_timing_check(41); always @(dq_in[42]) dq_timing_check(42); always @(dq_in[43]) dq_timing_check(43); always @(dq_in[44]) dq_timing_check(44); always @(dq_in[45]) dq_timing_check(45); always @(dq_in[46]) dq_timing_check(46); always @(dq_in[47]) dq_timing_check(47); always @(dq_in[48]) dq_timing_check(48); always @(dq_in[49]) dq_timing_check(49); always @(dq_in[50]) dq_timing_check(50); always @(dq_in[51]) dq_timing_check(51); always @(dq_in[52]) dq_timing_check(52); always @(dq_in[53]) dq_timing_check(53); always @(dq_in[54]) dq_timing_check(54); always @(dq_in[55]) dq_timing_check(55); always @(dq_in[56]) dq_timing_check(56); always @(dq_in[57]) dq_timing_check(57); always @(dq_in[58]) dq_timing_check(58); always @(dq_in[59]) dq_timing_check(59); always @(dq_in[60]) dq_timing_check(60); always @(dq_in[61]) dq_timing_check(61); always @(dq_in[62]) dq_timing_check(62); always @(dq_in[63]) dq_timing_check(63); task dqs_pos_timing_check; input i; reg [4:0] i; reg [3:0] j; begin if (write_levelization && i<16) begin if (ck_cntr - ck_load_mode < TWLMRD) $display ("%m: at time %t ERROR: tWLMRD violation on DQS bit %d positive edge.", $time, i); if (($time - tm_ck_pos < TWLS) || ($time - tm_ck_neg < TWLS)) $display ("%m: at time %t WARNING: tWLS violation on DQS bit %d positive edge. Indeterminate CK capture is possible.", $time, i); if (DEBUG) $display ("%m: at time %t Write Leveling @ DQS ck = %b", $time, diff_ck); dq_out_en_dly[i*`DQ_PER_DQS] <= #(TWLO) 1'b1; dq_out_dly[i*`DQ_PER_DQS] <= #(TWLO) diff_ck; for (j=1; j<`DQ_PER_DQS; j=j+1) begin dq_out_en_dly[i*`DQ_PER_DQS+j] <= #(TWLO + TWLOE) 1'b1; dq_out_dly[i*`DQ_PER_DQS+j] <= #(TWLO + TWLOE) 1'b0; end end if (dqs_in_valid && ((wdqs_pos_cntr[i] < wr_burst_length/2) || b2b_write)) begin if (dqs_in[i] ^ prev_dqs_in[i]) begin if (dll_locked) begin if (check_write_preamble[i]) begin if ($time - tm_dqs_pos[i] < $rtoi(TWPRE*tck_avg)) $display ("%m: at time %t ERROR: tWPRE violation on &s bit %d", $time, dqs_string[i/16], i%16); end else if (check_write_postamble[i]) begin if ($time - tm_dqs_neg[i] < $rtoi(TWPST*tck_avg)) $display ("%m: at time %t ERROR: tWPST violation on %s bit %d", $time, dqs_string[i/16], i%16); end else begin if ($time - tm_dqs_neg[i] < $rtoi(TDQSL*tck_avg)) $display ("%m: at time %t ERROR: tDQSL violation on %s bit %d", $time, dqs_string[i/16], i%16); end end if ($time - tm_dm[i%16] < TDS) $display ("%m: at time %t ERROR: tDS violation on DM bit %d by %t", $time, i, tm_dm[i%16] + TDS - $time); if (!dq_out_en) begin for (j=0; j<`DQ_PER_DQS; j=j+1) begin if ($time - tm_dq[(i%16)*`DQ_PER_DQS+j] < TDS) $display ("%m: at time %t ERROR: tDS violation on DQ bit %d by %t", $time, i*`DQ_PER_DQS+j, tm_dq[(i%16)*`DQ_PER_DQS+j] + TDS - $time); check_dq_tdipw[(i%16)*`DQ_PER_DQS+j] <= 1'b1; end end if ((wdqs_pos_cntr[i] < wr_burst_length/2) && !b2b_write) begin wdqs_pos_cntr[i] <= wdqs_pos_cntr[i] + 1; end else begin wdqs_pos_cntr[i] <= 1; end check_dm_tdipw[i%16] <= 1'b1; check_write_preamble[i] <= 1'b0; check_write_postamble[i] <= 1'b0; check_write_dqs_low[i] <= 1'b0; tm_dqs[i%16] <= $time; end else begin $display ("%m: at time %t ERROR: Invalid latching edge on %s bit %d", $time, dqs_string[i/16], i%16); end end tm_dqss_pos[i] <= $time; tm_dqs_pos[i] = $time; prev_dqs_in[i] <= dqs_in[i]; end endtask always @(posedge dqs_in[ 0]) dqs_pos_timing_check( 0); always @(posedge dqs_in[ 1]) dqs_pos_timing_check( 1); always @(posedge dqs_in[ 2]) dqs_pos_timing_check( 2); always @(posedge dqs_in[ 3]) dqs_pos_timing_check( 3); always @(posedge dqs_in[ 4]) dqs_pos_timing_check( 4); always @(posedge dqs_in[ 5]) dqs_pos_timing_check( 5); always @(posedge dqs_in[ 6]) dqs_pos_timing_check( 6); always @(posedge dqs_in[ 7]) dqs_pos_timing_check( 7); always @(posedge dqs_in[ 8]) dqs_pos_timing_check( 8); always @(posedge dqs_in[ 9]) dqs_pos_timing_check( 9); always @(posedge dqs_in[10]) dqs_pos_timing_check(10); always @(posedge dqs_in[11]) dqs_pos_timing_check(11); always @(posedge dqs_in[12]) dqs_pos_timing_check(12); always @(posedge dqs_in[13]) dqs_pos_timing_check(13); always @(posedge dqs_in[14]) dqs_pos_timing_check(14); always @(posedge dqs_in[15]) dqs_pos_timing_check(15); always @(negedge dqs_in[16]) dqs_pos_timing_check(16); always @(negedge dqs_in[17]) dqs_pos_timing_check(17); always @(negedge dqs_in[18]) dqs_pos_timing_check(18); always @(negedge dqs_in[19]) dqs_pos_timing_check(19); always @(negedge dqs_in[20]) dqs_pos_timing_check(20); always @(negedge dqs_in[21]) dqs_pos_timing_check(21); always @(negedge dqs_in[22]) dqs_pos_timing_check(22); always @(negedge dqs_in[23]) dqs_pos_timing_check(23); always @(negedge dqs_in[24]) dqs_pos_timing_check(24); always @(negedge dqs_in[25]) dqs_pos_timing_check(25); always @(negedge dqs_in[26]) dqs_pos_timing_check(26); always @(negedge dqs_in[27]) dqs_pos_timing_check(27); always @(negedge dqs_in[28]) dqs_pos_timing_check(28); always @(negedge dqs_in[29]) dqs_pos_timing_check(29); always @(negedge dqs_in[30]) dqs_pos_timing_check(30); always @(negedge dqs_in[31]) dqs_pos_timing_check(31); task dqs_neg_timing_check; input i; reg [4:0] i; reg [3:0] j; begin if (write_levelization && i<16) begin if (ck_cntr - ck_load_mode < TWLDQSEN) $display ("%m: at time %t ERROR: tWLDQSEN violation on DQS bit %d.", $time, i); if ($time - tm_dqs_pos[i] < $rtoi(TDQSH*tck_avg)) $display ("%m: at time %t ERROR: tDQSH violation on DQS bit %d by %t", $time, i, tm_dqs_pos[i] + TDQSH*tck_avg - $time); end if (dqs_in_valid && (wdqs_pos_cntr[i] > 0) && check_write_dqs_high[i]) begin if (dqs_in[i] ^ prev_dqs_in[i]) begin if (dll_locked) begin if ($time - tm_dqs_pos[i] < $rtoi(TDQSH*tck_avg)) $display ("%m: at time %t ERROR: tDQSH violation on %s bit %d", $time, dqs_string[i/16], i%16); if ($time - tm_ck_pos < $rtoi(TDSH*tck_avg)) $display ("%m: at time %t ERROR: tDSH violation on %s bit %d", $time, dqs_string[i/16], i%16); end if ($time - tm_dm[i%16] < TDS) $display ("%m: at time %t ERROR: tDS violation on DM bit %d by %t", $time, i, tm_dm[i%16] + TDS - $time); if (!dq_out_en) begin for (j=0; j<`DQ_PER_DQS; j=j+1) begin if ($time - tm_dq[(i%16)*`DQ_PER_DQS+j] < TDS) $display ("%m: at time %t ERROR: tDS violation on DQ bit %d by %t", $time, i*`DQ_PER_DQS+j, tm_dq[(i%16)*`DQ_PER_DQS+j] + TDS - $time); check_dq_tdipw[(i%16)*`DQ_PER_DQS+j] <= 1'b1; end end check_dm_tdipw[i%16] <= 1'b1; tm_dqs[i%16] <= $time; end else begin $display ("%m: at time %t ERROR: Invalid latching edge on %s bit %d", $time, dqs_string[i/16], i%16); end end check_write_dqs_high[i] <= 1'b0; tm_dqs_neg[i] = $time; prev_dqs_in[i] <= dqs_in[i]; end endtask always @(negedge dqs_in[ 0]) dqs_neg_timing_check( 0); always @(negedge dqs_in[ 1]) dqs_neg_timing_check( 1); always @(negedge dqs_in[ 2]) dqs_neg_timing_check( 2); always @(negedge dqs_in[ 3]) dqs_neg_timing_check( 3); always @(negedge dqs_in[ 4]) dqs_neg_timing_check( 4); always @(negedge dqs_in[ 5]) dqs_neg_timing_check( 5); always @(negedge dqs_in[ 6]) dqs_neg_timing_check( 6); always @(negedge dqs_in[ 7]) dqs_neg_timing_check( 7); always @(negedge dqs_in[ 8]) dqs_neg_timing_check( 8); always @(negedge dqs_in[ 9]) dqs_neg_timing_check( 9); always @(negedge dqs_in[10]) dqs_neg_timing_check(10); always @(negedge dqs_in[11]) dqs_neg_timing_check(11); always @(negedge dqs_in[12]) dqs_neg_timing_check(12); always @(negedge dqs_in[13]) dqs_neg_timing_check(13); always @(negedge dqs_in[14]) dqs_neg_timing_check(14); always @(negedge dqs_in[15]) dqs_neg_timing_check(15); always @(posedge dqs_in[16]) dqs_neg_timing_check(16); always @(posedge dqs_in[17]) dqs_neg_timing_check(17); always @(posedge dqs_in[18]) dqs_neg_timing_check(18); always @(posedge dqs_in[19]) dqs_neg_timing_check(19); always @(posedge dqs_in[20]) dqs_neg_timing_check(20); always @(posedge dqs_in[21]) dqs_neg_timing_check(21); always @(posedge dqs_in[22]) dqs_neg_timing_check(22); always @(posedge dqs_in[23]) dqs_neg_timing_check(23); always @(posedge dqs_in[24]) dqs_neg_timing_check(24); always @(posedge dqs_in[25]) dqs_neg_timing_check(25); always @(posedge dqs_in[26]) dqs_neg_timing_check(26); always @(posedge dqs_in[27]) dqs_neg_timing_check(27); always @(posedge dqs_in[28]) dqs_neg_timing_check(28); always @(posedge dqs_in[29]) dqs_neg_timing_check(29); always @(posedge dqs_in[30]) dqs_neg_timing_check(30); always @(posedge dqs_in[31]) dqs_neg_timing_check(31); endmodule
module t (clk); input clk; reg [31:0] r32; wire [3:0] w4; wire [4:0] w5; assign w4 = NUMONES_8 ( r32[7:0] ); assign w5 = NUMONES_16( r32[15:0] ); function [3:0] NUMONES_8; input [7:0] i8; reg [7:0] i8; begin NUMONES_8 = 4'b1; end endfunction // NUMONES_8 function [4:0] NUMONES_16; input [15:0] i16; reg [15:0] i16; begin NUMONES_16 = ( NUMONES_8( i16[7:0] ) + NUMONES_8( i16[15:8] )); end endfunction integer cyc; initial cyc=1; always @ (posedge clk) begin if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin r32 <= 32'h12345678; end if (cyc==2) begin if (w4 !== 1) $stop; if (w5 !== 2) $stop; $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // Take CRC data and apply to testblock inputs wire [9:0] in = crc[9:0]; /*AUTOWIRE*/ Test test (/*AUTOINST*/ // Inputs .clk (clk), .in (in[9:0])); // Aggregate outputs into a single result vector wire [63:0] result = {64'h0}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h0 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Inputs clk, in ); input clk; input [9:0] in; reg a [9:0]; integer ai; always @* begin for (ai=0;ai<10;ai=ai+1) begin a[ai]=in[ai]; end end reg [1:0] b [9:0]; integer j; generate genvar i; for (i=0; i<2; i=i+1) begin always @(posedge clk) begin for (j=0; j<10; j=j+1) begin if (a[j]) b[i][j] <= 1'b0; else b[i][j] <= 1'b1; end end end endgenerate endmodule
module outputs) wire [31:0] out; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .out (out[31:0]), // Inputs .clk (clk), .in (in[2:0])); // Aggregate outputs into a single result vector wire [63:0] result = {32'h0, out}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h704ca23e2a83e1c5 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module to apply values to the inputs and // merge the output values into the result vector. input clk; input [2:0] in; output reg [31:0] out; localparam ST_0 = 0; localparam ST_1 = 1; localparam ST_2 = 2; always @(posedge clk) begin case (1'b1) // synopsys parallel_case in[ST_0]: out <= 32'h1234; in[ST_1]: out <= 32'h4356; in[ST_2]: out <= 32'h9874; default: out <= 32'h1; endcase end endmodule
module outputs) wire [31:0] out; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .out (out[31:0]), // Inputs .clk (clk), .in (in[2:0])); // Aggregate outputs into a single result vector wire [63:0] result = {32'h0, out}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h704ca23e2a83e1c5 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module to apply values to the inputs and // merge the output values into the result vector. input clk; input [2:0] in; output reg [31:0] out; localparam ST_0 = 0; localparam ST_1 = 1; localparam ST_2 = 2; always @(posedge clk) begin case (1'b1) // synopsys parallel_case in[ST_0]: out <= 32'h1234; in[ST_1]: out <= 32'h4356; in[ST_2]: out <= 32'h9874; default: out <= 32'h1; endcase end endmodule
module outputs) threeansi_t outa; // From testa of TestAnsi.v three_t outna; // From test of TestNonAnsi.v // End of automatics TestNonAnsi test (// Outputs .out (outna), /*AUTOINST*/ // Inputs .clk (clk), .in (in)); TestAnsi testa (// Outputs .out (outa), /*AUTOINST*/ // Inputs .clk (clk), .in (in)); // Aggregate outputs into a single result vector wire [63:0] result = {57'h0, outna, 1'b0, outa}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h018decfea0a8828a if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module TestNonAnsi (/*AUTOARG*/ // Outputs out, // Inputs clk, in ); typedef reg [2:0] three_t; input clk; input three_t in; output three_t out; always @(posedge clk) begin out <= ~in; end endmodule
module TestAnsi ( input clk, input threeansi_t in, output threeansi_t out ); always @(posedge clk) begin out <= ~in; end endmodule
module outputs) threeansi_t outa; // From testa of TestAnsi.v three_t outna; // From test of TestNonAnsi.v // End of automatics TestNonAnsi test (// Outputs .out (outna), /*AUTOINST*/ // Inputs .clk (clk), .in (in)); TestAnsi testa (// Outputs .out (outa), /*AUTOINST*/ // Inputs .clk (clk), .in (in)); // Aggregate outputs into a single result vector wire [63:0] result = {57'h0, outna, 1'b0, outa}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h018decfea0a8828a if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module TestNonAnsi (/*AUTOARG*/ // Outputs out, // Inputs clk, in ); typedef reg [2:0] three_t; input clk; input three_t in; output three_t out; always @(posedge clk) begin out <= ~in; end endmodule
module TestAnsi ( input clk, input threeansi_t in, output threeansi_t out ); always @(posedge clk) begin out <= ~in; end endmodule
module outputs) threeansi_t outa; // From testa of TestAnsi.v three_t outna; // From test of TestNonAnsi.v // End of automatics TestNonAnsi test (// Outputs .out (outna), /*AUTOINST*/ // Inputs .clk (clk), .in (in)); TestAnsi testa (// Outputs .out (outa), /*AUTOINST*/ // Inputs .clk (clk), .in (in)); // Aggregate outputs into a single result vector wire [63:0] result = {57'h0, outna, 1'b0, outa}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h018decfea0a8828a if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module TestNonAnsi (/*AUTOARG*/ // Outputs out, // Inputs clk, in ); typedef reg [2:0] three_t; input clk; input three_t in; output three_t out; always @(posedge clk) begin out <= ~in; end endmodule
module TestAnsi ( input clk, input threeansi_t in, output threeansi_t out ); always @(posedge clk) begin out <= ~in; end endmodule
module outputs) // End of automatics reg clkgate_e2r; reg clkgate_e1r_l; always @(posedge clk or negedge reset_l) begin if (!reset_l) begin clkgate_e1r_l <= ~1'b1; end else begin clkgate_e1r_l <= ~clkgate_e2r; end end reg clkgate_e1f; always @(negedge clk) begin // Yes, it's really a = clkgate_e1f = ~clkgate_e1r_l | ~reset_l; end wire clkgated = clk & clkgate_e1f; reg [31:0] countgated; always @(posedge clkgated or negedge reset_l) begin if (!reset_l) begin countgated <= 32'h1000; end else begin countgated <= countgated + 32'd1; end end reg [31:0] count; always @(posedge clk or negedge reset_l) begin if (!reset_l) begin count <= 32'h1000; end else begin count <= count + 32'd1; end end reg [7:0] cyc; initial cyc=0; always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] rs %x cyc %d cg1f %x cnt %x cg %x\n",$time,reset_l,cyc,clkgate_e1f,count,countgated); `endif cyc <= cyc + 8'd1; case (cyc) 8'd00: begin reset_l <= ~1'b0; clkgate_e2r <= 1'b1; end 8'd01: begin reset_l <= ~1'b0; end 8'd02: begin end 8'd03: begin reset_l <= ~1'b1; // Need a posedge end 8'd04: begin end 8'd05: begin reset_l <= ~1'b0; end 8'd09: begin clkgate_e2r <= 1'b0; end 8'd11: begin clkgate_e2r <= 1'b1; end 8'd20: begin $write("*-* All Finished *-*\n"); $finish; end default: ; endcase case (cyc) 8'd00: ; 8'd01: ; 8'd02: ; 8'd03: ; 8'd04: if (count!=32'h00001000 || countgated!=32'h 00001000) $stop; 8'd05: if (count!=32'h00001000 || countgated!=32'h 00001000) $stop; 8'd06: if (count!=32'h00001000 || countgated!=32'h 00001000) $stop; 8'd07: if (count!=32'h00001001 || countgated!=32'h 00001001) $stop; 8'd08: if (count!=32'h00001002 || countgated!=32'h 00001002) $stop; 8'd09: if (count!=32'h00001003 || countgated!=32'h 00001003) $stop; 8'd10: if (count!=32'h00001004 || countgated!=32'h 00001004) $stop; 8'd11: if (count!=32'h00001005 || countgated!=32'h 00001005) $stop; 8'd12: if (count!=32'h00001006 || countgated!=32'h 00001005) $stop; 8'd13: if (count!=32'h00001007 || countgated!=32'h 00001005) $stop; 8'd14: if (count!=32'h00001008 || countgated!=32'h 00001006) $stop; 8'd15: if (count!=32'h00001009 || countgated!=32'h 00001007) $stop; 8'd16: if (count!=32'h0000100a || countgated!=32'h 00001008) $stop; 8'd17: if (count!=32'h0000100b || countgated!=32'h 00001009) $stop; 8'd18: if (count!=32'h0000100c || countgated!=32'h 0000100a) $stop; 8'd19: if (count!=32'h0000100d || countgated!=32'h 0000100b) $stop; 8'd20: if (count!=32'h0000100e || countgated!=32'h 0000100c) $stop; default: $stop; endcase end endmodule
module outputs) wire [2:0] pos1; // From test of Test.v wire [2:0] pos2; // From test of Test.v // End of automatics Test test ( // Outputs .pos1 (pos1[2:0]), .pos2 (pos2[2:0]), /*AUTOINST*/ // Inputs .clk (clk), .rst_n (rst_n)); // Aggregate outputs into a single result vector wire [63:0] result = {61'h0, pos1}; // What checksum will we end up with `define EXPECTED_SUM 64'h039ea4d039c2e70b // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; rst_n <= ~1'b0; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; rst_n <= ~1'b1; end else if (cyc<10) begin sum <= 64'h0; rst_n <= ~1'b1; end else if (cyc<90) begin if (pos1 !== pos2) $stop; end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test #(parameter SAMPLE_WIDTH = 5 ) ( `ifdef verilator // Some simulators don't support clog2 output reg [$clog2(SAMPLE_WIDTH)-1:0] pos1, `else output reg [log2(SAMPLE_WIDTH-1)-1:0] pos1, `endif output reg [log2(SAMPLE_WIDTH-1)-1:0] pos2, // System input clk, input rst_n ); function integer log2(input integer arg); begin for(log2=0; arg>0; log2=log2+1) arg = (arg >> 1); end endfunction always @ (posedge clk or negedge rst_n) if (!rst_n) begin pos1 <= 0; pos2 <= 0; end else begin pos1 <= pos1 + 1; pos2 <= pos2 + 1; end endmodule
module's undeclared outputs) reg [9:0] outq; // End of automatics // ============================= always @(/*AS*/index) begin case (index) // default below: no change 8'h00: begin outq = 10'h001; end 8'he0: begin outq = 10'h05b; end 8'he1: begin outq = 10'h126; end 8'he2: begin outq = 10'h369; end 8'he3: begin outq = 10'h291; end 8'he4: begin outq = 10'h2ca; end 8'he5: begin outq = 10'h25b; end 8'he6: begin outq = 10'h106; end 8'he7: begin outq = 10'h172; end 8'he8: begin outq = 10'h2f7; end 8'he9: begin outq = 10'h2d3; end 8'hea: begin outq = 10'h182; end 8'heb: begin outq = 10'h327; end 8'hec: begin outq = 10'h1d0; end 8'hed: begin outq = 10'h204; end 8'hee: begin outq = 10'h11f; end 8'hef: begin outq = 10'h365; end 8'hf0: begin outq = 10'h2c2; end 8'hf1: begin outq = 10'h2b5; end 8'hf2: begin outq = 10'h1f8; end 8'hf3: begin outq = 10'h2a7; end 8'hf4: begin outq = 10'h1be; end 8'hf5: begin outq = 10'h25e; end 8'hf6: begin outq = 10'h032; end 8'hf7: begin outq = 10'h2ef; end 8'hf8: begin outq = 10'h02f; end 8'hf9: begin outq = 10'h201; end 8'hfa: begin outq = 10'h054; end 8'hfb: begin outq = 10'h013; end 8'hfc: begin outq = 10'h249; end 8'hfd: begin outq = 10'h09a; end 8'hfe: begin outq = 10'h012; end 8'hff: begin outq = 10'h114; end default: ; // No change endcase end endmodule
module's undeclared outputs) reg [9:0] outq; // End of automatics // ============================= always @(/*AS*/index) begin case (index) // default below: no change 8'h00: begin outq = 10'h001; end 8'he0: begin outq = 10'h05b; end 8'he1: begin outq = 10'h126; end 8'he2: begin outq = 10'h369; end 8'he3: begin outq = 10'h291; end 8'he4: begin outq = 10'h2ca; end 8'he5: begin outq = 10'h25b; end 8'he6: begin outq = 10'h106; end 8'he7: begin outq = 10'h172; end 8'he8: begin outq = 10'h2f7; end 8'he9: begin outq = 10'h2d3; end 8'hea: begin outq = 10'h182; end 8'heb: begin outq = 10'h327; end 8'hec: begin outq = 10'h1d0; end 8'hed: begin outq = 10'h204; end 8'hee: begin outq = 10'h11f; end 8'hef: begin outq = 10'h365; end 8'hf0: begin outq = 10'h2c2; end 8'hf1: begin outq = 10'h2b5; end 8'hf2: begin outq = 10'h1f8; end 8'hf3: begin outq = 10'h2a7; end 8'hf4: begin outq = 10'h1be; end 8'hf5: begin outq = 10'h25e; end 8'hf6: begin outq = 10'h032; end 8'hf7: begin outq = 10'h2ef; end 8'hf8: begin outq = 10'h02f; end 8'hf9: begin outq = 10'h201; end 8'hfa: begin outq = 10'h054; end 8'hfb: begin outq = 10'h013; end 8'hfc: begin outq = 10'h249; end 8'hfd: begin outq = 10'h09a; end 8'hfe: begin outq = 10'h012; end 8'hff: begin outq = 10'h114; end default: ; // No change endcase end endmodule
module main_pll (// Clock in ports input CLK_IN1, // Clock out ports output CLK_OUT1 ); // Input buffering //------------------------------------ IBUFG clkin1_buf (.O (clkin1), .I (CLK_IN1)); // Clocking primitive //------------------------------------ // Instantiation of the DCM primitive // * Unused inputs are tied off // * Unused outputs are labeled unused wire psdone_unused; wire locked_int; wire [7:0] status_int; wire clkfb; wire clk0; wire clkfx; DCM_SP #(.CLKDV_DIVIDE (2.000), .CLKFX_DIVIDE (10), .CLKFX_MULTIPLY (15), .CLKIN_DIVIDE_BY_2 ("FALSE"), .CLKIN_PERIOD (10.0), .CLKOUT_PHASE_SHIFT ("NONE"), .CLK_FEEDBACK ("NONE"), .DESKEW_ADJUST ("SYSTEM_SYNCHRONOUS"), .PHASE_SHIFT (0), .STARTUP_WAIT ("FALSE")) dcm_sp_inst // Input clock (.CLKIN (clkin1), .CLKFB (clkfb), // Output clocks .CLK0 (clk0), .CLK90 (), .CLK180 (), .CLK270 (), .CLK2X (), .CLK2X180 (), .CLKFX (clkfx), .CLKFX180 (), .CLKDV (), // Ports for dynamic phase shift .PSCLK (1'b0), .PSEN (1'b0), .PSINCDEC (1'b0), .PSDONE (), // Other control and status signals .LOCKED (locked_int), .STATUS (status_int), .RST (1'b0), // Unused pin- tie low .DSSEN (1'b0)); // Output buffering //----------------------------------- // no phase alignment active, connect to ground assign clkfb = 1'b0; BUFG clkout1_buf (.O (CLK_OUT1), .I (clkfx)); endmodule
module main_pll (// Clock in ports input CLK_IN1, // Clock out ports output CLK_OUT1 ); // Input buffering //------------------------------------ IBUFG clkin1_buf (.O (clkin1), .I (CLK_IN1)); // Clocking primitive //------------------------------------ // Instantiation of the DCM primitive // * Unused inputs are tied off // * Unused outputs are labeled unused wire psdone_unused; wire locked_int; wire [7:0] status_int; wire clkfb; wire clk0; wire clkfx; DCM_SP #(.CLKDV_DIVIDE (2.000), .CLKFX_DIVIDE (10), .CLKFX_MULTIPLY (15), .CLKIN_DIVIDE_BY_2 ("FALSE"), .CLKIN_PERIOD (10.0), .CLKOUT_PHASE_SHIFT ("NONE"), .CLK_FEEDBACK ("NONE"), .DESKEW_ADJUST ("SYSTEM_SYNCHRONOUS"), .PHASE_SHIFT (0), .STARTUP_WAIT ("FALSE")) dcm_sp_inst // Input clock (.CLKIN (clkin1), .CLKFB (clkfb), // Output clocks .CLK0 (clk0), .CLK90 (), .CLK180 (), .CLK270 (), .CLK2X (), .CLK2X180 (), .CLKFX (clkfx), .CLKFX180 (), .CLKDV (), // Ports for dynamic phase shift .PSCLK (1'b0), .PSEN (1'b0), .PSINCDEC (1'b0), .PSDONE (), // Other control and status signals .LOCKED (locked_int), .STATUS (status_int), .RST (1'b0), // Unused pin- tie low .DSSEN (1'b0)); // Output buffering //----------------------------------- // no phase alignment active, connect to ground assign clkfb = 1'b0; BUFG clkout1_buf (.O (CLK_OUT1), .I (clkfx)); endmodule
module outputs) wire [9:0] outa0; // From s0 of t_case_huge_sub.v wire [9:0] outa1; // From s1 of t_case_huge_sub.v wire [9:0] outa2; // From s2 of t_case_huge_sub.v wire [9:0] outa3; // From s3 of t_case_huge_sub.v wire [9:0] outa4; // From s4 of t_case_huge_sub.v wire [9:0] outa5; // From s5 of t_case_huge_sub.v wire [9:0] outa6; // From s6 of t_case_huge_sub.v wire [9:0] outa7; // From s7 of t_case_huge_sub.v wire [1:0] outb0; // From s0 of t_case_huge_sub.v wire [1:0] outb1; // From s1 of t_case_huge_sub.v wire [1:0] outb2; // From s2 of t_case_huge_sub.v wire [1:0] outb3; // From s3 of t_case_huge_sub.v wire [1:0] outb4; // From s4 of t_case_huge_sub.v wire [1:0] outb5; // From s5 of t_case_huge_sub.v wire [1:0] outb6; // From s6 of t_case_huge_sub.v wire [1:0] outb7; // From s7 of t_case_huge_sub.v wire outc0; // From s0 of t_case_huge_sub.v wire outc1; // From s1 of t_case_huge_sub.v wire outc2; // From s2 of t_case_huge_sub.v wire outc3; // From s3 of t_case_huge_sub.v wire outc4; // From s4 of t_case_huge_sub.v wire outc5; // From s5 of t_case_huge_sub.v wire outc6; // From s6 of t_case_huge_sub.v wire outc7; // From s7 of t_case_huge_sub.v wire [9:0] outq; // From q of t_case_huge_sub4.v wire [3:0] outr; // From sub3 of t_case_huge_sub3.v wire [9:0] outsmall; // From sub2 of t_case_huge_sub2.v // End of automatics t_case_huge_sub2 sub2 ( // Outputs .outa (outsmall[9:0]), /*AUTOINST*/ // Inputs .index (index[9:0])); t_case_huge_sub3 sub3 (/*AUTOINST*/ // Outputs .outr (outr[3:0]), // Inputs .clk (clk), .index (index[9:0])); /* t_case_huge_sub AUTO_TEMPLATE ( .outa (outa@[]), .outb (outb@[]), .outc (outc@[]), .index (index@[])); */ t_case_huge_sub s0 (/*AUTOINST*/ // Outputs .outa (outa0[9:0]), // Templated .outb (outb0[1:0]), // Templated .outc (outc0), // Templated // Inputs .index (index0[7:0])); // Templated t_case_huge_sub s1 (/*AUTOINST*/ // Outputs .outa (outa1[9:0]), // Templated .outb (outb1[1:0]), // Templated .outc (outc1), // Templated // Inputs .index (index1[7:0])); // Templated t_case_huge_sub s2 (/*AUTOINST*/ // Outputs .outa (outa2[9:0]), // Templated .outb (outb2[1:0]), // Templated .outc (outc2), // Templated // Inputs .index (index2[7:0])); // Templated t_case_huge_sub s3 (/*AUTOINST*/ // Outputs .outa (outa3[9:0]), // Templated .outb (outb3[1:0]), // Templated .outc (outc3), // Templated // Inputs .index (index3[7:0])); // Templated t_case_huge_sub s4 (/*AUTOINST*/ // Outputs .outa (outa4[9:0]), // Templated .outb (outb4[1:0]), // Templated .outc (outc4), // Templated // Inputs .index (index4[7:0])); // Templated t_case_huge_sub s5 (/*AUTOINST*/ // Outputs .outa (outa5[9:0]), // Templated .outb (outb5[1:0]), // Templated .outc (outc5), // Templated // Inputs .index (index5[7:0])); // Templated t_case_huge_sub s6 (/*AUTOINST*/ // Outputs .outa (outa6[9:0]), // Templated .outb (outb6[1:0]), // Templated .outc (outc6), // Templated // Inputs .index (index6[7:0])); // Templated t_case_huge_sub s7 (/*AUTOINST*/ // Outputs .outa (outa7[9:0]), // Templated .outb (outb7[1:0]), // Templated .outc (outc7), // Templated // Inputs .index (index7[7:0])); // Templated t_case_huge_sub4 q (/*AUTOINST*/ // Outputs .outq (outq[9:0]), // Inputs .index (index[7:0])); integer cyc; initial cyc=1; initial index = 10'h0; always @ (posedge clk) begin if (cyc!=0) begin cyc <= cyc + 1; //$write("%x: %x\n",cyc,outr); //$write("%x: %x %x %x %x\n", cyc, outa1,outb1,outc1,index1); if (cyc==1) begin index <= 10'h236; end if (cyc==2) begin index <= 10'h022; if (outsmall != 10'h282) $stop; if (outr != 4'b0) $stop; if ({outa0,outb0,outc0}!={10'h282,2'd3,1'b0}) $stop; if ({outa1,outb1,outc1}!={10'h21c,2'd3,1'b1}) $stop; if ({outa2,outb2,outc2}!={10'h148,2'd0,1'b1}) $stop; if ({outa3,outb3,outc3}!={10'h3c0,2'd2,1'b0}) $stop; if ({outa4,outb4,outc4}!={10'h176,2'd1,1'b1}) $stop; if ({outa5,outb5,outc5}!={10'h3fc,2'd2,1'b1}) $stop; if ({outa6,outb6,outc6}!={10'h295,2'd3,1'b1}) $stop; if ({outa7,outb7,outc7}!={10'h113,2'd2,1'b1}) $stop; if (outq != 10'h001) $stop; end if (cyc==3) begin index <= 10'h165; if (outsmall != 10'h191) $stop; if (outr != 4'h5) $stop; if ({outa1,outb1,outc1}!={10'h379,2'd1,1'b0}) $stop; if ({outa2,outb2,outc2}!={10'h073,2'd0,1'b0}) $stop; if ({outa3,outb3,outc3}!={10'h2fd,2'd3,1'b1}) $stop; if ({outa4,outb4,outc4}!={10'h2e0,2'd3,1'b1}) $stop; if ({outa5,outb5,outc5}!={10'h337,2'd1,1'b1}) $stop; if ({outa6,outb6,outc6}!={10'h2c7,2'd3,1'b1}) $stop; if ({outa7,outb7,outc7}!={10'h19e,2'd3,1'b0}) $stop; if (outq != 10'h001) $stop; end if (cyc==4) begin index <= 10'h201; if (outsmall != 10'h268) $stop; if (outr != 4'h2) $stop; if ({outa1,outb1,outc1}!={10'h111,2'd1,1'b0}) $stop; if ({outa2,outb2,outc2}!={10'h1f9,2'd0,1'b0}) $stop; if ({outa3,outb3,outc3}!={10'h232,2'd0,1'b1}) $stop; if ({outa4,outb4,outc4}!={10'h255,2'd3,1'b0}) $stop; if ({outa5,outb5,outc5}!={10'h34c,2'd1,1'b1}) $stop; if ({outa6,outb6,outc6}!={10'h049,2'd1,1'b1}) $stop; if ({outa7,outb7,outc7}!={10'h197,2'd3,1'b0}) $stop; if (outq != 10'h001) $stop; end if (cyc==5) begin index <= 10'h3ff; if (outr != 4'hd) $stop; if (outq != 10'h001) $stop; end if (cyc==6) begin index <= 10'h0; if (outr != 4'hd) $stop; if (outq != 10'h114) $stop; end if (cyc==7) begin if (outr != 4'h4) $stop; end if (cyc==9) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module outputs) wire [9:0] outa0; // From s0 of t_case_huge_sub.v wire [9:0] outa1; // From s1 of t_case_huge_sub.v wire [9:0] outa2; // From s2 of t_case_huge_sub.v wire [9:0] outa3; // From s3 of t_case_huge_sub.v wire [9:0] outa4; // From s4 of t_case_huge_sub.v wire [9:0] outa5; // From s5 of t_case_huge_sub.v wire [9:0] outa6; // From s6 of t_case_huge_sub.v wire [9:0] outa7; // From s7 of t_case_huge_sub.v wire [1:0] outb0; // From s0 of t_case_huge_sub.v wire [1:0] outb1; // From s1 of t_case_huge_sub.v wire [1:0] outb2; // From s2 of t_case_huge_sub.v wire [1:0] outb3; // From s3 of t_case_huge_sub.v wire [1:0] outb4; // From s4 of t_case_huge_sub.v wire [1:0] outb5; // From s5 of t_case_huge_sub.v wire [1:0] outb6; // From s6 of t_case_huge_sub.v wire [1:0] outb7; // From s7 of t_case_huge_sub.v wire outc0; // From s0 of t_case_huge_sub.v wire outc1; // From s1 of t_case_huge_sub.v wire outc2; // From s2 of t_case_huge_sub.v wire outc3; // From s3 of t_case_huge_sub.v wire outc4; // From s4 of t_case_huge_sub.v wire outc5; // From s5 of t_case_huge_sub.v wire outc6; // From s6 of t_case_huge_sub.v wire outc7; // From s7 of t_case_huge_sub.v wire [9:0] outq; // From q of t_case_huge_sub4.v wire [3:0] outr; // From sub3 of t_case_huge_sub3.v wire [9:0] outsmall; // From sub2 of t_case_huge_sub2.v // End of automatics t_case_huge_sub2 sub2 ( // Outputs .outa (outsmall[9:0]), /*AUTOINST*/ // Inputs .index (index[9:0])); t_case_huge_sub3 sub3 (/*AUTOINST*/ // Outputs .outr (outr[3:0]), // Inputs .clk (clk), .index (index[9:0])); /* t_case_huge_sub AUTO_TEMPLATE ( .outa (outa@[]), .outb (outb@[]), .outc (outc@[]), .index (index@[])); */ t_case_huge_sub s0 (/*AUTOINST*/ // Outputs .outa (outa0[9:0]), // Templated .outb (outb0[1:0]), // Templated .outc (outc0), // Templated // Inputs .index (index0[7:0])); // Templated t_case_huge_sub s1 (/*AUTOINST*/ // Outputs .outa (outa1[9:0]), // Templated .outb (outb1[1:0]), // Templated .outc (outc1), // Templated // Inputs .index (index1[7:0])); // Templated t_case_huge_sub s2 (/*AUTOINST*/ // Outputs .outa (outa2[9:0]), // Templated .outb (outb2[1:0]), // Templated .outc (outc2), // Templated // Inputs .index (index2[7:0])); // Templated t_case_huge_sub s3 (/*AUTOINST*/ // Outputs .outa (outa3[9:0]), // Templated .outb (outb3[1:0]), // Templated .outc (outc3), // Templated // Inputs .index (index3[7:0])); // Templated t_case_huge_sub s4 (/*AUTOINST*/ // Outputs .outa (outa4[9:0]), // Templated .outb (outb4[1:0]), // Templated .outc (outc4), // Templated // Inputs .index (index4[7:0])); // Templated t_case_huge_sub s5 (/*AUTOINST*/ // Outputs .outa (outa5[9:0]), // Templated .outb (outb5[1:0]), // Templated .outc (outc5), // Templated // Inputs .index (index5[7:0])); // Templated t_case_huge_sub s6 (/*AUTOINST*/ // Outputs .outa (outa6[9:0]), // Templated .outb (outb6[1:0]), // Templated .outc (outc6), // Templated // Inputs .index (index6[7:0])); // Templated t_case_huge_sub s7 (/*AUTOINST*/ // Outputs .outa (outa7[9:0]), // Templated .outb (outb7[1:0]), // Templated .outc (outc7), // Templated // Inputs .index (index7[7:0])); // Templated t_case_huge_sub4 q (/*AUTOINST*/ // Outputs .outq (outq[9:0]), // Inputs .index (index[7:0])); integer cyc; initial cyc=1; initial index = 10'h0; always @ (posedge clk) begin if (cyc!=0) begin cyc <= cyc + 1; //$write("%x: %x\n",cyc,outr); //$write("%x: %x %x %x %x\n", cyc, outa1,outb1,outc1,index1); if (cyc==1) begin index <= 10'h236; end if (cyc==2) begin index <= 10'h022; if (outsmall != 10'h282) $stop; if (outr != 4'b0) $stop; if ({outa0,outb0,outc0}!={10'h282,2'd3,1'b0}) $stop; if ({outa1,outb1,outc1}!={10'h21c,2'd3,1'b1}) $stop; if ({outa2,outb2,outc2}!={10'h148,2'd0,1'b1}) $stop; if ({outa3,outb3,outc3}!={10'h3c0,2'd2,1'b0}) $stop; if ({outa4,outb4,outc4}!={10'h176,2'd1,1'b1}) $stop; if ({outa5,outb5,outc5}!={10'h3fc,2'd2,1'b1}) $stop; if ({outa6,outb6,outc6}!={10'h295,2'd3,1'b1}) $stop; if ({outa7,outb7,outc7}!={10'h113,2'd2,1'b1}) $stop; if (outq != 10'h001) $stop; end if (cyc==3) begin index <= 10'h165; if (outsmall != 10'h191) $stop; if (outr != 4'h5) $stop; if ({outa1,outb1,outc1}!={10'h379,2'd1,1'b0}) $stop; if ({outa2,outb2,outc2}!={10'h073,2'd0,1'b0}) $stop; if ({outa3,outb3,outc3}!={10'h2fd,2'd3,1'b1}) $stop; if ({outa4,outb4,outc4}!={10'h2e0,2'd3,1'b1}) $stop; if ({outa5,outb5,outc5}!={10'h337,2'd1,1'b1}) $stop; if ({outa6,outb6,outc6}!={10'h2c7,2'd3,1'b1}) $stop; if ({outa7,outb7,outc7}!={10'h19e,2'd3,1'b0}) $stop; if (outq != 10'h001) $stop; end if (cyc==4) begin index <= 10'h201; if (outsmall != 10'h268) $stop; if (outr != 4'h2) $stop; if ({outa1,outb1,outc1}!={10'h111,2'd1,1'b0}) $stop; if ({outa2,outb2,outc2}!={10'h1f9,2'd0,1'b0}) $stop; if ({outa3,outb3,outc3}!={10'h232,2'd0,1'b1}) $stop; if ({outa4,outb4,outc4}!={10'h255,2'd3,1'b0}) $stop; if ({outa5,outb5,outc5}!={10'h34c,2'd1,1'b1}) $stop; if ({outa6,outb6,outc6}!={10'h049,2'd1,1'b1}) $stop; if ({outa7,outb7,outc7}!={10'h197,2'd3,1'b0}) $stop; if (outq != 10'h001) $stop; end if (cyc==5) begin index <= 10'h3ff; if (outr != 4'hd) $stop; if (outq != 10'h001) $stop; end if (cyc==6) begin index <= 10'h0; if (outr != 4'hd) $stop; if (outq != 10'h114) $stop; end if (cyc==7) begin if (outr != 4'h4) $stop; end if (cyc==9) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg posedge_wr_clocks; reg prev_wr_clocks; reg [31:0] m_din; reg [31:0] m_dout; always @(negedge clk) begin prev_wr_clocks = 0; end reg comb_pos_1; reg comb_prev_1; always @ (/*AS*/clk or posedge_wr_clocks or prev_wr_clocks) begin comb_pos_1 = (clk &~ prev_wr_clocks); comb_prev_1 = comb_pos_1 | posedge_wr_clocks; comb_pos_1 = 1'b1; end always @ (posedge clk) begin posedge_wr_clocks = (clk &~ prev_wr_clocks); //surefire lint_off_line SEQASS prev_wr_clocks = prev_wr_clocks | posedge_wr_clocks; //surefire lint_off_line SEQASS if (posedge_wr_clocks) begin //$write("[%0t] Wrclk\n", $time); m_dout <= m_din; end end always @ (posedge clk) begin if (cyc!=0) begin cyc<=cyc+1; if (cyc==1) begin $write(" %x\n",comb_pos_1); m_din <= 32'hfeed; end if (cyc==2) begin $write(" %x\n",comb_pos_1); m_din <= 32'he11e; end if (cyc==3) begin m_din <= 32'he22e; $write(" %x\n",comb_pos_1); if (m_dout!=32'hfeed) $stop; end if (cyc==4) begin if (m_dout!=32'he11e) $stop; $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg posedge_wr_clocks; reg prev_wr_clocks; reg [31:0] m_din; reg [31:0] m_dout; always @(negedge clk) begin prev_wr_clocks = 0; end reg comb_pos_1; reg comb_prev_1; always @ (/*AS*/clk or posedge_wr_clocks or prev_wr_clocks) begin comb_pos_1 = (clk &~ prev_wr_clocks); comb_prev_1 = comb_pos_1 | posedge_wr_clocks; comb_pos_1 = 1'b1; end always @ (posedge clk) begin posedge_wr_clocks = (clk &~ prev_wr_clocks); //surefire lint_off_line SEQASS prev_wr_clocks = prev_wr_clocks | posedge_wr_clocks; //surefire lint_off_line SEQASS if (posedge_wr_clocks) begin //$write("[%0t] Wrclk\n", $time); m_dout <= m_din; end end always @ (posedge clk) begin if (cyc!=0) begin cyc<=cyc+1; if (cyc==1) begin $write(" %x\n",comb_pos_1); m_din <= 32'hfeed; end if (cyc==2) begin $write(" %x\n",comb_pos_1); m_din <= 32'he11e; end if (cyc==3) begin m_din <= 32'he22e; $write(" %x\n",comb_pos_1); if (m_dout!=32'hfeed) $stop; end if (cyc==4) begin if (m_dout!=32'he11e) $stop; $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; reg posedge_wr_clocks; reg prev_wr_clocks; reg [31:0] m_din; reg [31:0] m_dout; always @(negedge clk) begin prev_wr_clocks = 0; end reg comb_pos_1; reg comb_prev_1; always @ (/*AS*/clk or posedge_wr_clocks or prev_wr_clocks) begin comb_pos_1 = (clk &~ prev_wr_clocks); comb_prev_1 = comb_pos_1 | posedge_wr_clocks; comb_pos_1 = 1'b1; end always @ (posedge clk) begin posedge_wr_clocks = (clk &~ prev_wr_clocks); //surefire lint_off_line SEQASS prev_wr_clocks = prev_wr_clocks | posedge_wr_clocks; //surefire lint_off_line SEQASS if (posedge_wr_clocks) begin //$write("[%0t] Wrclk\n", $time); m_dout <= m_din; end end always @ (posedge clk) begin if (cyc!=0) begin cyc<=cyc+1; if (cyc==1) begin $write(" %x\n",comb_pos_1); m_din <= 32'hfeed; end if (cyc==2) begin $write(" %x\n",comb_pos_1); m_din <= 32'he11e; end if (cyc==3) begin m_din <= 32'he22e; $write(" %x\n",comb_pos_1); if (m_dout!=32'hfeed) $stop; end if (cyc==4) begin if (m_dout!=32'he11e) $stop; $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; // verilator lint_off WIDTH //============================================================ reg bad; initial begin bad=0; c96(96'h0_0000_0000_0000_0000, 96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0000, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0000, 96'h0_0000_0000_0000_0000, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0002, 96'h4_4444_4444_4444_4444, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_2000_0000_0000_0000, 96'h0_0000_0000_0000_0044, 96'h0_0888_8888_8888_8888); c96(96'h8_8888_8888_8888_8888, 96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0001, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h8_8888_8888_8888_8889, 96'h0_0000_0000_0000_0000, 96'h8_8888_8888_8888_8888); c96(96'h1_0000_0000_8eba_434a, 96'h0_0000_0000_0000_0001, 96'h1_0000_0000_8eba_434a, 96'h0); c96(96'h0003, 96'h0002, 96'h0001, 96'h0001); c96(96'h0003, 96'h0003, 96'h0001, 96'h0000); c96(96'h0003, 96'h0004, 96'h0000, 96'h0003); c96(96'h0000, 96'hffff, 96'h0000, 96'h0000); c96(96'hffff, 96'h0001, 96'hffff, 96'h0000); c96(96'hffff, 96'hffff, 96'h0001, 96'h0000); c96(96'hffff, 96'h0003, 96'h5555, 96'h0000); c96(96'hffff_ffff, 96'h0001, 96'hffff_ffff, 96'h0000); c96(96'hffff_ffff, 96'hffff, 96'h0001_0001, 96'h0000); c96(96'hfffe_ffff, 96'hffff, 96'h0000_ffff, 96'hfffe); c96(96'h1234_5678, 96'h9abc, 96'h0000_1e1e, 96'h2c70); c96(96'h0000_0000, 96'h0001_0000, 96'h0000, 96'h0000_0000); c96(96'h0007_0000, 96'h0003_0000, 96'h0002, 96'h0001_0000); c96(96'h0007_0005, 96'h0003_0000, 96'h0002, 96'h0001_0005); c96(96'h0006_0000, 96'h0002_0000, 96'h0003, 96'h0000_0000); c96(96'h8000_0001, 96'h4000_7000, 96'h0001, 96'h3fff_9001); c96(96'hbcde_789a, 96'hbcde_789a, 96'h0001, 96'h0000_0000); c96(96'hbcde_789b, 96'hbcde_789a, 96'h0001, 96'h0000_0001); c96(96'hbcde_7899, 96'hbcde_789a, 96'h0000, 96'hbcde_7899); c96(96'hffff_ffff, 96'hffff_ffff, 96'h0001, 96'h0000_0000); c96(96'hffff_ffff, 96'h0001_0000, 96'hffff, 96'h0000_ffff); c96(96'h0123_4567_89ab, 96'h0001_0000, 96'h0123_4567, 96'h0000_89ab); c96(96'h8000_fffe_0000, 96'h8000_ffff, 96'h0000_ffff, 96'h7fff_ffff); c96(96'h8000_0000_0003, 96'h2000_0000_0001, 96'h0003, 96'h2000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'h0001_0000_0000, 96'hffff_ffff, 96'h0000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'hffff_0000_0000, 96'h0001_0001, 96'h0000_0000_0000); c96(96'hfffe_ffff_0000_0000, 96'hffff_0000_0000, 96'h0000_ffff, 96'hfffe_0000_0000); c96(96'h1234_5678_0000_0000, 96'h9abc_0000_0000, 96'h0000_1e1e, 96'h2c70_0000_0000); c96(96'h0000_0000_0000_0000, 96'h0001_0000_0000_0000, 96'h0000, 96'h0000_0000_0000_0000); c96(96'h0007_0000_0000_0000, 96'h0003_0000_0000_0000, 96'h0002, 96'h0001_0000_0000_0000); c96(96'h0007_0005_0000_0000, 96'h0003_0000_0000_0000, 96'h0002, 96'h0001_0005_0000_0000); c96(96'h0006_0000_0000_0000, 96'h0002_0000_0000_0000, 96'h0003, 96'h0000_0000_0000_0000); c96(96'h8000_0001_0000_0000, 96'h4000_7000_0000_0000, 96'h0001, 96'h3fff_9001_0000_0000); c96(96'hbcde_789a_0000_0000, 96'hbcde_789a_0000_0000, 96'h0001, 96'h0000_0000_0000_0000); c96(96'hbcde_789b_0000_0000, 96'hbcde_789a_0000_0000, 96'h0001, 96'h0000_0001_0000_0000); c96(96'hbcde_7899_0000_0000, 96'hbcde_789a_0000_0000, 96'h0000, 96'hbcde_7899_0000_0000); c96(96'hffff_ffff_0000_0000, 96'hffff_ffff_0000_0000, 96'h0001, 96'h0000_0000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'h0001_0000_0000_0000, 96'hffff, 96'h0000_ffff_0000_0000); c96(96'h7fff_8000_0000_0000, 96'h8000_0000_0001, 96'h0000_fffe, 96'h7fff_ffff_0002); c96(96'h8000_0000_fffe_0000, 96'h8000_0000_ffff, 96'h0000_ffff, 96'h7fff_ffff_ffff); c96(96'h0008_8888_8888_8888_8888, 96'h0002_0000_0000_0000, 96'h0004_4444, 96'h0000_8888_8888_8888); if (bad) $stop; $write("*-* All Finished *-*\n"); $finish; end task c96; input [95:0] u; input [95:0] v; input [95:0] expq; input [95:0] expr; c96u( u, v, expq, expr); c96s( u, v, expq, expr); c96s(-u, v,-expq,-expr); c96s( u,-v,-expq, expr); c96s(-u,-v, expq,-expr); endtask task c96u; input [95:0] u; input [95:0] v; input [95:0] expq; input [95:0] expr; reg [95:0] gotq; reg [95:0] gotr; gotq = u/v; gotr = u%v; if (gotq != expq && v!=0) begin bad = 1; end if (gotr != expr && v!=0) begin bad = 1; end if (bad `ifdef TEST_VERBOSE || 1 `endif ) begin $write(" %x /u %x = got %x exp %x %% got %x exp %x", u,v,gotq,expq,gotr,expr); // Test for v=0 to prevent Xs causing grief if (gotq != expq && v!=0) $write(" BADQ"); if (gotr != expr && v!=0) $write(" BADR"); $write("\n"); end endtask task c96s; input signed [95:0] u; input signed [95:0] v; input signed [95:0] expq; input signed [95:0] expr; reg signed [95:0] gotq; reg signed [95:0] gotr; gotq = u/v; gotr = u%v; if (gotq != expq && v!=0) begin bad = 1; end if (gotr != expr && v!=0) begin bad = 1; end if (bad `ifdef TEST_VERBOSE || 1 `endif ) begin $write(" %x /s %x = got %x exp %x %% got %x exp %x", u,v,gotq,expq,gotr,expr); // Test for v=0 to prevent Xs causing grief if (gotq != expq && v!=0) $write(" BADQ"); if (gotr != expr && v!=0) $write(" BADR"); $write("\n"); end endtask endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; // verilator lint_off WIDTH //============================================================ reg bad; initial begin bad=0; c96(96'h0_0000_0000_0000_0000, 96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0000, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0000, 96'h0_0000_0000_0000_0000, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0002, 96'h4_4444_4444_4444_4444, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_2000_0000_0000_0000, 96'h0_0000_0000_0000_0044, 96'h0_0888_8888_8888_8888); c96(96'h8_8888_8888_8888_8888, 96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0001, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h8_8888_8888_8888_8889, 96'h0_0000_0000_0000_0000, 96'h8_8888_8888_8888_8888); c96(96'h1_0000_0000_8eba_434a, 96'h0_0000_0000_0000_0001, 96'h1_0000_0000_8eba_434a, 96'h0); c96(96'h0003, 96'h0002, 96'h0001, 96'h0001); c96(96'h0003, 96'h0003, 96'h0001, 96'h0000); c96(96'h0003, 96'h0004, 96'h0000, 96'h0003); c96(96'h0000, 96'hffff, 96'h0000, 96'h0000); c96(96'hffff, 96'h0001, 96'hffff, 96'h0000); c96(96'hffff, 96'hffff, 96'h0001, 96'h0000); c96(96'hffff, 96'h0003, 96'h5555, 96'h0000); c96(96'hffff_ffff, 96'h0001, 96'hffff_ffff, 96'h0000); c96(96'hffff_ffff, 96'hffff, 96'h0001_0001, 96'h0000); c96(96'hfffe_ffff, 96'hffff, 96'h0000_ffff, 96'hfffe); c96(96'h1234_5678, 96'h9abc, 96'h0000_1e1e, 96'h2c70); c96(96'h0000_0000, 96'h0001_0000, 96'h0000, 96'h0000_0000); c96(96'h0007_0000, 96'h0003_0000, 96'h0002, 96'h0001_0000); c96(96'h0007_0005, 96'h0003_0000, 96'h0002, 96'h0001_0005); c96(96'h0006_0000, 96'h0002_0000, 96'h0003, 96'h0000_0000); c96(96'h8000_0001, 96'h4000_7000, 96'h0001, 96'h3fff_9001); c96(96'hbcde_789a, 96'hbcde_789a, 96'h0001, 96'h0000_0000); c96(96'hbcde_789b, 96'hbcde_789a, 96'h0001, 96'h0000_0001); c96(96'hbcde_7899, 96'hbcde_789a, 96'h0000, 96'hbcde_7899); c96(96'hffff_ffff, 96'hffff_ffff, 96'h0001, 96'h0000_0000); c96(96'hffff_ffff, 96'h0001_0000, 96'hffff, 96'h0000_ffff); c96(96'h0123_4567_89ab, 96'h0001_0000, 96'h0123_4567, 96'h0000_89ab); c96(96'h8000_fffe_0000, 96'h8000_ffff, 96'h0000_ffff, 96'h7fff_ffff); c96(96'h8000_0000_0003, 96'h2000_0000_0001, 96'h0003, 96'h2000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'h0001_0000_0000, 96'hffff_ffff, 96'h0000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'hffff_0000_0000, 96'h0001_0001, 96'h0000_0000_0000); c96(96'hfffe_ffff_0000_0000, 96'hffff_0000_0000, 96'h0000_ffff, 96'hfffe_0000_0000); c96(96'h1234_5678_0000_0000, 96'h9abc_0000_0000, 96'h0000_1e1e, 96'h2c70_0000_0000); c96(96'h0000_0000_0000_0000, 96'h0001_0000_0000_0000, 96'h0000, 96'h0000_0000_0000_0000); c96(96'h0007_0000_0000_0000, 96'h0003_0000_0000_0000, 96'h0002, 96'h0001_0000_0000_0000); c96(96'h0007_0005_0000_0000, 96'h0003_0000_0000_0000, 96'h0002, 96'h0001_0005_0000_0000); c96(96'h0006_0000_0000_0000, 96'h0002_0000_0000_0000, 96'h0003, 96'h0000_0000_0000_0000); c96(96'h8000_0001_0000_0000, 96'h4000_7000_0000_0000, 96'h0001, 96'h3fff_9001_0000_0000); c96(96'hbcde_789a_0000_0000, 96'hbcde_789a_0000_0000, 96'h0001, 96'h0000_0000_0000_0000); c96(96'hbcde_789b_0000_0000, 96'hbcde_789a_0000_0000, 96'h0001, 96'h0000_0001_0000_0000); c96(96'hbcde_7899_0000_0000, 96'hbcde_789a_0000_0000, 96'h0000, 96'hbcde_7899_0000_0000); c96(96'hffff_ffff_0000_0000, 96'hffff_ffff_0000_0000, 96'h0001, 96'h0000_0000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'h0001_0000_0000_0000, 96'hffff, 96'h0000_ffff_0000_0000); c96(96'h7fff_8000_0000_0000, 96'h8000_0000_0001, 96'h0000_fffe, 96'h7fff_ffff_0002); c96(96'h8000_0000_fffe_0000, 96'h8000_0000_ffff, 96'h0000_ffff, 96'h7fff_ffff_ffff); c96(96'h0008_8888_8888_8888_8888, 96'h0002_0000_0000_0000, 96'h0004_4444, 96'h0000_8888_8888_8888); if (bad) $stop; $write("*-* All Finished *-*\n"); $finish; end task c96; input [95:0] u; input [95:0] v; input [95:0] expq; input [95:0] expr; c96u( u, v, expq, expr); c96s( u, v, expq, expr); c96s(-u, v,-expq,-expr); c96s( u,-v,-expq, expr); c96s(-u,-v, expq,-expr); endtask task c96u; input [95:0] u; input [95:0] v; input [95:0] expq; input [95:0] expr; reg [95:0] gotq; reg [95:0] gotr; gotq = u/v; gotr = u%v; if (gotq != expq && v!=0) begin bad = 1; end if (gotr != expr && v!=0) begin bad = 1; end if (bad `ifdef TEST_VERBOSE || 1 `endif ) begin $write(" %x /u %x = got %x exp %x %% got %x exp %x", u,v,gotq,expq,gotr,expr); // Test for v=0 to prevent Xs causing grief if (gotq != expq && v!=0) $write(" BADQ"); if (gotr != expr && v!=0) $write(" BADR"); $write("\n"); end endtask task c96s; input signed [95:0] u; input signed [95:0] v; input signed [95:0] expq; input signed [95:0] expr; reg signed [95:0] gotq; reg signed [95:0] gotr; gotq = u/v; gotr = u%v; if (gotq != expq && v!=0) begin bad = 1; end if (gotr != expr && v!=0) begin bad = 1; end if (bad `ifdef TEST_VERBOSE || 1 `endif ) begin $write(" %x /s %x = got %x exp %x %% got %x exp %x", u,v,gotq,expq,gotr,expr); // Test for v=0 to prevent Xs causing grief if (gotq != expq && v!=0) $write(" BADQ"); if (gotr != expr && v!=0) $write(" BADR"); $write("\n"); end endtask endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; // verilator lint_off WIDTH //============================================================ reg bad; initial begin bad=0; c96(96'h0_0000_0000_0000_0000, 96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0000, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0000, 96'h0_0000_0000_0000_0000, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0002, 96'h4_4444_4444_4444_4444, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h0_2000_0000_0000_0000, 96'h0_0000_0000_0000_0044, 96'h0_0888_8888_8888_8888); c96(96'h8_8888_8888_8888_8888, 96'h8_8888_8888_8888_8888, 96'h0_0000_0000_0000_0001, 96'h0); c96(96'h8_8888_8888_8888_8888, 96'h8_8888_8888_8888_8889, 96'h0_0000_0000_0000_0000, 96'h8_8888_8888_8888_8888); c96(96'h1_0000_0000_8eba_434a, 96'h0_0000_0000_0000_0001, 96'h1_0000_0000_8eba_434a, 96'h0); c96(96'h0003, 96'h0002, 96'h0001, 96'h0001); c96(96'h0003, 96'h0003, 96'h0001, 96'h0000); c96(96'h0003, 96'h0004, 96'h0000, 96'h0003); c96(96'h0000, 96'hffff, 96'h0000, 96'h0000); c96(96'hffff, 96'h0001, 96'hffff, 96'h0000); c96(96'hffff, 96'hffff, 96'h0001, 96'h0000); c96(96'hffff, 96'h0003, 96'h5555, 96'h0000); c96(96'hffff_ffff, 96'h0001, 96'hffff_ffff, 96'h0000); c96(96'hffff_ffff, 96'hffff, 96'h0001_0001, 96'h0000); c96(96'hfffe_ffff, 96'hffff, 96'h0000_ffff, 96'hfffe); c96(96'h1234_5678, 96'h9abc, 96'h0000_1e1e, 96'h2c70); c96(96'h0000_0000, 96'h0001_0000, 96'h0000, 96'h0000_0000); c96(96'h0007_0000, 96'h0003_0000, 96'h0002, 96'h0001_0000); c96(96'h0007_0005, 96'h0003_0000, 96'h0002, 96'h0001_0005); c96(96'h0006_0000, 96'h0002_0000, 96'h0003, 96'h0000_0000); c96(96'h8000_0001, 96'h4000_7000, 96'h0001, 96'h3fff_9001); c96(96'hbcde_789a, 96'hbcde_789a, 96'h0001, 96'h0000_0000); c96(96'hbcde_789b, 96'hbcde_789a, 96'h0001, 96'h0000_0001); c96(96'hbcde_7899, 96'hbcde_789a, 96'h0000, 96'hbcde_7899); c96(96'hffff_ffff, 96'hffff_ffff, 96'h0001, 96'h0000_0000); c96(96'hffff_ffff, 96'h0001_0000, 96'hffff, 96'h0000_ffff); c96(96'h0123_4567_89ab, 96'h0001_0000, 96'h0123_4567, 96'h0000_89ab); c96(96'h8000_fffe_0000, 96'h8000_ffff, 96'h0000_ffff, 96'h7fff_ffff); c96(96'h8000_0000_0003, 96'h2000_0000_0001, 96'h0003, 96'h2000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'h0001_0000_0000, 96'hffff_ffff, 96'h0000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'hffff_0000_0000, 96'h0001_0001, 96'h0000_0000_0000); c96(96'hfffe_ffff_0000_0000, 96'hffff_0000_0000, 96'h0000_ffff, 96'hfffe_0000_0000); c96(96'h1234_5678_0000_0000, 96'h9abc_0000_0000, 96'h0000_1e1e, 96'h2c70_0000_0000); c96(96'h0000_0000_0000_0000, 96'h0001_0000_0000_0000, 96'h0000, 96'h0000_0000_0000_0000); c96(96'h0007_0000_0000_0000, 96'h0003_0000_0000_0000, 96'h0002, 96'h0001_0000_0000_0000); c96(96'h0007_0005_0000_0000, 96'h0003_0000_0000_0000, 96'h0002, 96'h0001_0005_0000_0000); c96(96'h0006_0000_0000_0000, 96'h0002_0000_0000_0000, 96'h0003, 96'h0000_0000_0000_0000); c96(96'h8000_0001_0000_0000, 96'h4000_7000_0000_0000, 96'h0001, 96'h3fff_9001_0000_0000); c96(96'hbcde_789a_0000_0000, 96'hbcde_789a_0000_0000, 96'h0001, 96'h0000_0000_0000_0000); c96(96'hbcde_789b_0000_0000, 96'hbcde_789a_0000_0000, 96'h0001, 96'h0000_0001_0000_0000); c96(96'hbcde_7899_0000_0000, 96'hbcde_789a_0000_0000, 96'h0000, 96'hbcde_7899_0000_0000); c96(96'hffff_ffff_0000_0000, 96'hffff_ffff_0000_0000, 96'h0001, 96'h0000_0000_0000_0000); c96(96'hffff_ffff_0000_0000, 96'h0001_0000_0000_0000, 96'hffff, 96'h0000_ffff_0000_0000); c96(96'h7fff_8000_0000_0000, 96'h8000_0000_0001, 96'h0000_fffe, 96'h7fff_ffff_0002); c96(96'h8000_0000_fffe_0000, 96'h8000_0000_ffff, 96'h0000_ffff, 96'h7fff_ffff_ffff); c96(96'h0008_8888_8888_8888_8888, 96'h0002_0000_0000_0000, 96'h0004_4444, 96'h0000_8888_8888_8888); if (bad) $stop; $write("*-* All Finished *-*\n"); $finish; end task c96; input [95:0] u; input [95:0] v; input [95:0] expq; input [95:0] expr; c96u( u, v, expq, expr); c96s( u, v, expq, expr); c96s(-u, v,-expq,-expr); c96s( u,-v,-expq, expr); c96s(-u,-v, expq,-expr); endtask task c96u; input [95:0] u; input [95:0] v; input [95:0] expq; input [95:0] expr; reg [95:0] gotq; reg [95:0] gotr; gotq = u/v; gotr = u%v; if (gotq != expq && v!=0) begin bad = 1; end if (gotr != expr && v!=0) begin bad = 1; end if (bad `ifdef TEST_VERBOSE || 1 `endif ) begin $write(" %x /u %x = got %x exp %x %% got %x exp %x", u,v,gotq,expq,gotr,expr); // Test for v=0 to prevent Xs causing grief if (gotq != expq && v!=0) $write(" BADQ"); if (gotr != expr && v!=0) $write(" BADR"); $write("\n"); end endtask task c96s; input signed [95:0] u; input signed [95:0] v; input signed [95:0] expq; input signed [95:0] expr; reg signed [95:0] gotq; reg signed [95:0] gotr; gotq = u/v; gotr = u%v; if (gotq != expq && v!=0) begin bad = 1; end if (gotr != expr && v!=0) begin bad = 1; end if (bad `ifdef TEST_VERBOSE || 1 `endif ) begin $write(" %x /s %x = got %x exp %x %% got %x exp %x", u,v,gotq,expq,gotr,expr); // Test for v=0 to prevent Xs causing grief if (gotq != expq && v!=0) $write(" BADQ"); if (gotr != expr && v!=0) $write(" BADR"); $write("\n"); end endtask endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [7:0] crc; reg [2:0] sum; wire [2:0] in = crc[2:0]; wire [2:0] out; MxN_pipeline pipe (in, out, clk); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%b sum=%x\n",$time, cyc, crc, sum); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin // Setup crc <= 8'hed; sum <= 3'h0; end else if (cyc>10 && cyc<90) begin sum <= {sum[1:0],sum[2]} ^ out; end else if (cyc==99) begin if (crc !== 8'b01110000) $stop; if (sum !== 3'h3) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module dffn (q,d,clk); parameter BITS = 1; input [BITS-1:0] d; output reg [BITS-1:0] q; input clk; always @ (posedge clk) begin q <= d; end endmodule
module MxN_pipeline (in, out, clk); parameter M=3, N=4; input [M-1:0] in; output [M-1:0] out; input clk; // Unsupported: Per-bit array instantiations with output connections to non-wires. //wire [M*(N-1):1] t; //dffn #(M) p[N:1] ({out,t},{t,in},clk); wire [M*(N-1):1] w; wire [M*N:1] q; dffn #(M) p[N:1] (q,{w,in},clk); assign {out,w} = q; endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [7:0] crc; reg [2:0] sum; wire [2:0] in = crc[2:0]; wire [2:0] out; MxN_pipeline pipe (in, out, clk); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%b sum=%x\n",$time, cyc, crc, sum); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin // Setup crc <= 8'hed; sum <= 3'h0; end else if (cyc>10 && cyc<90) begin sum <= {sum[1:0],sum[2]} ^ out; end else if (cyc==99) begin if (crc !== 8'b01110000) $stop; if (sum !== 3'h3) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module dffn (q,d,clk); parameter BITS = 1; input [BITS-1:0] d; output reg [BITS-1:0] q; input clk; always @ (posedge clk) begin q <= d; end endmodule
module MxN_pipeline (in, out, clk); parameter M=3, N=4; input [M-1:0] in; output [M-1:0] out; input clk; // Unsupported: Per-bit array instantiations with output connections to non-wires. //wire [M*(N-1):1] t; //dffn #(M) p[N:1] ({out,t},{t,in},clk); wire [M*(N-1):1] w; wire [M*N:1] q; dffn #(M) p[N:1] (q,{w,in},clk); assign {out,w} = q; endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [7:0] crc; reg [2:0] sum; wire [2:0] in = crc[2:0]; wire [2:0] out; MxN_pipeline pipe (in, out, clk); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%b sum=%x\n",$time, cyc, crc, sum); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin // Setup crc <= 8'hed; sum <= 3'h0; end else if (cyc>10 && cyc<90) begin sum <= {sum[1:0],sum[2]} ^ out; end else if (cyc==99) begin if (crc !== 8'b01110000) $stop; if (sum !== 3'h3) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module dffn (q,d,clk); parameter BITS = 1; input [BITS-1:0] d; output reg [BITS-1:0] q; input clk; always @ (posedge clk) begin q <= d; end endmodule
module MxN_pipeline (in, out, clk); parameter M=3, N=4; input [M-1:0] in; output [M-1:0] out; input clk; // Unsupported: Per-bit array instantiations with output connections to non-wires. //wire [M*(N-1):1] t; //dffn #(M) p[N:1] ({out,t},{t,in},clk); wire [M*(N-1):1] w; wire [M*N:1] q; dffn #(M) p[N:1] (q,{w,in},clk); assign {out,w} = q; endmodule
module outputs) wire [31:0] out; // From test of Test.v // End of automatics // Take CRC data and apply to testblock inputs wire [31:0] in = crc[31:0]; Test test (/*AUTOINST*/ // Outputs .out (out[31:0]), // Inputs .clk (clk), .reset (reset), .enable (enable), .in (in[31:0])); wire [63:0] result = {32'h0, out}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; reset <= (cyc < 5); enable <= cyc[4] || (cyc < 2); if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h01e1553da1dcf3af if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs out, // Inputs clk, reset, enable, in ); input clk; input reset; input enable; input [31:0] in; output [31:0] out; // No gating reg [31:0] d10; always @(posedge clk) begin d10 <= in; end reg displayit; `ifdef VERILATOR // Harder test initial displayit = $c1("0"); // Something that won't optimize away `else initial displayit = '0; `endif // Obvious gating + PLI reg [31:0] d20; always @(posedge clk) begin if (enable) begin d20 <= d10; // Obvious gating if (displayit) begin $display("hello!"); // Must glob with other PLI statements end end end // Reset means second-level gating reg [31:0] d30, d31a, d31b, d32; always @(posedge clk) begin d32 <= d31b; if (reset) begin d30 <= 32'h0; d31a <= 32'h0; d31b <= 32'h0; d32 <= 32'h0; // Overlaps above, just to make things interesting end else begin // Mix two outputs d30 <= d20; if (enable) begin d31a <= d30; d31b <= d31a; end end end // Multiple ORs for gater reg [31:0] d40a,d40b; always @(posedge clk) begin if (reset) begin d40a <= 32'h0; d40b <= 32'h0; end if (enable) begin d40a <= d32; d40b <= d40a; end end // Non-optimizable reg [31:0] d91, d92; reg [31:0] inverted; always @(posedge clk) begin inverted = ~d40b; if (reset) begin d91 <= 32'h0; end else begin if (enable) begin d91 <= inverted; end else begin d92 <= inverted ^ 32'h12341234; // Inverted gating condition end end end wire [31:0] out = d91 ^ d92; endmodule
module outputs) wire [31:0] out; // From test of Test.v // End of automatics // Take CRC data and apply to testblock inputs wire [31:0] in = crc[31:0]; Test test (/*AUTOINST*/ // Outputs .out (out[31:0]), // Inputs .clk (clk), .reset (reset), .enable (enable), .in (in[31:0])); wire [63:0] result = {32'h0, out}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; reset <= (cyc < 5); enable <= cyc[4] || (cyc < 2); if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h01e1553da1dcf3af if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs out, // Inputs clk, reset, enable, in ); input clk; input reset; input enable; input [31:0] in; output [31:0] out; // No gating reg [31:0] d10; always @(posedge clk) begin d10 <= in; end reg displayit; `ifdef VERILATOR // Harder test initial displayit = $c1("0"); // Something that won't optimize away `else initial displayit = '0; `endif // Obvious gating + PLI reg [31:0] d20; always @(posedge clk) begin if (enable) begin d20 <= d10; // Obvious gating if (displayit) begin $display("hello!"); // Must glob with other PLI statements end end end // Reset means second-level gating reg [31:0] d30, d31a, d31b, d32; always @(posedge clk) begin d32 <= d31b; if (reset) begin d30 <= 32'h0; d31a <= 32'h0; d31b <= 32'h0; d32 <= 32'h0; // Overlaps above, just to make things interesting end else begin // Mix two outputs d30 <= d20; if (enable) begin d31a <= d30; d31b <= d31a; end end end // Multiple ORs for gater reg [31:0] d40a,d40b; always @(posedge clk) begin if (reset) begin d40a <= 32'h0; d40b <= 32'h0; end if (enable) begin d40a <= d32; d40b <= d40a; end end // Non-optimizable reg [31:0] d91, d92; reg [31:0] inverted; always @(posedge clk) begin inverted = ~d40b; if (reset) begin d91 <= 32'h0; end else begin if (enable) begin d91 <= inverted; end else begin d92 <= inverted ^ 32'h12341234; // Inverted gating condition end end end wire [31:0] out = d91 ^ d92; endmodule
module outputs) wire [31:0] out; // From test of Test.v // End of automatics // Take CRC data and apply to testblock inputs wire [31:0] in = crc[31:0]; Test test (/*AUTOINST*/ // Outputs .out (out[31:0]), // Inputs .clk (clk), .reset (reset), .enable (enable), .in (in[31:0])); wire [63:0] result = {32'h0, out}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; reset <= (cyc < 5); enable <= cyc[4] || (cyc < 2); if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h01e1553da1dcf3af if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs out, // Inputs clk, reset, enable, in ); input clk; input reset; input enable; input [31:0] in; output [31:0] out; // No gating reg [31:0] d10; always @(posedge clk) begin d10 <= in; end reg displayit; `ifdef VERILATOR // Harder test initial displayit = $c1("0"); // Something that won't optimize away `else initial displayit = '0; `endif // Obvious gating + PLI reg [31:0] d20; always @(posedge clk) begin if (enable) begin d20 <= d10; // Obvious gating if (displayit) begin $display("hello!"); // Must glob with other PLI statements end end end // Reset means second-level gating reg [31:0] d30, d31a, d31b, d32; always @(posedge clk) begin d32 <= d31b; if (reset) begin d30 <= 32'h0; d31a <= 32'h0; d31b <= 32'h0; d32 <= 32'h0; // Overlaps above, just to make things interesting end else begin // Mix two outputs d30 <= d20; if (enable) begin d31a <= d30; d31b <= d31a; end end end // Multiple ORs for gater reg [31:0] d40a,d40b; always @(posedge clk) begin if (reset) begin d40a <= 32'h0; d40b <= 32'h0; end if (enable) begin d40a <= d32; d40b <= d40a; end end // Non-optimizable reg [31:0] d91, d92; reg [31:0] inverted; always @(posedge clk) begin inverted = ~d40b; if (reset) begin d91 <= 32'h0; end else begin if (enable) begin d91 <= inverted; end else begin d92 <= inverted ^ 32'h12341234; // Inverted gating condition end end end wire [31:0] out = d91 ^ d92; endmodule
module outputs) wire [3:0] out; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .out (out[3:0]), // Inputs .clk (clk), .in (in[31:0])); // Aggregate outputs into a single result vector wire [63:0] result = {60'h0, out}; // What checksum will we end up with `define EXPECTED_SUM 64'h1a0d07009b6a30d2 // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs out, // Inputs clk, in ); input clk; input [31:0] in; output [3:0] out; assign out[0] = in[3:0] ==? 4'b1001; assign out[1] = in[3:0] !=? 4'b1001; assign out[2] = in[3:0] ==? 4'bx01x; assign out[3] = in[3:0] !=? 4'bx01x; endmodule
module t (clk); input clk; reg [63:0] inwide; reg [39:0] addr; integer cyc; initial cyc=1; always @ (posedge clk) begin `ifdef TEST_VERBOSE $write ("%x %x\n", cyc, addr); `endif if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin addr <= 40'h12_3456_7890; end if (cyc==2) begin if (addr !== 40'h1234567890) $stop; addr[31:0] <= 32'habcd_efaa; end if (cyc==3) begin if (addr !== 40'h12abcdefaa) $stop; addr[39:32] <= 8'h44; inwide <= 64'hffeeddcc_11334466; end if (cyc==4) begin if (addr !== 40'h44abcdefaa) $stop; addr[31:0] <= inwide[31:0]; end if (cyc==5) begin if (addr !== 40'h4411334466) $stop; $display ("Flip [%x]\n", inwide[3:0]); addr[{2'b0,inwide[3:0]}] <= ! addr[{2'b0,inwide[3:0]}]; end if (cyc==6) begin if (addr !== 40'h4411334426) $stop; end if (cyc==10) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (clk); input clk; reg [63:0] inwide; reg [39:0] addr; integer cyc; initial cyc=1; always @ (posedge clk) begin `ifdef TEST_VERBOSE $write ("%x %x\n", cyc, addr); `endif if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin addr <= 40'h12_3456_7890; end if (cyc==2) begin if (addr !== 40'h1234567890) $stop; addr[31:0] <= 32'habcd_efaa; end if (cyc==3) begin if (addr !== 40'h12abcdefaa) $stop; addr[39:32] <= 8'h44; inwide <= 64'hffeeddcc_11334466; end if (cyc==4) begin if (addr !== 40'h44abcdefaa) $stop; addr[31:0] <= inwide[31:0]; end if (cyc==5) begin if (addr !== 40'h4411334466) $stop; $display ("Flip [%x]\n", inwide[3:0]); addr[{2'b0,inwide[3:0]}] <= ! addr[{2'b0,inwide[3:0]}]; end if (cyc==6) begin if (addr !== 40'h4411334426) $stop; end if (cyc==10) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (clk); input clk; reg [63:0] inwide; reg [39:0] addr; integer cyc; initial cyc=1; always @ (posedge clk) begin `ifdef TEST_VERBOSE $write ("%x %x\n", cyc, addr); `endif if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin addr <= 40'h12_3456_7890; end if (cyc==2) begin if (addr !== 40'h1234567890) $stop; addr[31:0] <= 32'habcd_efaa; end if (cyc==3) begin if (addr !== 40'h12abcdefaa) $stop; addr[39:32] <= 8'h44; inwide <= 64'hffeeddcc_11334466; end if (cyc==4) begin if (addr !== 40'h44abcdefaa) $stop; addr[31:0] <= inwide[31:0]; end if (cyc==5) begin if (addr !== 40'h4411334466) $stop; $display ("Flip [%x]\n", inwide[3:0]); addr[{2'b0,inwide[3:0]}] <= ! addr[{2'b0,inwide[3:0]}]; end if (cyc==6) begin if (addr !== 40'h4411334426) $stop; end if (cyc==10) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (clk); input clk; reg [63:0] inwide; reg [39:0] addr; integer cyc; initial cyc=1; always @ (posedge clk) begin `ifdef TEST_VERBOSE $write ("%x %x\n", cyc, addr); `endif if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin addr <= 40'h12_3456_7890; end if (cyc==2) begin if (addr !== 40'h1234567890) $stop; addr[31:0] <= 32'habcd_efaa; end if (cyc==3) begin if (addr !== 40'h12abcdefaa) $stop; addr[39:32] <= 8'h44; inwide <= 64'hffeeddcc_11334466; end if (cyc==4) begin if (addr !== 40'h44abcdefaa) $stop; addr[31:0] <= inwide[31:0]; end if (cyc==5) begin if (addr !== 40'h4411334466) $stop; $display ("Flip [%x]\n", inwide[3:0]); addr[{2'b0,inwide[3:0]}] <= ! addr[{2'b0,inwide[3:0]}]; end if (cyc==6) begin if (addr !== 40'h4411334426) $stop; end if (cyc==10) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (clk); input clk; reg [63:0] inwide; reg [39:0] addr; integer cyc; initial cyc=1; always @ (posedge clk) begin `ifdef TEST_VERBOSE $write ("%x %x\n", cyc, addr); `endif if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin addr <= 40'h12_3456_7890; end if (cyc==2) begin if (addr !== 40'h1234567890) $stop; addr[31:0] <= 32'habcd_efaa; end if (cyc==3) begin if (addr !== 40'h12abcdefaa) $stop; addr[39:32] <= 8'h44; inwide <= 64'hffeeddcc_11334466; end if (cyc==4) begin if (addr !== 40'h44abcdefaa) $stop; addr[31:0] <= inwide[31:0]; end if (cyc==5) begin if (addr !== 40'h4411334466) $stop; $display ("Flip [%x]\n", inwide[3:0]); addr[{2'b0,inwide[3:0]}] <= ! addr[{2'b0,inwide[3:0]}]; end if (cyc==6) begin if (addr !== 40'h4411334426) $stop; end if (cyc==10) begin $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; // verilator lint_off BLKANDNBLK // verilator lint_off COMBDLY // verilator lint_off UNOPT // verilator lint_off UNOPTFLAT // verilator lint_off MULTIDRIVEN reg [31:0] runnerm1, runner; initial runner = 0; reg [31:0] runcount; initial runcount = 0; reg [31:0] clkrun; initial clkrun = 0; reg [31:0] clkcount; initial clkcount = 0; always @ (/*AS*/runner) begin runnerm1 = runner - 32'd1; end reg run0; always @ (/*AS*/runnerm1) begin if ((runner & 32'hf)!=0) begin runcount = runcount + 1; runner = runnerm1; $write (" seq runcount=%0d runner =%0x\n",runcount, runnerm1); end run0 = (runner[8:4]!=0 && runner[3:0]==0); end always @ (posedge run0) begin // Do something that forces another combo run clkcount <= clkcount + 1; runner[8:4] <= runner[8:4] - 1; runner[3:0] <= 3; $write ("[%0t] posedge runner=%0x\n", $time, runner); end reg [7:0] cyc; initial cyc=0; always @ (posedge clk) begin $write("[%0t] %x counts %0x %0x\n",$time,cyc,runcount,clkcount); cyc <= cyc + 8'd1; case (cyc) 8'd00: begin runner <= 0; end 8'd01: begin runner <= 32'h35; end default: ; endcase case (cyc) 8'd02: begin if (runcount!=32'he) $stop; if (clkcount!=32'h3) $stop; end 8'd03: begin $write("*-* All Finished *-*\n"); $finish; end default: ; endcase end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; // verilator lint_off BLKANDNBLK // verilator lint_off COMBDLY // verilator lint_off UNOPT // verilator lint_off UNOPTFLAT // verilator lint_off MULTIDRIVEN reg [31:0] runnerm1, runner; initial runner = 0; reg [31:0] runcount; initial runcount = 0; reg [31:0] clkrun; initial clkrun = 0; reg [31:0] clkcount; initial clkcount = 0; always @ (/*AS*/runner) begin runnerm1 = runner - 32'd1; end reg run0; always @ (/*AS*/runnerm1) begin if ((runner & 32'hf)!=0) begin runcount = runcount + 1; runner = runnerm1; $write (" seq runcount=%0d runner =%0x\n",runcount, runnerm1); end run0 = (runner[8:4]!=0 && runner[3:0]==0); end always @ (posedge run0) begin // Do something that forces another combo run clkcount <= clkcount + 1; runner[8:4] <= runner[8:4] - 1; runner[3:0] <= 3; $write ("[%0t] posedge runner=%0x\n", $time, runner); end reg [7:0] cyc; initial cyc=0; always @ (posedge clk) begin $write("[%0t] %x counts %0x %0x\n",$time,cyc,runcount,clkcount); cyc <= cyc + 8'd1; case (cyc) 8'd00: begin runner <= 0; end 8'd01: begin runner <= 32'h35; end default: ; endcase case (cyc) 8'd02: begin if (runcount!=32'he) $stop; if (clkcount!=32'h3) $stop; end 8'd03: begin $write("*-* All Finished *-*\n"); $finish; end default: ; endcase end endmodule
module t_math_imm2 (/*AUTOARG*/ // Outputs LogicImm, LowLogicImm, HighLogicImm, // Inputs LowMaskSel_Top, HighMaskSel_Top, LowMaskSel_Bot, HighMaskSel_Bot ); input [4:0] LowMaskSel_Top, HighMaskSel_Top; input [4:0] LowMaskSel_Bot, HighMaskSel_Bot; output [63:0] LogicImm; output [63:0] LowLogicImm, HighLogicImm; /* verilator lint_off UNSIGNED */ /* verilator lint_off CMPCONST */ genvar i; generate for (i=0;i<64;i=i+1) begin : MaskVal if (i >= 32) begin assign LowLogicImm[i] = (LowMaskSel_Top <= i[4:0]); assign HighLogicImm[i] = (HighMaskSel_Top >= i[4:0]); end else begin assign LowLogicImm[i] = (LowMaskSel_Bot <= i[4:0]); assign HighLogicImm[i] = (HighMaskSel_Bot >= i[4:0]); end end endgenerate assign LogicImm = LowLogicImm & HighLogicImm; endmodule
module t_math_imm2 (/*AUTOARG*/ // Outputs LogicImm, LowLogicImm, HighLogicImm, // Inputs LowMaskSel_Top, HighMaskSel_Top, LowMaskSel_Bot, HighMaskSel_Bot ); input [4:0] LowMaskSel_Top, HighMaskSel_Top; input [4:0] LowMaskSel_Bot, HighMaskSel_Bot; output [63:0] LogicImm; output [63:0] LowLogicImm, HighLogicImm; /* verilator lint_off UNSIGNED */ /* verilator lint_off CMPCONST */ genvar i; generate for (i=0;i<64;i=i+1) begin : MaskVal if (i >= 32) begin assign LowLogicImm[i] = (LowMaskSel_Top <= i[4:0]); assign HighLogicImm[i] = (HighMaskSel_Top >= i[4:0]); end else begin assign LowLogicImm[i] = (LowMaskSel_Bot <= i[4:0]); assign HighLogicImm[i] = (HighMaskSel_Bot >= i[4:0]); end end endgenerate assign LogicImm = LowLogicImm & HighLogicImm; endmodule
module t_math_imm2 (/*AUTOARG*/ // Outputs LogicImm, LowLogicImm, HighLogicImm, // Inputs LowMaskSel_Top, HighMaskSel_Top, LowMaskSel_Bot, HighMaskSel_Bot ); input [4:0] LowMaskSel_Top, HighMaskSel_Top; input [4:0] LowMaskSel_Bot, HighMaskSel_Bot; output [63:0] LogicImm; output [63:0] LowLogicImm, HighLogicImm; /* verilator lint_off UNSIGNED */ /* verilator lint_off CMPCONST */ genvar i; generate for (i=0;i<64;i=i+1) begin : MaskVal if (i >= 32) begin assign LowLogicImm[i] = (LowMaskSel_Top <= i[4:0]); assign HighLogicImm[i] = (HighMaskSel_Top >= i[4:0]); end else begin assign LowLogicImm[i] = (LowMaskSel_Bot <= i[4:0]); assign HighLogicImm[i] = (HighMaskSel_Bot >= i[4:0]); end end endgenerate assign LogicImm = LowLogicImm & HighLogicImm; endmodule
module acl_valid_fifo_counter #( parameter integer DEPTH = 32, // >0 parameter integer STRICT_DEPTH = 0, // 0|1 parameter integer ALLOW_FULL_WRITE = 0 // 0|1 ) ( input logic clock, input logic resetn, input logic valid_in, output logic valid_out, input logic stall_in, output logic stall_out, output logic empty, output logic full ); // No data, so just build a counter to count the number of valids stored in this "FIFO". // // The counter is constructed to count up to a MINIMUM value of DEPTH entries. // * Logical range of the counter C0 is [0, DEPTH]. // * empty = (C0 <= 0) // * full = (C0 >= DEPTH) // // To have efficient detection of the empty condition (C0 == 0), the range is offset // by -1 so that a negative number indicates empty. // * Logical range of the counter C1 is [-1, DEPTH-1]. // * empty = (C1 < 0) // * full = (C1 >= DEPTH-1) // The size of counter C1 is $clog2((DEPTH-1) + 1) + 1 => $clog2(DEPTH) + 1. // // To have efficient detection of the full condition (C1 >= DEPTH-1), change the // full condition to C1 == 2^$clog2(DEPTH-1), which is DEPTH-1 rounded up // to the next power of 2. This is only done if STRICT_DEPTH == 0, otherwise // the full condition is comparison vs. DEPTH-1. // * Logical range of the counter C2 is [-1, 2^$clog2(DEPTH-1)] // * empty = (C2 < 0) // * full = (C2 == 2^$clog2(DEPTH - 1)) // The size of counter C2 is $clog2(DEPTH-1) + 2. // * empty = MSB // * full = ~[MSB] & [MSB-1] localparam COUNTER_WIDTH = (STRICT_DEPTH == 0) ? ((DEPTH > 1 ? $clog2(DEPTH-1) : 0) + 2) : ($clog2(DEPTH) + 1); logic [COUNTER_WIDTH - 1:0] valid_counter /* synthesis maxfan=1 dont_merge */; logic incr, decr; assign empty = valid_counter[$bits(valid_counter) - 1]; assign full = (STRICT_DEPTH == 0) ? (~valid_counter[$bits(valid_counter) - 1] & valid_counter[$bits(valid_counter) - 2]) : (valid_counter == DEPTH - 1); assign incr = valid_in & ~stall_out; assign decr = valid_out & ~stall_in; assign valid_out = ~empty; assign stall_out = ALLOW_FULL_WRITE ? (full & stall_in) : full; always @( posedge clock or negedge resetn ) if( !resetn ) valid_counter <= {$bits(valid_counter){1'b1}}; // -1 else valid_counter <= valid_counter + incr - decr; endmodule
module acl_valid_fifo_counter #( parameter integer DEPTH = 32, // >0 parameter integer STRICT_DEPTH = 0, // 0|1 parameter integer ALLOW_FULL_WRITE = 0 // 0|1 ) ( input logic clock, input logic resetn, input logic valid_in, output logic valid_out, input logic stall_in, output logic stall_out, output logic empty, output logic full ); // No data, so just build a counter to count the number of valids stored in this "FIFO". // // The counter is constructed to count up to a MINIMUM value of DEPTH entries. // * Logical range of the counter C0 is [0, DEPTH]. // * empty = (C0 <= 0) // * full = (C0 >= DEPTH) // // To have efficient detection of the empty condition (C0 == 0), the range is offset // by -1 so that a negative number indicates empty. // * Logical range of the counter C1 is [-1, DEPTH-1]. // * empty = (C1 < 0) // * full = (C1 >= DEPTH-1) // The size of counter C1 is $clog2((DEPTH-1) + 1) + 1 => $clog2(DEPTH) + 1. // // To have efficient detection of the full condition (C1 >= DEPTH-1), change the // full condition to C1 == 2^$clog2(DEPTH-1), which is DEPTH-1 rounded up // to the next power of 2. This is only done if STRICT_DEPTH == 0, otherwise // the full condition is comparison vs. DEPTH-1. // * Logical range of the counter C2 is [-1, 2^$clog2(DEPTH-1)] // * empty = (C2 < 0) // * full = (C2 == 2^$clog2(DEPTH - 1)) // The size of counter C2 is $clog2(DEPTH-1) + 2. // * empty = MSB // * full = ~[MSB] & [MSB-1] localparam COUNTER_WIDTH = (STRICT_DEPTH == 0) ? ((DEPTH > 1 ? $clog2(DEPTH-1) : 0) + 2) : ($clog2(DEPTH) + 1); logic [COUNTER_WIDTH - 1:0] valid_counter /* synthesis maxfan=1 dont_merge */; logic incr, decr; assign empty = valid_counter[$bits(valid_counter) - 1]; assign full = (STRICT_DEPTH == 0) ? (~valid_counter[$bits(valid_counter) - 1] & valid_counter[$bits(valid_counter) - 2]) : (valid_counter == DEPTH - 1); assign incr = valid_in & ~stall_out; assign decr = valid_out & ~stall_in; assign valid_out = ~empty; assign stall_out = ALLOW_FULL_WRITE ? (full & stall_in) : full; always @( posedge clock or negedge resetn ) if( !resetn ) valid_counter <= {$bits(valid_counter){1'b1}}; // -1 else valid_counter <= valid_counter + incr - decr; endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; wire b; reg reset; integer cyc=0; Testit testit (/*AUTOINST*/ // Outputs .b (b), // Inputs .clk (clk), .reset (reset)); always @ (posedge clk) begin cyc <= cyc + 1; if (cyc==0) begin reset <= 1'b0; end else if (cyc<10) begin reset <= 1'b1; end else if (cyc<90) begin reset <= 1'b0; end else if (cyc==99) begin $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Testit (clk, reset, b); input clk; input reset; output b; wire [0:0] c; wire my_sig; wire [0:0] d; genvar i; generate for(i = 0; i >= 0; i = i-1) begin: fnxtclk1 fnxtclk fnxtclk1 (.u(c[i]), .reset(reset), .clk(clk), .w(d[i]) ); end endgenerate assign b = d[0]; assign c[0] = my_sig; assign my_sig = 1'b1; endmodule
module fnxtclk (u, reset, clk, w ); input u; input reset; input clk; output reg w; always @ (posedge clk or posedge reset) begin if (reset == 1'b1) begin w <= 1'b0; end else begin w <= u; end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // verilator lint_off LITENDIAN wire [10:41] sel2 = crc[31:0]; wire [10:100] sel3 = {crc[26:0],crc}; wire out20 = sel2[{1'b0,crc[3:0]} + 11]; wire [3:0] out21 = sel2[13 : 16]; wire [3:0] out22 = sel2[{1'b0,crc[3:0]} + 20 +: 4]; wire [3:0] out23 = sel2[{1'b0,crc[3:0]} + 20 -: 4]; wire out30 = sel3[{2'b0,crc[3:0]} + 11]; wire [3:0] out31 = sel3[13 : 16]; wire [3:0] out32 = sel3[crc[5:0] + 20 +: 4]; wire [3:0] out33 = sel3[crc[5:0] + 20 -: 4]; // Aggregate outputs into a single result vector wire [63:0] result = {38'h0, out20, out21, out22, out23, out30, out31, out32, out33}; reg [19:50] sel1; initial begin // Path clearing // 122333445 // 826048260 sel1 = 32'h12345678; if (sel1 != 32'h12345678) $stop; if (sel1[47 : 50] != 4'h8) $stop; if (sel1[31 : 34] != 4'h4) $stop; if (sel1[27 +: 4] != 4'h3) $stop; //==[27:30], in memory as [23:20] if (sel1[26 -: 4] != 4'h2) $stop; //==[23:26], in memory as [27:24] end // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] sels=%x,%x,%x,%x %x,%x,%x,%x\n",$time, out20,out21,out22,out23, out30,out31,out32,out33); $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h28bf65439eb12c00 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // verilator lint_off LITENDIAN wire [10:41] sel2 = crc[31:0]; wire [10:100] sel3 = {crc[26:0],crc}; wire out20 = sel2[{1'b0,crc[3:0]} + 11]; wire [3:0] out21 = sel2[13 : 16]; wire [3:0] out22 = sel2[{1'b0,crc[3:0]} + 20 +: 4]; wire [3:0] out23 = sel2[{1'b0,crc[3:0]} + 20 -: 4]; wire out30 = sel3[{2'b0,crc[3:0]} + 11]; wire [3:0] out31 = sel3[13 : 16]; wire [3:0] out32 = sel3[crc[5:0] + 20 +: 4]; wire [3:0] out33 = sel3[crc[5:0] + 20 -: 4]; // Aggregate outputs into a single result vector wire [63:0] result = {38'h0, out20, out21, out22, out23, out30, out31, out32, out33}; reg [19:50] sel1; initial begin // Path clearing // 122333445 // 826048260 sel1 = 32'h12345678; if (sel1 != 32'h12345678) $stop; if (sel1[47 : 50] != 4'h8) $stop; if (sel1[31 : 34] != 4'h4) $stop; if (sel1[27 +: 4] != 4'h3) $stop; //==[27:30], in memory as [23:20] if (sel1[26 -: 4] != 4'h2) $stop; //==[23:26], in memory as [27:24] end // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] sels=%x,%x,%x,%x %x,%x,%x,%x\n",$time, out20,out21,out22,out23, out30,out31,out32,out33); $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h28bf65439eb12c00 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module t (clk); input clk; // verilator lint_off WIDTH `define INT_RANGE 31:0 `define INT_RANGE_MAX 31 `define VECTOR_RANGE 63:0 reg [`INT_RANGE] stashb, stasha, stashn, stashm; function [`VECTOR_RANGE] copy_range; input [`VECTOR_RANGE] y; input [`INT_RANGE] b; input [`INT_RANGE] a; input [`VECTOR_RANGE] x; input [`INT_RANGE] n; input [`INT_RANGE] m; begin copy_range = y; stashb = b; stasha = a; stashn = n; stashm = m; end endfunction parameter DATA_SIZE = 16; parameter NUM_OF_REGS = 32; reg [NUM_OF_REGS*DATA_SIZE-1 : 0] memread_rf; reg [DATA_SIZE-1:0] memread_rf_reg; always @(memread_rf) begin : memread_convert memread_rf_reg = copy_range('d0, DATA_SIZE-'d1, DATA_SIZE-'d1, memread_rf, DATA_SIZE-'d1, DATA_SIZE-'d1); end integer cyc; initial cyc=1; always @ (posedge clk) begin if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin memread_rf = 512'haa; end if (cyc==3) begin if (stashb != 'd15) $stop; if (stasha != 'd15) $stop; if (stashn != 'd15) $stop; if (stashm != 'd15) $stop; $write("*-* All Finished *-*\n"); $finish; end end end endmodule
module outputs) wire [`AOA_BITS-1:0] AOA_B; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .AOA_B (AOA_B[`AOA_BITS-1:0]), // Inputs .DDIFF_B (DDIFF_B[`DDIFF_BITS-1:0]), .reset (reset), .clk (clk)); // Aggregate outputs into a single result vector wire [63:0] result = {56'h0, AOA_B}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3a74e9d34771ad93 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs AOA_B, // Inputs DDIFF_B, reset, clk ); input [`DDIFF_BITS-1:0] DDIFF_B; input reset; input clk; output reg [`AOA_BITS-1:0] AOA_B; reg [`AOA_BITS-1:0] AOA_NEXT_B; reg [`AOA_BITS-1:0] tmp; always @(posedge clk) begin if (reset) begin AOA_B <= 8'h80; end else begin AOA_B <= AOA_NEXT_B; end end always @* begin // verilator lint_off WIDTH tmp = ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER); t_aoa_update(AOA_NEXT_B, AOA_B, ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER)); // verilator lint_on WIDTH end task t_aoa_update; output [`AOA_BITS-1:0] aoa_reg_next; input [`AOA_BITS-1:0] aoa_reg; input [`AOA_BITS-1:0] aoa_delta_update; begin if ((`MAX_AOA-aoa_reg)<aoa_delta_update) //Overflow protection aoa_reg_next=`MAX_AOA; else aoa_reg_next=aoa_reg+aoa_delta_update; end endtask endmodule
module outputs) wire [`AOA_BITS-1:0] AOA_B; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .AOA_B (AOA_B[`AOA_BITS-1:0]), // Inputs .DDIFF_B (DDIFF_B[`DDIFF_BITS-1:0]), .reset (reset), .clk (clk)); // Aggregate outputs into a single result vector wire [63:0] result = {56'h0, AOA_B}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3a74e9d34771ad93 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs AOA_B, // Inputs DDIFF_B, reset, clk ); input [`DDIFF_BITS-1:0] DDIFF_B; input reset; input clk; output reg [`AOA_BITS-1:0] AOA_B; reg [`AOA_BITS-1:0] AOA_NEXT_B; reg [`AOA_BITS-1:0] tmp; always @(posedge clk) begin if (reset) begin AOA_B <= 8'h80; end else begin AOA_B <= AOA_NEXT_B; end end always @* begin // verilator lint_off WIDTH tmp = ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER); t_aoa_update(AOA_NEXT_B, AOA_B, ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER)); // verilator lint_on WIDTH end task t_aoa_update; output [`AOA_BITS-1:0] aoa_reg_next; input [`AOA_BITS-1:0] aoa_reg; input [`AOA_BITS-1:0] aoa_delta_update; begin if ((`MAX_AOA-aoa_reg)<aoa_delta_update) //Overflow protection aoa_reg_next=`MAX_AOA; else aoa_reg_next=aoa_reg+aoa_delta_update; end endtask endmodule
module outputs) wire [`AOA_BITS-1:0] AOA_B; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .AOA_B (AOA_B[`AOA_BITS-1:0]), // Inputs .DDIFF_B (DDIFF_B[`DDIFF_BITS-1:0]), .reset (reset), .clk (clk)); // Aggregate outputs into a single result vector wire [63:0] result = {56'h0, AOA_B}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3a74e9d34771ad93 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs AOA_B, // Inputs DDIFF_B, reset, clk ); input [`DDIFF_BITS-1:0] DDIFF_B; input reset; input clk; output reg [`AOA_BITS-1:0] AOA_B; reg [`AOA_BITS-1:0] AOA_NEXT_B; reg [`AOA_BITS-1:0] tmp; always @(posedge clk) begin if (reset) begin AOA_B <= 8'h80; end else begin AOA_B <= AOA_NEXT_B; end end always @* begin // verilator lint_off WIDTH tmp = ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER); t_aoa_update(AOA_NEXT_B, AOA_B, ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER)); // verilator lint_on WIDTH end task t_aoa_update; output [`AOA_BITS-1:0] aoa_reg_next; input [`AOA_BITS-1:0] aoa_reg; input [`AOA_BITS-1:0] aoa_delta_update; begin if ((`MAX_AOA-aoa_reg)<aoa_delta_update) //Overflow protection aoa_reg_next=`MAX_AOA; else aoa_reg_next=aoa_reg+aoa_delta_update; end endtask endmodule
module outputs) wire [`AOA_BITS-1:0] AOA_B; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .AOA_B (AOA_B[`AOA_BITS-1:0]), // Inputs .DDIFF_B (DDIFF_B[`DDIFF_BITS-1:0]), .reset (reset), .clk (clk)); // Aggregate outputs into a single result vector wire [63:0] result = {56'h0, AOA_B}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3a74e9d34771ad93 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs AOA_B, // Inputs DDIFF_B, reset, clk ); input [`DDIFF_BITS-1:0] DDIFF_B; input reset; input clk; output reg [`AOA_BITS-1:0] AOA_B; reg [`AOA_BITS-1:0] AOA_NEXT_B; reg [`AOA_BITS-1:0] tmp; always @(posedge clk) begin if (reset) begin AOA_B <= 8'h80; end else begin AOA_B <= AOA_NEXT_B; end end always @* begin // verilator lint_off WIDTH tmp = ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER); t_aoa_update(AOA_NEXT_B, AOA_B, ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER)); // verilator lint_on WIDTH end task t_aoa_update; output [`AOA_BITS-1:0] aoa_reg_next; input [`AOA_BITS-1:0] aoa_reg; input [`AOA_BITS-1:0] aoa_delta_update; begin if ((`MAX_AOA-aoa_reg)<aoa_delta_update) //Overflow protection aoa_reg_next=`MAX_AOA; else aoa_reg_next=aoa_reg+aoa_delta_update; end endtask endmodule
module outputs) wire [`AOA_BITS-1:0] AOA_B; // From test of Test.v // End of automatics Test test (/*AUTOINST*/ // Outputs .AOA_B (AOA_B[`AOA_BITS-1:0]), // Inputs .DDIFF_B (DDIFF_B[`DDIFF_BITS-1:0]), .reset (reset), .clk (clk)); // Aggregate outputs into a single result vector wire [63:0] result = {56'h0, AOA_B}; // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); `endif cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 64'h0; end else if (cyc<10) begin sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3a74e9d34771ad93 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module Test (/*AUTOARG*/ // Outputs AOA_B, // Inputs DDIFF_B, reset, clk ); input [`DDIFF_BITS-1:0] DDIFF_B; input reset; input clk; output reg [`AOA_BITS-1:0] AOA_B; reg [`AOA_BITS-1:0] AOA_NEXT_B; reg [`AOA_BITS-1:0] tmp; always @(posedge clk) begin if (reset) begin AOA_B <= 8'h80; end else begin AOA_B <= AOA_NEXT_B; end end always @* begin // verilator lint_off WIDTH tmp = ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER); t_aoa_update(AOA_NEXT_B, AOA_B, ((`HALF_DDIFF-DDIFF_B)/`BURP_DIVIDER)); // verilator lint_on WIDTH end task t_aoa_update; output [`AOA_BITS-1:0] aoa_reg_next; input [`AOA_BITS-1:0] aoa_reg; input [`AOA_BITS-1:0] aoa_delta_update; begin if ((`MAX_AOA-aoa_reg)<aoa_delta_update) //Overflow protection aoa_reg_next=`MAX_AOA; else aoa_reg_next=aoa_reg+aoa_delta_update; end endtask endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [63:0] crc; reg [31:0] sum; wire [15:0] out0; wire [15:0] out1; wire [15:0] inData = crc[15:0]; wire wr0a = crc[16]; wire wr0b = crc[17]; wire wr1a = crc[18]; wire wr1b = crc[19]; fifo fifo ( // Outputs .out0 (out0[15:0]), .out1 (out1[15:0]), // Inputs .clk (clk), .wr0a (wr0a), .wr0b (wr0b), .wr1a (wr1a), .wr1b (wr1b), .inData (inData[15:0])); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%x q=%x\n",$time, cyc, crc, sum); cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 32'h0; end else if (cyc>10 && cyc<90) begin sum <= {sum[30:0],sum[31]} ^ {out1, out0}; end else if (cyc==99) begin if (sum !== 32'he8bbd130) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module fifo (/*AUTOARG*/ // Outputs out0, out1, // Inputs clk, wr0a, wr0b, wr1a, wr1b, inData ); input clk; input wr0a; input wr0b; input wr1a; input wr1b; input [15:0] inData; output [15:0] out0; output [15:0] out1; reg [15:0] mem [1:0]; reg [15:0] memtemp2 [1:0]; reg [15:0] memtemp3 [1:0]; assign out0 = {mem[0] ^ memtemp2[0]}; assign out1 = {mem[1] ^ memtemp3[1]}; always @(posedge clk) begin // These mem assignments must be done in order after processing if (wr0a) begin memtemp2[0] <= inData; mem[0] <= inData; end if (wr0b) begin memtemp3[0] <= inData; mem[0] <= ~inData; end if (wr1a) begin memtemp3[1] <= inData; mem[1] <= inData; end if (wr1b) begin memtemp2[1] <= inData; mem[1] <= ~inData; end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [63:0] crc; reg [31:0] sum; wire [15:0] out0; wire [15:0] out1; wire [15:0] inData = crc[15:0]; wire wr0a = crc[16]; wire wr0b = crc[17]; wire wr1a = crc[18]; wire wr1b = crc[19]; fifo fifo ( // Outputs .out0 (out0[15:0]), .out1 (out1[15:0]), // Inputs .clk (clk), .wr0a (wr0a), .wr0b (wr0b), .wr1a (wr1a), .wr1b (wr1b), .inData (inData[15:0])); always @ (posedge clk) begin //$write("[%0t] cyc==%0d crc=%x q=%x\n",$time, cyc, crc, sum); cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= 32'h0; end else if (cyc>10 && cyc<90) begin sum <= {sum[30:0],sum[31]} ^ {out1, out0}; end else if (cyc==99) begin if (sum !== 32'he8bbd130) $stop; $write("*-* All Finished *-*\n"); $finish; end end endmodule
module fifo (/*AUTOARG*/ // Outputs out0, out1, // Inputs clk, wr0a, wr0b, wr1a, wr1b, inData ); input clk; input wr0a; input wr0b; input wr1a; input wr1b; input [15:0] inData; output [15:0] out0; output [15:0] out1; reg [15:0] mem [1:0]; reg [15:0] memtemp2 [1:0]; reg [15:0] memtemp3 [1:0]; assign out0 = {mem[0] ^ memtemp2[0]}; assign out1 = {mem[1] ^ memtemp3[1]}; always @(posedge clk) begin // These mem assignments must be done in order after processing if (wr0a) begin memtemp2[0] <= inData; mem[0] <= inData; end if (wr0b) begin memtemp3[0] <= inData; mem[0] <= ~inData; end if (wr1a) begin memtemp3[1] <= inData; mem[1] <= inData; end if (wr1b) begin memtemp2[1] <= inData; mem[1] <= ~inData; end end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; reg _ranit; reg rnd; reg [2:0] a; reg [2:0] b; reg [31:0] wide; // surefire lint_off STMINI initial _ranit = 0; wire sigone1 = 1'b1; wire sigone2 = 1'b1; reg ok; parameter [1:0] twounkn = 2'b?; // This gets extended to 2'b?? // Large case statements should be well optimizable. reg [2:0] anot; always @ (/*AS*/a) begin casez (a) default: anot = 3'b001; 3'd0: anot = 3'b111; 3'd1: anot = 3'b110; 3'd2: anot = 3'b101; 3'd3: anot = 3'b101; 3'd4: anot = 3'b011; 3'd5: anot = 3'b010; 3'd6: anot = 3'b001; // Same so folds with 7 endcase end always @ (posedge clk) begin if (!_ranit) begin _ranit <= 1; rnd <= 1; $write("[%0t] t_case: Running\n", $time); // a = 3'b101; b = 3'b111; // verilator lint_off CASEX casex (a) default: $stop; 3'bx1x: $stop; 3'b100: $stop; 3'bx01: ; endcase casez (a) default: $stop; 3'b?1?: $stop; 3'b100: $stop; 3'b?01: ; endcase casez (a) default: $stop; {1'b0, twounkn}: $stop; {1'b1, twounkn}: ; endcase casez (b) default: $stop; {1'b0, twounkn}: $stop; {1'b1, twounkn}: ; // {1'b0, 2'b??}: $stop; // {1'b1, 2'b??}: ; endcase case(a[0]) default: ; endcase casex(a) default: ; 3'b?0?: ; endcase // verilator lint_off CASEX //This is illegal, the default occurs before the statements. //case(a[0]) // default: $stop; // 1'b1: ; //endcase // wide = 32'h12345678; casez (wide) default: $stop; 32'h12345677, 32'h12345678, 32'h12345679: ; endcase // ok = 0; casez ({sigone1,sigone2}) //2'b10, 2'b01, 2'bXX: ; // verilator bails at this since in 2 state it can be true... 2'b10, 2'b01: ; 2'b00: ; default: ok=1'b1; endcase if (ok !== 1'b1) $stop; // if (rnd) begin $write(""); end // $write("*-* All Finished *-*\n"); $finish; end end // Check parameters in case statements parameter ALU_DO_REGISTER = 3'h1; // input selected by reg addr. parameter DSP_REGISTER_V = 6'h03; reg [2:0] alu_ctl_2s; // Delayed version of alu_ctl reg [5:0] reg_addr_2s; // Delayed version of reg_addr reg [7:0] ir_slave_2s; // Instruction Register delayed 2 phases reg [15:10] f_tmp_2s; // Delayed copy of F reg p00_2s; initial begin alu_ctl_2s = 3'h1; reg_addr_2s = 6'h3; ir_slave_2s= 0; f_tmp_2s= 0; casex ({alu_ctl_2s,reg_addr_2s, ir_slave_2s[7],ir_slave_2s[5:4],ir_slave_2s[1:0], f_tmp_2s[11:10]}) default: p00_2s = 1'b0; {ALU_DO_REGISTER,DSP_REGISTER_V,1'bx,2'bx,2'bx,2'bx}: p00_2s = 1'b1; endcase if (1'b0) $display ("%x %x %x %x", alu_ctl_2s, ir_slave_2s, f_tmp_2s, p00_2s); //Prevent unused // case ({1'b1, 1'b1}) default: $stop; {1'b1, p00_2s}: ; endcase end // Check wide overlapping cases // surefire lint_off CSEOVR parameter ANY_STATE = 7'h??; reg [19:0] foo; initial begin foo = {1'b0,1'b0,1'b0,1'b0,1'b0,7'h04,8'b0}; casez (foo) default: $stop; {1'b1,1'b?,1'b?,1'b?,1'b?,ANY_STATE,8'b?}: $stop; {1'b?,1'b1,1'b?,1'b?,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b1,1'b?,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b?,1'b1,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h04,8'b?}: ; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h06,8'hdf}: $stop; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h06,8'h00}: $stop; endcase end initial begin foo = 20'b1010; casex (foo[3:0]) default: $stop; 4'b0xxx, 4'b100x, 4'b11xx: $stop; 4'b1010: ; endcase end initial begin foo = 20'b1010; ok = 1'b0; // Test of RANGE(CONCAT reductions... casex ({foo[3:2],foo[1:0],foo[3]}) 5'bxx10x: begin ok=1'b0; foo=20'd1; ok=1'b1; end // Check multiple expressions 5'bxx00x: $stop; 5'bxx01x: $stop; 5'bxx11x: $stop; endcase if (!ok) $stop; end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; reg _ranit; reg rnd; reg [2:0] a; reg [2:0] b; reg [31:0] wide; // surefire lint_off STMINI initial _ranit = 0; wire sigone1 = 1'b1; wire sigone2 = 1'b1; reg ok; parameter [1:0] twounkn = 2'b?; // This gets extended to 2'b?? // Large case statements should be well optimizable. reg [2:0] anot; always @ (/*AS*/a) begin casez (a) default: anot = 3'b001; 3'd0: anot = 3'b111; 3'd1: anot = 3'b110; 3'd2: anot = 3'b101; 3'd3: anot = 3'b101; 3'd4: anot = 3'b011; 3'd5: anot = 3'b010; 3'd6: anot = 3'b001; // Same so folds with 7 endcase end always @ (posedge clk) begin if (!_ranit) begin _ranit <= 1; rnd <= 1; $write("[%0t] t_case: Running\n", $time); // a = 3'b101; b = 3'b111; // verilator lint_off CASEX casex (a) default: $stop; 3'bx1x: $stop; 3'b100: $stop; 3'bx01: ; endcase casez (a) default: $stop; 3'b?1?: $stop; 3'b100: $stop; 3'b?01: ; endcase casez (a) default: $stop; {1'b0, twounkn}: $stop; {1'b1, twounkn}: ; endcase casez (b) default: $stop; {1'b0, twounkn}: $stop; {1'b1, twounkn}: ; // {1'b0, 2'b??}: $stop; // {1'b1, 2'b??}: ; endcase case(a[0]) default: ; endcase casex(a) default: ; 3'b?0?: ; endcase // verilator lint_off CASEX //This is illegal, the default occurs before the statements. //case(a[0]) // default: $stop; // 1'b1: ; //endcase // wide = 32'h12345678; casez (wide) default: $stop; 32'h12345677, 32'h12345678, 32'h12345679: ; endcase // ok = 0; casez ({sigone1,sigone2}) //2'b10, 2'b01, 2'bXX: ; // verilator bails at this since in 2 state it can be true... 2'b10, 2'b01: ; 2'b00: ; default: ok=1'b1; endcase if (ok !== 1'b1) $stop; // if (rnd) begin $write(""); end // $write("*-* All Finished *-*\n"); $finish; end end // Check parameters in case statements parameter ALU_DO_REGISTER = 3'h1; // input selected by reg addr. parameter DSP_REGISTER_V = 6'h03; reg [2:0] alu_ctl_2s; // Delayed version of alu_ctl reg [5:0] reg_addr_2s; // Delayed version of reg_addr reg [7:0] ir_slave_2s; // Instruction Register delayed 2 phases reg [15:10] f_tmp_2s; // Delayed copy of F reg p00_2s; initial begin alu_ctl_2s = 3'h1; reg_addr_2s = 6'h3; ir_slave_2s= 0; f_tmp_2s= 0; casex ({alu_ctl_2s,reg_addr_2s, ir_slave_2s[7],ir_slave_2s[5:4],ir_slave_2s[1:0], f_tmp_2s[11:10]}) default: p00_2s = 1'b0; {ALU_DO_REGISTER,DSP_REGISTER_V,1'bx,2'bx,2'bx,2'bx}: p00_2s = 1'b1; endcase if (1'b0) $display ("%x %x %x %x", alu_ctl_2s, ir_slave_2s, f_tmp_2s, p00_2s); //Prevent unused // case ({1'b1, 1'b1}) default: $stop; {1'b1, p00_2s}: ; endcase end // Check wide overlapping cases // surefire lint_off CSEOVR parameter ANY_STATE = 7'h??; reg [19:0] foo; initial begin foo = {1'b0,1'b0,1'b0,1'b0,1'b0,7'h04,8'b0}; casez (foo) default: $stop; {1'b1,1'b?,1'b?,1'b?,1'b?,ANY_STATE,8'b?}: $stop; {1'b?,1'b1,1'b?,1'b?,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b1,1'b?,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b?,1'b1,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h04,8'b?}: ; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h06,8'hdf}: $stop; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h06,8'h00}: $stop; endcase end initial begin foo = 20'b1010; casex (foo[3:0]) default: $stop; 4'b0xxx, 4'b100x, 4'b11xx: $stop; 4'b1010: ; endcase end initial begin foo = 20'b1010; ok = 1'b0; // Test of RANGE(CONCAT reductions... casex ({foo[3:2],foo[1:0],foo[3]}) 5'bxx10x: begin ok=1'b0; foo=20'd1; ok=1'b1; end // Check multiple expressions 5'bxx00x: $stop; 5'bxx01x: $stop; 5'bxx11x: $stop; endcase if (!ok) $stop; end endmodule
module t (/*AUTOARG*/ // Inputs clk ); input clk; reg _ranit; reg rnd; reg [2:0] a; reg [2:0] b; reg [31:0] wide; // surefire lint_off STMINI initial _ranit = 0; wire sigone1 = 1'b1; wire sigone2 = 1'b1; reg ok; parameter [1:0] twounkn = 2'b?; // This gets extended to 2'b?? // Large case statements should be well optimizable. reg [2:0] anot; always @ (/*AS*/a) begin casez (a) default: anot = 3'b001; 3'd0: anot = 3'b111; 3'd1: anot = 3'b110; 3'd2: anot = 3'b101; 3'd3: anot = 3'b101; 3'd4: anot = 3'b011; 3'd5: anot = 3'b010; 3'd6: anot = 3'b001; // Same so folds with 7 endcase end always @ (posedge clk) begin if (!_ranit) begin _ranit <= 1; rnd <= 1; $write("[%0t] t_case: Running\n", $time); // a = 3'b101; b = 3'b111; // verilator lint_off CASEX casex (a) default: $stop; 3'bx1x: $stop; 3'b100: $stop; 3'bx01: ; endcase casez (a) default: $stop; 3'b?1?: $stop; 3'b100: $stop; 3'b?01: ; endcase casez (a) default: $stop; {1'b0, twounkn}: $stop; {1'b1, twounkn}: ; endcase casez (b) default: $stop; {1'b0, twounkn}: $stop; {1'b1, twounkn}: ; // {1'b0, 2'b??}: $stop; // {1'b1, 2'b??}: ; endcase case(a[0]) default: ; endcase casex(a) default: ; 3'b?0?: ; endcase // verilator lint_off CASEX //This is illegal, the default occurs before the statements. //case(a[0]) // default: $stop; // 1'b1: ; //endcase // wide = 32'h12345678; casez (wide) default: $stop; 32'h12345677, 32'h12345678, 32'h12345679: ; endcase // ok = 0; casez ({sigone1,sigone2}) //2'b10, 2'b01, 2'bXX: ; // verilator bails at this since in 2 state it can be true... 2'b10, 2'b01: ; 2'b00: ; default: ok=1'b1; endcase if (ok !== 1'b1) $stop; // if (rnd) begin $write(""); end // $write("*-* All Finished *-*\n"); $finish; end end // Check parameters in case statements parameter ALU_DO_REGISTER = 3'h1; // input selected by reg addr. parameter DSP_REGISTER_V = 6'h03; reg [2:0] alu_ctl_2s; // Delayed version of alu_ctl reg [5:0] reg_addr_2s; // Delayed version of reg_addr reg [7:0] ir_slave_2s; // Instruction Register delayed 2 phases reg [15:10] f_tmp_2s; // Delayed copy of F reg p00_2s; initial begin alu_ctl_2s = 3'h1; reg_addr_2s = 6'h3; ir_slave_2s= 0; f_tmp_2s= 0; casex ({alu_ctl_2s,reg_addr_2s, ir_slave_2s[7],ir_slave_2s[5:4],ir_slave_2s[1:0], f_tmp_2s[11:10]}) default: p00_2s = 1'b0; {ALU_DO_REGISTER,DSP_REGISTER_V,1'bx,2'bx,2'bx,2'bx}: p00_2s = 1'b1; endcase if (1'b0) $display ("%x %x %x %x", alu_ctl_2s, ir_slave_2s, f_tmp_2s, p00_2s); //Prevent unused // case ({1'b1, 1'b1}) default: $stop; {1'b1, p00_2s}: ; endcase end // Check wide overlapping cases // surefire lint_off CSEOVR parameter ANY_STATE = 7'h??; reg [19:0] foo; initial begin foo = {1'b0,1'b0,1'b0,1'b0,1'b0,7'h04,8'b0}; casez (foo) default: $stop; {1'b1,1'b?,1'b?,1'b?,1'b?,ANY_STATE,8'b?}: $stop; {1'b?,1'b1,1'b?,1'b?,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b1,1'b?,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b?,1'b1,1'b?,7'h00,8'b?}: $stop; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h04,8'b?}: ; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h06,8'hdf}: $stop; {1'b?,1'b?,1'b?,1'b?,1'b?,7'h06,8'h00}: $stop; endcase end initial begin foo = 20'b1010; casex (foo[3:0]) default: $stop; 4'b0xxx, 4'b100x, 4'b11xx: $stop; 4'b1010: ; endcase end initial begin foo = 20'b1010; ok = 1'b0; // Test of RANGE(CONCAT reductions... casex ({foo[3:2],foo[1:0],foo[3]}) 5'bxx10x: begin ok=1'b0; foo=20'd1; ok=1'b1; end // Check multiple expressions 5'bxx00x: $stop; 5'bxx01x: $stop; 5'bxx11x: $stop; endcase if (!ok) $stop; end endmodule
module outputs) wire [63:0] r1_d_d2r; // From file of file.v wire [63:0] r2_d_d2r; // From file of file.v // End of automatics file file (/*AUTOINST*/ // Outputs .r1_d_d2r (r1_d_d2r[63:0]), .r2_d_d2r (r2_d_d2r[63:0]), // Inputs .clk (clk), .r1_en (r1_en), .r1_ad (r1_ad[1:0]), .r2_en (r2_en), .r2_ad (r2_ad[1:0]), .w1_en (w1_en), .w1_a (w1_a[1:0]), .w1_d (w1_d[63:0]), .w2_en (w2_en), .w2_a (w2_a[1:0]), .w2_d (w2_d[63:0])); always @ (posedge clk) begin //$write("[%0t] cyc==%0d EN=%b%b%b%b R0=%x R1=%x\n",$time, cyc, r1_en,r2_en,w1_en,w2_en, r1_d_d2r, r2_d_d2r); cyc <= cyc + 1; crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; sum <= {r1_d_d2r ^ r2_d_d2r} ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; end else if (cyc<10) begin // We've manually verified all X's are out of the design by this point sum <= 64'h0; end else if (cyc<90) begin end else if (cyc==99) begin $write("*-* All Finished *-*\n"); $write("[%0t] cyc==%0d crc=%x %x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== 64'h5e9ea8c33a97f81e) $stop; $finish; end end endmodule