synthemesc-impulse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/LICENSE +28 -0
- data/README.rdoc +5 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/lib/impulse.rb +2 -0
- data/lib/project.rb +102 -0
- data/lib/template.rb +47 -0
- metadata +70 -0
data/LICENSE
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Impulse C is Copyright (c) 2003-2007 Impulse Accelerated Technologies, Inc.
|
2
|
+
Please see your CoDeveloper license for more information. The license below
|
3
|
+
is only applicable to the Impulse Ruby gem. Please do not contact Impulse
|
4
|
+
Accelerated Technologies with questions regarding support for this gem.
|
5
|
+
|
6
|
+
----------------------------------------------------------------------------
|
7
|
+
|
8
|
+
Impulse Ruby gem Copyright (c) 2009 Joshua Eckstein.
|
9
|
+
http://impulse.rubyforge.org/
|
10
|
+
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
a copy of this software and associated documentation files (the
|
13
|
+
"Software"), to deal in the Software without restriction, including
|
14
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
16
|
+
permit persons to whom the Software is furnished to do so, subject to
|
17
|
+
the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be
|
20
|
+
included in all copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
23
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
25
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
26
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
27
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
28
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
= Ruby tools for ImpulseC
|
2
|
+
|
3
|
+
ImpulseC is a platform for synthesizing Verilog or other hardware description format out of ANSI C. This means if you can write C, you can make a chip, and doing so puts you safely in mad scientist territory.
|
4
|
+
|
5
|
+
The Ruby tools for ImpulseC allow you to create and test ImpulseC programs, projects, and templates in Ruby.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "impulse"
|
8
|
+
gem.summary = %Q{Ruby tools for the Impulse platform}
|
9
|
+
gem.email = "josh@agentcomputer.com"
|
10
|
+
gem.homepage = "http://github.com/synthemesc/impulse"
|
11
|
+
gem.authors = ["Joshua Eckstein"]
|
12
|
+
gem.rubyforge_project = "impulse"
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
|
16
|
+
Jeweler::RubyforgeTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
if File.exist?('VERSION.yml')
|
47
|
+
config = YAML.load(File.read('VERSION.yml'))
|
48
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
+
else
|
50
|
+
version = ""
|
51
|
+
end
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "impulse #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
rdoc.options << '--accessor' << 'attr_xml=RW'
|
58
|
+
end
|
59
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/impulse.rb
ADDED
data/lib/project.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "facets"
|
3
|
+
|
4
|
+
module Impulse
|
5
|
+
# A CoDeveloper project is a simple plaintext file with an <em>.icProj</em>
|
6
|
+
# extension. It holds a version, a list of CoDeveloper options, and a file
|
7
|
+
# listing. Currently this class only supports version and options.
|
8
|
+
class Project
|
9
|
+
# A regular expression that matches lines we can process.
|
10
|
+
ValidOptionLine = /\$(Option|Version)\s\"[\w\.]*=?[\w\s\.\(\)]*\"/.freeze
|
11
|
+
|
12
|
+
# A hash of +option => value+ pairs for options listed in this project.
|
13
|
+
attr_accessor :options
|
14
|
+
|
15
|
+
# The version of CoDeveloper this project is compatible with.
|
16
|
+
attr_accessor :version
|
17
|
+
|
18
|
+
# Reads a Project from +project_file+. If +project_file+ isn't
|
19
|
+
# readable, an empty Project will be created that can be saved with save!
|
20
|
+
def initialize(project_file=nil)
|
21
|
+
@version = "0.00"
|
22
|
+
@options = Hash.new
|
23
|
+
|
24
|
+
skipped_lines_header = false
|
25
|
+
File.open(project_file).each_with_index do |line, line_number|
|
26
|
+
next unless line.match ValidOptionLine
|
27
|
+
print("Skipping lines: ") unless skipped_lines_header
|
28
|
+
skipped_lines_header = true
|
29
|
+
print("#{line_number+1} ")
|
30
|
+
|
31
|
+
key, value = line.split(nil, 2).last.delete("\"").split("=", 2)
|
32
|
+
@version = key.chomp if line.match /^\$Version/
|
33
|
+
|
34
|
+
if line.match /^\$Option/
|
35
|
+
# CamelCase to :camel_case
|
36
|
+
key = key.pathize.to_sym
|
37
|
+
value.chomp!
|
38
|
+
next if value.empty?
|
39
|
+
|
40
|
+
# Project file booleans to Ruby booleans
|
41
|
+
case value
|
42
|
+
when "0" then value = false
|
43
|
+
when "1" then value = true
|
44
|
+
end
|
45
|
+
|
46
|
+
@options.merge!({ key => value })
|
47
|
+
end
|
48
|
+
end
|
49
|
+
puts "done."
|
50
|
+
@filename = project_file
|
51
|
+
self
|
52
|
+
rescue Errno::ENOENT
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
# Quick sugar for getting project options.
|
57
|
+
#
|
58
|
+
# project = Project.new("Mandelbrot.icProj")
|
59
|
+
# project[:gen_code_const_prop] # => true
|
60
|
+
#
|
61
|
+
def [](option)
|
62
|
+
@options[option]
|
63
|
+
end
|
64
|
+
|
65
|
+
# Quick sugar for setting project options.
|
66
|
+
#
|
67
|
+
# project[:gen_code_scalarize] = true
|
68
|
+
# project[:gen_code_dual_clocks] = false
|
69
|
+
#
|
70
|
+
def []=(option, value)
|
71
|
+
@options[option] = value
|
72
|
+
end
|
73
|
+
|
74
|
+
# Saves a project file.
|
75
|
+
def save!
|
76
|
+
timestamp = Time.now.strftime("%m-%d-%Y %H:%m:%S")
|
77
|
+
File.open(@filename, "w") do |f|
|
78
|
+
f.puts "# Impulse project file saved from #{__FILE__} #{timestamp}"
|
79
|
+
f.puts %Q($Version "#{@version}")
|
80
|
+
@options.each_pair do |key, val|
|
81
|
+
# symbol_style back to SymbolStyle
|
82
|
+
key = key.to_s.camelcase
|
83
|
+
|
84
|
+
# Convert Ruby types back into file types
|
85
|
+
if val.kind_of?(TrueClass) then val = "1"
|
86
|
+
elsif val.kind_of?(FalseClass) then val = "0"
|
87
|
+
else val = val.to_s ; end
|
88
|
+
|
89
|
+
# For some reason the Simulate/LaunchHwExe keys
|
90
|
+
# use the non-capped Hw. Everything else does.
|
91
|
+
unless key.match(/Exe$/)
|
92
|
+
key.gsub!(/Sw/, 'SW')
|
93
|
+
key.gsub!(/Hw/, 'HW')
|
94
|
+
end
|
95
|
+
|
96
|
+
# Write it
|
97
|
+
f.puts %Q($Option "#{key}=#{val}")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/template.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "rexml/document"
|
2
|
+
|
3
|
+
module Impulse
|
4
|
+
# A CoDeveloper template is an XML file, usually named <em>Template.config</em>.
|
5
|
+
# It holds a template name and description.
|
6
|
+
class Template
|
7
|
+
include REXML
|
8
|
+
|
9
|
+
def self.attr_xml(ivar) #:nodoc:
|
10
|
+
instance_eval do
|
11
|
+
define_method(ivar) do
|
12
|
+
instance_variable_get("@#{ivar}").text.strip
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method("#{ivar}=") do |new_value|
|
16
|
+
instance_variable_get("@#{ivar}").send(:text=, new_value.strip)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_xml :title
|
22
|
+
attr_xml :description
|
23
|
+
attr_accessor :filename
|
24
|
+
|
25
|
+
# Reads a Template from +template_file+. If +template_file+ isn't
|
26
|
+
# readable, an empty Template will be created that can be saved with save!
|
27
|
+
def initialize(template_file=nil)
|
28
|
+
begin
|
29
|
+
@xml = Document.new File.new(template_file), { :compress_whitespace => :all }
|
30
|
+
@title = XPath.first(@xml, "//ProjectTemplate/Title")
|
31
|
+
@description = XPath.first(@xml, "//ProjectTemplate/Description")
|
32
|
+
rescue Errno::ENOENT, NoMethodError
|
33
|
+
@xml = Document.new, { :compress_whitespace => :all }
|
34
|
+
root = @xml.add_element "ProjectTemplate"
|
35
|
+
@title = root.add_element "Title"
|
36
|
+
@description = root.add_element "Description"
|
37
|
+
end
|
38
|
+
@filename = template_file
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
# Saves the current Template to +filename+.
|
43
|
+
def save!
|
44
|
+
@xml.write File.open(@filename, "w"), 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: synthemesc-impulse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joshua Eckstein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-15 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: facets
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: josh@agentcomputer.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- VERSION
|
40
|
+
- lib/impulse.rb
|
41
|
+
- lib/project.rb
|
42
|
+
- lib/template.rb
|
43
|
+
has_rdoc: false
|
44
|
+
homepage: http://github.com/synthemesc/impulse
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: impulse
|
65
|
+
rubygems_version: 1.2.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Ruby tools for the Impulse platform
|
69
|
+
test_files: []
|
70
|
+
|