origen_swd 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f760d7e0b8b2b523a41db1db1c4408b59003f5a8
4
+ data.tar.gz: e7901ced8faff7f18ad00345ec9c0a67f0e5bfad
5
+ SHA512:
6
+ metadata.gz: 968243cdbf15859e482874e51526e3a7ef58edc628e39cd101328bd9cf1dd9cc597c3a84e3ef7606a218154701259ce9129e0c413380c888f987d3a334cc31ad
7
+ data.tar.gz: a5171a1d4a1f8f3d2a6f147a5b2e9c58d5ba1f4cdd10f8693a2d75183cc63e238e340ef9d6a65e194d8ba777b8db9c42a0cc505120199137d1009bec4144a8b0
@@ -0,0 +1,59 @@
1
+ class OrigenSWDApplication < Origen::Application
2
+
3
+ # This information is used in headers and email templates, set it specific
4
+ # to your application
5
+ config.name = "Origen SWD"
6
+ config.initials = "OrigenSWD"
7
+
8
+ self.name = "origen_swd"
9
+ self.namespace = "OrigenSWD"
10
+ config.rc_url = "git@github.com/Origen-SDK/origen_swd.git"
11
+ config.release_externally = true
12
+
13
+ # To enable deployment of your documentation to a web server (via the 'origen web'
14
+ # command) fill in these attributes.
15
+ config.web_directory = "git@github.com:Origen-SDK/Origen-SDK.github.io.git/swd"
16
+ config.web_domain = "http://origen-sdk.org/swd"
17
+
18
+ config.semantically_version = true
19
+
20
+ config.lint_test = {
21
+ # Require the lint tests to pass before allowing a release to proceed
22
+ run_on_tag: true,
23
+ # Auto correct violations where possible whenever 'origen lint' is run
24
+ auto_correct: true,
25
+ # Limit the testing for large legacy applications
26
+ #level: :easy,
27
+ # Run on these directories/files by default
28
+ #files: ["lib", "config/application.rb"],
29
+ }
30
+
31
+ # Ensure that all tests pass before allowing a release to continue
32
+ def validate_release
33
+ if !system("origen examples") #|| !system("origen specs")
34
+ puts "Sorry but you can't release with failing tests, please fix them and try again."
35
+ exit 1
36
+ else
37
+ puts "All tests passing, proceeding with release process!"
38
+ end
39
+ end
40
+
41
+ # Run code coverage when deploying the web site
42
+ def before_deploy_site
43
+ Dir.chdir Origen.root do
44
+ system "origen examples -c"
45
+ dir = "#{Origen.root}/web/output/coverage"
46
+ FileUtils.remove_dir(dir, true) if File.exists?(dir)
47
+ system "mv #{Origen.root}/coverage #{dir}"
48
+ end
49
+ end
50
+
51
+ # Deploy the website automatically after a production tag
52
+ def after_release_email(tag, note, type, selector, options)
53
+ command = "origen web compile --remote --api"
54
+ Dir.chdir Origen.root do
55
+ system command
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,51 @@
1
+ # This file should be used to extend the origen command line tool with tasks
2
+ # specific to your application.
3
+ #
4
+ # Also see the official docs on adding commands:
5
+ # http://origen-sdk.org/origen/latest/guides/custom/commands/
6
+
7
+ # Map any command aliases here, for example to allow origen -x to refer to a
8
+ # command called execute you would add a reference as shown below:
9
+ aliases ={
10
+ # "-x" => "execute",
11
+ }
12
+
13
+ # The requested command is passed in here as @command, this checks it against
14
+ # the above alias table and should not be removed.
15
+ @command = aliases[@command] || @command
16
+
17
+ # Now branch to the specific task code
18
+ case @command
19
+
20
+ when "examples"
21
+ Origen.load_application
22
+ status = 0
23
+
24
+ # Pattern generator tests
25
+ ARGV = %w(example -t debug -r approved)
26
+ load "#{Origen.top}/lib/origen/commands/generate.rb"
27
+
28
+ if Origen.app.stats.changed_files == 0 &&
29
+ Origen.app.stats.new_files == 0 &&
30
+ Origen.app.stats.changed_patterns == 0 &&
31
+ Origen.app.stats.new_patterns == 0
32
+
33
+ Origen.app.stats.report_pass
34
+ else
35
+ Origen.app.stats.report_fail
36
+ status = 1
37
+ end
38
+ puts
39
+ exit status
40
+
41
+ # Always leave an else clause to allow control to fall back through to the
42
+ # Origen command handler.
43
+ # You probably want to also add the command details to the help shown via
44
+ # origen -h, you can do this be assigning the required text to @application_commands
45
+ # before handing control back to Origen. Un-comment the example below to get started.
46
+ else
47
+ @application_commands = <<-EOT
48
+ examples Run the examples (tests), -c will enable coverage
49
+ EOT
50
+
51
+ end
@@ -0,0 +1,15 @@
1
+ # This file is similar to environment.rb and will be loaded
2
+ # automatically at the start of each invocation of Origen.
3
+ #
4
+ # However the major difference is that it will not be loaded
5
+ # if the application is imported by a 3rd party app - in that
6
+ # case only environment.rb is loaded.
7
+ #
8
+ # Therefore this file should be used to load anything you need
9
+ # to setup a development environment for this app, normally
10
+ # this would be used to define some dummy classes to instantiate
11
+ # your objects so that they can be tested and/or interacted with
12
+ # in the console.
13
+ module OrigenSWD
14
+ autoload :DUT, "origen_swd/dut"
15
+ end
@@ -0,0 +1 @@
1
+ require "origen_swd"
data/config/users.rb ADDED
@@ -0,0 +1,19 @@
1
+ # This file defines the users associated with your project, it is basically the
2
+ # mailing list for release notes.
3
+ #
4
+ # You can split your users into "admin" and "user" groups, the main difference
5
+ # between the two is that admin users will get all tag emails, users will get
6
+ # emails on external/official releases only.
7
+ #
8
+ # Users are also prohibited from running the "origen tag" task, but this is
9
+ # really just to prevent a casual user from executing it inadvertently and is
10
+ # not intended to be a serious security gate.
11
+ module Origen
12
+ module Users
13
+ def users
14
+ @users ||= [
15
+
16
+ ]
17
+ end
18
+ end
19
+ end
data/config/version.rb ADDED
@@ -0,0 +1,8 @@
1
+ module OrigenSWD
2
+ MAJOR = 0
3
+ MINOR = 3
4
+ BUGFIX = 1
5
+ DEV = nil
6
+
7
+ VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
8
+ end
data/lib/origen_swd.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'origen'
2
+ require_relative '../config/application.rb'
3
+
4
+ module OrigenSWD
5
+ autoload :Driver, 'origen_swd/driver'
6
+
7
+ # Returns an instance of the OrigenSWD::Driver
8
+ def swd
9
+ @swd ||= Driver.new(self)
10
+ end
11
+ end
@@ -0,0 +1,55 @@
1
+ module OrigenSWD
2
+ # To use this driver the owner model must define the following pins (an alias is fine):
3
+ # :swd_clk
4
+ # :swd_dio
5
+ #
6
+ class Driver
7
+ # Returns the parent object that instantiated the driver, could be
8
+ # either a DUT object or a protocol abstraction
9
+ attr_reader :owner
10
+
11
+ def initialize(owner, options = {})
12
+ @owner = owner
13
+ @current_apaddr = 0
14
+ @orundetect = 0
15
+ end
16
+
17
+ # Hardware interface
18
+ def send_data(data, size, options = {})
19
+ if options.key?(:overlay)
20
+ $tester.label(options[:overlay])
21
+ size.times do |bit|
22
+ owner.pin(:swd_clk).drive(1)
23
+ $tester.label("// SWD Data Pin #{bit}")
24
+ owner.pin(:swd_dio).drive(data[bit])
25
+ $tester.cycle
26
+ end
27
+ owner.pin(:swd_dio).dont_care
28
+ else
29
+ size.times do |bit|
30
+ owner.pin(:swd_clk).drive(1)
31
+ owner.pin(:swd_dio).drive(data[bit])
32
+ $tester.cycle
33
+ end
34
+ owner.pin(:swd_dio).dont_care
35
+ end
36
+ end
37
+
38
+ def get_data(size, options = {})
39
+ should_store = $dut.pin(:swd_dio).is_to_be_stored?
40
+ owner.pin(:swd_dio).dont_care
41
+ size.times do |bit|
42
+ $tester.store_next_cycle($dut.pin(:swd_dio)) if should_store
43
+ $dut.pin(:swd_dio).assert(options[:compare_data][bit]) if options.key?(:compare_data)
44
+ $tester.cycle
45
+ end
46
+ end
47
+
48
+ def swd_dio_to_0(size)
49
+ owner.pin(:swd_dio).drive(0)
50
+ size.times do |bit|
51
+ $tester.cycle
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,24 @@
1
+ module OrigenSWD
2
+ # This is a dummy DUT model which is used
3
+ # to instantiate and test the SWD locally
4
+ # during development.
5
+ #
6
+ # It is not included when this library is imported.
7
+ class DUT
8
+ include OrigenSWD
9
+ include Origen::Callbacks
10
+ include Origen::Registers
11
+ include Origen::Pins
12
+
13
+ def initialize(options = {})
14
+ add_reg :test, 0x0, 32, data: { pos: 0, bits: 32 },
15
+ bit: { pos: 0 }
16
+ add_pin :swd_clk
17
+ add_pin :swd_dio
18
+ end
19
+
20
+ def startup(options)
21
+ $tester.set_timeset('swd', 40)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,59 @@
1
+ Pattern.create do
2
+
3
+ address = 0x00002020
4
+ rwb = 0
5
+ ap_dp = 1
6
+ wdata = 0xAAAA5555
7
+ start = 1
8
+ apndp = 1
9
+ rnw = rwb
10
+ addr = address >> 2
11
+ parity_pr = ap_dp ^ rwb ^ (addr >> 3) ^ (addr >> 2) & (0x01) ^ (addr >> 1) & (0x01) ^ addr & 0x01
12
+ trn = 0
13
+ data = wdata
14
+ require_dp = 0
15
+ line_reset = 0
16
+ stop = 0
17
+ park = 1
18
+
19
+ cc 'SWD transaction'
20
+ cc 'Packet Request Phase'
21
+
22
+ annotate 'Send Start Bit'
23
+ $dut.swd.send_data(start, 1)
24
+ cc('Send APnDP Bit (DP or AP Access Register Bit)', prefix: true)
25
+ $dut.swd.send_data(apndp, 1)
26
+ c2 'Send RnW Bit (read or write bit)'
27
+ $dut.swd.send_data(rnw, 1)
28
+ c2 'Send Address Bits (2 bits)'
29
+ $dut.swd.send_data(addr, 2)
30
+ c2 'Send Parity Bit'
31
+ $dut.swd.send_data(parity_pr, 1)
32
+ c2 'Send Stop Bit'
33
+ $dut.swd.send_data(stop, 1)
34
+ c2 'Send Park Bit'
35
+ $dut.swd.send_data(park, 1)
36
+
37
+ cc 'Acknowledge Response phase'
38
+ $dut.swd.send_data(0xf, trn + 1)
39
+ $dut.swd.get_data(3)
40
+
41
+ cc 'Write Data Phase'
42
+ cc 'Write'
43
+ cc 'Send ACK Bits'
44
+ $dut.swd.send_data(0xf, trn + 1)
45
+ cc 'SWD 32-Bit Write Start'
46
+ $dut.swd.send_data(data, 32, overlay: 'write_ovl')
47
+ cc 'SWD 32-Bit Write End'
48
+ cc 'Send Write Parity Bit'
49
+ xor = 0
50
+ 32.times do |bit|
51
+ xor ^= (data >> bit) & 0x01
52
+ end
53
+ xor
54
+ $dut.swd.send_data(xor, 1)
55
+
56
+ cc 'SWD DIO to 0 for 10 cycles'
57
+ $dut.swd.swd_dio_to_0(10)
58
+
59
+ end
@@ -0,0 +1,82 @@
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 application provides a SWD driver.
10
+
11
+ ### How To Import
12
+
13
+ In your Gemfile add:
14
+
15
+ ~~~ruby
16
+ gem "origen_swd", ">= <%= Origen.app.version %>"
17
+ ~~~
18
+
19
+ or if your application is a plugin add this to your <code>.gemspec</code>
20
+
21
+ ~~~ruby
22
+ spec.add_development_dependency "origen_swd", ">= <%= Origen.app.version %>"
23
+ ~~~
24
+
25
+ __NOTE:__ You will also need to include <code>require 'origen_swd'</code> somewhere in your environment. This can be done in <code>config/environment.rb</code> for example.
26
+
27
+
28
+ ### How To Use
29
+
30
+ Include the <code>OrigenSWD</code> module to add a JTAG driver to your class and
31
+ define the required pins.
32
+
33
+ Including the module adds a <code>swd</code> method which will return an instance of
34
+ [<code>OrigenSWD::Driver</code>](<%= path "api/OrigenSWD/Driver.html" %>).
35
+
36
+ Here is an example integration:
37
+
38
+ ~~~ruby
39
+
40
+ class DUT
41
+ include OrigenSWD
42
+ include Origen::Pins
43
+
44
+ def initialize(options = {})
45
+ add_pin :swd_clk
46
+ add_pin :swd_dio
47
+ end
48
+ end
49
+
50
+
51
+ DUT.new.swd # => An instance of OrigenSWD::Driver
52
+ ~~~
53
+
54
+
55
+ ### How To Setup a Development Environment
56
+
57
+ [Clone the repository from Github](https://github.com/Origen-SDK/origen_swd).
58
+
59
+ An instance of the OrigenSWD driver is hooked up to a dummy DUT
60
+ object for use in the console:
61
+
62
+ ~~~
63
+ origen i
64
+
65
+ > $dut.swd
66
+ => #<OrigenSWD::Driver:0x0000001ee48e78>
67
+ ~~~
68
+
69
+ Follow the instructions here if you want to make a 3rd party app
70
+ workspace use your development copy of the OrigenSWD plugin:
71
+ [Setting up a Plugin Development Environment](http://origen-sdk.org/origen/latest/guides/plugins)
72
+
73
+ This plugin also contains a test suite, makes sure this passes before committing
74
+ any changes!
75
+
76
+ ~~~
77
+ origen examples
78
+ ~~~
79
+
80
+ <%= disqus_comments %>
81
+
82
+ % end
@@ -0,0 +1,16 @@
1
+ ---
2
+ title: <%= options[:title] || Origen.config.name %>
3
+ analytics: UA-64455560-1
4
+ ---
5
+ <%= render "templates/web/partials/navbar.html", :tab => options[:tab] %>
6
+
7
+ <div class="row">
8
+ %# The markdown attribute is important if you are going to include content written
9
+ %# in markdown, without this is will be included verbatim
10
+ <div class="span12" markdown="1">
11
+ <%= yield %>
12
+
13
+ <%= disqus_comments %>
14
+
15
+ </div>
16
+ </div>
@@ -0,0 +1,22 @@
1
+ <nav class="navbar navbar-inverse navbar-fixed-top">
2
+ <div class="container">
3
+ <div class="navbar-header">
4
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
5
+ <span class="sr-only">Toggle navigation</span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ </button>
10
+ <a class="navbar-brand" href="<%= path "/" %>">Home</a>
11
+ </div>
12
+ <div id="navbar" class="collapse navbar-collapse">
13
+ <ul class="nav navbar-nav">
14
+ <li class="<%= options[:tab] == :api ? 'active' : '' %>"><a href="<%= path "/api/" %>">API</a></li>
15
+ <li class="<%= options[:tab] == :coverage ? 'active' : '' %>"><a href="<%= path "/coverage" %>">Coverage</a></li>
16
+ <li class="<%= options[:tab] == :release ? 'active' : '' %>"><a href="<%= path "/release_notes" %>">Release Notes</a></li>
17
+ <li><a href="https://github.com/Origen-SDK/origen_swd">Github</a></li>
18
+ </ul>
19
+ <%= import "origen/web/logo.html" %>
20
+ </div><!--/.nav-collapse -->
21
+ </div>
22
+ </nav>
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: origen_swd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Ronnie Lajaunie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: origen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: origen_doc_helpers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ description:
42
+ email:
43
+ - Ronnie.Lajaunie@freescale.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - config/application.rb
49
+ - config/commands.rb
50
+ - config/development.rb
51
+ - config/environment.rb
52
+ - config/users.rb
53
+ - config/version.rb
54
+ - lib/origen_swd.rb
55
+ - lib/origen_swd/driver.rb
56
+ - lib/origen_swd/dut.rb
57
+ - pattern/example.rb
58
+ - templates/web/index.md.erb
59
+ - templates/web/layouts/_basic.html.erb
60
+ - templates/web/partials/_navbar.html.erb
61
+ homepage: http://origen-sdk.org/origen_swd
62
+ licenses: []
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.9.3
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.11
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Driver for single-wire-debug interface.
84
+ test_files: []
85
+ has_rdoc: