]> iEval git - clump.git/blob - newstable.pl
implement routing + storei instruction
[clump.git] / newstable.pl
1 #!/usr/bin/perl
2 use v5.14;
3 use warnings;
4
5 my @diffs = (
6 [-1, 0],
7 # [-1, 1],
8 [0 , 1],
9 # [1 , 1],
10 [1 , 0],
11 # [1 , -1],
12 [0 , -1],
13 # [-1, -1]
14 );
15
16 my @cpus;
17
18 my @newstable;
19
20 my $side = 4; # there are $side * $side CPUs
21
22 for my $line (0 .. ($side - 1)) {
23 $cpus[$line] = [ ($line * $side) .. (($line + 1) * $side - 1) ]
24 }
25
26 for my $cpu (0 .. ($side * $side - 1)) {
27 my $x = $cpu / $side;
28 my $y = $cpu % $side;
29 for my $direction (0 .. $#diffs) {
30 my $nx = ($x + $diffs[$direction][0] + $side) % $side;
31 my $ny = ($y + $diffs[$direction][1] + $side) % $side;
32 $newstable[$cpu][$direction] = $cpus[$nx][$ny];
33 }
34 }
35
36 for my $direction (0 .. $#diffs) {
37 print "$direction: news_out = {";
38 printf 'news_in[%2d]', $newstable[0][$direction];
39 for my $cpu (1 .. ($side * $side - 1)) {
40 printf ', news_in[%2d]', $newstable[$cpu][$direction];
41 }
42 say '};'
43 }
This page took 0.046414 seconds and 5 git commands to generate.