1 |
48 |
alirezamon |
use constant::boolean;
|
2 |
16 |
alirezamon |
|
3 |
|
|
use lib 'lib/perl';
|
4 |
|
|
|
5 |
|
|
use strict;
|
6 |
|
|
use warnings;
|
7 |
43 |
alirezamon |
|
8 |
|
|
|
9 |
|
|
use FindBin;
|
10 |
|
|
use lib $FindBin::Bin;
|
11 |
|
|
|
12 |
16 |
alirezamon |
use soc;
|
13 |
|
|
use ip;
|
14 |
|
|
use ip_gen;
|
15 |
|
|
use Cwd;
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
######################
|
22 |
|
|
# soc_generate_verilog
|
23 |
|
|
#####################
|
24 |
|
|
|
25 |
|
|
sub soc_generate_verilog{
|
26 |
48 |
alirezamon |
my ($soc,$sw_path,$txview)= @_;
|
27 |
25 |
alirezamon |
my $soc_name=$soc->object_get_attribute('soc_name');
|
28 |
16 |
alirezamon |
#my $top_ip=ip_gen->ip_gen_new();
|
29 |
|
|
my $top_ip=ip_gen->top_gen_new();
|
30 |
|
|
if(!defined $soc_name){$soc_name='soc'};
|
31 |
|
|
|
32 |
|
|
my @instances=$soc->soc_get_all_instances();
|
33 |
|
|
my $io_sim_v;
|
34 |
48 |
alirezamon |
my $top_io_short;
|
35 |
28 |
alirezamon |
my $core_id= $soc->object_get_attribute('global_param','CORE_ID');
|
36 |
|
|
$core_id= 0 if(!defined $core_id);
|
37 |
48 |
alirezamon |
my $param_as_in_v_all="\tparameter\tCORE_ID=$core_id,
|
38 |
34 |
alirezamon |
\tparameter\tSW_LOC=\"$sw_path\"";
|
39 |
28 |
alirezamon |
|
40 |
|
|
|
41 |
|
|
|
42 |
48 |
alirezamon |
my $system_v_all="";
|
43 |
|
|
my $param_pass_v_all="\t\t.CORE_ID(CORE_ID),\n\t\t.SW_LOC(SW_LOC)";
|
44 |
16 |
alirezamon |
my $body_v;
|
45 |
|
|
|
46 |
48 |
alirezamon |
my ($param_v_all, $local_param_v_all, $wire_def_v_all, $inst_v_all, $plugs_assign_v_all, $sockets_assign_v_all,$io_full_v_all,$top_io_pass_all,$io_sim_v_all);
|
47 |
|
|
my $top_io_short_all="\tjtag_debug_reset_in";
|
48 |
|
|
my $top_io_full_all="\tinput \tjtag_debug_reset_in;\n";
|
49 |
17 |
alirezamon |
my $wires=soc->new_wires();
|
50 |
|
|
my $intfc=interface->interface_new();
|
51 |
25 |
alirezamon |
|
52 |
48 |
alirezamon |
|
53 |
16 |
alirezamon |
foreach my $id (@instances){
|
54 |
48 |
alirezamon |
my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v,$io_sim_v,
|
55 |
|
|
$top_io_short,$param_as_in_v,$param_pass_v,$system_v,$assigned_ports,$top_io_pass,$src_io_short, $src_io_full)=gen_module_inst($id,$soc,$top_ip,$intfc,$wires);
|
56 |
16 |
alirezamon |
my $inst = $soc->soc_get_instance_name($id);
|
57 |
|
|
add_text_to_string(\$body_v,"/*******************\n*\n*\t$inst\n*\n*\n*********************/\n");
|
58 |
48 |
alirezamon |
add_text_to_string(\$param_as_in_v_all,",\n$param_as_in_v") if(defined($param_as_in_v));
|
59 |
16 |
alirezamon |
add_text_to_string(\$local_param_v_all,"$local_param_v\n") if(defined($local_param_v));
|
60 |
48 |
alirezamon |
add_text_to_string(\$param_pass_v_all,",\n$param_pass_v") if(defined($param_pass_v));
|
61 |
|
|
add_text_to_string(\$system_v_all,"$system_v\n") if(defined($system_v));
|
62 |
16 |
alirezamon |
add_text_to_string(\$wire_def_v_all,"$wire_def_v\n") if(defined($wire_def_v));
|
63 |
|
|
add_text_to_string(\$inst_v_all,$inst_v) if(defined($inst_v));
|
64 |
|
|
add_text_to_string(\$plugs_assign_v_all,"$plugs_assign_v\n") if(defined($plugs_assign_v));
|
65 |
|
|
add_text_to_string(\$sockets_assign_v_all,"$sockets_assign_v\n")if(defined($sockets_assign_v));
|
66 |
48 |
alirezamon |
add_text_to_string(\$io_full_v_all,"$io_full_v\n") if(length($io_full_v)>3);
|
67 |
|
|
add_text_to_string(\$top_io_full_all,"$io_top_full_v\n") if(length($io_top_full_v)>3);
|
68 |
|
|
$top_io_pass_all = (defined $top_io_pass_all )? "$top_io_pass_all,\n$top_io_pass" : $top_io_pass if(defined($top_io_pass));
|
69 |
|
|
$io_sim_v_all = (defined $io_sim_v_all )? "$io_sim_v_all,\n$io_sim_v" : $io_sim_v if(defined($io_sim_v));
|
70 |
|
|
$top_io_short_all = (defined $top_io_short_all)? "$top_io_short_all,\n$top_io_short" : $top_io_short if(defined($top_io_short));
|
71 |
16 |
alirezamon |
|
72 |
43 |
alirezamon |
|
73 |
16 |
alirezamon |
#print "$param_v $local_param_v $wire_def_v $inst_v $plugs_assign_v $sockets_assign_v $io_full_v";
|
74 |
|
|
|
75 |
|
|
}
|
76 |
17 |
alirezamon |
my ($addr_map,$addr_localparam,$module_addr_localparam)= generate_address_cmp($soc,$wires);
|
77 |
16 |
alirezamon |
|
78 |
|
|
#add functions
|
79 |
|
|
my $dir = Cwd::getcwd();
|
80 |
|
|
open my $file1, "<", "$dir/lib/verilog/functions.v" or die;
|
81 |
|
|
my $functions_all='';
|
82 |
|
|
while (my $f1 = readline ($file1)) {
|
83 |
|
|
$functions_all="$functions_all $f1 ";
|
84 |
|
|
}
|
85 |
|
|
close($file1);
|
86 |
17 |
alirezamon |
my $unused_wiers_v=assign_unconnected_wires($wires,$intfc);
|
87 |
|
|
|
88 |
48 |
alirezamon |
$unused_wiers_v="" if(!defined $unused_wiers_v);
|
89 |
|
|
$sockets_assign_v_all="" if(!defined $sockets_assign_v_all);
|
90 |
16 |
alirezamon |
|
91 |
48 |
alirezamon |
my $has_ni =check_for_ni($soc);
|
92 |
56 |
alirezamon |
my $import = ($has_ni)? "\n\t`NOC_CONF\n" : "";
|
93 |
|
|
my $tscale = ($has_ni)? "`include \"pronoc_def.v\"\n" : "`timescale 1ns / 1ps\n";
|
94 |
48 |
alirezamon |
|
95 |
|
|
my $global_localparam=get_golal_param_v();
|
96 |
56 |
alirezamon |
my $soc_v = (defined $param_as_in_v_all )? "$tscale module $soc_name #(\n $param_as_in_v_all\n)(\n$io_sim_v_all\n);\n$import\n": "$tscale module $soc_name (\n$io_sim_v_all\n);\n $import\n";
|
97 |
48 |
alirezamon |
$soc_v = $soc_v."
|
98 |
|
|
$functions_all
|
99 |
|
|
$system_v_all
|
100 |
|
|
$global_localparam
|
101 |
|
|
$local_param_v_all
|
102 |
|
|
$addr_localparam
|
103 |
|
|
$module_addr_localparam
|
104 |
|
|
$io_full_v_all
|
105 |
|
|
$wire_def_v_all
|
106 |
|
|
$unused_wiers_v
|
107 |
|
|
$inst_v_all
|
108 |
|
|
$plugs_assign_v_all
|
109 |
|
|
$sockets_assign_v_all
|
110 |
|
|
$addr_map
|
111 |
|
|
endmodule
|
112 |
|
|
|
113 |
|
|
";
|
114 |
16 |
alirezamon |
|
115 |
|
|
|
116 |
34 |
alirezamon |
$soc->object_add_attribute('top_ip',undef,$top_ip);
|
117 |
17 |
alirezamon |
#print @assigned_wires;
|
118 |
16 |
alirezamon |
|
119 |
48 |
alirezamon |
#generate top module
|
120 |
|
|
my ($clk_set, $clk_io_sim,$clk_io_full, $clk_assigned_port)= get_top_clk_setting($soc);
|
121 |
|
|
$top_io_short_all=(defined $top_io_short_all)? "$top_io_short_all,\n$clk_io_sim" : $clk_io_sim;
|
122 |
|
|
$top_io_full_all=$top_io_full_all."\n$clk_io_full";
|
123 |
|
|
$top_io_pass_all=$top_io_pass_all.",\n$clk_assigned_port";
|
124 |
|
|
my %jtag_info= get_soc_jtag_v($soc,$soc_name,$txview);
|
125 |
|
|
my $jtag_v=add_jtag_ctrl (\%jtag_info,$txview);
|
126 |
|
|
my @chains = (sort { $b <=> $a } keys %jtag_info);
|
127 |
|
|
$soc->object_add_attribute('JTAG','M_CHAIN',$chains[0]);
|
128 |
|
|
|
129 |
56 |
alirezamon |
my $top_v = (defined $param_as_in_v_all )? "module ${soc_name}_top #(\n $param_as_in_v_all\n)(\n$top_io_short_all\n);\n": "module ${soc_name}_top (\n $top_io_short_all\n);\n $import ";
|
130 |
25 |
alirezamon |
|
131 |
48 |
alirezamon |
|
132 |
|
|
#my $ins= gen_soc_instance_v($soc,$soc_name,$param_pass_v,$txview);
|
133 |
|
|
|
134 |
|
|
my $pass = (defined $param_pass_v_all )? "#(\n$param_pass_v_all\n\t)\n": "";
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
$top_v=$top_v."
|
138 |
|
|
$functions_all
|
139 |
|
|
$global_localparam
|
140 |
|
|
$local_param_v_all
|
141 |
|
|
$top_io_full_all
|
142 |
|
|
$clk_set
|
143 |
|
|
$jtag_v
|
144 |
|
|
\t${soc_name}${pass}\tthe_${soc_name}
|
145 |
|
|
\t(
|
146 |
|
|
$top_io_pass_all
|
147 |
|
|
\t);
|
148 |
|
|
endmodule
|
149 |
|
|
";
|
150 |
|
|
|
151 |
|
|
my ($readme,$prog)=gen_system_info($soc,$param_as_in_v_all);
|
152 |
28 |
alirezamon |
return ("$soc_v",$top_v,$readme,$prog);
|
153 |
25 |
alirezamon |
|
154 |
|
|
|
155 |
16 |
alirezamon |
}
|
156 |
|
|
|
157 |
48 |
alirezamon |
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
sub append_to_hash {
|
161 |
|
|
my ($ref,$att1,$att2,$data)=@_;
|
162 |
|
|
my %hash= %{$ref};
|
163 |
|
|
my $r = $hash{$att1}{$att2};
|
164 |
|
|
my @array= (defined $r)? @{$r} : ();
|
165 |
|
|
push (@array,$data);
|
166 |
|
|
$hash{$att1}{$att2} = \@array;
|
167 |
|
|
return %hash;
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
sub get_soc_jtag_v{
|
172 |
|
|
my ($soc,$soc_name,$txview)=@_;
|
173 |
|
|
|
174 |
|
|
my $processor_en=0;
|
175 |
|
|
#my $jtag_insts="";
|
176 |
|
|
#my $altera_jtag_ctrl=0;
|
177 |
|
|
#my $xilinx_jtag_ctrl=0;
|
178 |
|
|
#my $xilinx_jtag_ctrl_in;
|
179 |
|
|
#my $xilinx_jtag_ctrl_out;
|
180 |
|
|
my $jtag_inst_name="";
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
my $top=$soc->soc_get_top();
|
184 |
|
|
my @intfcs=$top->top_get_intfc_list();
|
185 |
|
|
|
186 |
|
|
my %jtag_info;
|
187 |
|
|
|
188 |
|
|
foreach my $intfc (@intfcs){
|
189 |
|
|
if( $intfc =~ /socket:jtag_to_wb\[/){ #check JTAG connect parameter. if it is XILINX then connect it to jtag tap
|
190 |
|
|
my @ports=$top->top_get_intfc_ports_list($intfc);
|
191 |
|
|
foreach my $p (@ports){
|
192 |
|
|
my($id,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
|
193 |
|
|
my $JTAG_CONNECT=$soc->soc_get_module_param_value ($id,'JTAG_CONNECT');
|
194 |
|
|
$JTAG_CONNECT=remove_all_white_spaces($JTAG_CONNECT);
|
195 |
|
|
if($JTAG_CONNECT =~ /XILINX_JTAG_WB/){
|
196 |
|
|
my $chain=$soc->soc_get_module_param_value ($id,'JTAG_CHAIN');
|
197 |
|
|
my $index=$soc->soc_get_module_param_value ($id,'JTAG_INDEX');
|
198 |
|
|
$jtag_inst_name= $soc->soc_get_instance_name($id);
|
199 |
|
|
my %params = $soc->soc_get_module_param($id);
|
200 |
|
|
my $new_range = add_instantc_name_to_parameters(\%params,$id,$range);
|
201 |
|
|
%jtag_info=append_to_hash (\%jtag_info,$chain,'wire',"\twire [ $new_range ] ${p};");
|
202 |
|
|
# $jtag_def=$jtag_def."\twire [ $new_range ] ${p};\n";
|
203 |
|
|
if($type eq 'input'){
|
204 |
|
|
# $jtag_insts=$jtag_insts."$id XILINX JTAG,";
|
205 |
|
|
%jtag_info=append_to_hash (\%jtag_info,0,'inst',"$id XILINX JTAG");
|
206 |
|
|
# $xilinx_jtag_ctrl++;
|
207 |
|
|
%jtag_info=append_to_hash (\%jtag_info,$chain,'xilinx_num',1);
|
208 |
|
|
# $xilinx_jtag_ctrl_in=(defined $xilinx_jtag_ctrl_in)? "$xilinx_jtag_ctrl_in,$p" : "$p";
|
209 |
|
|
%jtag_info=append_to_hash (\%jtag_info,$chain,'input',$p);
|
210 |
|
|
%jtag_info=check_jtag_indexs(\%jtag_info,$chain,$index,$txview,$jtag_inst_name,0);
|
211 |
|
|
#print "\%jtag_info=check_jtag_indexs(\%jtag_info,$chain,$index,$txview,$jtag_inst_name);\n"
|
212 |
|
|
|
213 |
|
|
}else {
|
214 |
|
|
# $xilinx_jtag_ctrl_out=(defined $xilinx_jtag_ctrl_out)? "$xilinx_jtag_ctrl_out,$p" : "$p";
|
215 |
|
|
%jtag_info=append_to_hash (\%jtag_info,$chain,'output',$p);
|
216 |
|
|
}
|
217 |
|
|
}#'"XILINX_JTAG_WB"'
|
218 |
|
|
|
219 |
|
|
elsif($JTAG_CONNECT eq '"ALTERA_JTAG_WB"'){
|
220 |
|
|
my $index=$soc->soc_get_module_param_value ($id,'JTAG_INDEX');
|
221 |
|
|
if($type eq 'input'){
|
222 |
|
|
# $jtag_insts=$jtag_insts."$id ALTERA JTAG,";
|
223 |
|
|
%jtag_info=append_to_hash (\%jtag_info,0,'inst',"$id ALTERA JTAG");
|
224 |
|
|
%jtag_info=append_to_hash (\%jtag_info,0,'altera_num',1);
|
225 |
|
|
%jtag_info=check_jtag_indexs(\%jtag_info,0,$index,$txview,$jtag_inst_name,0);
|
226 |
|
|
# $altera_jtag_ctrl++;
|
227 |
|
|
|
228 |
|
|
}
|
229 |
|
|
}#'"ALTERA_JTAG_WB"'
|
230 |
|
|
|
231 |
|
|
} #$p
|
232 |
|
|
}#if
|
233 |
|
|
|
234 |
|
|
}
|
235 |
|
|
#print Dumper \%jtag_info;
|
236 |
|
|
return %jtag_info;
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
|
240 |
16 |
alirezamon |
#################
|
241 |
|
|
# gen_module_inst
|
242 |
|
|
###############
|
243 |
|
|
|
244 |
48 |
alirezamon |
sub get_io_nc_info {
|
245 |
|
|
my($soc,$port,$inst,$intfc_name,$id)=@_;
|
246 |
|
|
my $IO='no';
|
247 |
|
|
my $NC='no';
|
248 |
|
|
my($i_type,$i_name,$i_num) =split("[:\[ \\]]", $intfc_name);
|
249 |
|
|
if($i_type eq 'plug'){
|
250 |
|
|
my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($id,$i_name,$i_num);
|
251 |
|
|
if($connect_id eq 'IO'){ $IO='yes';}
|
252 |
|
|
if($connect_id eq 'NC'){ $NC='yes';}
|
253 |
|
|
}
|
254 |
|
|
if($i_type eq 'socket' && $i_name ne'wb_addr_map'){
|
255 |
|
|
|
256 |
|
|
my ($ref1,$ref2)= $soc->soc_get_modules_plug_connected_to_socket($id,$i_name,$i_num);
|
257 |
|
|
my %connected_plugs=%$ref1;
|
258 |
|
|
my %connected_plug_nums=%$ref2;
|
259 |
|
|
if(!%connected_plugs ){
|
260 |
|
|
my ($s_type,$s_value,$s_connection_num)=$soc->soc_get_socket_of_instance($id,$i_name);
|
261 |
|
|
my $v=$soc->soc_get_module_param_value($id,$s_value);
|
262 |
|
|
if ( length( $v || '' )){ $IO='no';} else {
|
263 |
|
|
my $con= $soc->object_get_attribute("Unset-intfc" ,"$inst-$port");
|
264 |
|
|
if(!defined $con){ $IO='yes';}
|
265 |
|
|
else{
|
266 |
|
|
$IO='yes' if $con eq 'IO';
|
267 |
|
|
}
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
return ($IO ,$NC);
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
|
278 |
|
|
|
279 |
16 |
alirezamon |
sub gen_module_inst {
|
280 |
48 |
alirezamon |
my ($id,$soc,$top_ip,$intfc,$wires, $sim_only)=@_;
|
281 |
|
|
$sim_only = 0 if (!defined $sim_only);
|
282 |
|
|
my ($io_sim_v,$top_io_short,$param_as_in_v,$param_pass_v,$system_v);
|
283 |
|
|
my $top_io_pass;
|
284 |
|
|
my $src_io_short;
|
285 |
|
|
my $src_io_full="";
|
286 |
16 |
alirezamon |
my $module =$soc->soc_get_module($id);
|
287 |
|
|
my $module_name =$soc->soc_get_module_name($id);
|
288 |
|
|
my $category =$soc->soc_get_category($id);
|
289 |
|
|
|
290 |
48 |
alirezamon |
|
291 |
16 |
alirezamon |
my $inst = $soc->soc_get_instance_name($id);
|
292 |
|
|
my %params = $soc->soc_get_module_param($id);
|
293 |
48 |
alirezamon |
my %params_type = $soc->soc_get_module_param_type($id);
|
294 |
17 |
alirezamon |
|
295 |
48 |
alirezamon |
|
296 |
|
|
|
297 |
|
|
my $src_ip=$soc ->object_get_attribute('SOURCE_SET',"IP");
|
298 |
16 |
alirezamon |
my $ip = ip->lib_new ();
|
299 |
48 |
alirezamon |
$ip->add_ip($src_ip) if defined $src_ip;
|
300 |
16 |
alirezamon |
|
301 |
48 |
alirezamon |
|
302 |
16 |
alirezamon |
my @ports=$ip->ip_list_ports($category,$module);
|
303 |
48 |
alirezamon |
my ($inst_v,$intfc_v,$plugs_assign_v,$sockets_assign_v);
|
304 |
25 |
alirezamon |
my $wire_def_v="";
|
305 |
48 |
alirezamon |
my $io_full_v="";
|
306 |
|
|
my $io_top_full_v="";
|
307 |
16 |
alirezamon |
$plugs_assign_v="\n";
|
308 |
|
|
|
309 |
48 |
alirezamon |
|
310 |
16 |
alirezamon |
my $counter=0;
|
311 |
|
|
my @param_order=$soc->soc_get_instance_param_order($id);
|
312 |
|
|
|
313 |
48 |
alirezamon |
my ($param_v,$local_param_v,$instance_param_v)= gen_parameter_v(\%params,$id,$inst,$category,$module,$ip,\$param_as_in_v,\@param_order,$top_ip,\$param_pass_v,\%params_type);
|
314 |
16 |
alirezamon |
|
315 |
|
|
|
316 |
25 |
alirezamon |
|
317 |
16 |
alirezamon |
$top_ip->top_add_def_to_instance($id,'module',$module);
|
318 |
|
|
$top_ip->top_add_def_to_instance($id,'module_name',$module_name);
|
319 |
|
|
$top_ip->top_add_def_to_instance($id,'category',$category);
|
320 |
|
|
$top_ip->top_add_def_to_instance($id,'instance',$inst);
|
321 |
|
|
|
322 |
43 |
alirezamon |
#
|
323 |
48 |
alirezamon |
my $assigned_ports="";
|
324 |
16 |
alirezamon |
|
325 |
|
|
#module name
|
326 |
25 |
alirezamon |
$inst_v=( defined $instance_param_v )? "$module_name #(\n": $module_name ;
|
327 |
16 |
alirezamon |
#module parameters
|
328 |
25 |
alirezamon |
$inst_v=( defined $instance_param_v)? "$inst_v $instance_param_v\n\t)": $inst_v;
|
329 |
16 |
alirezamon |
#module instance name
|
330 |
43 |
alirezamon |
$inst_v="$inst_v $inst \t(\n";
|
331 |
16 |
alirezamon |
#module ports
|
332 |
|
|
$counter=0;
|
333 |
|
|
foreach my $port (@ports){
|
334 |
|
|
my ($type,$range,$intfc_name,$i_port)=$ip->ip_get_port($category,$module,$port);
|
335 |
|
|
my $assigned_port;
|
336 |
|
|
my($i_type,$i_name,$i_num) =split("[:\[ \\]]", $intfc_name);
|
337 |
38 |
alirezamon |
|
338 |
48 |
alirezamon |
my ($IO ,$NC) =get_io_nc_info($soc,$port,$inst,$intfc_name,$id);
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
16 |
alirezamon |
if($NC eq 'yes'){
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
}
|
346 |
|
|
elsif($IO eq 'yes' || !defined $i_type || !defined $i_name || !defined $i_num){ #its an IO port
|
347 |
48 |
alirezamon |
if($i_port eq 'NC' ){
|
348 |
25 |
alirezamon |
$NC='yes';
|
349 |
|
|
}else {
|
350 |
48 |
alirezamon |
$i_name ='IO' if( !defined $i_name);
|
351 |
|
|
|
352 |
|
|
|
353 |
25 |
alirezamon |
$assigned_port="$inst\_$port";
|
354 |
48 |
alirezamon |
$io_sim_v= (!defined $io_sim_v)? "\t$assigned_port" : "$io_sim_v,\n\t$assigned_port";
|
355 |
25 |
alirezamon |
my $new_range = add_instantc_name_to_parameters(\%params,$inst,$range);
|
356 |
48 |
alirezamon |
my $r = (!defined $new_range)? 0 : (length ($new_range)>1 )? 1 : 0;
|
357 |
|
|
|
358 |
|
|
my $str = (!defined $new_range) ? "\t\t\t" :
|
359 |
|
|
($new_range =~ /:/ ) ? "\t[ $new_range ]\t" : "\t$new_range\t";
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
my $port_def= "\t$type $str $assigned_port;\n";
|
363 |
|
|
$io_full_v=$io_full_v.$port_def;
|
364 |
|
|
|
365 |
|
|
if ($i_name eq 'RxD_sim' && $sim_only == 0){
|
366 |
|
|
#do notthing
|
367 |
|
|
}
|
368 |
|
|
elsif($i_name eq 'enable'){
|
369 |
|
|
$top_io_pass = (!defined $top_io_pass )? "\t\t.$assigned_port($assigned_port & jtag_cpu_en)" : "$top_io_pass,\n\t\t.$assigned_port($assigned_port & jtag_cpu_en)";
|
370 |
|
|
$top_io_short= (!defined $top_io_short)? "\t$assigned_port" : "$top_io_short, \n\t$assigned_port";
|
371 |
|
|
$io_top_full_v= $io_top_full_v.$port_def;
|
372 |
|
|
} elsif($i_name eq 'reset' || $i_name eq 'clk'){
|
373 |
|
|
#connection done using get_top_clk_setting
|
374 |
|
|
$src_io_short= (!defined $src_io_short)? "\t$assigned_port" : "$src_io_short, \n\t$assigned_port";
|
375 |
|
|
$src_io_full= $src_io_full.$port_def;
|
376 |
|
|
} elsif( $i_name eq 'jtag_to_wb' ){
|
377 |
|
|
$top_io_pass = (!defined $top_io_pass )? "\t\t.$assigned_port($assigned_port)" : "$top_io_pass,\n\t\t.$assigned_port($assigned_port)";
|
378 |
|
|
|
379 |
|
|
}else{
|
380 |
|
|
$top_io_short= (!defined $top_io_short)? "\t$assigned_port" : "$top_io_short, \n\t$assigned_port";
|
381 |
|
|
$top_io_pass = (!defined $top_io_pass )? "\t\t.$assigned_port($assigned_port)" : "$top_io_pass,\n\t\t.$assigned_port($assigned_port)";
|
382 |
|
|
$io_top_full_v= $io_top_full_v.$port_def;
|
383 |
|
|
}
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
25 |
alirezamon |
# $top_ip->ipgen_add_port($assigned_port, $new_range, $type ,$intfc_name,$i_port);
|
388 |
|
|
$top_ip->top_add_port($id,$assigned_port, $new_range, $type ,$intfc_name,$i_port);
|
389 |
|
|
}
|
390 |
16 |
alirezamon |
|
391 |
|
|
|
392 |
|
|
}
|
393 |
|
|
else{ # port connected internally using interface
|
394 |
|
|
$assigned_port="$inst\_$i_type\_$i_name\_$i_num\_$i_port";
|
395 |
|
|
|
396 |
|
|
#create plug wires
|
397 |
25 |
alirezamon |
my ($wire_string,$port_name)=generate_wire ($range,$assigned_port,$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
|
398 |
|
|
#add wire def if it is not defined before
|
399 |
|
|
|
400 |
|
|
add_text_to_string(\$wire_def_v,$wire_string) if ($wire_def_v !~ /[\s\]]$port_name;/);
|
401 |
16 |
alirezamon |
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
if($i_type eq 'plug'){
|
405 |
|
|
#read socket port name
|
406 |
|
|
my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($id,$i_name,$i_num);
|
407 |
|
|
my ($i_range,$t,$i_connect)=$intfc->get_port_info_of_plug($i_name,$i_port);
|
408 |
|
|
#my $connect_port= "socket_$i_name\_$i_num\_$i_connect";
|
409 |
|
|
if(defined $connect_socket_num){
|
410 |
|
|
my $connect_n=$soc->soc_get_instance_name($connect_id);
|
411 |
|
|
my $connect_port= "$connect_n\_socket_$i_name\_$connect_socket_num\_$i_connect";
|
412 |
|
|
#connect plug port to socket port
|
413 |
|
|
my $new_range = add_instantc_name_to_parameters(\%params,$inst,$range);
|
414 |
48 |
alirezamon |
my $r= (!defined $range)? 0 : (length ($range)>1 )? 1 :0;
|
415 |
17 |
alirezamon |
|
416 |
48 |
alirezamon |
my $connect_port_range=($r==1)?"$connect_port\[$new_range\]":$connect_port;
|
417 |
|
|
|
418 |
17 |
alirezamon |
if($type eq 'input' ){
|
419 |
|
|
$plugs_assign_v= "$plugs_assign_v \tassign $assigned_port = $connect_port_range;\n";
|
420 |
|
|
$wires->wire_add($assigned_port,"connected",1);
|
421 |
|
|
|
422 |
|
|
}else{
|
423 |
|
|
$plugs_assign_v= "$plugs_assign_v \tassign $connect_port = $assigned_port;\n";
|
424 |
|
|
$wires->wire_add($connect_port,"connected",1);
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
|
428 |
16 |
alirezamon |
}
|
429 |
|
|
}#plug
|
430 |
|
|
else{ #socket
|
431 |
|
|
my ($s_type,$s_value,$s_connection_num)=$soc->soc_get_socket_of_instance($id,$i_name);
|
432 |
|
|
my $v=$soc->soc_get_module_param_value($id,$s_value);
|
433 |
|
|
my ($i_range,$t,$i_connect)=$intfc->get_port_info_of_socket($i_name,$i_port);
|
434 |
|
|
if ( length( $v || '' )) {
|
435 |
|
|
$v--;
|
436 |
|
|
my $name= $soc->soc_get_instance_name($id);
|
437 |
|
|
my $joint= "$name\_$i_type\_$i_name\_$v\_$i_port";
|
438 |
|
|
|
439 |
25 |
alirezamon |
my ($wire_string,$port_name)=generate_wire ($i_range,"$name\_$i_type\_$i_name\_$v\_$i_port",$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
|
440 |
|
|
add_text_to_string(\$wire_def_v,$wire_string) if ($wire_def_v !~ /[\s\]]$port_name;/);
|
441 |
16 |
alirezamon |
|
442 |
|
|
for(my $i=$v-1; $i>=0; $i--) {
|
443 |
|
|
$joint= "$joint ,$name\_$i_type\_$i_name\_$i\_$i_port";
|
444 |
|
|
#create socket wires
|
445 |
|
|
#create plug wires
|
446 |
25 |
alirezamon |
my ($wire_string,$port_name)=generate_wire ($i_range,"$name\_$i_type\_$i_name\_$i\_$i_port",$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
|
447 |
|
|
add_text_to_string(\$wire_def_v,$wire_string) if ($wire_def_v !~ /[\s\]]$port_name;/);
|
448 |
16 |
alirezamon |
|
449 |
|
|
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
|
|
}
|
455 |
17 |
alirezamon |
$wires->wire_add($assigned_port,"connected",1) if($type eq 'input');
|
456 |
|
|
if($type ne 'input' ){
|
457 |
|
|
my @w=split('\s*,\s*',$joint);
|
458 |
|
|
foreach my $q (@w) {
|
459 |
|
|
$wires->wire_add($q,"connected",1);
|
460 |
|
|
}
|
461 |
|
|
|
462 |
|
|
}
|
463 |
|
|
$joint=($v>0)? "\{ $joint\ }" : "$joint";
|
464 |
|
|
my $text=($type eq 'input' )? "\tassign $assigned_port = $joint;\n": "\tassign $joint = $assigned_port;\n";
|
465 |
|
|
|
466 |
16 |
alirezamon |
add_text_to_string(\$sockets_assign_v,$text);
|
467 |
|
|
}
|
468 |
|
|
|
469 |
|
|
|
470 |
|
|
|
471 |
|
|
}#socket
|
472 |
|
|
|
473 |
|
|
|
474 |
|
|
}
|
475 |
|
|
|
476 |
48 |
alirezamon |
$i_name ='IO' if (!defined $i_name);
|
477 |
|
|
my $reset_jtag_ored = ($i_name eq 'reset')? '| jtag_system_reset' : '';
|
478 |
|
|
my $reset_jtag_nc = ($i_name eq 'reset')? 'jtag_system_reset' : '';
|
479 |
16 |
alirezamon |
|
480 |
48 |
alirezamon |
|
481 |
17 |
alirezamon |
if (++$counter == scalar(@ports)){#last port def
|
482 |
16 |
alirezamon |
|
483 |
|
|
$inst_v=($NC eq 'yes')? "$inst_v\t\t.$port()\n": "$inst_v\t\t.$port($assigned_port)\n";
|
484 |
48 |
alirezamon |
$assigned_ports=($NC eq 'yes')? "$assigned_ports\t\t.$port($reset_jtag_nc)\n": "$assigned_ports\t\t.$port($assigned_port $reset_jtag_ored)\n";
|
485 |
16 |
alirezamon |
|
486 |
|
|
}
|
487 |
|
|
else {
|
488 |
|
|
$inst_v=($NC eq 'yes')? "$inst_v\t\t.$port(),\n":"$inst_v\t\t.$port($assigned_port),\n";
|
489 |
48 |
alirezamon |
$assigned_ports=($NC eq 'yes')? "$assigned_ports\t\t.$port($reset_jtag_nc),\n":"$assigned_ports\t\t.$port($assigned_port $reset_jtag_ored),\n";
|
490 |
16 |
alirezamon |
}
|
491 |
|
|
|
492 |
17 |
alirezamon |
if($type ne 'input' && $NC ne 'yes' ){
|
493 |
|
|
$wires->wire_add($assigned_port,"connected",1);
|
494 |
|
|
|
495 |
|
|
}
|
496 |
16 |
alirezamon |
|
497 |
|
|
|
498 |
|
|
|
499 |
|
|
}
|
500 |
|
|
$inst_v="$inst_v\t);\n";
|
501 |
|
|
|
502 |
48 |
alirezamon |
|
503 |
|
|
|
504 |
43 |
alirezamon |
my $hdr =$ip->ip_get($category,$module,'system_v');
|
505 |
|
|
if(defined $hdr){
|
506 |
|
|
$hdr=replace_golb_var($hdr,\%params);
|
507 |
48 |
alirezamon |
$system_v= "$system_v $hdr\n";
|
508 |
43 |
alirezamon |
}
|
509 |
17 |
alirezamon |
|
510 |
48 |
alirezamon |
return ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v, $io_full_v,
|
511 |
|
|
$io_top_full_v,$io_sim_v,$top_io_short,$param_as_in_v,$param_pass_v,$system_v,$assigned_ports,$top_io_pass,
|
512 |
|
|
$src_io_short, $src_io_full);
|
513 |
|
|
#return ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v,$param_pass_v,$assigned_ports);
|
514 |
17 |
alirezamon |
|
515 |
16 |
alirezamon |
|
516 |
|
|
}
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
sub add_instantc_name_to_parameters{
|
520 |
|
|
my ($params_ref,$inst,$range)=@_;
|
521 |
|
|
my $new_range=$range;
|
522 |
|
|
#print "$new_range\n";
|
523 |
38 |
alirezamon |
return $new_range if(!defined $range);
|
524 |
16 |
alirezamon |
my @list=sort keys%{$params_ref};
|
525 |
|
|
foreach my $param (@list){
|
526 |
|
|
my $new_param= "$inst\_$param";
|
527 |
|
|
($new_range=$new_range)=~ s/\b$param\b/$new_param/g;
|
528 |
|
|
#print "$new_range= s/\b$param\b/$new_param/g\n";
|
529 |
|
|
}
|
530 |
|
|
return $new_range;
|
531 |
|
|
}
|
532 |
|
|
|
533 |
|
|
|
534 |
|
|
sub gen_parameter_v{
|
535 |
48 |
alirezamon |
my ($param_ref,$id,$inst,$category,$module,$ip,$param_as_in_v,$ref_ordered,$top_ip,$param_pass_v,$param_type_ref)=@_;
|
536 |
|
|
my %params=%{$param_ref};
|
537 |
|
|
my %params_type=%{$param_type_ref};
|
538 |
16 |
alirezamon |
my @param_order;
|
539 |
|
|
@param_order=@{$ref_ordered} if(defined $ref_ordered);
|
540 |
|
|
|
541 |
|
|
my ($param_v,$local_param_v,$instance_param_v);
|
542 |
|
|
my @list;
|
543 |
48 |
alirezamon |
@list= (@param_order)? @param_order : sort keys%params;
|
544 |
16 |
alirezamon |
my $first_param=1;
|
545 |
25 |
alirezamon |
|
546 |
16 |
alirezamon |
$local_param_v="";
|
547 |
|
|
$param_v="";
|
548 |
25 |
alirezamon |
|
549 |
16 |
alirezamon |
#add instance name to parameter value
|
550 |
|
|
foreach my $param (@list){
|
551 |
|
|
$params{$param}=add_instantc_name_to_parameters(\%params,$inst,$params{$param});
|
552 |
48 |
alirezamon |
#%params_type{$param}=add_instantc_name_to_parameters(\%params_type,$inst,$params_type{$param});
|
553 |
16 |
alirezamon |
}
|
554 |
|
|
|
555 |
|
|
|
556 |
|
|
#print parameters
|
557 |
|
|
foreach my $param (@list){
|
558 |
|
|
my $inst_param= "$inst\_$param";
|
559 |
38 |
alirezamon |
my ($default,$type,$content,$info,$vfile_param_type,$redefine_param)= $ip->ip_get_parameter($category,$module,$param);
|
560 |
25 |
alirezamon |
$vfile_param_type= "Don't include" if (!defined $vfile_param_type );
|
561 |
48 |
alirezamon |
if ($vfile_param_type eq "Localparam"){
|
562 |
|
|
my $type = $params_type{$param};
|
563 |
|
|
$type = "Localparam" if (! defined $type);
|
564 |
|
|
$vfile_param_type = ($type eq 'Parameter')? "Parameter" : "Localparam";
|
565 |
|
|
}
|
566 |
|
|
|
567 |
|
|
|
568 |
|
|
|
569 |
|
|
#$vfile_param_type= "Parameter" if ($vfile_param_type eq 1);
|
570 |
|
|
#$vfile_param_type= "Localparam" if ($vfile_param_type eq 0);
|
571 |
25 |
alirezamon |
$redefine_param=1 if (! defined $redefine_param);
|
572 |
|
|
$redefine_param=0 if ($vfile_param_type eq "Don't include");
|
573 |
|
|
if($redefine_param eq 1){
|
574 |
|
|
$instance_param_v=($first_param eq 1)? "\t\t.$param($inst_param)" : "$instance_param_v,\n\t\t.$param($inst_param)";
|
575 |
|
|
$first_param=0;
|
576 |
16 |
alirezamon |
|
577 |
|
|
}
|
578 |
|
|
|
579 |
|
|
|
580 |
25 |
alirezamon |
|
581 |
|
|
if($vfile_param_type eq "Localparam"){
|
582 |
16 |
alirezamon |
$local_param_v="$local_param_v\tlocalparam\t$inst_param=$params{$param};\n";
|
583 |
42 |
alirezamon |
$top_ip->top_add_localparam($id,$inst_param,$params{$param},$type,$content,$info,$vfile_param_type,$redefine_param);
|
584 |
25 |
alirezamon |
}
|
585 |
|
|
elsif($vfile_param_type eq "Parameter"){
|
586 |
48 |
alirezamon |
#print "$inst_param($inst_param)\n";
|
587 |
16 |
alirezamon |
$param_v="$param_v\tparameter\t$inst_param=$params{$param};\n";
|
588 |
48 |
alirezamon |
$$param_pass_v =(defined ($$param_pass_v ))? "$$param_pass_v,\n\t\t.$inst_param($inst_param)": "\t\t.$inst_param($inst_param)";
|
589 |
16 |
alirezamon |
$$param_as_in_v=(defined ($$param_as_in_v))? "$$param_as_in_v ,\n\tparameter\t$inst_param=$params{$param}":
|
590 |
|
|
" \tparameter\t$inst_param=$params{$param}";
|
591 |
|
|
#add parameter to top
|
592 |
|
|
#$top_ip $inst_param
|
593 |
25 |
alirezamon |
$top_ip->top_add_parameter($id,$inst_param,$params{$param},$type,$content,$info,$vfile_param_type,$redefine_param);
|
594 |
16 |
alirezamon |
|
595 |
|
|
}
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
|
599 |
|
|
}
|
600 |
|
|
|
601 |
|
|
return ($param_v,$local_param_v,$instance_param_v);
|
602 |
|
|
|
603 |
|
|
|
604 |
|
|
}
|
605 |
|
|
|
606 |
|
|
###############
|
607 |
|
|
# generate_address_cmp
|
608 |
|
|
##############
|
609 |
|
|
|
610 |
|
|
sub generate_address_cmp{
|
611 |
17 |
alirezamon |
my ($soc,$wires)=@_;
|
612 |
16 |
alirezamon |
my $number=0;
|
613 |
|
|
my $addr_mp_v="\n//Wishbone slave address match\n";
|
614 |
|
|
my $instance_addr_localparam="\n//Wishbone slave base address based on instance name\n";
|
615 |
|
|
my $module_addr_localparam="\n//Wishbone slave base address based on module name. \n";
|
616 |
|
|
|
617 |
|
|
my @all_instances=$soc->soc_get_all_instances();
|
618 |
|
|
foreach my $instance_id (@all_instances){
|
619 |
|
|
my $instance_name=$soc->soc_get_instance_name($instance_id);
|
620 |
|
|
my @plugs= $soc->soc_get_all_plugs_of_an_instance($instance_id);
|
621 |
|
|
foreach my $plug (@plugs){
|
622 |
25 |
alirezamon |
my @nums=$soc->soc_list_plug_nums($instance_id,$plug);
|
623 |
16 |
alirezamon |
foreach my $num (@nums){
|
624 |
|
|
my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($instance_id,$plug,$num);
|
625 |
|
|
if((defined $connect_socket) && ($connect_socket eq 'wb_slave')){
|
626 |
25 |
alirezamon |
#read wishbone bus address and data width size
|
627 |
|
|
my $Aw=$soc->soc_get_module_param_value ($connect_id,'Aw');
|
628 |
|
|
my $Dw=$soc->soc_get_module_param_value ($connect_id,'Dw');
|
629 |
|
|
$Aw=32 if (!defined $Aw);
|
630 |
|
|
$Dw=32 if (!defined $Dw);
|
631 |
16 |
alirezamon |
add_text_to_string(\$addr_mp_v,"/* $instance_name wb_slave $num */\n");
|
632 |
25 |
alirezamon |
#count how many nibbles we have in address size
|
633 |
|
|
my $hh= ($Aw % 4)? ($Aw >> 2)+1 : ($Aw >> 2);
|
634 |
|
|
$hh= "'h%0${hh}x";#hex address nibble num
|
635 |
|
|
#change addresses to word as the assign addresses by ProNoC GUI are in bytes
|
636 |
|
|
my $bytenum=($Dw/8);
|
637 |
|
|
my $base_hex=$Aw.sprintf($hh, ($base/$bytenum));
|
638 |
|
|
my $end_hex=$Aw.sprintf($hh, ($end/$bytenum));
|
639 |
|
|
#my $base_hex=sprintf("32'h%08x", ($base>>2));
|
640 |
|
|
#my $end_hex=sprintf("32'h%08x", ($end>>2));
|
641 |
|
|
add_text_to_string(\$instance_addr_localparam,"\tlocalparam \t$instance_name\_WB$num\_BASE_ADDR\t=\t$base_hex;\n");
|
642 |
|
|
add_text_to_string(\$instance_addr_localparam,"\tlocalparam \t$instance_name\_WB$num\_END_ADDR\t=\t$end_hex;\n");
|
643 |
16 |
alirezamon |
if($instance_name ne $instance_id){
|
644 |
25 |
alirezamon |
add_text_to_string(\$module_addr_localparam,"\tlocalparam \t$instance_id\_WB$num\_BASE_ADDR\t=\t$base_hex;\n");
|
645 |
|
|
add_text_to_string(\$module_addr_localparam,"\tlocalparam \t$instance_id\_WB$num\_END_ADDR\t=\t$end_hex;\n");
|
646 |
16 |
alirezamon |
}
|
647 |
|
|
|
648 |
17 |
alirezamon |
my $connect_name=$soc->soc_get_instance_name($connect_id);
|
649 |
|
|
$wires->wire_add("$connect_name\_socket_wb_addr_map_0_sel_one_hot","connected",1);
|
650 |
25 |
alirezamon |
$addr_mp_v="$addr_mp_v \tassign $connect_name\_socket_wb_addr_map_0_sel_one_hot[$connect_socket_num\] = (($connect_name\_socket_wb_addr_map_0_grant_addr >= $instance_name\_WB$num\_BASE_ADDR) & ($connect_name\_socket_wb_addr_map_0_grant_addr <= $instance_name\_WB$num\_END_ADDR));\n";
|
651 |
16 |
alirezamon |
|
652 |
|
|
$number++;
|
653 |
|
|
}#if
|
654 |
|
|
}#foreach my $num
|
655 |
|
|
}#foreach my $plug
|
656 |
|
|
}#foreach my $instance_id
|
657 |
|
|
|
658 |
|
|
add_text_to_string(\$instance_addr_localparam,"\n");
|
659 |
|
|
add_text_to_string(\$module_addr_localparam,"\n");
|
660 |
|
|
return ($addr_mp_v,$instance_addr_localparam,$module_addr_localparam);
|
661 |
|
|
}
|
662 |
|
|
|
663 |
|
|
|
664 |
|
|
sub add_text_to_string{
|
665 |
|
|
my ($string,$text)=@_;
|
666 |
|
|
if(defined $text){
|
667 |
|
|
$$string=(defined ($$string))? "$$string $text" : $text;
|
668 |
|
|
}
|
669 |
|
|
}
|
670 |
|
|
|
671 |
|
|
|
672 |
|
|
|
673 |
|
|
sub generate_wire {
|
674 |
17 |
alirezamon |
my($range,$port_name,$inst_name,$params_ref,$i_type,$i_name,$i_num,$i_port, $wires)=@_;
|
675 |
16 |
alirezamon |
my $wire_string;
|
676 |
17 |
alirezamon |
my $new_range;
|
677 |
48 |
alirezamon |
my $r= (!defined $range)? 0 : (length ($range)>1 )? 1 :0;
|
678 |
|
|
|
679 |
|
|
if($r ==1 ){
|
680 |
16 |
alirezamon |
#replace parameter in range
|
681 |
17 |
alirezamon |
$new_range = add_instantc_name_to_parameters($params_ref,$inst_name,$range);
|
682 |
16 |
alirezamon |
$wire_string= "\twire\t[ $new_range ] $port_name;\n";
|
683 |
|
|
}
|
684 |
|
|
else{
|
685 |
|
|
$wire_string="\twire\t\t\t $port_name;\n";
|
686 |
17 |
alirezamon |
}
|
687 |
|
|
$wires->wire_add("$port_name","range",$new_range);
|
688 |
|
|
$wires->wire_add("$port_name","inst_name",$inst_name);
|
689 |
|
|
$wires->wire_add("$port_name","i_type",$i_type);
|
690 |
|
|
$wires->wire_add("$port_name","i_name",$i_name);
|
691 |
|
|
$wires->wire_add("$port_name","i_num",$i_num);
|
692 |
|
|
$wires->wire_add("$port_name","i_port",$i_port);
|
693 |
|
|
|
694 |
25 |
alirezamon |
return ($wire_string,$port_name);
|
695 |
16 |
alirezamon |
}
|
696 |
|
|
|
697 |
17 |
alirezamon |
sub port_width_repeat{
|
698 |
|
|
my ($range,$value)=@_;
|
699 |
18 |
alirezamon |
return "$value" if (!defined $range);
|
700 |
|
|
$range= remove_all_white_spaces($range);
|
701 |
17 |
alirezamon |
my ($h,$l)=split(':',$range);
|
702 |
|
|
return "$value" if(!defined $h ) ; # port width is 1
|
703 |
|
|
return "$value" if($h eq "0" && "$l" eq "0"); # port width is 1
|
704 |
|
|
$h=$l if($h eq "0" && "$l" ne "0");
|
705 |
|
|
if($h =~ /-1$/){ # the address ranged is endup with -1
|
706 |
|
|
$h =~ s/-1$//; # remove -1
|
707 |
|
|
return "\{$h\{$value\}\}" if($h =~ /\)$/);
|
708 |
|
|
return "\{($h)\{$value\}\}" if($h =~ /[\*\.\+\-\^\%\&]/);
|
709 |
|
|
return "\{$h\{$value\}\}";
|
710 |
|
|
}
|
711 |
|
|
return "\{($h+1){$value}}";
|
712 |
|
|
}
|
713 |
16 |
alirezamon |
|
714 |
17 |
alirezamon |
sub assign_unconnected_wires{
|
715 |
|
|
my($wires,$intfc)=@_;
|
716 |
|
|
my $unused_wire_v=undef;
|
717 |
|
|
|
718 |
|
|
my @all_wires=$wires->wires_list();
|
719 |
|
|
foreach my $p (@all_wires ){
|
720 |
|
|
if(!defined $wires->wire_get($p,"connected")){ # unconnected wires
|
721 |
|
|
# Take default value from interface definition
|
722 |
|
|
#$wires->wire_get("$p","inst_name");
|
723 |
|
|
my $i_type=$wires->wire_get($p,"i_type");
|
724 |
|
|
my $i_name= $wires->wire_get($p,"i_name");
|
725 |
|
|
my $i_num=$wires->wire_get($p,"i_num");
|
726 |
|
|
my $i_port=$wires->wire_get($p,"i_port");
|
727 |
|
|
my $new_range=$wires->wire_get($p,"range");
|
728 |
|
|
my ($range,$type,$connect,$default_out) = ($i_type eq "socket" )? $intfc->get_port_info_of_socket($i_name,$i_port):
|
729 |
|
|
$intfc->get_port_info_of_plug($i_name,$i_port);
|
730 |
|
|
#""Active high","Don't care"
|
731 |
|
|
|
732 |
|
|
my $default=(!defined $default_out )? port_width_repeat($new_range,"1\'bx"):
|
733 |
|
|
($default_out eq 'Active low' )? port_width_repeat($new_range,"1\'b0"):
|
734 |
|
|
($default_out eq 'Active high')? port_width_repeat($new_range,"1\'b1"):
|
735 |
|
|
($default_out eq 'Don\'t care')? port_width_repeat($new_range,"1\'bx"): $default_out;
|
736 |
|
|
|
737 |
|
|
|
738 |
18 |
alirezamon |
$unused_wire_v= (defined $unused_wire_v)? "$unused_wire_v \tassign ${p} = $default;\n" : "\tassign ${p} = $default;\n";
|
739 |
17 |
alirezamon |
|
740 |
|
|
}
|
741 |
|
|
|
742 |
|
|
}
|
743 |
|
|
$unused_wire_v="\n//Take the default value for ports that defined by interfaces but did not assigned to any wires.\n $unused_wire_v\n\n" if(defined $unused_wire_v);
|
744 |
|
|
return $unused_wire_v;
|
745 |
16 |
alirezamon |
|
746 |
17 |
alirezamon |
|
747 |
|
|
}
|
748 |
16 |
alirezamon |
|
749 |
|
|
|
750 |
|
|
|
751 |
|
|
|
752 |
25 |
alirezamon |
sub gen_soc_instance_v{
|
753 |
48 |
alirezamon |
my ($soc,$soc_name,$param_pass_v,$txview)=@_;
|
754 |
|
|
|
755 |
25 |
alirezamon |
my $processor_en=0;
|
756 |
48 |
alirezamon |
my $altera_jtag_ctrl=0;
|
757 |
|
|
my $xilinx_jtag_ctrl=0; #if it becomes larger than 0 then add jtag to wb module
|
758 |
|
|
my $jtag_insts="";
|
759 |
|
|
my $xilinx_jtag_ctrl_in;
|
760 |
|
|
my $xilinx_jtag_ctrl_out;
|
761 |
|
|
my $rpin = "1\'b0";
|
762 |
|
|
my $clkpin;
|
763 |
|
|
my $soc_v="
|
764 |
|
|
// Allow software to remote reset/enable the cpu via jtag
|
765 |
25 |
alirezamon |
wire jtag_cpu_en, jtag_system_reset;
|
766 |
48 |
alirezamon |
";
|
767 |
16 |
alirezamon |
|
768 |
25 |
alirezamon |
my $mm="$soc_name #(\n $param_pass_v \n\t)the_${soc_name}(\n";
|
769 |
|
|
my $top=$soc->soc_get_top();
|
770 |
|
|
my @intfcs=$top->top_get_intfc_list();
|
771 |
48 |
alirezamon |
my $i=0;
|
772 |
25 |
alirezamon |
my $ss="";
|
773 |
|
|
my $ww="";
|
774 |
|
|
|
775 |
48 |
alirezamon |
my $jtag_inst_name="";
|
776 |
|
|
|
777 |
|
|
foreach my $intfc (@intfcs){
|
778 |
25 |
alirezamon |
|
779 |
|
|
#reset
|
780 |
|
|
if( $intfc eq 'plug:reset[0]'){
|
781 |
|
|
my @ports=$top->top_get_intfc_ports_list($intfc);
|
782 |
|
|
foreach my $p (@ports){
|
783 |
48 |
alirezamon |
my($id,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
|
784 |
25 |
alirezamon |
$mm="$mm," if ($i);
|
785 |
|
|
$mm="$mm\n\t\t.$p(${p}_ored_jtag)";
|
786 |
|
|
$ss="$ss\tassign ${p}_ored_jtag = (jtag_system_reset | $p);\n";
|
787 |
|
|
$ww="$ww\twire ${p}_ored_jtag;\n";
|
788 |
48 |
alirezamon |
$rpin = $p;
|
789 |
25 |
alirezamon |
$i=1;
|
790 |
|
|
|
791 |
|
|
}
|
792 |
|
|
}
|
793 |
48 |
alirezamon |
|
794 |
25 |
alirezamon |
#enable
|
795 |
|
|
elsif( $intfc eq 'plug:enable[0]'){
|
796 |
|
|
my @ports=$top->top_get_intfc_ports_list($intfc);
|
797 |
|
|
foreach my $p (@ports){
|
798 |
48 |
alirezamon |
my($id,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
|
799 |
25 |
alirezamon |
$mm="$mm," if ($i);
|
800 |
|
|
$mm="$mm\n\t\t.$p(${p}_anded_jtag)";
|
801 |
|
|
$ss="$ss\tassign ${p}_anded_jtag= (jtag_cpu_en & $p);\n";
|
802 |
|
|
$ww="$ww\twire ${p}_anded_jtag;\n";
|
803 |
|
|
$processor_en=1;
|
804 |
|
|
$i=1;
|
805 |
|
|
|
806 |
|
|
}
|
807 |
48 |
alirezamon |
}
|
808 |
25 |
alirezamon |
|
809 |
38 |
alirezamon |
#RxD_sim
|
810 |
|
|
elsif( $intfc eq 'socket:RxD_sim[0]'){
|
811 |
48 |
alirezamon |
#This interface is for simulation only donot include it in top module
|
812 |
38 |
alirezamon |
my @ports=$top->top_get_intfc_ports_list($intfc);
|
813 |
|
|
foreach my $p (@ports){
|
814 |
|
|
$mm="$mm," if ($i);
|
815 |
|
|
$mm="$mm\n\t\t.$p( )";
|
816 |
|
|
$i=1;
|
817 |
48 |
alirezamon |
}
|
818 |
|
|
}
|
819 |
|
|
|
820 |
|
|
|
821 |
|
|
#jtag_to_wb
|
822 |
|
|
elsif( $intfc =~ /socket:jtag_to_wb\[/){ #check JTAG connect parameter. if it is XILINX then connect it to jtag tap
|
823 |
|
|
my @ports=$top->top_get_intfc_ports_list($intfc);
|
824 |
|
|
foreach my $p (@ports){
|
825 |
|
|
my($id,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
|
826 |
|
|
|
827 |
|
|
|
828 |
|
|
my $JTAG_CONNECT=remove_all_white_spaces($soc->soc_get_module_param_value ($id,'JTAG_CONNECT'));
|
829 |
|
|
|
830 |
|
|
#print "$inst,$range,$type,$intfc_name,$intfc_port-> $JTAG_CONNECT;";
|
831 |
|
|
if($JTAG_CONNECT eq '"XILINX_JTAG_WB"'){
|
832 |
|
|
$jtag_inst_name= $soc->soc_get_instance_name($id);
|
833 |
|
|
|
834 |
|
|
|
835 |
|
|
my %params = $soc->soc_get_module_param($id);
|
836 |
|
|
my $new_range = add_instantc_name_to_parameters(\%params,$id,$range);
|
837 |
|
|
$ww="$ww\twire [ $new_range ] ${p};\n";
|
838 |
|
|
|
839 |
|
|
$mm="$mm," if ($i);
|
840 |
|
|
$mm="$mm\n\t\t.$p($p)";
|
841 |
|
|
if($type eq 'input'){
|
842 |
|
|
$jtag_insts=$jtag_insts."$id XILINX JTAG,";
|
843 |
|
|
$xilinx_jtag_ctrl++;
|
844 |
|
|
$xilinx_jtag_ctrl_in=(defined $xilinx_jtag_ctrl_in)? "$xilinx_jtag_ctrl_in,$p" : "$p";
|
845 |
|
|
}else {
|
846 |
|
|
$xilinx_jtag_ctrl_out=(defined $xilinx_jtag_ctrl_out)? "$xilinx_jtag_ctrl_out,$p" : "$p";
|
847 |
|
|
}
|
848 |
|
|
|
849 |
|
|
|
850 |
|
|
}else{#Dont not connect
|
851 |
|
|
$mm="$mm," if ($i);
|
852 |
|
|
$mm="$mm\n\t\t.$p( )";
|
853 |
|
|
}
|
854 |
|
|
|
855 |
|
|
if($JTAG_CONNECT =~ /ALTERA_JTAG_WB/){
|
856 |
|
|
|
857 |
|
|
if($type eq 'input'){
|
858 |
|
|
$jtag_insts=$jtag_insts."$id ALTERA JTAG,";
|
859 |
|
|
$altera_jtag_ctrl++;
|
860 |
|
|
|
861 |
|
|
}
|
862 |
|
|
}
|
863 |
|
|
$i=1;
|
864 |
38 |
alirezamon |
}
|
865 |
|
|
|
866 |
|
|
}
|
867 |
48 |
alirezamon |
|
868 |
|
|
|
869 |
|
|
|
870 |
25 |
alirezamon |
else {
|
871 |
|
|
#other interface
|
872 |
|
|
my @ports=$top->top_get_intfc_ports_list($intfc);
|
873 |
|
|
foreach my $p (@ports){
|
874 |
48 |
alirezamon |
my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
|
875 |
|
|
$clkpin=$p if( $intfc eq 'plug:clk[0]');
|
876 |
25 |
alirezamon |
$mm="$mm," if ($i);
|
877 |
|
|
$mm="$mm\n\t\t.$p($p)";
|
878 |
|
|
$i=1;
|
879 |
|
|
|
880 |
48 |
alirezamon |
}
|
881 |
|
|
}
|
882 |
25 |
alirezamon |
|
883 |
|
|
}
|
884 |
|
|
$mm="$mm\n\t);";
|
885 |
|
|
add_text_to_string(\$soc_v,"$ww\n");
|
886 |
|
|
add_text_to_string(\$soc_v,"$mm\n");
|
887 |
|
|
add_text_to_string(\$soc_v,"$ss\n");
|
888 |
48 |
alirezamon |
|
889 |
25 |
alirezamon |
|
890 |
48 |
alirezamon |
if($altera_jtag_ctrl>0 && $xilinx_jtag_ctrl>0 ){
|
891 |
|
|
add_colored_info($txview,"Found JTAG comminication ports from differnt FPGA vendors:$jtag_insts. ",'red');
|
892 |
|
|
|
893 |
|
|
}elsif ($xilinx_jtag_ctrl>0){
|
894 |
|
|
$xilinx_jtag_ctrl_in ="{$xilinx_jtag_ctrl_in}" if($xilinx_jtag_ctrl != 1);
|
895 |
|
|
$xilinx_jtag_ctrl_out ="{$xilinx_jtag_ctrl_out}" if($xilinx_jtag_ctrl != 1);
|
896 |
|
|
|
897 |
|
|
$soc_v = $soc_v."
|
898 |
|
|
xilinx_jtag_wb #(
|
899 |
|
|
.JWB_NUM($xilinx_jtag_ctrl),
|
900 |
|
|
.JDw(${jtag_inst_name}_JDw),
|
901 |
|
|
.JAw(${jtag_inst_name}_JAw)
|
902 |
|
|
)jwb(
|
903 |
|
|
|
904 |
|
|
.reset($rpin),
|
905 |
|
|
.cpu_en(jtag_cpu_en),
|
906 |
|
|
.system_reset(jtag_system_reset),
|
907 |
|
|
.wb_to_jtag_all($xilinx_jtag_ctrl_out),
|
908 |
|
|
.jtag_to_wb_all($xilinx_jtag_ctrl_in)
|
909 |
|
|
);
|
910 |
|
|
|
911 |
|
|
";
|
912 |
|
|
|
913 |
|
|
}elsif($altera_jtag_ctrl>0) {
|
914 |
|
|
$soc_v = $soc_v."
|
915 |
|
|
jtag_system_en jtag_en (
|
916 |
|
|
.cpu_en(jtag_cpu_en),
|
917 |
|
|
.system_reset(jtag_system_reset)
|
918 |
25 |
alirezamon |
|
919 |
48 |
alirezamon |
);
|
920 |
|
|
";
|
921 |
|
|
|
922 |
|
|
}else{
|
923 |
|
|
$soc_v = $soc_v."
|
924 |
|
|
//No jtag connection has found in the design
|
925 |
|
|
assign jtag_cpu_en=1\'b0;
|
926 |
|
|
assign jtag_system_reset=1'b0;
|
927 |
|
|
";
|
928 |
|
|
}
|
929 |
|
|
|
930 |
|
|
$soc_v=$soc_v."\n endmodule\n";
|
931 |
25 |
alirezamon |
return $soc_v;
|
932 |
|
|
|
933 |
|
|
}
|
934 |
|
|
|
935 |
|
|
|
936 |
|
|
|
937 |
|
|
|
938 |
|
|
|
939 |
42 |
alirezamon |
sub gen_soc_instance_v_no_modfy{
|
940 |
|
|
my ($soc,$soc_name,$param_pass_v)=@_;
|
941 |
|
|
my $soc_v;
|
942 |
|
|
my $processor_en=0;
|
943 |
|
|
|
944 |
25 |
alirezamon |
|
945 |
42 |
alirezamon |
my $mm="$soc_name #(\n $param_pass_v \n\t)the_${soc_name}(\n";
|
946 |
25 |
alirezamon |
|
947 |
42 |
alirezamon |
my $top=$soc->soc_get_top();
|
948 |
|
|
my @intfcs=$top->top_get_intfc_list();
|
949 |
|
|
|
950 |
|
|
my $i=0;
|
951 |
25 |
alirezamon |
|
952 |
42 |
alirezamon |
|
953 |
|
|
|
954 |
|
|
|
955 |
|
|
my $ss="";
|
956 |
|
|
my $ww="";
|
957 |
|
|
|
958 |
48 |
alirezamon |
foreach my $intfc (@intfcs){
|
959 |
42 |
alirezamon |
|
960 |
|
|
|
961 |
48 |
alirezamon |
|
962 |
42 |
alirezamon |
|
963 |
|
|
|
964 |
|
|
my @ports=$top->top_get_intfc_ports_list($intfc);
|
965 |
|
|
foreach my $p (@ports){
|
966 |
|
|
my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
|
967 |
48 |
alirezamon |
$mm="$mm," if ($i);
|
968 |
|
|
if( $intfc =~ /socket:jtag_to_wb\[/){#dont include jtag connection
|
969 |
|
|
$mm="$mm\n\t\t.$p( )";
|
970 |
|
|
}else{
|
971 |
|
|
$mm="$mm\n\t\t.$p($p)";
|
972 |
|
|
}
|
973 |
42 |
alirezamon |
$i=1;
|
974 |
|
|
|
975 |
|
|
|
976 |
|
|
}
|
977 |
|
|
|
978 |
|
|
|
979 |
|
|
}
|
980 |
|
|
$mm="$mm\n\t);";
|
981 |
|
|
add_text_to_string(\$soc_v,"$ww\n");
|
982 |
|
|
add_text_to_string(\$soc_v,"$mm\n");
|
983 |
|
|
add_text_to_string(\$soc_v,"$ss\n");
|
984 |
|
|
add_text_to_string(\$soc_v,"\n endmodule\n");
|
985 |
|
|
|
986 |
|
|
|
987 |
|
|
|
988 |
|
|
return $soc_v;
|
989 |
25 |
alirezamon |
|
990 |
42 |
alirezamon |
}
|
991 |
25 |
alirezamon |
|
992 |
|
|
|
993 |
|
|
|
994 |
42 |
alirezamon |
|
995 |
|
|
|
996 |
|
|
|
997 |
|
|
|
998 |
|
|
|
999 |
25 |
alirezamon |
sub gen_system_info {
|
1000 |
|
|
my ($soc,$param)=@_;
|
1001 |
|
|
my ($wb_slaves,$wb_masters,$other,$jtag);
|
1002 |
|
|
#my (@newbase,@newend,@connects);
|
1003 |
|
|
|
1004 |
|
|
|
1005 |
28 |
alirezamon |
$jtag='';
|
1006 |
25 |
alirezamon |
|
1007 |
28 |
alirezamon |
my @all_instances=$soc->soc_get_all_instances();
|
1008 |
25 |
alirezamon |
|
1009 |
28 |
alirezamon |
my %jtagwb; my %ram;
|
1010 |
|
|
|
1011 |
|
|
|
1012 |
25 |
alirezamon |
foreach my $instance_id (@all_instances){
|
1013 |
28 |
alirezamon |
my $category=$soc->soc_get_category($instance_id);
|
1014 |
|
|
|
1015 |
25 |
alirezamon |
my @plugs= $soc->soc_get_all_plugs_of_an_instance($instance_id);
|
1016 |
|
|
foreach my $plug (@plugs){
|
1017 |
|
|
my @nums=$soc->soc_list_plug_nums($instance_id,$plug);
|
1018 |
|
|
foreach my $num (@nums){
|
1019 |
|
|
my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($instance_id,$plug,$num);
|
1020 |
28 |
alirezamon |
|
1021 |
25 |
alirezamon |
my $instance_name=$soc->soc_get_instance_name($instance_id);
|
1022 |
|
|
my $connect_name=$soc->soc_get_instance_name($connect_id);
|
1023 |
|
|
#get interfaces
|
1024 |
|
|
if((defined $connect_socket) && ($connect_socket eq 'wb_slave')){
|
1025 |
|
|
|
1026 |
|
|
$base=sprintf("0x%08x", $base);
|
1027 |
|
|
$end=sprintf("0x%08x", $end);
|
1028 |
28 |
alirezamon |
add_text_to_string(\$wb_slaves, "\t$instance_name, $name, $connect_name, $base, $end\n");
|
1029 |
|
|
if ($category eq 'RAM') {
|
1030 |
|
|
$ram{$instance_id}{'base'}=$base;
|
1031 |
|
|
$ram{$instance_id}{'end'}=$end;
|
1032 |
|
|
$ram{$instance_id}{'connect'}=$connect_id;
|
1033 |
|
|
}
|
1034 |
25 |
alirezamon |
|
1035 |
|
|
}#if
|
1036 |
|
|
elsif((defined $connect_socket) && ($connect_socket eq 'wb_master')){
|
1037 |
|
|
add_text_to_string(\$wb_masters,"\t$instance_name, $name, $connect_name\n");
|
1038 |
|
|
}
|
1039 |
|
|
elsif(defined $connect_socket) {
|
1040 |
|
|
add_text_to_string(\$other,"\t$instance_name, $name, $connect_name\n");
|
1041 |
|
|
|
1042 |
|
|
}
|
1043 |
|
|
# get jtag_wbs
|
1044 |
|
|
if((defined $connect_socket) && ($connect_socket eq 'wb_master') && ($instance_id =~ /jtag_wb/)){
|
1045 |
48 |
alirezamon |
my $index=$soc->soc_get_module_param_value($instance_id,'JTAG_INDEX');
|
1046 |
|
|
my $chain=$soc->soc_get_module_param_value($instance_id,'JTAG_CHAIN');
|
1047 |
|
|
my $vendor_connect =$soc->soc_get_module_param_value($instance_id,'JTAG_CONNECT');
|
1048 |
|
|
add_text_to_string(\$jtag, "\t$instance_name, $connect_name, $index\n");
|
1049 |
28 |
alirezamon |
|
1050 |
|
|
$jtagwb{$connect_id}{'index'}=$index;
|
1051 |
48 |
alirezamon |
$jtagwb{$connect_id}{'chain'}=$chain;
|
1052 |
|
|
$jtagwb{$connect_id}{'vendor_connect'}=$vendor_connect;
|
1053 |
25 |
alirezamon |
}
|
1054 |
|
|
|
1055 |
|
|
|
1056 |
|
|
}#foreach my $num
|
1057 |
|
|
}#foreach my $plug
|
1058 |
|
|
}#foreach my $instance_id
|
1059 |
|
|
|
1060 |
28 |
alirezamon |
#Generate memory programming command
|
1061 |
45 |
alirezamon |
my $prog='#!/bin/bash
|
1062 |
25 |
alirezamon |
|
1063 |
38 |
alirezamon |
#JTAG_INTFC="$PRONOC_WORK/toolchain/bin/JTAG_INTFC"
|
1064 |
|
|
source ./jtag_intfc.sh
|
1065 |
28 |
alirezamon |
|
1066 |
|
|
';
|
1067 |
|
|
|
1068 |
|
|
|
1069 |
|
|
foreach my $instance_id (@all_instances){
|
1070 |
|
|
my $category=$soc->soc_get_category($instance_id);
|
1071 |
|
|
if ($category eq 'RAM') {
|
1072 |
|
|
|
1073 |
|
|
my $jtag_connect=$soc->soc_get_module_param_value($instance_id,'JTAG_CONNECT');
|
1074 |
48 |
alirezamon |
$jtag_connect=remove_all_white_spaces($jtag_connect);
|
1075 |
28 |
alirezamon |
my $aw=$soc->soc_get_module_param_value($instance_id,'Aw');
|
1076 |
|
|
my $dw=$soc->soc_get_module_param_value($instance_id,'Dw');
|
1077 |
|
|
my $JTAG_INDEX=$soc->soc_get_module_param_value($instance_id,'JTAG_INDEX');
|
1078 |
48 |
alirezamon |
my $JTAG_CHAIN=$soc->soc_get_module_param_value($instance_id,'JTAG_CHAIN');
|
1079 |
28 |
alirezamon |
|
1080 |
|
|
#check if jtag_index is a parameter
|
1081 |
|
|
my $v=$soc->soc_get_module_param_value($instance_id,$JTAG_INDEX);
|
1082 |
|
|
$JTAG_INDEX = $v if (defined $v);
|
1083 |
|
|
$v= $soc->object_get_attribute('global_param',$JTAG_INDEX);
|
1084 |
|
|
$JTAG_INDEX = $v if (defined $v);
|
1085 |
|
|
|
1086 |
34 |
alirezamon |
my $BINFILE=$soc->soc_get_module_param_value($instance_id,'JTAG_MEM_FILE');
|
1087 |
28 |
alirezamon |
($BINFILE)=$BINFILE=~ /"([^"]*)"/ if(defined $BINFILE);
|
1088 |
38 |
alirezamon |
$BINFILE=(defined $BINFILE) ? "./RAM/".$BINFILE.'.bin' : './RAM/ram0.bin';
|
1089 |
28 |
alirezamon |
|
1090 |
|
|
my $OFSSET="0x00000000";
|
1091 |
34 |
alirezamon |
my $end=((1 << $aw)*($dw/8))-1;
|
1092 |
28 |
alirezamon |
my $BOUNDRY=sprintf("0x%08x", $end);
|
1093 |
48 |
alirezamon |
if($jtag_connect =~ /ALTERA_JTAG_WB/ ) {
|
1094 |
38 |
alirezamon |
$prog= "$prog \$JTAG_INTFC -n $JTAG_INDEX -s \"$OFSSET\" -e \"$BOUNDRY\" -i \"$BINFILE\" -c";
|
1095 |
28 |
alirezamon |
#print "prog= $prog\n";
|
1096 |
|
|
|
1097 |
48 |
alirezamon |
} elsif ($jtag_connect =~ /XILINX_JTAG_WB/){
|
1098 |
|
|
$prog= "$prog \$JTAG_INTFC -t $JTAG_CHAIN -n $JTAG_INDEX -s \"$OFSSET\" -e \"$BOUNDRY\" -i \"$BINFILE\" -c";
|
1099 |
|
|
|
1100 |
|
|
}
|
1101 |
|
|
|
1102 |
|
|
elsif ($jtag_connect eq 'ALTERA_IMCE'){
|
1103 |
28 |
alirezamon |
#TODO add later
|
1104 |
48 |
alirezamon |
$prog= "$prog ".'>&2 echo'." \"ALTERA_IMCE runtime programming is not supported yet for programming $instance_id\"\n";
|
1105 |
28 |
alirezamon |
|
1106 |
|
|
} else{
|
1107 |
48 |
alirezamon |
#check if its connected to jtag_wb via the bus
|
1108 |
28 |
alirezamon |
my $connect_id = $ram{$instance_id}{'connect'};
|
1109 |
|
|
my $OFSSET = $ram{$instance_id}{'base'};
|
1110 |
|
|
my $BOUNDRY = $ram{$instance_id}{'end'};
|
1111 |
|
|
if(defined $connect_id){
|
1112 |
|
|
#print "id=$connect_id\n";
|
1113 |
|
|
my $JTAG_INDEX= $jtagwb{$connect_id}{'index'};
|
1114 |
48 |
alirezamon |
my $JTAG_CHAIN= $jtagwb{$connect_id}{'chain'};
|
1115 |
|
|
my $JTAG_VENDOR= $jtagwb{$connect_id}{'vendor_connect'};
|
1116 |
|
|
|
1117 |
|
|
my $t="";
|
1118 |
|
|
$t="-t $JTAG_CHAIN"if($JTAG_VENDOR =~ /XILINX_JTAG_WB/);
|
1119 |
|
|
|
1120 |
|
|
if(defined $JTAG_INDEX){
|
1121 |
28 |
alirezamon |
$v= $soc->object_get_attribute('global_param',$JTAG_INDEX);
|
1122 |
|
|
$JTAG_INDEX = $v if (defined $v);
|
1123 |
48 |
alirezamon |
$prog= "$prog \$JTAG_INTFC $t -n $JTAG_INDEX -s \"$OFSSET\" -e \"$BOUNDRY\" -i \"$BINFILE\" -c";
|
1124 |
28 |
alirezamon |
#print "prog= $prog\n";
|
1125 |
|
|
|
1126 |
48 |
alirezamon |
}else{
|
1127 |
|
|
$prog= "$prog".'>&2 echo'." \"JTAG runtime programming is not enabled in $instance_id\"\n";
|
1128 |
28 |
alirezamon |
|
1129 |
48 |
alirezamon |
}
|
1130 |
42 |
alirezamon |
|
1131 |
|
|
}else{
|
1132 |
48 |
alirezamon |
$prog= "$prog".'>&2 echo'."\"JTAG runtime programming is not enabled in $instance_id\"\n";
|
1133 |
42 |
alirezamon |
|
1134 |
|
|
}
|
1135 |
28 |
alirezamon |
}
|
1136 |
|
|
|
1137 |
|
|
|
1138 |
|
|
}
|
1139 |
|
|
|
1140 |
|
|
|
1141 |
|
|
}
|
1142 |
|
|
|
1143 |
|
|
|
1144 |
25 |
alirezamon |
my $lisence= get_license_header("readme");
|
1145 |
|
|
my $warning=autogen_warning();
|
1146 |
|
|
|
1147 |
|
|
|
1148 |
48 |
alirezamon |
$wb_slaves = " \t\t NOTE: No wishbone slaves interface has been found in the design " if (!defined $wb_slaves);
|
1149 |
|
|
$wb_masters= " \t\t NOTE: No wishbone master interface has been found in the design " if (!defined $wb_masters);
|
1150 |
25 |
alirezamon |
|
1151 |
|
|
my $readme="
|
1152 |
|
|
$warning
|
1153 |
|
|
$lisence
|
1154 |
|
|
|
1155 |
|
|
***********************
|
1156 |
|
|
** Program the memories
|
1157 |
|
|
***********************
|
1158 |
|
|
|
1159 |
|
|
If the memory core and jtag_wb are connected to the same wishbone bus, you can program the memory using
|
1160 |
|
|
|
1161 |
45 |
alirezamon |
bash program.sh
|
1162 |
25 |
alirezamon |
|
1163 |
|
|
|
1164 |
|
|
|
1165 |
|
|
***************************
|
1166 |
|
|
** soc parameters
|
1167 |
|
|
***************************
|
1168 |
|
|
|
1169 |
|
|
$param
|
1170 |
|
|
|
1171 |
|
|
****************************
|
1172 |
|
|
** wishbone bus(es) info
|
1173 |
|
|
****************************
|
1174 |
|
|
#slave interfaces:
|
1175 |
48 |
alirezamon |
#instance name, interface name, connected to, base address, boundary address
|
1176 |
25 |
alirezamon |
$wb_slaves
|
1177 |
|
|
|
1178 |
|
|
#master interfaces:
|
1179 |
|
|
#instance name, interface name, connected to
|
1180 |
|
|
$wb_masters
|
1181 |
|
|
|
1182 |
|
|
****************************
|
1183 |
|
|
** Jtag to wishbone interface (jtag_wb) info:
|
1184 |
|
|
****************************
|
1185 |
|
|
|
1186 |
48 |
alirezamon |
#instance name, instance name, JTAG_INDEX
|
1187 |
25 |
alirezamon |
$jtag
|
1188 |
|
|
|
1189 |
|
|
|
1190 |
|
|
";
|
1191 |
|
|
|
1192 |
28 |
alirezamon |
|
1193 |
|
|
|
1194 |
|
|
|
1195 |
|
|
return ($readme,$prog);
|
1196 |
25 |
alirezamon |
|
1197 |
|
|
|
1198 |
|
|
|
1199 |
|
|
}
|
1200 |
|
|
|
1201 |
|
|
|
1202 |
|
|
|
1203 |
42 |
alirezamon |
######################
|
1204 |
|
|
# soc_generate_verilog
|
1205 |
|
|
#####################
|
1206 |
25 |
alirezamon |
|
1207 |
48 |
alirezamon |
sub soc_generate_verilator{
|
1208 |
42 |
alirezamon |
my ($soc,$sw_path,$name,$params_ref)= @_;
|
1209 |
|
|
my $soc_name=$soc->object_get_attribute('soc_name');
|
1210 |
|
|
my $top_ip=ip_gen->top_gen_new();
|
1211 |
|
|
if(!defined $soc_name){$soc_name='soc'};
|
1212 |
|
|
|
1213 |
|
|
my @instances=$soc->soc_get_all_instances();
|
1214 |
|
|
my $io_sim_v;
|
1215 |
48 |
alirezamon |
my $top_io_short_all;
|
1216 |
42 |
alirezamon |
my $core_id= $soc->object_get_attribute('global_param','CORE_ID');
|
1217 |
|
|
$core_id= 0 if(!defined $core_id);
|
1218 |
48 |
alirezamon |
my $param_as_in_v_all="\tparameter\tCORE_ID=$core_id,
|
1219 |
42 |
alirezamon |
\tparameter\tSW_LOC=\"$sw_path\"\n,";
|
1220 |
25 |
alirezamon |
|
1221 |
48 |
alirezamon |
my $param_pass_v_all="\t\t.CORE_ID(CORE_ID),\n\t\t.SW_LOC(SW_LOC)";
|
1222 |
42 |
alirezamon |
my $body_v;
|
1223 |
|
|
|
1224 |
48 |
alirezamon |
my ($param_v_all, $local_param_v_all, $wire_def_v_all, $inst_v_all, $plugs_assign_v_all, $sockets_assign_v_all,$io_full_v_all,$top_io_full_all,$system_v_all);
|
1225 |
|
|
my ($src_io_full_all,$src_io_short_all);
|
1226 |
42 |
alirezamon |
my $wires=soc->new_wires();
|
1227 |
|
|
my $intfc=interface->interface_new();
|
1228 |
|
|
|
1229 |
|
|
|
1230 |
|
|
foreach my $id (@instances){
|
1231 |
48 |
alirezamon |
my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v,$io_sim_v,
|
1232 |
|
|
$top_io_short,$param_as_in_v,$param_pass_v,$system_v,$assigned_ports,$top_io_pass,$src_io_short, $src_io_full)=gen_module_inst($id,$soc,$top_ip,$intfc,$wires,1);
|
1233 |
42 |
alirezamon |
my $inst = $soc->soc_get_instance_name($id);
|
1234 |
|
|
add_text_to_string(\$body_v,"/*******************\n*\n*\t$inst\n*\n*\n*********************/\n");
|
1235 |
48 |
alirezamon |
add_text_to_string(\$param_as_in_v_all,",\n$param_as_in_v") if(defined ($param_as_in_v));
|
1236 |
42 |
alirezamon |
add_text_to_string(\$local_param_v_all,"$local_param_v\n") if(defined($local_param_v));
|
1237 |
48 |
alirezamon |
add_text_to_string(\$param_pass_v_all,",\n$param_pass_v") if(defined($param_pass_v));
|
1238 |
42 |
alirezamon |
add_text_to_string(\$wire_def_v_all,"$wire_def_v\n") if(defined($wire_def_v));
|
1239 |
|
|
add_text_to_string(\$inst_v_all,$inst_v) if(defined($inst_v));
|
1240 |
|
|
add_text_to_string(\$plugs_assign_v_all,"$plugs_assign_v\n") if(defined($plugs_assign_v));
|
1241 |
|
|
add_text_to_string(\$sockets_assign_v_all,"$sockets_assign_v\n")if(defined($sockets_assign_v));
|
1242 |
48 |
alirezamon |
add_text_to_string(\$io_full_v_all,"$io_full_v\n") if(length($io_full_v)>3);
|
1243 |
|
|
add_text_to_string(\$top_io_full_all,"$io_top_full_v\n") if(length($io_top_full_v)>3);
|
1244 |
|
|
add_text_to_string(\$src_io_full_all,"$src_io_full\n") if(length($src_io_full)>3);
|
1245 |
|
|
|
1246 |
|
|
$top_io_short_all = (defined $top_io_short_all)? "$top_io_short_all,\n$top_io_short" : $top_io_short if(defined($top_io_short));
|
1247 |
|
|
$src_io_short_all = (defined $src_io_short_all)? "$src_io_short_all,\n$src_io_short" : $src_io_short if(defined($src_io_short));
|
1248 |
42 |
alirezamon |
#print "$param_v $local_param_v $wire_def_v $inst_v $plugs_assign_v $sockets_assign_v $io_full_v";
|
1249 |
|
|
|
1250 |
|
|
}
|
1251 |
48 |
alirezamon |
|
1252 |
|
|
|
1253 |
|
|
|
1254 |
42 |
alirezamon |
my ($addr_map,$addr_localparam,$module_addr_localparam)= generate_address_cmp($soc,$wires);
|
1255 |
25 |
alirezamon |
|
1256 |
42 |
alirezamon |
#add functions
|
1257 |
|
|
my $dir = Cwd::getcwd();
|
1258 |
|
|
open my $file1, "<", "$dir/lib/verilog/functions.v" or die;
|
1259 |
|
|
my $functions_all='';
|
1260 |
|
|
while (my $f1 = readline ($file1)) {
|
1261 |
|
|
$functions_all="$functions_all $f1 ";
|
1262 |
|
|
}
|
1263 |
|
|
close($file1);
|
1264 |
|
|
my $unused_wiers_v=assign_unconnected_wires($wires,$intfc);
|
1265 |
48 |
alirezamon |
|
1266 |
42 |
alirezamon |
|
1267 |
|
|
$soc->object_add_attribute('top_ip',undef,$top_ip);
|
1268 |
|
|
#print @assigned_wires;
|
1269 |
25 |
alirezamon |
|
1270 |
42 |
alirezamon |
#generate topmodule
|
1271 |
|
|
my $params_v="
|
1272 |
|
|
\tparameter\tCORE_ID=$core_id;
|
1273 |
|
|
\tparameter\tSW_LOC=\"$sw_path\";\n";
|
1274 |
|
|
|
1275 |
|
|
|
1276 |
|
|
my %all_param=soc_get_all_parameters($soc);
|
1277 |
|
|
my @order= soc_get_all_parameters_order($soc);
|
1278 |
|
|
|
1279 |
|
|
|
1280 |
|
|
|
1281 |
|
|
#replace global parameters
|
1282 |
|
|
my @list=sort keys%{$params_ref};
|
1283 |
|
|
foreach my $p (@list){
|
1284 |
|
|
my %hash=%{$params_ref};
|
1285 |
|
|
$all_param{$p}= $hash{$p};
|
1286 |
|
|
}
|
1287 |
|
|
|
1288 |
|
|
foreach my $p (@order){
|
1289 |
|
|
add_text_to_string(\$params_v,"\tlocalparam $p = $all_param{$p};\n") if(defined $all_param{$p} );
|
1290 |
|
|
}
|
1291 |
|
|
|
1292 |
48 |
alirezamon |
|
1293 |
|
|
$top_io_short_all=(defined $top_io_short_all)? "$top_io_short_all,\n$src_io_short_all" : $src_io_short_all;
|
1294 |
|
|
$top_io_full_all=$top_io_full_all."\n$src_io_full_all";
|
1295 |
|
|
# $top_io_pass_all=$top_io_pass_all.",\n$clk_assigned_port";
|
1296 |
|
|
|
1297 |
|
|
my $has_ni =check_for_ni($soc);
|
1298 |
56 |
alirezamon |
my $import = ($has_ni)? "\n\t`NOC_CONF\n" : "";
|
1299 |
48 |
alirezamon |
|
1300 |
42 |
alirezamon |
my $verilator_v = "
|
1301 |
|
|
/*********************
|
1302 |
|
|
${name}
|
1303 |
|
|
*********************/
|
1304 |
|
|
|
1305 |
56 |
alirezamon |
module ${name} (\n $top_io_short_all\n);\n $import \n";
|
1306 |
48 |
alirezamon |
my $ins= gen_soc_instance_v_no_modfy($soc,$soc_name,$param_pass_v_all);
|
1307 |
|
|
$verilator_v.="
|
1308 |
|
|
$functions_all
|
1309 |
|
|
/* verilator lint_off WIDTH */
|
1310 |
|
|
$params_v
|
1311 |
|
|
/* verilator lint_on WIDTH */
|
1312 |
|
|
$top_io_full_all
|
1313 |
|
|
$ins
|
1314 |
|
|
";
|
1315 |
|
|
my ($readme,$prog)=gen_system_info($soc,$param_as_in_v_all);
|
1316 |
42 |
alirezamon |
return ($verilator_v);
|
1317 |
25 |
alirezamon |
|
1318 |
|
|
|
1319 |
42 |
alirezamon |
}
|
1320 |
25 |
alirezamon |
|
1321 |
42 |
alirezamon |
|
1322 |
48 |
alirezamon |
sub get_golal_param_v{
|
1323 |
|
|
my $project_dir = get_project_dir(); #mpsoc dir addr
|
1324 |
|
|
my $paths_file= "$project_dir/mpsoc/perl_gui/lib/glob_params";
|
1325 |
|
|
my $paramv='';
|
1326 |
|
|
if (-f $paths_file ){
|
1327 |
|
|
my $self= do $paths_file;
|
1328 |
|
|
my @parameters = object_get_attribute_order($self,'Parameters');
|
1329 |
|
|
foreach my $p (@parameters) {
|
1330 |
|
|
my $v =object_get_attribute($self,'Parameters',$p);
|
1331 |
|
|
$paramv.="\t localparam $p = $v;\n" if(defined $v);
|
1332 |
|
|
}
|
1333 |
|
|
}
|
1334 |
|
|
return $paramv;
|
1335 |
|
|
}
|
1336 |
42 |
alirezamon |
|
1337 |
|
|
|
1338 |
|
|
|
1339 |
|
|
|
1340 |
16 |
alirezamon |
1;
|
1341 |
|
|
|
1342 |
|
|
|