soc_maker 0.1.1
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 +7 -0
- data/.gitignore +5 -0
- data/History.txt +4 -0
- data/LICENSE +678 -0
- data/README.rdoc +228 -0
- data/Rakefile +46 -0
- data/bin/soc_maker_cli +80 -0
- data/bin/soc_maker_parser +85 -0
- data/core_lib/cores/adv_debug_sys/01_adv_debug_sys.yaml +245 -0
- data/core_lib/cores/or1200_rel2/01_or1200.yaml +208 -0
- data/core_lib/cores/or1200_rel2/02_or1200_files.yaml +421 -0
- data/core_lib/cores/or1200_rel2/03_or1200_sparam.yaml +188 -0
- data/core_lib/cores/or1200_rel2/or1200_defines.v.in +1799 -0
- data/core_lib/cores/ram_wb/ram_wb.yaml +102 -0
- data/core_lib/cores/ram_wb/ram_wb_b3.v.in +259 -0
- data/core_lib/cores/uart16550/01_uart16550.yaml +99 -0
- data/core_lib/cores/uart16550/02_uart16550_files.yaml +70 -0
- data/core_lib/cores/wb_connect/minsoc_tc_top.v +1802 -0
- data/core_lib/cores/wb_connect/wb_connect.yaml +733 -0
- data/core_lib/inc.yaml +13 -0
- data/core_lib/interfaces/clk_rst/clk.yaml +9 -0
- data/core_lib/interfaces/clk_rst/rst.yaml +9 -0
- data/core_lib/interfaces/clk_rst/single.yaml +7 -0
- data/core_lib/interfaces/debug/debug.yaml +32 -0
- data/core_lib/interfaces/jtag/jtag.yaml +13 -0
- data/core_lib/interfaces/jtag/jtag_tap.yaml +22 -0
- data/core_lib/interfaces/power/or_power.yaml +25 -0
- data/core_lib/interfaces/uart/uart.yaml +21 -0
- data/core_lib/interfaces/wishbone/wishbone_ma_b3.yaml +54 -0
- data/core_lib/interfaces/wishbone/wishbone_sl_b3.yaml +51 -0
- data/doc/class_arch.uml +5113 -0
- data/doc/fig/hierarchical.svg +273 -0
- data/examples/or1200_test/or1200_test.cmd +78 -0
- data/examples/or1200_test/or1200_test.rb +136 -0
- data/examples/or1200_test/rtl/or1200_test_top.vhd +274 -0
- data/examples/or1200_test/rtl/s3astarter.ucf +10 -0
- data/examples/or1200_test/rtl/xilinx_internal_jtag.v +438 -0
- data/examples/or1200_test/rtl/xilinx_internal_jtag_options.v +12 -0
- data/examples/or1200_test/sw/README.txt +35 -0
- data/examples/or1200_test/sw/bin2vmem.c +159 -0
- data/examples/or1200_test/sw/board.h +24 -0
- data/examples/or1200_test/sw/compile.sh +18 -0
- data/examples/or1200_test/sw/except.S +152 -0
- data/examples/or1200_test/sw/int.c +79 -0
- data/examples/or1200_test/sw/int.h +14 -0
- data/examples/or1200_test/sw/interconnect.h +17 -0
- data/examples/or1200_test/sw/interrupts.c +14 -0
- data/examples/or1200_test/sw/main.c +16 -0
- data/examples/or1200_test/sw/or1200.h +454 -0
- data/examples/or1200_test/sw/orp.ld +60 -0
- data/examples/or1200_test/sw/reset.S +112 -0
- data/examples/or1200_test/sw/support.c +123 -0
- data/examples/or1200_test/sw/support.h +33 -0
- data/examples/or1200_test/sw/tick.c +30 -0
- data/examples/or1200_test/sw/tick.h +2 -0
- data/examples/or1200_test/sw/uart.c +136 -0
- data/examples/or1200_test/sw/uart.h +126 -0
- data/lib/soc_maker.rb +324 -0
- data/lib/soc_maker/cli.rb +544 -0
- data/lib/soc_maker/conf.rb +310 -0
- data/lib/soc_maker/core_def.rb +579 -0
- data/lib/soc_maker/core_inst.rb +305 -0
- data/lib/soc_maker/err.rb +211 -0
- data/lib/soc_maker/hdl_coder.rb +500 -0
- data/lib/soc_maker/hdl_file.rb +166 -0
- data/lib/soc_maker/hdl_parser.rb +431 -0
- data/lib/soc_maker/ifc_def.rb +193 -0
- data/lib/soc_maker/ifc_port.rb +133 -0
- data/lib/soc_maker/ifc_spc.rb +180 -0
- data/lib/soc_maker/lib.rb +289 -0
- data/lib/soc_maker/lib_inc.rb +109 -0
- data/lib/soc_maker/parameter.rb +149 -0
- data/lib/soc_maker/soc_def.rb +847 -0
- data/lib/soc_maker/sparameter.rb +289 -0
- data/lib/soc_maker/version.rb +8 -0
- data/lib/soc_maker/ypp.rb +130 -0
- data/soc_maker.gemspec +28 -0
- data/spec/cli_cmds1.txt +39 -0
- data/spec/cli_spec.rb +49 -0
- data/spec/conf_spec.rb +44 -0
- data/spec/core_def_spec.rb +503 -0
- data/spec/core_inst_spec.rb +169 -0
- data/spec/hdl_file_spec.rb +154 -0
- data/spec/hdl_parser_spec.rb +201 -0
- data/spec/ifc_def_spec.rb +121 -0
- data/spec/ifc_port_spec.rb +92 -0
- data/spec/ifc_spc_spec.rb +196 -0
- data/spec/lib_inc_spec.rb +99 -0
- data/spec/lib_spec.rb +209 -0
- data/spec/parameter_spec.rb +86 -0
- data/spec/soc_def_spec.rb +611 -0
- data/spec/soc_maker_spec.rb +7 -0
- data/spec/sparameter_spec.rb +182 -0
- data/spec/spec_helper.rb +78 -0
- data/spec/test_soc.yaml +105 -0
- data/spec/test_soc2.yaml +60 -0
- data/spec/test_soc_lib/cores/core_A_rel1/00_core_a.yaml +75 -0
- data/spec/test_soc_lib/cores/core_A_rel1/01_core_a.yaml +57 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a.vhd +29 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg.vhd.src +3 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg2.vhd.src +4 -0
- data/spec/test_soc_lib/cores/core_A_rel1/core_a_pkg3.v.src +6 -0
- data/spec/test_soc_lib/cores/core_B_rel1/core_b.vhd +25 -0
- data/spec/test_soc_lib/cores/core_B_rel1/core_b.yaml +36 -0
- data/spec/test_soc_lib/cores/core_C_v1/core_C.vhd +57 -0
- data/spec/test_soc_lib/cores/core_C_v1/core_c.yaml +42 -0
- data/spec/test_soc_lib/cores/soc_A/soc_A.yaml +12 -0
- data/spec/test_soc_lib/cores/soc_maker_include.yaml +6 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/bidir_ifc.yaml +19 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/core_AB_ifc.yaml +15 -0
- data/spec/test_soc_lib/ifcs/core_AB_ifc/top_ifc.yaml +9 -0
- data/spec/test_soc_lib/soc_maker_include.yaml +4 -0
- data/spec/yaml_examples.rb +367 -0
- data/spec/ypp_spec.rb +156 -0
- data/test/test_soc_maker.rb +0 -0
- metadata +255 -0
data/spec/cli_cmds1.txt
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
# Do
|
4
|
+
# ./bin/soc_maker_cli -l spec/test_soc_lib examples/run.txt
|
5
|
+
# to run this example
|
6
|
+
#
|
7
|
+
|
8
|
+
# list all cores and interfaces in our library
|
9
|
+
list
|
10
|
+
|
11
|
+
n my_soc my_soc,v1 top
|
12
|
+
|
13
|
+
# create two instances of core_A and core_B
|
14
|
+
a core_A,rel1 A_inst
|
15
|
+
a core_B,rel1 B_inst
|
16
|
+
|
17
|
+
|
18
|
+
# set parameter 'param1' for 'A_inst'
|
19
|
+
p A_inst param1 8
|
20
|
+
|
21
|
+
p A_inst param2 16
|
22
|
+
|
23
|
+
# set static-parameter for core_A
|
24
|
+
sparameter core_A,rel1 p2 3
|
25
|
+
|
26
|
+
# connect A_inst and B_inst
|
27
|
+
c some_connection A_inst ifc01 B_inst myifc
|
28
|
+
|
29
|
+
# add a third instance
|
30
|
+
a core_A,rel1 C_inst
|
31
|
+
|
32
|
+
# delete the instance
|
33
|
+
d C_inst
|
34
|
+
|
35
|
+
# generate the files
|
36
|
+
g
|
37
|
+
|
38
|
+
s test.yaml
|
39
|
+
|
data/spec/cli_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: cli_spec.rb
|
4
|
+
#
|
5
|
+
# Author: Christian Hättich
|
6
|
+
#
|
7
|
+
# Project: System-On-Chip Maker
|
8
|
+
#
|
9
|
+
# Target: Linux / Windows / Mac
|
10
|
+
#
|
11
|
+
# Language: ruby
|
12
|
+
#
|
13
|
+
#
|
14
|
+
###############################################################
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
|
18
|
+
#
|
19
|
+
# This program is free software: you can redistribute it and/or modify
|
20
|
+
# it under the terms of the GNU General Public License as published by
|
21
|
+
# the Free Software Foundation, either version 3 of the License, or
|
22
|
+
# (at your option) any later version.
|
23
|
+
#
|
24
|
+
# This program is distributed in the hope that it will be useful,
|
25
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
+
# GNU General Public License for more details.
|
28
|
+
#
|
29
|
+
# You should have received a copy of the GNU General Public License
|
30
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
###############################################################
|
34
|
+
require_relative( 'spec_helper' )
|
35
|
+
|
36
|
+
|
37
|
+
describe SOCMaker::Cli, "running an example cli file" do
|
38
|
+
|
39
|
+
it "should raise no error for this example" do
|
40
|
+
|
41
|
+
cli = SOCMaker::Cli.instance
|
42
|
+
SOCMaker::conf[ :cores_search_path ] = ["./spec/test_soc_lib"]
|
43
|
+
SOCMaker::lib.refresh
|
44
|
+
File.readlines( "./spec/cli_cmds1.txt" ).each{ |line| cli.process_cmd line }
|
45
|
+
SOCMaker::lib.clear
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
data/spec/conf_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: conf_spec.rb
|
4
|
+
#
|
5
|
+
# Author: Christian Hättich
|
6
|
+
#
|
7
|
+
# Project: System-On-Chip Maker
|
8
|
+
#
|
9
|
+
# Target: Linux / Windows / Mac
|
10
|
+
#
|
11
|
+
# Language: ruby
|
12
|
+
#
|
13
|
+
#
|
14
|
+
###############################################################
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
|
18
|
+
#
|
19
|
+
# This program is free software: you can redistribute it and/or modify
|
20
|
+
# it under the terms of the GNU General Public License as published by
|
21
|
+
# the Free Software Foundation, either version 3 of the License, or
|
22
|
+
# (at your option) any later version.
|
23
|
+
#
|
24
|
+
# This program is distributed in the hope that it will be useful,
|
25
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
+
# GNU General Public License for more details.
|
28
|
+
#
|
29
|
+
# You should have received a copy of the GNU General Public License
|
30
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
###############################################################
|
34
|
+
#
|
35
|
+
# Description:
|
36
|
+
#
|
37
|
+
#
|
38
|
+
#
|
39
|
+
###############################################################
|
40
|
+
require_relative( 'spec_helper' )
|
41
|
+
|
42
|
+
describe SOCMaker::Conf, "TODO: implement test" do
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,503 @@
|
|
1
|
+
###############################################################
|
2
|
+
#
|
3
|
+
# File: core_def_spec.rb
|
4
|
+
#
|
5
|
+
# Author: Christian Hättich
|
6
|
+
#
|
7
|
+
# Project: System-On-Chip Maker
|
8
|
+
#
|
9
|
+
# Target: Linux / Windows / Mac
|
10
|
+
#
|
11
|
+
# Language: ruby
|
12
|
+
#
|
13
|
+
#
|
14
|
+
###############################################################
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org
|
18
|
+
#
|
19
|
+
# This program is free software: you can redistribute it and/or modify
|
20
|
+
# it under the terms of the GNU General Public License as published by
|
21
|
+
# the Free Software Foundation, either version 3 of the License, or
|
22
|
+
# (at your option) any later version.
|
23
|
+
#
|
24
|
+
# This program is distributed in the hope that it will be useful,
|
25
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
+
# GNU General Public License for more details.
|
28
|
+
#
|
29
|
+
# You should have received a copy of the GNU General Public License
|
30
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
31
|
+
#
|
32
|
+
#
|
33
|
+
###############################################################
|
34
|
+
#
|
35
|
+
# Description:
|
36
|
+
# Test specification for SOCMaker::CoreDef
|
37
|
+
#
|
38
|
+
#
|
39
|
+
#
|
40
|
+
#
|
41
|
+
###############################################################
|
42
|
+
require_relative( 'spec_helper' )
|
43
|
+
|
44
|
+
require "yaml_examples.rb"
|
45
|
+
|
46
|
+
|
47
|
+
describe SOCMaker::CoreDef do
|
48
|
+
|
49
|
+
include_context "yaml examples"
|
50
|
+
|
51
|
+
describe '#initialize' do
|
52
|
+
|
53
|
+
context 'with the minimum of input arguments' do
|
54
|
+
subject { SOCMaker::CoreDef.new( "acore", "acore,v1", "top" ) }
|
55
|
+
its( :class ) { should == SOCMaker::CoreDef }
|
56
|
+
its( :name ) { should == "acore" }
|
57
|
+
its( :id ) { should == :"acore,v1" }
|
58
|
+
its( :toplevel ) { should == "top" }
|
59
|
+
|
60
|
+
its( :vccmd ) { should == "" }
|
61
|
+
its( :description ) { should == "" }
|
62
|
+
its( :date ) { should == "" }
|
63
|
+
its( :license ) { should == "" }
|
64
|
+
its( :licensefile ) { should == "" }
|
65
|
+
its( :author ) { should == "" }
|
66
|
+
its( :authormail ) { should == "" }
|
67
|
+
its( :vccmd ) { should == "" }
|
68
|
+
its( :interfaces ) { should == {} }
|
69
|
+
its( :functions ) { should == {} }
|
70
|
+
its( :inst_parameters ) { should == {} }
|
71
|
+
its( :static_parameters ) { should == {} }
|
72
|
+
its( :hdlfiles ) { should == {} }
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
context 'from yaml strings' do
|
78
|
+
it "not raise any error" do
|
79
|
+
@valid_yamls.each do |setup|
|
80
|
+
SOCMaker::from_s( setup[:yaml] ).class.should == SOCMaker::CoreDef
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
context 'with an invalid name ' do
|
87
|
+
it "raises InitError when nil" do
|
88
|
+
expect{ SOCMaker::CoreDef.new( nil, "v1", "top" ) }.
|
89
|
+
to raise_error( SOCMaker::ERR::InitError )
|
90
|
+
end
|
91
|
+
|
92
|
+
it "raises InitError when zero-length" do
|
93
|
+
expect{ SOCMaker::CoreDef.new( "", "v1", "top" ) }.
|
94
|
+
to raise_error( SOCMaker::ERR::InitError )
|
95
|
+
end
|
96
|
+
|
97
|
+
it "raise InitError when not of type string" do
|
98
|
+
expect{ SOCMaker::CoreDef.new( 3, "v1", "top" ) }.
|
99
|
+
to raise_error( SOCMaker::ERR::InitError )
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
context 'with an invalid id' do
|
107
|
+
it "raises InitError when nil" do
|
108
|
+
expect{ SOCMaker::CoreDef.new( "acore", nil, "top" ) }.
|
109
|
+
to raise_error( SOCMaker::ERR::InitError )
|
110
|
+
end
|
111
|
+
|
112
|
+
it "raises InitError when zero-length" do
|
113
|
+
expect{ SOCMaker::CoreDef.new( "acore", "", "top" ) }.
|
114
|
+
to raise_error( SOCMaker::ERR::InitError )
|
115
|
+
end
|
116
|
+
|
117
|
+
it "raises InitError when not of type string " do
|
118
|
+
expect{ SOCMaker::CoreDef.new( "acore", [ 1, 2, 3 ], "top" ) }.
|
119
|
+
to raise_error( SOCMaker::ERR::InitError )
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
context 'with an invalid toplevel name' do
|
126
|
+
it "raises InitError when nil" do
|
127
|
+
expect{ SOCMaker::CoreDef.new( "acore", "acore,v1", nil ) }.
|
128
|
+
to raise_error( SOCMaker::ERR::InitError )
|
129
|
+
end
|
130
|
+
|
131
|
+
it "raises InitError when zero-length" do
|
132
|
+
expect{ SOCMaker::CoreDef.new( "acore", "acore,v1", "" ) }.
|
133
|
+
to raise_error( SOCMaker::ERR::InitError )
|
134
|
+
end
|
135
|
+
|
136
|
+
it "raises InitError when not of type string " do
|
137
|
+
expect{ SOCMaker::CoreDef.new( "acore", "acore,v1", [ 1, 2, 3 ] ) }.
|
138
|
+
to raise_error( SOCMaker::ERR::InitError )
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
context 'auto-completion of field' do
|
144
|
+
%w[ description date license licensefile
|
145
|
+
author authormail vccmd ].each do |m|
|
146
|
+
it "#{m} to an empty string" do
|
147
|
+
c = SOCMaker::CoreDef.new( "acore", "v1", "top" )
|
148
|
+
c.instance_variable_get( '@'+m ).class.should be == String
|
149
|
+
c.instance_variable_get( '@'+m ).should be == ""
|
150
|
+
end
|
151
|
+
end
|
152
|
+
%w[ interfaces functions
|
153
|
+
inst_parameters
|
154
|
+
static_parameters
|
155
|
+
hdlfiles ].each do |m|
|
156
|
+
it "#{m} to an empty Hash" do
|
157
|
+
c = SOCMaker::CoreDef.new( "acore", "v1", "top" )
|
158
|
+
c.instance_variable_get( '@'+m ).class.should be == Hash
|
159
|
+
c.instance_variable_get( '@'+m ).should be == {}
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
context 'with an invalid' do
|
166
|
+
%w[ description date license licensefile
|
167
|
+
author authormail vccmd ].each do |m|
|
168
|
+
it "#{m} (not as string)" do
|
169
|
+
# pass an numerical value
|
170
|
+
expect{ SOCMaker::CoreDef.new( "acore", "v1", "top", { m => 4 } ) }.
|
171
|
+
to raise_error( SOCMaker::ERR::InitError )
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
%w[ interfaces functions
|
176
|
+
inst_parameters
|
177
|
+
static_parameters hdlfiles ].each do |m|
|
178
|
+
it "#{m} (not as hash)" do
|
179
|
+
# pass an numerical value
|
180
|
+
expect{ SOCMaker::CoreDef.new( "acore", "v1", "top", { m => 4 } ) }.
|
181
|
+
to raise_error( SOCMaker::ERR::InitError )
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
context 'with nil entry of hash' do
|
188
|
+
%w[ interfaces
|
189
|
+
inst_parameters
|
190
|
+
static_parameters
|
191
|
+
hdlfiles ].each do |field|
|
192
|
+
it "#{field}" do
|
193
|
+
expect{ SOCMaker::CoreDef.new( "A core",
|
194
|
+
"acore,v1",
|
195
|
+
"top",
|
196
|
+
field => { "entry-name" => nil } ) }
|
197
|
+
.to raise_error( SOCMaker::ERR::InitError )
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "#dir_name" do
|
206
|
+
let( :inst ) { SOCMaker::CoreDef.new( "A Core", "acore,v1", "top" ) }
|
207
|
+
it "returns an id without ','" do
|
208
|
+
expect( inst.dir_name ).to eq( "acore_v1" )
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
describe "#add_interface" do
|
215
|
+
|
216
|
+
before( :each ) do
|
217
|
+
|
218
|
+
ifc_s1 = SOCMaker::IfcSpc.new( "Interface 2", "i1,v1", 'ports' => { x1:{dir:1}, x2:{dir:0} } )
|
219
|
+
SOCMaker::lib.add_ifc( ifc_s1 )
|
220
|
+
@p1 = SOCMaker::IfcPort.new( "x1", 1 )
|
221
|
+
@p2 = SOCMaker::IfcPort.new( "x2", 2 )
|
222
|
+
@c = SOCMaker::CoreDef.new( "A core", "acore,v1", "top" )
|
223
|
+
@c.add_interface( 'my_ifc', 'i1,v1', 0, { m_x1: @p1, m_x2: @p2 } )
|
224
|
+
end
|
225
|
+
after( :each ) do
|
226
|
+
SOCMaker::lib.clear
|
227
|
+
end
|
228
|
+
|
229
|
+
context "error handling" do
|
230
|
+
it "raises an error if name is used twice" do
|
231
|
+
expect{ @c.add_interface( 'my_ifc', 'i1,v1', 0, { m_x1: @p1, m_x2: @p2 } ) }.to raise_error( SOCMaker::ERR::ProcessingError )
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
it "adds an interface" do
|
236
|
+
expect( @c.interfaces[ :my_ifc ] ).not_to be_nil
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
describe "#to_s" do
|
243
|
+
before( :each ) do
|
244
|
+
@c = SOCMaker::CoreDef.new( "A core", "acore,v1", "top" )
|
245
|
+
end
|
246
|
+
|
247
|
+
context "string creation" do
|
248
|
+
it{ expect( @c.to_s ).not_to be_nil }
|
249
|
+
it{ expect( @c.to_s.size ).to be > 0 }
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
describe "#all_static_parameters" do
|
255
|
+
before( :each ) do
|
256
|
+
@c = SOCMaker::CoreDef.new( "A core", "acore,v1", "top" )
|
257
|
+
end
|
258
|
+
context "empty hash" do
|
259
|
+
it {expect( @c.all_static_parameters ).to eq( {} ) }
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "::get_and_ensure_dir!" do
|
264
|
+
before( :each ) do
|
265
|
+
|
266
|
+
@build_dir_bak = SOCMaker::conf[ :build_dir ]
|
267
|
+
@hdl_dir_bak = SOCMaker::conf[ :hdl_dir ]
|
268
|
+
@build_dir = "./spec/test_build_dir"
|
269
|
+
@hdl_dir = "./some/hdl/path/sub_dir"
|
270
|
+
@sub_dir = "my_dir_name"
|
271
|
+
SOCMaker::conf[ :build_dir ] = @build_dir
|
272
|
+
SOCMaker::conf[ :hdl_dir ] = @hdl_dir
|
273
|
+
@final_dir = File.expand_path( File.join( @build_dir, @hdl_dir, @sub_dir ) )
|
274
|
+
end
|
275
|
+
after( :each ) do
|
276
|
+
SOCMaker::conf[ :build_dir ] = @build_dir_bak
|
277
|
+
SOCMaker::conf[ :hdl_dir ] = @hdl_dir_bak
|
278
|
+
FileUtils.rm_rf( @build_dir )
|
279
|
+
end
|
280
|
+
|
281
|
+
context "directory creation" do
|
282
|
+
it do
|
283
|
+
expect( SOCMaker::CoreDef::get_and_ensure_dst_dir!( @sub_dir ) ).to eq( @final_dir )
|
284
|
+
expect( File.exist?( @final_dir ) ).to be( true )
|
285
|
+
expect( SOCMaker::CoreDef::get_and_ensure_dst_dir!( @sub_dir ) ).to eq( @final_dir )
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
describe "#ifc_specification" do
|
295
|
+
|
296
|
+
after( :each ) do
|
297
|
+
SOCMaker::lib.clear
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should return the spec instances" do
|
301
|
+
ifc_spc = SOCMaker::IfcSpc.new( "Ifc 1", "i1,v1", 'ports' => { p1:{dir:1} } )
|
302
|
+
SOCMaker::lib.add_ifc( ifc_spc )
|
303
|
+
p1 = SOCMaker::IfcPort.new( "p1", 1 )
|
304
|
+
inst = SOCMaker::CoreDef.new( "A Core", "acore,v1", "top", "interfaces" =>
|
305
|
+
{ "my_ifc" => SOCMaker::IfcDef.new( "i1", "i1,v1", 0, { m_p1: p1 } ) } )
|
306
|
+
expect( inst.ifc_specification( "my_ifc" ) ).to equal( ifc_spc )
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
describe "#update_vcs" do
|
312
|
+
it "should not do any 'system' call when no vccmd is given" do
|
313
|
+
inst = SOCMaker::CoreDef.new( "A Core", "acore,v1", "top" )
|
314
|
+
inst.should_not_receive(:system)
|
315
|
+
inst.update_vcs
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should a 'system' call when a vccmd is given" do
|
319
|
+
inst = SOCMaker::CoreDef.new( "A Core", "acore,v1", "top", "vccmd" => "svn co my-url" )
|
320
|
+
inst.src_dir = "dir"
|
321
|
+
inst.should_receive(:system).with( "cd dir && svn co my-url" )
|
322
|
+
inst.update_vcs
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
describe "::core_cnt" do
|
328
|
+
context "hash creation" do
|
329
|
+
it{ expect( SOCMaker::CoreDef::core_cnt( %w[ i1 i2 i3 i2 i3 i4 i5 ] ) )
|
330
|
+
.to eq( { "i1" => 1, "i2" => 2, "i3" => 2, "i4" => 1, "i5"=> 1 } ) }
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
describe "#all_core_id" do
|
335
|
+
before( :each ) do
|
336
|
+
@c = SOCMaker::CoreDef.new( "A core", "acore,v1", "top" )
|
337
|
+
end
|
338
|
+
context "return of id array" do
|
339
|
+
it{ expect( @c.all_core_id ).to eq( [ :"acore,v1" ] ) }
|
340
|
+
end
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "#generics" do
|
345
|
+
it 'should iterate over all generics (inst. parameters)' do
|
346
|
+
|
347
|
+
|
348
|
+
p1 = SOCMaker::Parameter.new( "integer" )
|
349
|
+
p2 = SOCMaker::Parameter.new( "string" )
|
350
|
+
p3 = SOCMaker::Parameter.new( "integer" )
|
351
|
+
p4 = SOCMaker::Parameter.new( "string" )
|
352
|
+
|
353
|
+
c = SOCMaker::CoreDef.new( "acore", "v1", "top",
|
354
|
+
{ 'inst_parameters' => { p1: p1, p2: p2, p3: p3, p4: p4 } } )
|
355
|
+
|
356
|
+
a_name = [];
|
357
|
+
a_type = [];
|
358
|
+
a_default = [];
|
359
|
+
a_is_last = [];
|
360
|
+
c.generics do |name,type,default,is_last|
|
361
|
+
a_name << name
|
362
|
+
a_type << type
|
363
|
+
a_default << default
|
364
|
+
a_is_last << is_last
|
365
|
+
end
|
366
|
+
a_name.should be == %w[ p1 p2 p3 p4 ]
|
367
|
+
a_type.should be == %w[ integer string integer string ]
|
368
|
+
a_default.should be == [ 0, 0, 0, 0 ]
|
369
|
+
a_is_last.should be == [ false, false, false, true ]
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
describe "#ports" do
|
377
|
+
|
378
|
+
after( :each ) do
|
379
|
+
SOCMaker::lib.clear
|
380
|
+
end
|
381
|
+
|
382
|
+
before( :each ) do
|
383
|
+
ifc_s1 = SOCMaker::IfcSpc.new( "Interface 1", "i1,v1", 'ports' => { p1:{dir:1}, p2:{dir:1}, p3:{dir:0,default:'X'} } )
|
384
|
+
ifc_s2 = SOCMaker::IfcSpc.new( "Interface 2", "i2,v1", 'ports' => { x1:{dir:1}, x2:{dir:0} } )
|
385
|
+
SOCMaker::lib.add_ifc( ifc_s1 )
|
386
|
+
SOCMaker::lib.add_ifc( ifc_s2 )
|
387
|
+
|
388
|
+
p1 = SOCMaker::IfcPort.new( "p1", 1 )
|
389
|
+
p2 = SOCMaker::IfcPort.new( "p2", 2 )
|
390
|
+
p3 = SOCMaker::IfcPort.new( "p3", 3 )
|
391
|
+
x1 = SOCMaker::IfcPort.new( "x1", 1 )
|
392
|
+
x2 = SOCMaker::IfcPort.new( "x2", 2 )
|
393
|
+
|
394
|
+
ifc_d1 = SOCMaker::IfcDef.new( "i1", "i1,v1", 0, { m_p1: p1, m_p2: p2, m_p3: p3 } )
|
395
|
+
ifc_d2 = SOCMaker::IfcDef.new( "i2", "i2,v1", 0, { m_x1: x1, m_x2: x2 } )
|
396
|
+
|
397
|
+
@c = SOCMaker::CoreDef.new( "A core", "acore,v1", "top",
|
398
|
+
{ 'interfaces' => { i1: ifc_d1, i2: ifc_d2 } } )
|
399
|
+
end
|
400
|
+
|
401
|
+
it 'should iterate over all ports of all interfaces' do
|
402
|
+
r_name = []
|
403
|
+
r_dir = []
|
404
|
+
r_len = []
|
405
|
+
r_default = []
|
406
|
+
r_ref = []
|
407
|
+
r_is_last = []
|
408
|
+
@c.ports do |arg_name,arg_dir,arg_len,arg_default,arg_ref,arg_is_last|
|
409
|
+
r_name << arg_name
|
410
|
+
r_dir << arg_dir
|
411
|
+
r_len << arg_len
|
412
|
+
r_default << arg_default
|
413
|
+
r_ref << arg_ref
|
414
|
+
r_is_last << arg_is_last
|
415
|
+
end
|
416
|
+
expect( r_name.sort ).to eq( %w[ m_p1 m_p2 m_p3 m_x1 m_x2 ].sort )
|
417
|
+
expect( r_dir.sort ).to eq( [ 1, 1, 0, 1, 0 ].sort )
|
418
|
+
expect( r_len.sort ).to eq( [ 1, 2, 3, 1, 2 ].sort )
|
419
|
+
expect( r_default.sort ).to eq( [ "0", "0", "X", "0", "0" ].sort )
|
420
|
+
expect( r_ref.sort ).to eq( [ "p1", "p2", "p3", "x1", "x2" ].sort )
|
421
|
+
expect( r_is_last ).to eq( [ false, false, false, false, true ] )
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'should iterate over all ports of a specific interface' do
|
425
|
+
r_name = []
|
426
|
+
r_dir = []
|
427
|
+
r_len = []
|
428
|
+
r_default = []
|
429
|
+
r_ref = []
|
430
|
+
r_is_last = []
|
431
|
+
@c.ports( "i1" ) do |arg_name, arg_dir, arg_len, arg_default, arg_ref, arg_is_last|
|
432
|
+
r_name << arg_name
|
433
|
+
r_dir << arg_dir
|
434
|
+
r_len << arg_len
|
435
|
+
r_default << arg_default
|
436
|
+
r_ref << arg_ref
|
437
|
+
r_is_last << arg_is_last
|
438
|
+
end
|
439
|
+
expect( r_name.sort ).to eq( %w[ m_p1 m_p2 m_p3 ].sort )
|
440
|
+
expect( r_dir.sort ).to eq( [ 1, 1, 0 ].sort )
|
441
|
+
expect( r_len.sort ).to eq( [ 1, 2, 3 ].sort )
|
442
|
+
expect( r_default.sort ).to eq( [ "0", "0", "X" ].sort )
|
443
|
+
expect( r_ref.sort ).to eq( [ "p1", "p2", "p3" ].sort )
|
444
|
+
expect( r_is_last ).to eq( [ false, false, true ] )
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
describe "#consistency_check" do
|
454
|
+
|
455
|
+
it "should throw an error if an incomplete interface is used" do
|
456
|
+
|
457
|
+
# three (auto) mandatory ports
|
458
|
+
ifc_s1 = SOCMaker::IfcSpc.new( "i1", "v1", 'ports' => { p1: { dir: 1}, p2: {dir: 1}, p3: {dir:0} } )
|
459
|
+
SOCMaker::lib.add_ifc( ifc_s1 )
|
460
|
+
|
461
|
+
# interface implementaiton with only two of the three ports
|
462
|
+
p1 = SOCMaker::IfcPort.new( "p1", 1 )
|
463
|
+
p2 = SOCMaker::IfcPort.new( "p2", 2 )
|
464
|
+
ifc_d1 = SOCMaker::IfcDef.new( "i1", "v1", 0, { m_p1: p1, m_p2: p2 } )
|
465
|
+
|
466
|
+
c = SOCMaker::CoreDef.new( "acore", "v1", "top",
|
467
|
+
{ 'interfaces' => { i1: ifc_d1 } } )
|
468
|
+
|
469
|
+
|
470
|
+
expect{ c.consistence_check }.
|
471
|
+
to raise_error( SOCMaker::ERR::ConsistenceError )
|
472
|
+
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
describe "object handling, en-decoding:" do
|
477
|
+
|
478
|
+
it "should be possible to encode and decode a core definition" do
|
479
|
+
o1 = SOCMaker::CoreDef.new( "acore", "acore,v1", "top" )
|
480
|
+
yaml_str = o1.to_yaml
|
481
|
+
o2 = YAML::load( yaml_str )
|
482
|
+
o1.should be == o2
|
483
|
+
end
|
484
|
+
|
485
|
+
it "should return false for two non-equal objects" do
|
486
|
+
file = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }
|
487
|
+
o1 = SOCMaker::CoreDef.new( "acore", "acore,v1", "top", "hdlfiles" => file )
|
488
|
+
o2 = Marshal::load(Marshal.dump(o1))
|
489
|
+
o2.id = "acore,v2"
|
490
|
+
( o2 == o1 ).should be == false
|
491
|
+
o2 = Marshal::load(Marshal.dump(o1))
|
492
|
+
o2.hdlfiles[ "file.vhd".to_sym ].use_syn = false
|
493
|
+
( o2 == o1 ).should be == false
|
494
|
+
end
|
495
|
+
|
496
|
+
end
|
497
|
+
|
498
|
+
end
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
# vim: noai:ts=2:sw=2
|