1 // Copyright 2017 Gnarly Grey LLC
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 reg [3:0] i_mem_wstrb;
32 reg [31:0] i_mem_addr;
33 reg [31:0] i_mem_wdata;
37 wire [31:0] o_mem_rdata;
48 reg [31:0] test_data [0:31];
50 integer uint8_addr = 0;
51 integer uint16_addr = 128;
52 integer uint32_addr = 256;
57 .i_cfg_access(i_cfg_access),
58 .i_mem_valid(i_mem_valid),
59 .o_mem_ready(o_mem_ready),
60 .i_mem_wstrb(i_mem_wstrb),
61 .i_mem_addr(i_mem_addr),
62 .i_mem_wdata(i_mem_wdata),
63 .o_mem_rdata(o_mem_rdata),
75 .TimingModel("S27KL0641DABHI000"))
106 $display("Waiting for device power-up...");
108 $display("Reading the ID/CFG registers");
116 wait(o_mem_ready == 1);
117 $display("ID0: 0x%H", o_mem_rdata[15:0]);
124 wait(o_mem_ready == 1);
125 $display("ID1: 0x%H", o_mem_rdata[15:0]);
132 wait(o_mem_ready == 1);
133 $display("CFG0: 0x%H", o_mem_rdata[15:0]);
140 wait(o_mem_ready == 1);
141 $display("CFG1: 0x%H", o_mem_rdata[15:0]);
144 test_data[0] = 32'hDEADBEEF;
145 for(i = 1; i < 32; i = i + 1) begin
146 test_data[i] = {test_data[i - 1][27:0], test_data[i - 1][31:28]};
149 $display("UINT8_t test");
150 for(i = 0; i < 32; i = i + 1) begin
151 i_mem_wdata = test_data[i];
152 i_mem_addr = uint8_addr + (i << 2);
153 for(k = 0; k < 4; k = k + 1) begin
155 i_mem_wstrb = (1 << k);
158 wait(o_mem_ready == 1);
163 $display("expected\tread\t\tstatus");
165 for(i = 0; i < 32; i = i + 1) begin
166 i_mem_addr = uint8_addr + (i << 2);
167 for(k = 0; k < 4; k = k + 1) begin
171 wait(o_mem_ready == 1);
172 if((o_mem_rdata & (255 << k*8)) == (test_data[i] & (255 << k*8))) begin
173 $display("0x%H\t0x%H\tOK", (test_data[i] & (255 << k*8)), (o_mem_rdata & (255 << k*8)));
175 $display("0x%H\t0x%H\tFAIL", (test_data[i] & (255 << k*8)), (o_mem_rdata & (255 << k*8)));
181 $display("UINT16_t test");
182 for(i = 0; i < 32; i = i + 1) begin
183 i_mem_wdata = test_data[i];
184 i_mem_addr = uint16_addr + (i << 2);
185 for(k = 0; k < 2; k = k + 1) begin
187 i_mem_wstrb = (3 << (k*2));
190 wait(o_mem_ready == 1);
195 $display("expected\tread\t\tstatus");
197 for(i = 0; i < 32; i = i + 1) begin
198 i_mem_addr = uint8_addr + (i << 2);
199 for(k = 0; k < 2; k = k + 1) begin
203 wait(o_mem_ready == 1);
204 if((o_mem_rdata & (16'hFFFF << k*16)) == (test_data[i] & (16'hFFFF << k*16))) begin
205 $display("0x%H\t0x%H\tOK", (test_data[i] & (16'hFFFF << k*16)), (o_mem_rdata & (16'hFFFF << k*16)));
207 $display("0x%H\t0x%H\tFAIL", (test_data[i] & (16'hFFFF << k*16)), (o_mem_rdata & (16'hFFFF << k*16)));
213 $display("UINT32_t test");
214 for(i = 0; i < 32; i = i + 1) begin
215 i_mem_wdata = test_data[i];
216 i_mem_addr = uint32_addr + (i << 2);
221 wait(o_mem_ready == 1);
225 $display("expected\tread\t\tstatus");
227 for(i = 0; i < 32; i = i + 1) begin
228 i_mem_addr = uint8_addr + (i << 2);
232 wait(o_mem_ready == 1);
233 if(o_mem_rdata == test_data[i]) begin
234 $display("0x%H\t0x%H\tOK", (test_data[i]), (o_mem_rdata));
236 $display("0x%H\t0x%H\tFAIL", (test_data[i]), (o_mem_rdata));
250 $dumpfile("hypersim.fst");
252 $dumpvars(0, i_rstn);
254 $dumpvars(0, o_resetn);
255 $dumpvars(0, o_csn0);
256 $dumpvars(0, o_csn1);
257 $dumpvars(0, io_rwds);
259 $dumpvars(0, i_cfg_access);
260 $dumpvars(0, i_mem_valid);
261 $dumpvars(0, o_mem_ready);
262 $dumpvars(0, i_mem_wstrb);
263 $dumpvars(0, i_mem_addr);
264 $dumpvars(0, i_mem_wdata);
265 $dumpvars(0, o_mem_rdata);