origen_spi 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/bin/fix_my_workspace +100 -100
- data/config/application.rb +103 -103
- data/config/boot.rb +24 -24
- data/config/commands.rb +87 -87
- data/config/version.rb +8 -8
- data/lib/origen_spi.rb +19 -19
- data/lib/origen_spi/driver.rb +374 -367
- data/lib/tasks/origen_spi.rake +6 -6
- data/pattern/clear_flags_test.rb +17 -17
- data/pattern/clock_test.rb +38 -38
- data/pattern/keep_ss_active.rb +24 -24
- data/pattern/overlay_test.rb +17 -17
- data/pattern/shift_test.rb +66 -66
- data/templates/web/index.md.erb +87 -87
- data/templates/web/layouts/_basic.html.erb +13 -13
- data/templates/web/partials/_navbar.html.erb +20 -20
- data/templates/web/release_notes.md.erb +5 -5
- metadata +3 -3
data/lib/tasks/origen_spi.rake
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# You can define any Rake tasks to support your application here (or in any file
|
2
|
-
# ending in .rake in this directory).
|
3
|
-
#
|
4
|
-
# Rake (Ruby Make) is very useful for creating build scripts, see this short video
|
5
|
-
# for a quick introduction:
|
6
|
-
# http://railscasts.com/episodes/66-custom-rake-tasks
|
1
|
+
# You can define any Rake tasks to support your application here (or in any file
|
2
|
+
# ending in .rake in this directory).
|
3
|
+
#
|
4
|
+
# Rake (Ruby Make) is very useful for creating build scripts, see this short video
|
5
|
+
# for a quick introduction:
|
6
|
+
# http://railscasts.com/episodes/66-custom-rake-tasks
|
data/pattern/clear_flags_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
Pattern.create do
|
2
|
-
tester.set_timeset 'tp0', 20
|
3
|
-
dut.pin(:ss).drive 1
|
4
|
-
dut.pin(:sclk).drive 0
|
5
|
-
dut.pin(:mosi).drive 0
|
6
|
-
dut.pin(:miso).dont_care
|
7
|
-
|
8
|
-
tester.cycle
|
9
|
-
|
10
|
-
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
-
in_data = Origen::Registers::Reg.dummy(12).read 0x5a5
|
12
|
-
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in'
|
13
|
-
dut.spi.shift master_out: out_data, master_in: in_data
|
14
|
-
|
15
|
-
tester.cycle
|
16
|
-
cc 'shifting in same register, should be no compares'
|
17
|
-
dut.spi.shift master_in: in_data
|
1
|
+
Pattern.create do
|
2
|
+
tester.set_timeset 'tp0', 20
|
3
|
+
dut.pin(:ss).drive 1
|
4
|
+
dut.pin(:sclk).drive 0
|
5
|
+
dut.pin(:mosi).drive 0
|
6
|
+
dut.pin(:miso).dont_care
|
7
|
+
|
8
|
+
tester.cycle
|
9
|
+
|
10
|
+
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
+
in_data = Origen::Registers::Reg.dummy(12).read 0x5a5
|
12
|
+
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in'
|
13
|
+
dut.spi.shift master_out: out_data, master_in: in_data
|
14
|
+
|
15
|
+
tester.cycle
|
16
|
+
cc 'shifting in same register, should be no compares'
|
17
|
+
dut.spi.shift master_in: in_data
|
18
18
|
end
|
data/pattern/clock_test.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
Pattern.create do
|
2
|
-
tester.set_timeset 'tp0', 20
|
3
|
-
dut.pin(:ss).drive 1
|
4
|
-
dut.pin(:sclk).drive 0
|
5
|
-
dut.pin(:mosi).drive 0
|
6
|
-
dut.pin(:miso).dont_care
|
7
|
-
|
8
|
-
tester.cycle
|
9
|
-
dut.spi.sclk_cycle
|
10
|
-
tester.cycle
|
11
|
-
|
12
|
-
cc 'change multiple to 2'
|
13
|
-
dut.spi.clk_multiple = 2
|
14
|
-
dut.spi.sclk_cycle
|
15
|
-
tester.cycle
|
16
|
-
|
17
|
-
cc 'change multiple to 80'
|
18
|
-
dut.spi.clk_multiple = 80
|
19
|
-
dut.spi.sclk_cycle
|
20
|
-
tester.cycle
|
21
|
-
|
22
|
-
cc 'change clock format and repeat'
|
23
|
-
dut.pin(:sclk).drive 1
|
24
|
-
dut.spi.clk_format = :rh
|
25
|
-
dut.spi.clk_multiple = 1
|
26
|
-
dut.spi.sclk_cycle
|
27
|
-
tester.cycle
|
28
|
-
|
29
|
-
cc 'change multiple to 2'
|
30
|
-
dut.spi.clk_multiple = 2
|
31
|
-
dut.spi.sclk_cycle
|
32
|
-
tester.cycle
|
33
|
-
|
34
|
-
cc 'change multiple to 80'
|
35
|
-
dut.spi.clk_multiple = 80
|
36
|
-
dut.spi.sclk_cycle
|
37
|
-
tester.cycle
|
38
|
-
|
1
|
+
Pattern.create do
|
2
|
+
tester.set_timeset 'tp0', 20
|
3
|
+
dut.pin(:ss).drive 1
|
4
|
+
dut.pin(:sclk).drive 0
|
5
|
+
dut.pin(:mosi).drive 0
|
6
|
+
dut.pin(:miso).dont_care
|
7
|
+
|
8
|
+
tester.cycle
|
9
|
+
dut.spi.sclk_cycle
|
10
|
+
tester.cycle
|
11
|
+
|
12
|
+
cc 'change multiple to 2'
|
13
|
+
dut.spi.clk_multiple = 2
|
14
|
+
dut.spi.sclk_cycle
|
15
|
+
tester.cycle
|
16
|
+
|
17
|
+
cc 'change multiple to 80'
|
18
|
+
dut.spi.clk_multiple = 80
|
19
|
+
dut.spi.sclk_cycle
|
20
|
+
tester.cycle
|
21
|
+
|
22
|
+
cc 'change clock format and repeat'
|
23
|
+
dut.pin(:sclk).drive 1
|
24
|
+
dut.spi.clk_format = :rh
|
25
|
+
dut.spi.clk_multiple = 1
|
26
|
+
dut.spi.sclk_cycle
|
27
|
+
tester.cycle
|
28
|
+
|
29
|
+
cc 'change multiple to 2'
|
30
|
+
dut.spi.clk_multiple = 2
|
31
|
+
dut.spi.sclk_cycle
|
32
|
+
tester.cycle
|
33
|
+
|
34
|
+
cc 'change multiple to 80'
|
35
|
+
dut.spi.clk_multiple = 80
|
36
|
+
dut.spi.sclk_cycle
|
37
|
+
tester.cycle
|
38
|
+
|
39
39
|
end
|
data/pattern/keep_ss_active.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
Pattern.create do
|
2
|
-
tester.set_timeset 'tp0', 20
|
3
|
-
dut.pin(:ss).drive 1
|
4
|
-
dut.pin(:sclk).drive 0
|
5
|
-
dut.pin(:mosi).drive 0
|
6
|
-
dut.pin(:miso).dont_care
|
7
|
-
|
8
|
-
tester.cycle
|
9
|
-
|
10
|
-
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
-
in_data = Origen::Registers::Reg.dummy(12).read 0x5a5
|
12
|
-
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in -- keeping ss active'
|
13
|
-
dut.spi.shift master_out: out_data, master_in: in_data, keep_ss_active: true
|
14
|
-
|
15
|
-
cc 'cycle with ss active'
|
16
|
-
tester.cycle
|
17
|
-
|
18
|
-
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in -- allow ss inactive'
|
19
|
-
in_data.read
|
20
|
-
dut.spi.shift master_out: out_data, master_in: in_data
|
21
|
-
|
22
|
-
cc 'cycle with ss inactive'
|
23
|
-
tester.cycle
|
24
|
-
|
1
|
+
Pattern.create do
|
2
|
+
tester.set_timeset 'tp0', 20
|
3
|
+
dut.pin(:ss).drive 1
|
4
|
+
dut.pin(:sclk).drive 0
|
5
|
+
dut.pin(:mosi).drive 0
|
6
|
+
dut.pin(:miso).dont_care
|
7
|
+
|
8
|
+
tester.cycle
|
9
|
+
|
10
|
+
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
+
in_data = Origen::Registers::Reg.dummy(12).read 0x5a5
|
12
|
+
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in -- keeping ss active'
|
13
|
+
dut.spi.shift master_out: out_data, master_in: in_data, keep_ss_active: true
|
14
|
+
|
15
|
+
cc 'cycle with ss active'
|
16
|
+
tester.cycle
|
17
|
+
|
18
|
+
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in -- allow ss inactive'
|
19
|
+
in_data.read
|
20
|
+
dut.spi.shift master_out: out_data, master_in: in_data
|
21
|
+
|
22
|
+
cc 'cycle with ss inactive'
|
23
|
+
tester.cycle
|
24
|
+
|
25
25
|
end
|
data/pattern/overlay_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
Pattern.create do
|
2
|
-
tester.set_timeset 'tp0', 20
|
3
|
-
dut.pin(:ss).drive 1
|
4
|
-
dut.pin(:sclk).drive 0
|
5
|
-
dut.pin(:mosi).drive 0
|
6
|
-
dut.pin(:miso).dont_care
|
7
|
-
|
8
|
-
tester.cycle
|
9
|
-
tester.overlay_style = :label
|
10
|
-
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
-
out_data.bits[3..0].overlay 'heres_the_label'
|
12
|
-
dut.spi.shift master_out: out_data
|
13
|
-
|
14
|
-
cc 'repeat test reversing bit order'
|
15
|
-
dut.spi.data_order = :msb0
|
16
|
-
out_data.bits[3..0].overlay 'heres_the_other_label'
|
17
|
-
dut.spi.shift master_out: out_data
|
1
|
+
Pattern.create do
|
2
|
+
tester.set_timeset 'tp0', 20
|
3
|
+
dut.pin(:ss).drive 1
|
4
|
+
dut.pin(:sclk).drive 0
|
5
|
+
dut.pin(:mosi).drive 0
|
6
|
+
dut.pin(:miso).dont_care
|
7
|
+
|
8
|
+
tester.cycle
|
9
|
+
tester.overlay_style = :label
|
10
|
+
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
+
out_data.bits[3..0].overlay 'heres_the_label'
|
12
|
+
dut.spi.shift master_out: out_data
|
13
|
+
|
14
|
+
cc 'repeat test reversing bit order'
|
15
|
+
dut.spi.data_order = :msb0
|
16
|
+
out_data.bits[3..0].overlay 'heres_the_other_label'
|
17
|
+
dut.spi.shift master_out: out_data
|
18
18
|
end
|
data/pattern/shift_test.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
Pattern.create do
|
2
|
-
tester.set_timeset 'tp0', 20
|
3
|
-
dut.pin(:ss).drive 1
|
4
|
-
dut.pin(:sclk).drive 0
|
5
|
-
dut.pin(:mosi).drive 0
|
6
|
-
dut.pin(:miso).dont_care
|
7
|
-
|
8
|
-
tester.cycle
|
9
|
-
|
10
|
-
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
-
in_data = Origen::Registers::Reg.dummy(12).read 0x5a5
|
12
|
-
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in'
|
13
|
-
dut.spi.shift master_out: out_data, master_in: in_data
|
14
|
-
|
15
|
-
tester.cycle
|
16
|
-
|
17
|
-
cc 'repeat 12-bits lsb first, 0x7 out, 0x5a5 in; clock multiple = 4'
|
18
|
-
out_data.write 7
|
19
|
-
in_data.read 0x5a5
|
20
|
-
dut.spi.clk_multiple = 4
|
21
|
-
dut.spi.shift master_out: out_data, master_in: in_data
|
22
|
-
|
23
|
-
tester.cycle
|
24
|
-
|
25
|
-
cc 'repeat 12-bits, 0x7 out, 0x5a5 in; clock multiple = 4, with msb first, move miso compare to cycle 3'
|
26
|
-
out_data.write 7
|
27
|
-
in_data.read 0x5a5
|
28
|
-
dut.spi.data_order = :msb0
|
29
|
-
dut.spi.miso_compare_cycle = 3
|
30
|
-
dut.spi.shift master_out: out_data, master_in: in_data
|
31
|
-
|
32
|
-
tester.cycle
|
33
|
-
|
34
|
-
cc 'Now check bit masking'
|
35
|
-
cc 'shift 0xa5a, 12-bits, msb first, multiple = 1, clk format :rh, all bits masked'
|
36
|
-
dut.spi.clk_format = :rh
|
37
|
-
dut.spi.clk_multiple = 1
|
38
|
-
dut.spi.shift master_out: 0xa5a, size: 12
|
39
|
-
|
40
|
-
tester.cycle
|
41
|
-
|
42
|
-
cc 'repeat same, comparing for LLLL_XXXX_HHHH, clock back to :rl'
|
43
|
-
dut.spi.clk_format = :rl
|
44
|
-
in_data.write 0xf
|
45
|
-
in_data.bits[11..8].read
|
46
|
-
in_data.bits[7..4].clear_flags
|
47
|
-
in_data.bits[3..0].read
|
48
|
-
dut.spi.shift master_out: 0xa5a, master_in: in_data
|
49
|
-
|
50
|
-
tester.cycle
|
51
|
-
|
52
|
-
cc 'test capture'
|
53
|
-
in_data.bits[11..8].read
|
54
|
-
in_data.bits[7..4].store
|
55
|
-
in_data.bits[3..0].read
|
56
|
-
dut.spi.shift master_out: 0xa5a, master_in: in_data
|
57
|
-
|
58
|
-
tester.cycle
|
59
|
-
|
60
|
-
# cc 'test overlay, label should appear at bit 3'
|
61
|
-
# out_data.write 0xa5a
|
62
|
-
# out_data.bits[3..0].overlay 'heres_the_label'
|
63
|
-
# tester.overlay_style = :label
|
64
|
-
# dut.spi.shift master_out: out_data
|
65
|
-
|
66
|
-
# tester.cycle
|
1
|
+
Pattern.create do
|
2
|
+
tester.set_timeset 'tp0', 20
|
3
|
+
dut.pin(:ss).drive 1
|
4
|
+
dut.pin(:sclk).drive 0
|
5
|
+
dut.pin(:mosi).drive 0
|
6
|
+
dut.pin(:miso).dont_care
|
7
|
+
|
8
|
+
tester.cycle
|
9
|
+
|
10
|
+
out_data = Origen::Registers::Reg.dummy(12).write 7
|
11
|
+
in_data = Origen::Registers::Reg.dummy(12).read 0x5a5
|
12
|
+
cc 'shifting 12-bits lsb first, 0x7 out, 0x5a5 in'
|
13
|
+
dut.spi.shift master_out: out_data, master_in: in_data
|
14
|
+
|
15
|
+
tester.cycle
|
16
|
+
|
17
|
+
cc 'repeat 12-bits lsb first, 0x7 out, 0x5a5 in; clock multiple = 4'
|
18
|
+
out_data.write 7
|
19
|
+
in_data.read 0x5a5
|
20
|
+
dut.spi.clk_multiple = 4
|
21
|
+
dut.spi.shift master_out: out_data, master_in: in_data
|
22
|
+
|
23
|
+
tester.cycle
|
24
|
+
|
25
|
+
cc 'repeat 12-bits, 0x7 out, 0x5a5 in; clock multiple = 4, with msb first, move miso compare to cycle 3'
|
26
|
+
out_data.write 7
|
27
|
+
in_data.read 0x5a5
|
28
|
+
dut.spi.data_order = :msb0
|
29
|
+
dut.spi.miso_compare_cycle = 3
|
30
|
+
dut.spi.shift master_out: out_data, master_in: in_data
|
31
|
+
|
32
|
+
tester.cycle
|
33
|
+
|
34
|
+
cc 'Now check bit masking'
|
35
|
+
cc 'shift 0xa5a, 12-bits, msb first, multiple = 1, clk format :rh, all bits masked'
|
36
|
+
dut.spi.clk_format = :rh
|
37
|
+
dut.spi.clk_multiple = 1
|
38
|
+
dut.spi.shift master_out: 0xa5a, size: 12
|
39
|
+
|
40
|
+
tester.cycle
|
41
|
+
|
42
|
+
cc 'repeat same, comparing for LLLL_XXXX_HHHH, clock back to :rl'
|
43
|
+
dut.spi.clk_format = :rl
|
44
|
+
in_data.write 0xf
|
45
|
+
in_data.bits[11..8].read
|
46
|
+
in_data.bits[7..4].clear_flags
|
47
|
+
in_data.bits[3..0].read
|
48
|
+
dut.spi.shift master_out: 0xa5a, master_in: in_data
|
49
|
+
|
50
|
+
tester.cycle
|
51
|
+
|
52
|
+
cc 'test capture'
|
53
|
+
in_data.bits[11..8].read
|
54
|
+
in_data.bits[7..4].store
|
55
|
+
in_data.bits[3..0].read
|
56
|
+
dut.spi.shift master_out: 0xa5a, master_in: in_data
|
57
|
+
|
58
|
+
tester.cycle
|
59
|
+
|
60
|
+
# cc 'test overlay, label should appear at bit 3'
|
61
|
+
# out_data.write 0xa5a
|
62
|
+
# out_data.bits[3..0].overlay 'heres_the_label'
|
63
|
+
# tester.overlay_style = :label
|
64
|
+
# dut.spi.shift master_out: out_data
|
65
|
+
|
66
|
+
# tester.cycle
|
67
67
|
end
|
data/templates/web/index.md.erb
CHANGED
@@ -1,87 +1,87 @@
|
|
1
|
-
% render "layouts/basic.html" do
|
2
|
-
|
3
|
-
%# HTML tags can be embedded in mark down files if you want to do specific custom
|
4
|
-
%# formatting like this, but in most cases that is not required.
|
5
|
-
<h1><%= Origen.app.namespace %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
|
6
|
-
|
7
|
-
### Purpose
|
8
|
-
|
9
|
-
This plugin implements SPI protocol with the tester acting as the master. There are 4 pins standard to SPI,
|
10
|
-
however only sclk is required by this plugin. Any pins that aren't provided are ignored. This plugin seeks
|
11
|
-
to be very flexible given that the SPI standard is itself very flexible.
|
12
|
-
|
13
|
-
### How To Install
|
14
|
-
|
15
|
-
In your Gemfile add:
|
16
|
-
|
17
|
-
~~~ruby
|
18
|
-
gem "<%= Origen.app.name %>"
|
19
|
-
~~~
|
20
|
-
|
21
|
-
or if your application is a plugin, then add this to your <code>.gemspec</code>
|
22
|
-
|
23
|
-
~~~ruby
|
24
|
-
spec.add_runtime_dependency "<%= Origen.app.name %>", ">= <%= Origen.app.version %>"
|
25
|
-
~~~
|
26
|
-
|
27
|
-
__NOTE:__ In the case of a plugin, you will also need to <code>require '<%= Origen.app.name %>'</code> somewhere in your environment.
|
28
|
-
|
29
|
-
|
30
|
-
### How To Use
|
31
|
-
|
32
|
-
The spi driver is intended to be instantiated as a sub_block. The configuration can be passed in as a hash and / or
|
33
|
-
can be changed after instantiation. See API for more details.
|
34
|
-
|
35
|
-
~~~ruby
|
36
|
-
sub_block :spi, class_name: 'OrigenSpi::Driver',
|
37
|
-
sclk_pin: dut.pin(:sclk),
|
38
|
-
mosi_pin: dut.pin(:mosi),
|
39
|
-
miso_pin: dut.pin(:miso),
|
40
|
-
ss_pin: dut.pin(:ss),
|
41
|
-
# :rl - return low - input data changes while sclk is low and is latched on rising edge
|
42
|
-
clk_format: :rl,
|
43
|
-
# drive state of 0 activates the slave port
|
44
|
-
ss_active: 0,
|
45
|
-
# wait time after ss_active and before any sclk activity
|
46
|
-
clk_wait_time: {time_in_cycles: 2},
|
47
|
-
# number of sclks per tester.cycle
|
48
|
-
clk_multiple: 1,
|
49
|
-
data_order: :lsb0
|
50
|
-
~~~
|
51
|
-
|
52
|
-
~~~ruby
|
53
|
-
# configuration can be changed after instantiation like this
|
54
|
-
dut.spi.clk_multiple = 80
|
55
|
-
dut.spi.miso_compare_cycle = 79
|
56
|
-
dut.spi.ss_pin = nil
|
57
|
-
~~~
|
58
|
-
|
59
|
-
Once the driver is instantiated shift operations can be performed by calls to the shift method (overlay/store/masking etc. is handled):
|
60
|
-
|
61
|
-
~~~ruby
|
62
|
-
# shift out, masking input compares
|
63
|
-
dut.spi.shift master_out: 0xFF, size: 32
|
64
|
-
|
65
|
-
# shift out, register - size doesn't need to be passed when register is provided
|
66
|
-
dut.spi.shift master_out: dut.my_reg
|
67
|
-
|
68
|
-
# shift in read examples:
|
69
|
-
dut.spi.shift master_in: 0xFF, size: 32
|
70
|
-
|
71
|
-
# provide a register to mask or store (mark the bits appropriately)
|
72
|
-
dut.spi.shift master_in: dut.my_reg
|
73
|
-
|
74
|
-
# simultaneous shift in/out
|
75
|
-
dut.spi.shift master_out: some_value_or_reg, master_in: some_other_value_or_reg
|
76
|
-
~~~
|
77
|
-
|
78
|
-
|
79
|
-
### How To Setup a Development Environment
|
80
|
-
|
81
|
-
To setup a development environment:
|
82
|
-
|
83
|
-
~~~
|
84
|
-
git clone https://github.com/Origen-SDK/origen_spi.git
|
85
|
-
~~~
|
86
|
-
|
87
|
-
% end
|
1
|
+
% render "layouts/basic.html" do
|
2
|
+
|
3
|
+
%# HTML tags can be embedded in mark down files if you want to do specific custom
|
4
|
+
%# formatting like this, but in most cases that is not required.
|
5
|
+
<h1><%= Origen.app.namespace %> <span style="font-size: 14px">(<%= Origen.app.version %>)</span></h1>
|
6
|
+
|
7
|
+
### Purpose
|
8
|
+
|
9
|
+
This plugin implements SPI protocol with the tester acting as the master. There are 4 pins standard to SPI,
|
10
|
+
however only sclk is required by this plugin. Any pins that aren't provided are ignored. This plugin seeks
|
11
|
+
to be very flexible given that the SPI standard is itself very flexible.
|
12
|
+
|
13
|
+
### How To Install
|
14
|
+
|
15
|
+
In your Gemfile add:
|
16
|
+
|
17
|
+
~~~ruby
|
18
|
+
gem "<%= Origen.app.name %>"
|
19
|
+
~~~
|
20
|
+
|
21
|
+
or if your application is a plugin, then add this to your <code>.gemspec</code>
|
22
|
+
|
23
|
+
~~~ruby
|
24
|
+
spec.add_runtime_dependency "<%= Origen.app.name %>", ">= <%= Origen.app.version %>"
|
25
|
+
~~~
|
26
|
+
|
27
|
+
__NOTE:__ In the case of a plugin, you will also need to <code>require '<%= Origen.app.name %>'</code> somewhere in your environment.
|
28
|
+
|
29
|
+
|
30
|
+
### How To Use
|
31
|
+
|
32
|
+
The spi driver is intended to be instantiated as a sub_block. The configuration can be passed in as a hash and / or
|
33
|
+
can be changed after instantiation. See API for more details.
|
34
|
+
|
35
|
+
~~~ruby
|
36
|
+
sub_block :spi, class_name: 'OrigenSpi::Driver',
|
37
|
+
sclk_pin: dut.pin(:sclk),
|
38
|
+
mosi_pin: dut.pin(:mosi),
|
39
|
+
miso_pin: dut.pin(:miso),
|
40
|
+
ss_pin: dut.pin(:ss),
|
41
|
+
# :rl - return low - input data changes while sclk is low and is latched on rising edge
|
42
|
+
clk_format: :rl,
|
43
|
+
# drive state of 0 activates the slave port
|
44
|
+
ss_active: 0,
|
45
|
+
# wait time after ss_active and before any sclk activity
|
46
|
+
clk_wait_time: {time_in_cycles: 2},
|
47
|
+
# number of sclks per tester.cycle
|
48
|
+
clk_multiple: 1,
|
49
|
+
data_order: :lsb0
|
50
|
+
~~~
|
51
|
+
|
52
|
+
~~~ruby
|
53
|
+
# configuration can be changed after instantiation like this
|
54
|
+
dut.spi.clk_multiple = 80
|
55
|
+
dut.spi.miso_compare_cycle = 79
|
56
|
+
dut.spi.ss_pin = nil
|
57
|
+
~~~
|
58
|
+
|
59
|
+
Once the driver is instantiated shift operations can be performed by calls to the shift method (overlay/store/masking etc. is handled):
|
60
|
+
|
61
|
+
~~~ruby
|
62
|
+
# shift out, masking input compares
|
63
|
+
dut.spi.shift master_out: 0xFF, size: 32
|
64
|
+
|
65
|
+
# shift out, register - size doesn't need to be passed when register is provided
|
66
|
+
dut.spi.shift master_out: dut.my_reg
|
67
|
+
|
68
|
+
# shift in read examples:
|
69
|
+
dut.spi.shift master_in: 0xFF, size: 32
|
70
|
+
|
71
|
+
# provide a register to mask or store (mark the bits appropriately)
|
72
|
+
dut.spi.shift master_in: dut.my_reg
|
73
|
+
|
74
|
+
# simultaneous shift in/out
|
75
|
+
dut.spi.shift master_out: some_value_or_reg, master_in: some_other_value_or_reg
|
76
|
+
~~~
|
77
|
+
|
78
|
+
|
79
|
+
### How To Setup a Development Environment
|
80
|
+
|
81
|
+
To setup a development environment:
|
82
|
+
|
83
|
+
~~~
|
84
|
+
git clone https://github.com/Origen-SDK/origen_spi.git
|
85
|
+
~~~
|
86
|
+
|
87
|
+
% end
|