diff --git a/src/stdlib/dv/stimulus.v b/src/stdlib/dv/stimulus.v index fc6f993..ae4cb55 100644 --- a/src/stdlib/dv/stimulus.v +++ b/src/stdlib/dv/stimulus.v @@ -1,143 +1,141 @@ // A stimulus file provides inputs signals to the design under test (DUT). // This stimulus module is designed to be compatible with verilog simulators, // emulators, and FPGA prototyping. This is akin to a simple test vector generator -// No looping supported! -// -// Memory format: -// b0 = valid, -// b1-7 = wait time -// b8-bxxx = packet // // Test Process: // 1. Zero out memory (or write program) // 2. Set go signal -// -module stimulus #( parameter DW = 32, // Memory width=DW+ - parameter MAW = 15, // Memory address width - parameter HEXFILE = "NONE" // Name of hex file - ) - ( - //Asynchronous Stimulus Reset - input nreset, - input ext_start, // Start driving stimulus - input use_timestamps,//b1-7 used for timestamps - input ignore_valid,//b0 valid bit ignored - //External Load port - input ext_clk,// External clock for write path - input ext_access, // Valid packet for memory - input [DW-1:0] ext_packet, // Packet for memory - //DUT Drive port - input dut_clk, // DUT side clock - input dut_wait, // DUT stall signal - output stim_access, // Access signal - output [DW-1:0] stim_packet, // Packet - output stim_done // Stimulus program done - ); +// 3. Drive out all valid packets sequentially - localparam MD = 1< 1) ? mem_data[CW:1] : 'b0; end - `STIM_PAUSE : + STIM_PAUSE : begin - rd_state[1:0] <= (|rd_delay[6:0]) ? `STIM_PAUSE : `STIM_ACTIVE; - rd_delay[6:0] <= rd_delay[6:0] - 1'b1; + rd_state[1:0] <= (|rd_delay) ? STIM_PAUSE : STIM_ACTIVE; + rd_delay <= rd_delay - 1'b1; end endcase // case (rd_state[1:0]) - + //Output Driver - assign stim_done = (rd_state[1:0] == `STIM_DONE); - assign stim_valid = ignore_valid | stim_packet[0]; - + assign stim_done = (rd_state[1:0] == STIM_DONE); + assign valid_packet = (CW==0) | mem_data[0]; + //################################# // RAM //################################# //write port - always @(posedge ext_clk) + always @(posedge ext_clk) if(ext_access) - ram[wr_addr[MAW-1:0]] <= ext_packet[DW-1:0]; + ram[wr_addr[MAW-1:0]] <= ext_packet[MW-1:0]; //read port always @ (posedge dut_clk) begin - stim_packet[DW-1:0] <= ram[rd_addr[MAW-1:0]]; - stim_read <= (rd_state==`STIM_ACTIVE); //mem-cycle adjust + mem_data[MW-1:0] <= ram[rd_addr[MAW-1:0]]; + mem_read <= (rd_state==STIM_ACTIVE); //mem-cycle adjust end //Shut off access immediately, but pipeline delay by one cycle - assign stim_access = stim_valid & stim_read & ~stim_done; - -endmodule // stimulus + assign stim_valid = valid_packet & mem_read & ~stim_done; + assign stim_packet[DW-1:0] = mem_data[MW-1:CW]; - +endmodule // stimulus diff --git a/src/stdlib/dv/tb_oh_stimulus.v b/src/stdlib/dv/tb_oh_stimulus.v new file mode 100644 index 0000000..3e135b5 --- /dev/null +++ b/src/stdlib/dv/tb_oh_stimulus.v @@ -0,0 +1,52 @@ +module testbench(); + + localparam DW = 144; + localparam CW = 8; + localparam FILENAME = "test.mem"; // + + /*AUTOINPUT*/ + /*AUTOWIRE*/ + // Beginning of automatic wires (for undeclared instantiated-module outputs) + wire nreset; // From oh_simctrl of oh_simctrl.v + wire start; // From oh_simctrl of oh_simctrl.v + wire stim_done; // From oh_stimulus of oh_stimulus.v + wire [DW-1:0] stim_packet; // From oh_stimulus of oh_stimulus.v + wire stim_valid; // From oh_stimulus of oh_stimulus.v + wire vdd; // From oh_simctrl of oh_simctrl.v + wire vss; // From oh_simctrl of oh_simctrl.v + // End of automatics + + oh_stimulus #(.DW(DW), + .CW(CW), + .FILENAME(FILENAME)) + oh_stimulus(.dut_ready (1'b1), + .dut_clk (dut_clk), + .ext_valid (1'b0), + .ext_packet ({(DW + CW){1'b0}}), + .ext_clk (ext_clk), + .ext_start (start), + /*AUTOINST*/ + // Outputs + .stim_valid (stim_valid), + .stim_packet (stim_packet[DW-1:0]), + .stim_done (stim_done), + // Inputs + .nreset (nreset)); + + oh_simctrl oh_simctrl(.stim_done (1'b0), + .test_done (1'b1), + .test_diff (1'b0), + .dut_active (1'b1), + .clk1 (ext_clk), + .clk2 (dut_clk), + /*AUTOINST*/ + // Outputs + .nreset (nreset), + .start (start), + .vdd (vdd), + .vss (vss)); + +endmodule // tb +// Local Variables: +// verilog-library-directories:("." "../hdl") +// End: