Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single spi #4

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ddbf7e3
glitches
mattvenn Nov 15, 2018
4734746
savefile
mattvenn Nov 16, 2018
05b7d34
savefile
mattvenn Nov 16, 2018
e1f09eb
looking at null bytes
mattvenn Nov 16, 2018
067cc73
move gtkwave filters
Nov 18, 2018
f21638c
working with regular clock
Nov 18, 2018
9760a04
tidy up sspi dir
Nov 18, 2018
5a43d03
formal
Nov 18, 2018
696e225
formally verified with CDC
mattvenn Nov 19, 2018
e006d8e
assign spi_rdy and err high
mattvenn Nov 19, 2018
e229432
added more testbench support files
mattvenn Nov 20, 2018
a25d0c4
no_glitch localparam to turn on clock glitching
mattvenn Nov 20, 2018
ed19d85
testing spi comms and camera
mattvenn Nov 21, 2018
07048df
wait for acks properly by controlling cs pin manually
mattvenn Nov 21, 2018
332e583
add length and position to read and write routines
mattvenn Nov 21, 2018
a9efb1b
random write/read test
mattvenn Nov 21, 2018
1ae583a
kernel upload, run and readout works, but only with 128byte reads
mattvenn Nov 21, 2018
b67c8d5
fixed ACK: working with 1024 byte write/reads
mattvenn Nov 21, 2018
4575fe0
nicer formatting
mattvenn Nov 21, 2018
02e10bd
include spi client verilog
mattvenn Nov 26, 2018
1bbcbb3
pcf for lattice up5k dev board
mattvenn Nov 26, 2018
5a1619e
gtkwave config
mattvenn Nov 26, 2018
931fafa
Merge branch 'single_spi_reg_clock' of mattvenn.net:~/symbiotic_eda/m…
mattvenn Nov 26, 2018
443d1e4
change print for python2
mattvenn Nov 26, 2018
9f1006e
Merge branch 'single_spi_reg_clock' of mattvenn.net:~/symbiotic_eda/m…
mattvenn Nov 26, 2018
ed52c10
pinout
mattvenn Nov 26, 2018
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

savefile

  • Loading branch information
mattvenn committed Nov 16, 2018
commit 47347469f953e3ca48908e79ee28e430599e1e77
@@ -4,8 +4,8 @@ gtkwave: testbench
gtkwave testbench.vcd spi.gtkwave


testbench: testbench.v top.v
iverilog -DTRACE -s testbench -o testbench testbench.v top.v $(shell yosys-config --datdir/ice40/cells_sim.v)
testbench: testbench.v top.v memory.v sequencer.v compute.v
iverilog -DTRACE -s testbench -o testbench testbench.v top.v memory.v sequencer.v compute.v $(shell yosys-config --datdir/ice40/cells_sim.v)
vvp -N testbench > >( tee testbench.log; )

clean:
@@ -0,0 +1,7 @@
20 = status
21 = wbuf
22 = rbuf
23 = wmem
24 = rmem
25 = run
26 = stop
@@ -0,0 +1,139 @@
[*]
[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI
[*] Fri Nov 16 14:38:41 2018
[*]
[dumpfile] "/home/matt/work/fpga/mlaccel/rtl/sspi/testbench.vcd"
[dumpfile_mtime] "Fri Nov 16 14:38:13 2018"
[dumpfile_size] 1538886
[savefile] "/home/matt/work/fpga/mlaccel/rtl/sspi/spi.gtkwave"
[timestart] 0
[size] 1917 1020
[pos] -1 -1
*-16.000000 89100 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[treeopen] testbench.
[treeopen] testbench.uut.
[treeopen] testbench.uut.mem.
[treeopen] testbench.uut.mem.ram[0].
[sst_width] 253
[signals_width] 492
[sst_expanded] 1
[sst_vpaned_height] 306
@28
testbench.clock
@2024
^1 /tmp/../home/matt/work/fpga/mlaccel/rtl/sspi/state_filter.txt
testbench.uut.state[5:0]
@22
testbench.uut.buffer_ptr[10:0]
testbench.uut.dout_data[7:0]
@8025
testbench.cursor
@28
testbench.uut.reset
testbench.uut.spi.spi_csb_di
testbench.spi_clk
@2022
^2 /tmp/../home/matt/work/fpga/mlaccel/rtl/sspi/cmd_filter.txt
testbench.uut.din_data[7:0]
@22
testbench.uut.dout_data[7:0]
@28
testbench.uut.din_start
testbench.uut.spi.di_start
testbench.uut.din_valid
testbench.uut.spi_active
@c00022
testbench.xfer[7:0]
@28
(0)testbench.xfer[7:0]
(1)testbench.xfer[7:0]
(2)testbench.xfer[7:0]
(3)testbench.xfer[7:0]
(4)testbench.xfer[7:0]
(5)testbench.xfer[7:0]
(6)testbench.xfer[7:0]
(7)testbench.xfer[7:0]
@1401200
-group_end
@28
testbench.spi_mosi_reg
testbench.spi_miso
@200
-
@28
testbench.uut.dout_valid
testbench.uut.dout_ready
testbench.uut.spi.dout_busy
@c00024
testbench.uut.spi.do_data[7:0]
@28
(0)testbench.uut.spi.do_data[7:0]
(1)testbench.uut.spi.do_data[7:0]
(2)testbench.uut.spi.do_data[7:0]
(3)testbench.uut.spi.do_data[7:0]
(4)testbench.uut.spi.do_data[7:0]
(5)testbench.uut.spi.do_data[7:0]
(6)testbench.uut.spi.do_data[7:0]
(7)testbench.uut.spi.do_data[7:0]
@1401200
-group_end
@24
testbench.uut.spi.do_bit[2:0]
testbench.uut.spi.glitch_guard_do_bit_q0[7:0]
testbench.uut.spi.glitch_guard_do_bit[7:0]
@28
testbench.uut.spi_clk
testbench.uut.spi.spi_miso
@200
-
@c00028
testbench.uut.spi.din_data[7:0]
@28
(0)testbench.uut.spi.din_data[7:0]
(1)testbench.uut.spi.din_data[7:0]
(2)testbench.uut.spi.din_data[7:0]
(3)testbench.uut.spi.din_data[7:0]
(4)testbench.uut.spi.din_data[7:0]
(5)testbench.uut.spi.din_data[7:0]
(6)testbench.uut.spi.din_data[7:0]
(7)testbench.uut.spi.din_data[7:0]
@1401200
-group_end
@24
testbench.uut.spi.di_bit[2:0]
@c00022
testbench.uut.spi.di_data[7:0]
@28
(0)testbench.uut.spi.di_data[7:0]
(1)testbench.uut.spi.di_data[7:0]
(2)testbench.uut.spi.di_data[7:0]
(3)testbench.uut.spi.di_data[7:0]
(4)testbench.uut.spi.di_data[7:0]
(5)testbench.uut.spi.di_data[7:0]
(6)testbench.uut.spi.di_data[7:0]
(7)testbench.uut.spi.di_data[7:0]
@1401200
-group_end
@28
testbench.uut.spi.spi_mosi
@200
-
@28
testbench.uut.spi.spi_clk_di
testbench.uut.spi.glitch_guard_clock_q0
testbench.uut.spi.glitch_guard_negedge
testbench.uut.spi.glitch_guard_posedge
testbench.uut.spi.clk_q1
testbench.uut.spi.clk_q2
@200
-
@22
testbench.uut.mem.addr0[13:0]
testbench.uut.mem.addr[15:0]
testbench.uut.mem.rdata[63:0]
testbench.uut.mem.wdata[63:0]
testbench.uut.state[5:0]
testbench.uut.buffer_ptr[10:0]
testbench.uut.mem.wen[7:0]
[pattern_trace] 1
[pattern_trace] 0
@@ -0,0 +1,14 @@
0 = halt
1 = status
2 = wbuf
3 = rbuf
4 = wmem0
5 = wmem1
6 = wmem2
7 = wmem3
8 = rmem0
9 = rmem1
10 = rmem2
11 = rmem3
12 = run0
13 = run1
@@ -163,16 +163,23 @@ module testbench;

task xfer_wait;
begin
xfer_negedge;
xfer_posedge;

xfer_negedge;
spi_miso_reg = 1'bz;
xfer_posedge;

// xfer_negedge;
// xfer_posedge;

end
endtask

task xfer_recv;
begin
xfer_negedge;
spi_miso_reg = 1'bz;
xfer_posedge;

xfer_negedge;
xfer[7] = spi_miso;
xfer_posedge;
@@ -230,8 +237,8 @@ module testbench;
reg [7:0] outdata [0:128*1024-1];

initial begin
$readmemh("../asm/demo.hex", indata);
$readmemh("../sim/demo_out.hex", outdata);
$readmemh("../../asm/demo.hex", indata);
$readmemh("../../sim/demo_out.hex", outdata);
end

initial begin
@@ -242,81 +249,45 @@ module testbench;
$display("Uploading demo kernel.");
$fflush;

i= 0;
len = 1;
cursor = 0;
while (cursor < 128*1024) begin
if (indata[cursor] !== 8'h XX) begin
len = 1;
while ((len < 1024) && (len+cursor < 128*1024) &&
(indata[cursor+len] !== 8'h XX)) len = len+1;

if ((cursor % 2) != 0) begin
cursor = cursor - 1;
len = len + 1;
end

if ((len % 4) != 0) begin
len = len - (len % 4) + 4;
end

if (len > 1024) begin
len = 1024;
end

$display(" uploading %4d bytes to 0x%05x", len, cursor);
while (cursor < 32) begin
i = 0;
$display(" uploading %4d bytes from 0x%05x", len, cursor);
$fflush;

xfer_start;
xfer_send_byte(8'h 21);
for (i = 0; i < len; i = i+1)
xfer_send_byte(indata[cursor+i]);
xfer_send_byte(cursor);
xfer_stop;

xfer_start;
xfer_send_byte(8'h 23);
xfer_send_hword(cursor >> 1);
xfer_send_byte(len >> 2);
xfer_send_hword(cursor);
xfer_send_byte(len);
xfer_wait;
xfer_recv;

while (xfer != 8'h 00)
xfer_recv;
xfer_stop;

cursor = cursor + len;
end else begin
cursor = cursor + 1;
end
end

$display("Readback.");
$fflush;

len = 1;
cursor = 0;
while (cursor < 128*1024) begin
if (indata[cursor] !== 8'h XX) begin
len = 1;
while ((len < 1024) && (len+cursor < 128*1024) &&
(indata[cursor+len] !== 8'h XX)) len = len+1;

if ((cursor % 2) != 0) begin
cursor = cursor - 1;
len = len + 1;
end

if ((len % 4) != 0) begin
len = len - (len % 4) + 4;
end

if (len > 1024) begin
len = 1024;
end

while (cursor < 32) begin
$display(" downloading %4d bytes from 0x%05x", len, cursor);
$fflush;

xfer_start;
xfer_send_byte(8'h 24);
xfer_send_hword(cursor >> 1);
xfer_send_byte(len >> 2);
xfer_send_hword(cursor);
xfer_send_byte(len);
xfer_wait;
xfer_recv;
while (xfer != 8'h 00)
@@ -326,20 +297,17 @@ module testbench;
xfer_start;
xfer_send_byte(8'h 22);
xfer_wait;
for (i = 0; i < len; i = i+1) begin
xfer_recv;
if (indata[cursor+i] !== 8'h XX && indata[cursor+i] !== xfer) begin
$display("ERROR at %d: expected 0x%02x, got 0x%02x", cursor+i, indata[cursor+i], xfer);
end
end
xfer_recv;
if( xfer != cursor) begin
$display("ERROR at %4d: expected 0x%02x, got 0x%02x", cursor, cursor, xfer);
end
xfer_stop;

cursor = cursor + len;
end else begin
cursor = cursor + 1;
end
end


$finish;
$display("Running kernel.");
$fflush;

ProTip! Use n and p to navigate between commits in a pull request.