bat 1.0.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.
- data/History.txt +4 -0
- data/Manifest.txt +37 -0
- data/README.txt +19 -0
- data/Rakefile +65 -0
- data/bin/bat +92 -0
- data/lib/Buf1.rb +27 -0
- data/lib/Bufz.rb +46 -0
- data/lib/Dffpc.rb +40 -0
- data/lib/FivePorts.rb +19 -0
- data/lib/FourPorts.rb +19 -0
- data/lib/Gnd.rb +10 -0
- data/lib/Input.rb +9 -0
- data/lib/Inst.rb +51 -0
- data/lib/Inv.rb +9 -0
- data/lib/Mux2.rb +25 -0
- data/lib/Nand2.rb +9 -0
- data/lib/Nand2c.rb +9 -0
- data/lib/Nand3.rb +9 -0
- data/lib/Nand3c.rb +9 -0
- data/lib/Nand4.rb +9 -0
- data/lib/Nand4c.rb +9 -0
- data/lib/Nor2.rb +9 -0
- data/lib/Nor2c.rb +9 -0
- data/lib/Nor3.rb +9 -0
- data/lib/OnePort.rb +11 -0
- data/lib/Output.rb +17 -0
- data/lib/ParseHelper.rb +80 -0
- data/lib/Parser.rb +137 -0
- data/lib/Port.rb +24 -0
- data/lib/ThreePorts.rb +17 -0
- data/lib/TwoPorts.rb +16 -0
- data/lib/Vdd.rb +10 -0
- data/lib/Xor2.rb +9 -0
- data/lib/version.rb +9 -0
- data/setup.rb +1585 -0
- data/test/test_bat.rb +222 -0
- data/test/test_helper.rb +7 -0
- metadata +84 -0
data/test/test_bat.rb
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestInv < Test::Unit::TestCase
|
4
|
+
def test_abelout
|
5
|
+
i = Inv.new("inst1")
|
6
|
+
# make a random port
|
7
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
8
|
+
# connect our gate's port to the port we created
|
9
|
+
i.get_port("p0").add_connection(a)
|
10
|
+
# test that port was set correctly
|
11
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
12
|
+
# test for the correct ABEL output
|
13
|
+
assert_equal("inst1p1 = !inst2p2;\n", i.abelout)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestOutput < Test::Unit::TestCase
|
18
|
+
def test_abelout
|
19
|
+
i = Output.new("inst1")
|
20
|
+
# make a random port
|
21
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
22
|
+
# connect our gate's port to the port we created
|
23
|
+
i.get_port("p0").add_connection(a)
|
24
|
+
# test that port was set correctly
|
25
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
26
|
+
# test for the correct ABEL output
|
27
|
+
assert_equal("inst1p0 = inst2p2;\n", i.abelout)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class TestNor2 < Test::Unit::TestCase
|
32
|
+
def test_abelout
|
33
|
+
i = Nor2.new("inst1")
|
34
|
+
# make some random ports
|
35
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
36
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
37
|
+
# connect our gate's ports to the ports we created
|
38
|
+
i.get_port("p0").add_connection(a)
|
39
|
+
i.get_port("p1").add_connection(b)
|
40
|
+
# test that ports were set correctly
|
41
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
42
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
43
|
+
# test for the correct ABEL output
|
44
|
+
assert_equal("inst1p2 = !(inst2p2 # inst3p2);\n", i.abelout)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class TestNor2c < Test::Unit::TestCase
|
49
|
+
def test_abelout
|
50
|
+
i = Nor2c.new("inst1")
|
51
|
+
# make some random ports
|
52
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
53
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
54
|
+
# connect our gate's ports to the ports we created
|
55
|
+
i.get_port("p0").add_connection(a)
|
56
|
+
i.get_port("p1").add_connection(b)
|
57
|
+
# test that ports were set correctly
|
58
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
59
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
60
|
+
# test for the correct ABEL output
|
61
|
+
assert_equal("inst1p2 = (inst2p2 # inst3p2);\n", i.abelout)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class TestNand2 < Test::Unit::TestCase
|
66
|
+
def test_abelout
|
67
|
+
i = Nand2.new("inst1")
|
68
|
+
# make some random ports
|
69
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
70
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
71
|
+
# connect our gate's ports to the ports we created
|
72
|
+
i.get_port("p0").add_connection(a)
|
73
|
+
i.get_port("p1").add_connection(b)
|
74
|
+
# test that ports were set correctly
|
75
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
76
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
77
|
+
# test for the correct ABEL output
|
78
|
+
assert_equal("inst1p2 = !(inst2p2 & inst3p2);\n", i.abelout)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class TestNand2c < Test::Unit::TestCase
|
83
|
+
def test_abelout
|
84
|
+
i = Nand2c.new("inst1")
|
85
|
+
# make some random ports
|
86
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
87
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
88
|
+
# connect our gate's ports to the ports we created
|
89
|
+
i.get_port("p0").add_connection(a)
|
90
|
+
i.get_port("p1").add_connection(b)
|
91
|
+
# test that ports were set correctly
|
92
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
93
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
94
|
+
# test for the correct ABEL output
|
95
|
+
assert_equal("inst1p2 = (inst2p2 & inst3p2);\n", i.abelout)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class TestXor2 < Test::Unit::TestCase
|
100
|
+
def test_abelout
|
101
|
+
i = Xor2.new("inst1")
|
102
|
+
# make some random ports
|
103
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
104
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
105
|
+
# connect our gate's ports to the ports we created
|
106
|
+
i.get_port("p0").add_connection(a)
|
107
|
+
i.get_port("p1").add_connection(b)
|
108
|
+
# test that ports were set correctly
|
109
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
110
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
111
|
+
# test for the correct ABEL output
|
112
|
+
assert_equal("inst1p2 = (inst2p2 $ inst3p2);\n", i.abelout)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class TestNor3 < Test::Unit::TestCase
|
117
|
+
def test_abelout
|
118
|
+
i = Nor3.new("inst1")
|
119
|
+
# make some random ports
|
120
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
121
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
122
|
+
c = Port.new("inst4","Nor2","inst4p2")
|
123
|
+
# connect our gate's ports to the ports we created
|
124
|
+
i.get_port("p0").add_connection(a)
|
125
|
+
i.get_port("p1").add_connection(b)
|
126
|
+
i.get_port("p2").add_connection(c)
|
127
|
+
# test that ports were set correctly
|
128
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
129
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
130
|
+
assert_equal("inst4p2",i.get_port("p2").connections.first.name)
|
131
|
+
# test for the correct ABEL output
|
132
|
+
assert_equal("inst1p3 = !(inst2p2 # inst3p2 # inst4p2);\n", i.abelout)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class TestNand3 < Test::Unit::TestCase
|
137
|
+
def test_abelout
|
138
|
+
i = Nand3.new("inst1")
|
139
|
+
# make some random ports
|
140
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
141
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
142
|
+
c = Port.new("inst4","Nor2","inst4p2")
|
143
|
+
# connect our gate's ports to the ports we created
|
144
|
+
i.get_port("p0").add_connection(a)
|
145
|
+
i.get_port("p1").add_connection(b)
|
146
|
+
i.get_port("p2").add_connection(c)
|
147
|
+
# test that ports were set correctly
|
148
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
149
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
150
|
+
assert_equal("inst4p2",i.get_port("p2").connections.first.name)
|
151
|
+
# test for the correct ABEL output
|
152
|
+
assert_equal("inst1p3 = !(inst2p2 & inst3p2 & inst4p2);\n", i.abelout)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
class TestNand3c < Test::Unit::TestCase
|
157
|
+
def test_abelout
|
158
|
+
i = Nand3c.new("inst1")
|
159
|
+
# make some random ports
|
160
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
161
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
162
|
+
c = Port.new("inst4","Nor2","inst4p2")
|
163
|
+
# connect our gate's ports to the ports we created
|
164
|
+
i.get_port("p0").add_connection(a)
|
165
|
+
i.get_port("p1").add_connection(b)
|
166
|
+
i.get_port("p2").add_connection(c)
|
167
|
+
# test that ports were set correctly
|
168
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
169
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
170
|
+
assert_equal("inst4p2",i.get_port("p2").connections.first.name)
|
171
|
+
# test for the correct ABEL output
|
172
|
+
assert_equal("inst1p3 = (inst2p2 & inst3p2 & inst4p2);\n", i.abelout)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class TestNand4 < Test::Unit::TestCase
|
177
|
+
def test_abelout
|
178
|
+
i = Nand4.new("inst1")
|
179
|
+
# make some random ports
|
180
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
181
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
182
|
+
c = Port.new("inst4","Nor2","inst4p2")
|
183
|
+
d = Port.new("inst5","Nand2","inst5p2")
|
184
|
+
# connect our gate's ports to the ports we created
|
185
|
+
i.get_port("p0").add_connection(a)
|
186
|
+
i.get_port("p1").add_connection(b)
|
187
|
+
i.get_port("p2").add_connection(c)
|
188
|
+
i.get_port("p3").add_connection(d)
|
189
|
+
# test that ports were set correctly
|
190
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
191
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
192
|
+
assert_equal("inst4p2",i.get_port("p2").connections.first.name)
|
193
|
+
assert_equal("inst5p2",i.get_port("p3").connections.first.name)
|
194
|
+
# test for the correct ABEL output
|
195
|
+
assert_equal("inst1p4 = !(inst2p2 & inst3p2 & inst4p2 & inst5p2);\n", i.abelout)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class TestNand4c < Test::Unit::TestCase
|
200
|
+
def test_abelout
|
201
|
+
i = Nand4c.new("inst1")
|
202
|
+
# make some random ports
|
203
|
+
a = Port.new("inst2","Nand2","inst2p2")
|
204
|
+
b = Port.new("inst3","Nor2","inst3p2")
|
205
|
+
c = Port.new("inst4","Nor2","inst4p2")
|
206
|
+
d = Port.new("inst5","Nand2","inst5p2")
|
207
|
+
# connect our gate's ports to the ports we created
|
208
|
+
i.get_port("p0").add_connection(a)
|
209
|
+
i.get_port("p1").add_connection(b)
|
210
|
+
i.get_port("p2").add_connection(c)
|
211
|
+
i.get_port("p3").add_connection(d)
|
212
|
+
# test that ports were set correctly
|
213
|
+
assert_equal("inst2p2",i.get_port("p0").connections.first.name)
|
214
|
+
assert_equal("inst3p2",i.get_port("p1").connections.first.name)
|
215
|
+
assert_equal("inst4p2",i.get_port("p2").connections.first.name)
|
216
|
+
assert_equal("inst5p2",i.get_port("p3").connections.first.name)
|
217
|
+
# test for the correct ABEL output
|
218
|
+
assert_equal("inst1p4 = (inst2p2 & inst3p2 & inst4p2 & inst5p2);\n", i.abelout)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# TODO - need tests for DFFPC, MUX2, BUF1, BUFZ
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
%w[ParseHelper Parser Inst Port OnePort TwoPorts ThreePorts FourPorts FivePorts
|
4
|
+
Input Output Dffpc Bufz Mux2 Buf1 Gnd Inv Nand2 Nand2c Nand3 Nand3c Nand4
|
5
|
+
Nand4c Nor2 Nor2c Nor3 Vdd Xor2].each do |r|
|
6
|
+
require r
|
7
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: bat
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-04-26 00:00:00 -07:00
|
8
|
+
summary: B2 Logic to ABEL Translator
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: jamiequint@gmail.com
|
12
|
+
homepage: http://bat.rubyforge.org
|
13
|
+
rubyforge_project: bat
|
14
|
+
description: B2 Logic to ABEL Translator
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Jamie Quint
|
31
|
+
- Ian Tagge
|
32
|
+
files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- Rakefile
|
37
|
+
- lib/version.rb
|
38
|
+
- lib/ParseHelper.rb
|
39
|
+
- lib/Parser.rb
|
40
|
+
- lib/Inst.rb
|
41
|
+
- lib/Port.rb
|
42
|
+
- lib/OnePort.rb
|
43
|
+
- lib/TwoPorts.rb
|
44
|
+
- lib/ThreePorts.rb
|
45
|
+
- lib/FourPorts.rb
|
46
|
+
- lib/FivePorts.rb
|
47
|
+
- lib/Input.rb
|
48
|
+
- lib/Output.rb
|
49
|
+
- lib/Dffpc.rb
|
50
|
+
- lib/Bufz.rb
|
51
|
+
- lib/Mux2.rb
|
52
|
+
- lib/Buf1.rb
|
53
|
+
- lib/Gnd.rb
|
54
|
+
- lib/Inv.rb
|
55
|
+
- lib/Nand2.rb
|
56
|
+
- lib/Nand2c.rb
|
57
|
+
- lib/Nand3.rb
|
58
|
+
- lib/Nand3c.rb
|
59
|
+
- lib/Nand4.rb
|
60
|
+
- lib/Nand4c.rb
|
61
|
+
- lib/Nor2.rb
|
62
|
+
- lib/Nor2c.rb
|
63
|
+
- lib/Nor3.rb
|
64
|
+
- lib/Vdd.rb
|
65
|
+
- lib/Xor2.rb
|
66
|
+
- bin/bat
|
67
|
+
- setup.rb
|
68
|
+
- test/test_bat.rb
|
69
|
+
- test/test_helper.rb
|
70
|
+
test_files:
|
71
|
+
- test/test_bat.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
extra_rdoc_files: []
|
76
|
+
|
77
|
+
executables:
|
78
|
+
- bat
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
dependencies: []
|
84
|
+
|