#! /usr/local/bin/perl

# created on Thu Feb 22 11:23:06 EST 2001

$myname = `basename $0`;
chop $myname ;

if (@ARGV != 1) {
    print STDERR <<EOF;
Usage: $myname source_directory

  'source_directory' should contain the top of the directory tree from
  the "picoJava-II v2.0" download.

  This script copies Verilog source files from the picoJava-II
  distribution (v2.0) and places them in the current directory. Some
  files are slightly modified:
    1. fixed typos
    2. removed unnecessary parallel_case and full_case directives
    3. added flops to break timing loops
    4. added synthesizable logic to replace macrocells
       (e.g. RAM, ROM, register files)
    5. added new clk_gate input for gated clock logic

  The resulting code is *not* a functional picoJava processor, however
  it is purely synthesizable code which is useful for EDA tool
  testing.

  For more information about the picoJava-II processor and how to get
  the sources see
  http://www.sun.com/microelectronics/communitysource/picojava

  Created by Steve Golson -- Trilobyte Systems -- sgolson\@trilobyte.com
EOF
    exit 1;
}

# get arguments

$sourcedir = $ARGV[0];

############################################################################

die "Cannot find source directory ${sourcedir}/picoJava-II: $!\n" unless (-d ${sourcedir}."/picoJava-II");

##### code_seq.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/code_seq.v > code_seq.v") or die "Couldn't fork while building code_seq.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building code_seq.v: $!\n";
$expected_cksum = "2086308133\\s+5384\\s+code_seq.v";
chop($new_cksum = `cksum code_seq.v`);
die "Checksum failed for file code_seq.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### code_seq_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/code_seq_cntl.v > code_seq_cntl.v") or die "Couldn't fork while building code_seq_cntl.v: $!\n";
print WRITEME <<EOF;
920d
909c
   case(branch)
.
862c
   case(branch)
.
814c
   case(branch)
.
766c
   case(branch)
.
472c
     case(1'b1)  	// synopsys parallel_case
.
360c
     case(opcode)
.
347c
     case(opcode)
.
328c
      case(opcode)
.
216c
     case(opcode)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building code_seq_cntl.v: $!\n";
$expected_cksum = "3592833975\\s+23490\\s+code_seq_cntl.v";
chop($new_cksum = `cksum code_seq_cntl.v`);
die "Checksum failed for file code_seq_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### code_seq_dp.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/code_seq_dp.v > code_seq_dp.v") or die "Couldn't fork while building code_seq_dp.v: $!\n";
print WRITEME <<EOF;
404c
    case(nx_opcode_v)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building code_seq_dp.v: $!\n";
$expected_cksum = "406966229\\s+12663\\s+code_seq_dp.v";
chop($new_cksum = `cksum code_seq_dp.v`);
die "Checksum failed for file code_seq_dp.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### cpu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/rtl/cpu.v > cpu.v") or die "Couldn't fork while building cpu.v: $!\n";
print WRITEME <<EOF;
628a
        .clk_gate               (clk_gate),
.
91a
        input clk_gate;
.
42a
	clk_gate, 
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building cpu.v: $!\n";
$expected_cksum = "1753690994\\s+26506\\s+cpu.v";
chop($new_cksum = `cksum cpu.v`);
die "Checksum failed for file cpu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### custom_cells_behv.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/rtl/custom_cells_behv.v > custom_cells_behv.v") or die "Couldn't fork while building custom_cells_behv.v: $!\n";
print WRITEME <<EOF;
2200c
        casex ({~b3_num[3],~b2_num[3],~b1_num[3],~b0_num[3]})
.
2183c
        casex (di[7:0])
.
2170c
        casex (di[15:8])
.
2157c
        casex (di[23:16])
.
2144c
        casex (di[31:24])
.
1680c
	casex ({np3[2],np2[2],np1[2],np0[2]})
.
1668c
	casex ({np7[2],np6[2],np5[2],np4[2]})
.
1656c
	casex (bit_eql_not[3:0])
.
1647c
	casex (bit_eql_not[7:4])
.
1638c
	casex (bit_eql_not[11:8])
.
1629c
	casex (bit_eql_not[15:12])
.
1620c
	casex (bit_eql_not[19:16])
.
1611c
	casex (bit_eql_not[23:20])
.
1602c
	casex (bit_eql_not[27:24])
.
1593c
	casex (bit_eql_not[31:28])
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building custom_cells_behv.v: $!\n";
$expected_cksum = "387100858\\s+179491\\s+custom_cells_behv.v";
chop($new_cksum = `cksum custom_cells_behv.v`);
die "Checksum failed for file custom_cells_behv.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dc_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/dc_dec.v > dc_dec.v") or die "Couldn't fork while building dc_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dc_dec.v: $!\n";
$expected_cksum = "1361206187\\s+40505\\s+dc_dec.v";
chop($new_cksum = `cksum dc_dec.v`);
die "Checksum failed for file dc_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dcctl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/dcctl.v > dcctl.v") or die "Couldn't fork while building dcctl.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dcctl.v: $!\n";
$expected_cksum = "4257057914\\s+27239\\s+dcctl.v";
chop($new_cksum = `cksum dcctl.v`);
die "Checksum failed for file dcctl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dcram_dummy.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcram/rtl/dcram_dummy.v > dcram_dummy.v") or die "Couldn't fork while building dcram_dummy.v: $!\n";
print WRITEME <<EOF;
50a
    data_out <= data_in_dly ^ addr_dly;
    dcache_test_err_l <= ^{
			   bist_mode_dly,
			   bist_reset_dly,
			   test_mode_dly,
			   data_in_dly,
			   we_dly,
			   bypass_dly,
			   bank_sel_dly,
			   reg_enable_dly};
  end

.
49a
always @ (posedge clk) begin
    bist_mode_dly <= bist_mode;
    bist_reset_dly <= bist_reset;
    test_mode_dly <= test_mode;
    data_in_dly <= data_in;
    we_dly <= we;
    bypass_dly <= bypass;
    bank_sel_dly <= bank_sel;
    reg_enable_dly <= reg_enable;
    addr_dly <= addr;
.
46,48c
reg [1:0] bist_mode_dly;
reg bist_reset_dly;
reg test_mode_dly;
reg [63:0] data_in_dly;
reg [3:0] we_dly;
reg bypass_dly;
reg [1:0] bank_sel_dly;
reg reg_enable_dly;
reg [`dc_msb:0] addr_dly;
reg [63:0] data_out;
reg dcache_test_err_l;
.
22a
// this replaces dcram_shell with random synthesizable logic
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dcram_dummy.v: $!\n";
$expected_cksum = "4155895764\\s+2412\\s+dcram_dummy.v";
chop($new_cksum = `cksum dcram_dummy.v`);
die "Checksum failed for file dcram_dummy.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dcu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/dcu.v > dcu.v") or die "Couldn't fork while building dcu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dcu.v: $!\n";
$expected_cksum = "1405426347\\s+18339\\s+dcu.v";
chop($new_cksum = `cksum dcu.v`);
die "Checksum failed for file dcu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dcu_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/dcu_dpath.v > dcu_dpath.v") or die "Couldn't fork while building dcu_dpath.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dcu_dpath.v: $!\n";
$expected_cksum = "1362393833\\s+17143\\s+dcu_dpath.v";
chop($new_cksum = `cksum dcu_dpath.v`);
die "Checksum failed for file dcu_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dcudp_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/dcudp_cntl.v > dcudp_cntl.v") or die "Couldn't fork while building dcudp_cntl.v: $!\n";
print WRITEME <<EOF;
594c
case (cur_state)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dcudp_cntl.v: $!\n";
$expected_cksum = "58618755\\s+23222\\s+dcudp_cntl.v";
chop($new_cksum = `cksum dcudp_cntl.v`);
die "Checksum failed for file dcudp_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### dtag_dummy.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dtag/rtl/dtag_dummy.v > dtag_dummy.v") or die "Couldn't fork while building dtag_dummy.v: $!\n";
print WRITEME <<EOF;
86a
  hit0_out <= ^{set_sel_dly,wb_set_sel_dly};
  hit1_out <= ^{tag_we_dly,reg_enable_dly};
  dtag_dout <= tag_in_dly ^ cmp_addr_in_dly ^ addr_dly ^ stat_addr_dly;
  stat_out <= stat_in_dly ^ stat_we_dly;
  dtag_test_err_l <= ^{test_mode_dly,bist_mode_dly,bist_reset_dly};
  end
.
85a
always @ (posedge clk) begin
  tag_in_dly <= tag_in;
  cmp_addr_in_dly <= cmp_addr_in;
  stat_in_dly <= stat_in;
  set_sel_dly <= set_sel;
  wb_set_sel_dly <= wb_set_sel;
  tag_we_dly <= tag_we;
  stat_we_dly <= stat_we ;
  addr_dly <= addr;
  stat_addr_dly <= stat_addr;
  reg_enable_dly <= reg_enable;
  test_mode_dly <= test_mode;
  bist_mode_dly <= bist_mode;
  bist_reset_dly <= bist_reset;
.
84a
reg 			hit0_out;
reg 			hit1_out;
reg  [`dt_msb:0]	dtag_dout;
reg	[4:0]		stat_out;
reg 			dtag_test_err_l;
.
76,83c
reg	[`dt_msb:0]	tag_in_dly;
reg	[`dt_msb:0]	cmp_addr_in_dly;
reg	[4:0]		stat_in_dly;
reg			set_sel_dly;
reg			wb_set_sel_dly;
reg			tag_we_dly;
reg	[4:0]		stat_we_dly;
reg	[`dc_msb:4]	addr_dly;
reg	[`dc_msb:4]	stat_addr_dly;
reg			reg_enable_dly;
reg			test_mode_dly;
reg   [1:0]		bist_mode_dly;
reg			bist_reset_dly;
.
23a
// this replaces dtag_shell with random synthesizable logic

.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building dtag_dummy.v: $!\n";
$expected_cksum = "544797950\\s+3541\\s+dtag_dummy.v";
chop($new_cksum = `cksum dtag_dummy.v`);
die "Checksum failed for file dtag_dummy.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ex.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/ex.v > ex.v") or die "Couldn't fork while building ex.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ex.v: $!\n";
$expected_cksum = "2359336990\\s+35364\\s+ex.v";
chop($new_cksum = `cksum ex.v`);
die "Checksum failed for file ex.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ex_ctl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/ex_ctl.v > ex_ctl.v") or die "Couldn't fork while building ex_ctl.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ex_ctl.v: $!\n";
$expected_cksum = "3103281697\\s+103574\\s+ex_ctl.v";
chop($new_cksum = `cksum ex_ctl.v`);
die "Checksum failed for file ex_ctl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ex_decode.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/ex_decode.v > ex_decode.v") or die "Couldn't fork while building ex_decode.v: $!\n";
print WRITEME <<EOF;
133c
case (opcode_1_op_r[7:0])
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ex_decode.v: $!\n";
$expected_cksum = "2704742507\\s+21838\\s+ex_decode.v";
chop($new_cksum = `cksum ex_decode.v`);
die "Checksum failed for file ex_decode.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ex_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/ex_dpath.v > ex_dpath.v") or die "Couldn't fork while building ex_dpath.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ex_dpath.v: $!\n";
$expected_cksum = "2694629856\\s+34242\\s+ex_dpath.v";
chop($new_cksum = `cksum ex_dpath.v`);
die "Checksum failed for file ex_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ex_len_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/ex_len_dec.v > ex_len_dec.v") or die "Couldn't fork while building ex_len_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ex_len_dec.v: $!\n";
$expected_cksum = "115214427\\s+10169\\s+ex_len_dec.v";
chop($new_cksum = `cksum ex_len_dec.v`);
die "Checksum failed for file ex_len_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ex_regs.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/ex_regs.v > ex_regs.v") or die "Couldn't fork while building ex_regs.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ex_regs.v: $!\n";
$expected_cksum = "1652546124\\s+47631\\s+ex_regs.v";
chop($new_cksum = `cksum ex_regs.v`);
die "Checksum failed for file ex_regs.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### exponent.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/exponent.v > exponent.v") or die "Couldn't fork while building exponent.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building exponent.v: $!\n";
$expected_cksum = "1567657206\\s+5391\\s+exponent.v";
chop($new_cksum = `cksum exponent.v`);
die "Checksum failed for file exponent.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### exponent_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/exponent_cntl.v > exponent_cntl.v") or die "Couldn't fork while building exponent_cntl.v: $!\n";
print WRITEME <<EOF;
189c
   case(expfunc)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building exponent_cntl.v: $!\n";
$expected_cksum = "2371035324\\s+12356\\s+exponent_cntl.v";
chop($new_cksum = `cksum exponent_cntl.v`);
die "Checksum failed for file exponent_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### exponent_dp.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/exponent_dp.v > exponent_dp.v") or die "Couldn't fork while building exponent_dp.v: $!\n";
print WRITEME <<EOF;
359c
  case(nx_exconfunc)
.
346c
                case(nx_mconfunc)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building exponent_dp.v: $!\n";
$expected_cksum = "2320189775\\s+10820\\s+exponent_dp.v";
chop($new_cksum = `cksum exponent_dp.v`);
die "Checksum failed for file exponent_dp.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### f_fpu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/f_fpu.v > f_fpu.v") or die "Couldn't fork while building f_fpu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building f_fpu.v: $!\n";
$expected_cksum = "3461078694\\s+9873\\s+f_fpu.v";
chop($new_cksum = `cksum f_fpu.v`);
die "Checksum failed for file f_fpu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### fdec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/fdec.v > fdec.v") or die "Couldn't fork while building fdec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building fdec.v: $!\n";
$expected_cksum = "3691707501\\s+15460\\s+fdec.v";
chop($new_cksum = `cksum fdec.v`);
die "Checksum failed for file fdec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### fold_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/fold_dec.v > fold_dec.v") or die "Couldn't fork while building fold_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building fold_dec.v: $!\n";
$expected_cksum = "1769565760\\s+3275\\s+fold_dec.v";
chop($new_cksum = `cksum fold_dec.v`);
die "Checksum failed for file fold_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### fold_logic.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/fold_logic.v > fold_logic.v") or die "Couldn't fork while building fold_logic.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building fold_logic.v: $!\n";
$expected_cksum = "3753489180\\s+2824\\s+fold_logic.v";
chop($new_cksum = `cksum fold_logic.v`);
die "Checksum failed for file fold_logic.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### fp_roms.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/fp_roms.v > fp_roms.v") or die "Couldn't fork while building fp_roms.v: $!\n";
print WRITEME <<EOF;
56a
always @ (int_adr)
  case (int_adr)
    8'h00:   mem1 = 64'h0000000000000000;
    8'h01:   mem1 = 64'h001cb80000022c00;
    8'h02:   mem1 = 64'h003c4c0000162800;
    8'h03:   mem1 = 64'h0020101801000006;
    8'h04:   mem1 = 64'h001094001600bc03;
    8'h05:   mem1 = 64'h003c1c18791e1dc2;
    8'h06:   mem1 = 64'h0001c000000c3800;
    8'h07:   mem1 = 64'h002c000017022800;
    8'h08:   mem1 = 64'h003c2400191e1dc2;
    8'h09:   mem1 = 64'h002c000017022800;
    8'h0a:   mem1 = 64'h001090001640bc37;
    8'h0b:   mem1 = 64'h002c403010000005;
    8'h0c:   mem1 = 64'h002c300119800080;
    8'h0d:   mem1 = 64'h001c380017680020;
    8'h0e:   mem1 = 64'h002c000514020000;
    8'h0f:   mem1 = 64'h0008200019810440;
    8'h10:   mem1 = 64'h003c7c0000142800;
    8'h11:   mem1 = 64'h002c000000020400;
    8'h12:   mem1 = 64'h003c240000042000;
    8'h13:   mem1 = 64'h0000400000000000;
    8'h14:   mem1 = 64'h001c6c0000022000;
    8'h15:   mem1 = 64'h002c000000020000;
    8'h16:   mem1 = 64'h002ca00080000800;
    8'h17:   mem1 = 64'h002c000017000000;
    8'h18:   mem1 = 64'h001d780000022400;
    8'h19:   mem1 = 64'h003c840000182800;
    8'h1a:   mem1 = 64'h003cec3000042400;
    8'h1b:   mem1 = 64'h002c000000000000;
    8'h1c:   mem1 = 64'h001ca80014494008;
    8'h1d:   mem1 = 64'h003c8c0520047400;
    8'h1e:   mem1 = 64'h002c78001600bc07;
    8'h1f:   mem1 = 64'h001c640000000000;
    8'h20:   mem1 = 64'h00189c0000000000;
    8'h21:   mem1 = 64'h001c800000200000;
    8'h22:   mem1 = 64'h0019cc0000000000;
    8'h23:   mem1 = 64'h003d600000142400;
    8'h24:   mem1 = 64'h002c38000e800000;
    8'h25:   mem1 = 64'h002c38000e800000;
    8'h26:   mem1 = 64'h002c000000000000;
    8'h27:   mem1 = 64'h0024980000000000;
    8'h28:   mem1 = 64'h002c000014200030;
    8'h29:   mem1 = 64'h001cbc0000022c00;
    8'h2a:   mem1 = 64'h0000bc0017080020;
    8'h2b:   mem1 = 64'h000004000e8a3800;
    8'h2c:   mem1 = 64'h001cb40014494008;
    8'h2d:   mem1 = 64'h002cc00017080020;
    8'h2e:   mem1 = 64'h003cc00000182c00;
    8'h2f:   mem1 = 64'h003cac0000180000;
    8'h30:   mem1 = 64'h0018c40000000000;
    8'h31:   mem1 = 64'h002c000400020000;
    8'h32:   mem1 = 64'h002c000000000000;
    8'h33:   mem1 = 64'h001cd00017480008;
    8'h34:   mem1 = 64'h002c000500020000;
    8'h35:   mem1 = 64'h003d0400001c2800;
    8'h36:   mem1 = 64'h0000400000000000;
    8'h37:   mem1 = 64'h0034e81373010404;
    8'h38:   mem1 = 64'h0000000000000000;
    8'h39:   mem1 = 64'h002c000500020000;
    8'h3a:   mem1 = 64'h003cec10101e1c05;
    8'h3b:   mem1 = 64'h002c000014022800;
    8'h3c:   mem1 = 64'h003cf400101e1c05;
    8'h3d:   mem1 = 64'h002c000014022800;
    8'h3e:   mem1 = 64'h0001480018020180;
    8'h3f:   mem1 = 64'h002c000000000000;
    8'h40:   mem1 = 64'h002e5800000c0400;
    8'h41:   mem1 = 64'h003cd80000162800;
    8'h42:   mem1 = 64'h001c540014020428;
    8'h43:   mem1 = 64'h003e540019043a82;
    8'h44:   mem1 = 64'h003de40000162000;
    8'h45:   mem1 = 64'h003e240000142800;
    8'h46:   mem1 = 64'h003e640000162800;
    8'h47:   mem1 = 64'h002c000010000005;
    8'h48:   mem1 = 64'h002d20011b000100;
    8'h49:   mem1 = 64'h002c000500020000;
    8'h4a:   mem1 = 64'h002d24000001c007;
    8'h4b:   mem1 = 64'h002d2c0119800080;
    8'h4c:   mem1 = 64'h001d240017080020;
    8'h4d:   mem1 = 64'h001e4c001709c020;
    8'h4e:   mem1 = 64'h0000a00003c00030;
    8'h4f:   mem1 = 64'h003d700500044800;
    8'h50:   mem1 = 64'h00010c000e8a3800;
    8'h51:   mem1 = 64'h003d740520044c00;
    8'h52:   mem1 = 64'h0028440000000000;
    8'h53:   mem1 = 64'h002d4c011b000100;
    8'h54:   mem1 = 64'h002c000500020000;
    8'h55:   mem1 = 64'h002e4c1800000002;
    8'h56:   mem1 = 64'h002d580119800080;
    8'h57:   mem1 = 64'h002c000000000000;
    8'h58:   mem1 = 64'h001d640000000000;
    8'h59:   mem1 = 64'h0025380003000000;
    8'h5a:   mem1 = 64'h003d880000140000;
    8'h5b:   mem1 = 64'h003d600000142400;
    8'h5c:   mem1 = 64'h003d600000142000;
    8'h5d:   mem1 = 64'h003d600000142000;
    8'h5e:   mem1 = 64'h002c000000000000;
    8'h5f:   mem1 = 64'h002ded42000c1000;
    8'h60:   mem1 = 64'h003da00000142800;
    8'h61:   mem1 = 64'h0015a40010000003;
    8'h62:   mem1 = 64'h001d8c0000000000;
    8'h63:   mem1 = 64'h002c000014020000;
    8'h64:   mem1 = 64'h002c000019800100;
    8'h65:   mem1 = 64'h003d980000182800;
    8'h66:   mem1 = 64'h001d9c0000200000;
    8'h67:   mem1 = 64'h0025840721000001;
    8'h68:   mem1 = 64'h001d940000000000;
    8'h69:   mem1 = 64'h002da400198a3880;
    8'h6a:   mem1 = 64'h001db40000000000;
    8'h6b:   mem1 = 64'h001db00000200000;
    8'h6c:   mem1 = 64'h002c000014000000;
    8'h6d:   mem1 = 64'h003dac0000180000;
    8'h6e:   mem1 = 64'h003d6c0500045400;
    8'h6f:   mem1 = 64'h002dd38014060438;
    8'h70:   mem1 = 64'h003dc40000162400;
    8'h71:   mem1 = 64'h0000400000000000;
    8'h72:   mem1 = 64'h002c000014022400;
    8'h73:   mem1 = 64'h002c000000000000;
    8'h74:   mem1 = 64'h001e1800000002c0;
    8'h75:   mem1 = 64'h001dd80000200000;
    8'h76:   mem1 = 64'h002c000517022830;
    8'h77:   mem1 = 64'h0008f00018000183;
    8'h78:   mem1 = 64'h002c000517022830;
    8'h79:   mem1 = 64'h0000400000000000;
    8'h7a:   mem1 = 64'h0000000000000000;
    8'h7b:   mem1 = 64'h002df1c000000000;
    8'h7c:   mem1 = 64'h002df64000000000;
    8'h7d:   mem1 = 64'h002dfac000000000;
    8'h7e:   mem1 = 64'h0002534014000038;
    8'h7f:   mem1 = 64'h002c34000001c000;
    8'h80:   mem1 = 64'h00020c0019522e82;
    8'h81:   mem1 = 64'h00011c0061120402;
    8'h82:   mem1 = 64'h002c000000020000;
    8'h83:   mem1 = 64'h002e10000e8a0000;
    8'h84:   mem1 = 64'h002a1c00c0023ac0;
    8'h85:   mem1 = 64'h002c340000000003;
    8'h86:   mem1 = 64'h001a14001981c243;
    8'h87:   mem1 = 64'h0001d000190001c2;
    8'h88:   mem1 = 64'h002c000517022830;
    8'h89:   mem1 = 64'h001e2800000a3800;
    8'h8a:   mem1 = 64'h003e2c000e942800;
    8'h8b:   mem1 = 64'h001e300500000000;
    8'h8c:   mem1 = 64'h002c000517022830;
    8'h8d:   mem1 = 64'h001e380000000000;
    8'h8e:   mem1 = 64'h002c000200020000;
    8'h8f:   mem1 = 64'h001e400000000000;
    8'h90:   mem1 = 64'h003e44000e940000;
    8'h91:   mem1 = 64'h001e200000000000;
    8'h92:   mem1 = 64'h00255c0019000005;
    8'h93:   mem1 = 64'h002c000500020000;
    8'h94:   mem1 = 64'h0029fc0000130400;
    8'h95:   mem1 = 64'h003e60000e943800;
    8'h96:   mem1 = 64'h002a5c00c00a3a00;
    8'h97:   mem1 = 64'h002e5c00f98c0600;
    8'h98:   mem1 = 64'h002a5c00c00a3a00;
    8'h99:   mem1 = 64'h003e680000142800;
    8'h9a:   mem1 = 64'h001e6c0000000000;
    8'h9b:   mem1 = 64'h003e700000182800;
    8'h9c:   mem1 = 64'h001e30050ea00000;
    8'h9d:   mem1 = 64'h001de00000200000;
    8'h9e:   mem1 = 64'h002c000000000000;
    8'h9f:   mem1 = 64'h002c000000000000;
    8'ha0:   mem1 = 64'h0000000000000000;
    8'ha1:   mem1 = 64'h0000000000000000;
    8'ha2:   mem1 = 64'h0000000000000000;
    8'ha3:   mem1 = 64'h0000000000000000;
    8'ha4:   mem1 = 64'h0000000000000000;
    8'ha5:   mem1 = 64'h0000000000000000;
    8'ha6:   mem1 = 64'h0000000000000000;
    8'ha7:   mem1 = 64'h0000000000000000;
    8'ha8:   mem1 = 64'h0000000000000000;
    8'ha9:   mem1 = 64'h0000000000000000;
    8'haa:   mem1 = 64'h0000000000000000;
    8'hab:   mem1 = 64'h0000000000000000;
    8'hac:   mem1 = 64'h0000000000000000;
    8'had:   mem1 = 64'h0000000000000000;
    8'hae:   mem1 = 64'h0000000000000000;
    8'haf:   mem1 = 64'h0000000000000000;
    8'hb0:   mem1 = 64'h0000000000000000;
    8'hb1:   mem1 = 64'h0000000000000000;
    8'hb2:   mem1 = 64'h0000000000000000;
    8'hb3:   mem1 = 64'h0000000000000000;
    8'hb4:   mem1 = 64'h0000000000000000;
    8'hb5:   mem1 = 64'h0000000000000000;
    8'hb6:   mem1 = 64'h0000000000000000;
    8'hb7:   mem1 = 64'h0000000000000000;
    8'hb8:   mem1 = 64'h0000000000000000;
    8'hb9:   mem1 = 64'h0000000000000000;
    8'hba:   mem1 = 64'h0000000000000000;
    8'hbb:   mem1 = 64'h0000000000000000;
    8'hbc:   mem1 = 64'h0000000000000000;
    8'hbd:   mem1 = 64'h0000000000000000;
    8'hbe:   mem1 = 64'h0000000000000000;
    8'hbf:   mem1 = 64'h0000000000000000;
    default: mem1 = 64'hx;
  endcase

.
55c
always @ (int_adr)
  case (int_adr)
    8'h00:   mem0 = 64'h0000000000000000;
    8'h01:   mem0 = 64'h003c0800001c2800;
    8'h02:   mem0 = 64'h00240c0b448ef800;
    8'h03:   mem0 = 64'h0020280019800080;
    8'h04:   mem0 = 64'h0034143010010403;
    8'h05:   mem0 = 64'h0008200019810440;
    8'h06:   mem0 = 64'h000dbc82000c1800;
    8'h07:   mem0 = 64'h0008200019810440;
    8'h08:   mem0 = 64'h003c480000044400;
    8'h09:   mem0 = 64'h002c000000000000;
    8'h0a:   mem0 = 64'h002c2c1801000001;
    8'h0b:   mem0 = 64'h0030300810000003;
    8'h0c:   mem0 = 64'h001c34001449400b;
    8'h0d:   mem0 = 64'h003c3c280384441b;
    8'h0e:   mem0 = 64'h003c480000044400;
    8'h0f:   mem0 = 64'h0020780000000003;
    8'h10:   mem0 = 64'h0001480019820040;
    8'h11:   mem0 = 64'h002c000000000000;
    8'h12:   mem0 = 64'h0020780000000000;
    8'h13:   mem0 = 64'h002ca00080000000;
    8'h14:   mem0 = 64'h003d080000140000;
    8'h15:   mem0 = 64'h00005800000a0000;
    8'h16:   mem0 = 64'h003c500003142400;
    8'h17:   mem0 = 64'h002dd000000c3003;
    8'h18:   mem0 = 64'h003c5c0000140003;
    8'h19:   mem0 = 64'h002c000500000000;
    8'h1a:   mem0 = 64'h003c60000015e007;
    8'h1b:   mem0 = 64'h002c000500000000;
    8'h1c:   mem0 = 64'h003c740600041800;
    8'h1d:   mem0 = 64'h002c000514000000;
    8'h1e:   mem0 = 64'h00002c1821000002;
    8'h1f:   mem0 = 64'h001c88060eaa3800;
    8'h20:   mem0 = 64'h002c00050e800000;
    8'h21:   mem0 = 64'h0019cc0000002800;
    8'h22:   mem0 = 64'h002c000500000000;
    8'h23:   mem0 = 64'h0022480001000002;
    8'h24:   mem0 = 64'h002c2c1801000001;
    8'h25:   mem0 = 64'h002c101801000001;
    8'h26:   mem0 = 64'h002c000517000030;
    8'h27:   mem0 = 64'h002c000200000000;
    8'h28:   mem0 = 64'h003ca40000140000;
    8'h29:   mem0 = 64'h000004000e8a3800;
    8'h2a:   mem0 = 64'h0000bc0003800018;
    8'h2b:   mem0 = 64'h002c3c00a0000000;
    8'h2c:   mem0 = 64'h0004d40b5c01b8c0;
    8'h2d:   mem0 = 64'h002cc00003800018;
    8'h2e:   mem0 = 64'h0000b00014020428;
    8'h2f:   mem0 = 64'h0000700014020428;
    8'h30:   mem0 = 64'h002cac000e8a3800;
    8'h31:   mem0 = 64'h002c000200020000;
    8'h32:   mem0 = 64'h002c000019800080;
    8'h33:   mem0 = 64'h002c000018100540;
    8'h34:   mem0 = 64'h002c000000000000;
    8'h35:   mem0 = 64'h0038cc08100e3804;
    8'h36:   mem0 = 64'h002ca00080000400;
    8'h37:   mem0 = 64'h002ce01013000004;
    8'h38:   mem0 = 64'h001ce42017480408;
    8'h39:   mem0 = 64'h0008f00078010580;
    8'h3a:   mem0 = 64'h0008f00078010580;
    8'h3b:   mem0 = 64'h0008f00078010580;
    8'h3c:   mem0 = 64'h003cfc0020044403;
    8'h3d:   mem0 = 64'h003cfc0020044400;
    8'h3e:   mem0 = 64'h003db80603041800;
    8'h3f:   mem0 = 64'h0000f81010000085;
    8'h40:   mem0 = 64'h00240c0b448ef800;
    8'h41:   mem0 = 64'h0024dc035c0fb8c0;
    8'h42:   mem0 = 64'h002c000000123000;
    8'h43:   mem0 = 64'h002c184000123800;
    8'h44:   mem0 = 64'h00017d0000123800;
    8'h45:   mem0 = 64'h002e0c0019810680;
    8'h46:   mem0 = 64'h0001400019810680;
    8'h47:   mem0 = 64'h0029200523021400;
    8'h48:   mem0 = 64'h001d24001449c008;
    8'h49:   mem0 = 64'h002cec1000000005;
    8'h4a:   mem0 = 64'h00292c0500023400;
    8'h4b:   mem0 = 64'h001d300014494008;
    8'h4c:   mem0 = 64'h0001280003800018;
    8'h4d:   mem0 = 64'h000154000381c018;
    8'h4e:   mem0 = 64'h002c000014600030;
    8'h4f:   mem0 = 64'h002c000014000000;
    8'h50:   mem0 = 64'h003d440600041000;
    8'h51:   mem0 = 64'h002c000017000000;
    8'h52:   mem0 = 64'h00294c0503020800;
    8'h53:   mem0 = 64'h001d500014480008;
    8'h54:   mem0 = 64'h002c000000000000;
    8'h55:   mem0 = 64'h0029580500020c00;
    8'h56:   mem0 = 64'h001d340014494008;
    8'h57:   mem0 = 64'h002c000019800080;
    8'h58:   mem0 = 64'h0025380003000000;
    8'h59:   mem0 = 64'h002c000017000000;
    8'h5a:   mem0 = 64'h003d3c0600041000;
    8'h5b:   mem0 = 64'h002e480023000000;
    8'h5c:   mem0 = 64'h002e480023000000;
    8'h5d:   mem0 = 64'h0022480001000002;
    8'h5e:   mem0 = 64'h002c000517000030;
    8'h5f:   mem0 = 64'h003d8000001de800;
    8'h60:   mem0 = 64'h00019c0019800080;
    8'h61:   mem0 = 64'h0025900014400030;
    8'h62:   mem0 = 64'h003d900014440430;
    8'h63:   mem0 = 64'h0029900014400030;
    8'h64:   mem0 = 64'h002c000000002400;
    8'h65:   mem0 = 64'h0019900014400030;
    8'h66:   mem0 = 64'h003da80019940080;
    8'h67:   mem0 = 64'h0019900014400030;
    8'h68:   mem0 = 64'h003d980000182800;
    8'h69:   mem0 = 64'h00016800000c3800;
    8'h6a:   mem0 = 64'h0025840721000001;
    8'h6b:   mem0 = 64'h0025840721000001;
    8'h6c:   mem0 = 64'h0025840721000001;
    8'h6d:   mem0 = 64'h0025840721000001;
    8'h6e:   mem0 = 64'h002c000517000000;
    8'h6f:   mem0 = 64'h002c00c014060438;
    8'h70:   mem0 = 64'h003c1840001a2400;
    8'h71:   mem0 = 64'h002ca00080000c00;
    8'h72:   mem0 = 64'h003ddc1000040405;
    8'h73:   mem0 = 64'h003dd40200180000;
    8'h74:   mem0 = 64'h003dc8002005e403;
    8'h75:   mem0 = 64'h002c000000000000;
    8'h76:   mem0 = 64'h002c000000000000;
    8'h77:   mem0 = 64'h002cfc0000004403;
    8'h78:   mem0 = 64'h002ca00080001800;
    8'h79:   mem0 = 64'h002ca00080001000;
    8'h7a:   mem0 = 64'h003d1000001c2000;
    8'h7b:   mem0 = 64'h0001ed8000000000;
    8'h7c:   mem0 = 64'h0001f20000000000;
    8'h7d:   mem0 = 64'h0001f68000000000;
    8'h7e:   mem0 = 64'h0001fb0003800038;
    8'h7f:   mem0 = 64'h002c3400140c0410;
    8'h80:   mem0 = 64'h003d1400201c2800;
    8'h81:   mem0 = 64'h002c000000000000;
    8'h82:   mem0 = 64'h002c300000000000;
    8'h83:   mem0 = 64'h000200020e8c3800;
    8'h84:   mem0 = 64'h003e100019be2e00;
    8'h85:   mem0 = 64'h002dd00000000003;
    8'h86:   mem0 = 64'h00021800e00002c3;
    8'h87:   mem0 = 64'h00021c00198c0600;
    8'h88:   mem0 = 64'h002c000217022800;
    8'h89:   mem0 = 64'h003e34000e982800;
    8'h8a:   mem0 = 64'h002c0005000a3800;
    8'h8b:   mem0 = 64'h002c00020e8a3800;
    8'h8c:   mem0 = 64'h002c000000000000;
    8'h8d:   mem0 = 64'h003e3c0000180000;
    8'h8e:   mem0 = 64'h002c000500022800;
    8'h8f:   mem0 = 64'h002ca0008e801400;
    8'h90:   mem0 = 64'h002ca0008e801400;
    8'h91:   mem0 = 64'h002c000217022800;
    8'h92:   mem0 = 64'h0024c80010000005;
    8'h93:   mem0 = 64'h000a040019810440;
    8'h94:   mem0 = 64'h003d1800201c2800;
    8'h95:   mem0 = 64'h000100000e8a3800;
    8'h96:   mem0 = 64'h003e5800f9943a00;
    8'h97:   mem0 = 64'h001e0800e0120400;
    8'h98:   mem0 = 64'h0002500000023800;
    8'h99:   mem0 = 64'h003e740000180000;
    8'h9a:   mem0 = 64'h001e7c0000200000;
    8'h9b:   mem0 = 64'h002c000500000000;
    8'h9c:   mem0 = 64'h002c000517000030;
    8'h9d:   mem0 = 64'h001e780000000000;
    8'h9e:   mem0 = 64'h002ca00080001800;
    8'h9f:   mem0 = 64'h002c00050e823800;
    8'ha0:   mem0 = 64'h0000000000000000;
    8'ha1:   mem0 = 64'h0000000000000000;
    8'ha2:   mem0 = 64'h0000000000000000;
    8'ha3:   mem0 = 64'h0000000000000000;
    8'ha4:   mem0 = 64'h0000000000000000;
    8'ha5:   mem0 = 64'h0000000000000000;
    8'ha6:   mem0 = 64'h0000000000000000;
    8'ha7:   mem0 = 64'h0000000000000000;
    8'ha8:   mem0 = 64'h0000000000000000;
    8'ha9:   mem0 = 64'h0000000000000000;
    8'haa:   mem0 = 64'h0000000000000000;
    8'hab:   mem0 = 64'h0000000000000000;
    8'hac:   mem0 = 64'h0000000000000000;
    8'had:   mem0 = 64'h0000000000000000;
    8'hae:   mem0 = 64'h0000000000000000;
    8'haf:   mem0 = 64'h0000000000000000;
    8'hb0:   mem0 = 64'h0000000000000000;
    8'hb1:   mem0 = 64'h0000000000000000;
    8'hb2:   mem0 = 64'h0000000000000000;
    8'hb3:   mem0 = 64'h0000000000000000;
    8'hb4:   mem0 = 64'h0000000000000000;
    8'hb5:   mem0 = 64'h0000000000000000;
    8'hb6:   mem0 = 64'h0000000000000000;
    8'hb7:   mem0 = 64'h0000000000000000;
    8'hb8:   mem0 = 64'h0000000000000000;
    8'hb9:   mem0 = 64'h0000000000000000;
    8'hba:   mem0 = 64'h0000000000000000;
    8'hbb:   mem0 = 64'h0000000000000000;
    8'hbc:   mem0 = 64'h0000000000000000;
    8'hbd:   mem0 = 64'h0000000000000000;
    8'hbe:   mem0 = 64'h0000000000000000;
    8'hbf:   mem0 = 64'h0000000000000000;
    default: mem0 = 64'hx;
  endcase
.
51,52c
        do0 <= (int_enable) ? mem0: do0;
        do1 <= (int_enable) ? mem1: do1;
.
43,49d
40,41c
always @ (posedge clk) begin
  int_adr <= tm ? tadr:adr ;
  int_enable <= tm ? te : (rom_en & me);
  end
.
37,38c
reg    [7:0]   int_adr;
reg            int_enable;
.
33,35c
reg    [63:0] mem0;
reg    [63:0] mem1;
reg    [63:0] do1,do0;
.
22a
// make a synthesizable pipelined ROM
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building fp_roms.v: $!\n";
$expected_cksum = "2886421972\\s+17990\\s+fp_roms.v";
chop($new_cksum = `cksum fp_roms.v`);
die "Checksum failed for file fp_roms.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### hold_logic.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/pipe/rtl/hold_logic.v > hold_logic.v") or die "Couldn't fork while building hold_logic.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building hold_logic.v: $!\n";
$expected_cksum = "1290587492\\s+7429\\s+hold_logic.v";
chop($new_cksum = `cksum hold_logic.v`);
die "Checksum failed for file hold_logic.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ibuf_ctl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icu/rtl/ibuf_ctl.v > ibuf_ctl.v") or die "Couldn't fork while building ibuf_ctl.v: $!\n";
print WRITEME <<EOF;
626a
    default     : encod_shift_e = 3'bxxx;
.
618c
    casex(iu_shift_e)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ibuf_ctl.v: $!\n";
$expected_cksum = "1391090234\\s+23744\\s+ibuf_ctl.v";
chop($new_cksum = `cksum ibuf_ctl.v`);
die "Checksum failed for file ibuf_ctl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ibuffer.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icu/rtl/ibuffer.v > ibuffer.v") or die "Couldn't fork while building ibuffer.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ibuffer.v: $!\n";
$expected_cksum = "2105971619\\s+21491\\s+ibuffer.v";
chop($new_cksum = `cksum ibuffer.v`);
die "Checksum failed for file ibuffer.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ic_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icu/rtl/ic_cntl.v > ic_cntl.v") or die "Couldn't fork while building ic_cntl.v: $!\n";
print WRITEME <<EOF;
642c
case    (cur_state)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ic_cntl.v: $!\n";
$expected_cksum = "325793146\\s+25294\\s+ic_cntl.v";
chop($new_cksum = `cksum ic_cntl.v`);
die "Checksum failed for file ic_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### icctl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icu/rtl/icctl.v > icctl.v") or die "Couldn't fork while building icctl.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building icctl.v: $!\n";
$expected_cksum = "3623832376\\s+10729\\s+icctl.v";
chop($new_cksum = `cksum icctl.v`);
die "Checksum failed for file icctl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### icram_dummy.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icram/rtl/icram_dummy.v > icram_dummy.v") or die "Couldn't fork while building icram_dummy.v: $!\n";
print WRITEME <<EOF;
62a
  icram_dout <= {icu_din_dly2,icu_din_dly} ^ icu_addr_dly;
  icache_test_err_l <= ^{
			 icu_ram_we_dly,
			 enable_dly,
			 test_mode_dly,
			 bist_mode_dly,
			 bist_reset};
end

.
61a
always @ (posedge clk) begin
  icu_din_dly <= icu_din;
  icu_din_dly2 <= icu_din_dly;
  icu_ram_we_dly <= icu_ram_we;
  enable_dly <= enable;
  icu_addr_dly <= icu_addr;
  test_mode_dly <= test_mode;
  bist_mode_dly <= bist_mode;
  bist_reset_dly <= bist_reset;
.
56,60c
reg       [31:0]      icu_din_dly,icu_din_dly2;
reg        [1:0]      icu_ram_we_dly;
reg                   enable_dly;
reg  [`ic_msb:3]      icu_addr_dly;
reg                   test_mode_dly;
reg        [1:0]      bist_mode_dly;
reg                   bist_reset_dly;
reg      [63:0]       icram_dout;
reg                   icache_test_err_l;
.
23a
// this replaces icram_shell with random synthesizable logic
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building icram_dummy.v: $!\n";
$expected_cksum = "3757573692\\s+3167\\s+icram_dummy.v";
chop($new_cksum = `cksum icram_dummy.v`);
die "Checksum failed for file icram_dummy.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### icu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icu/rtl/icu.v > icu.v") or die "Couldn't fork while building icu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building icu.v: $!\n";
$expected_cksum = "2757895549\\s+12282\\s+icu.v";
chop($new_cksum = `cksum icu.v`);
die "Checksum failed for file icu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### icu_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/icu/rtl/icu_dpath.v > icu_dpath.v") or die "Couldn't fork while building icu_dpath.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building icu_dpath.v: $!\n";
$expected_cksum = "102085243\\s+17935\\s+icu_dpath.v";
chop($new_cksum = `cksum icu_dpath.v`);
die "Checksum failed for file icu_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ieu_rom.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ieu_rom.v > ieu_rom.v") or die "Couldn't fork while building ieu_rom.v: $!\n";
print WRITEME <<EOF;
29,45d
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ieu_rom.v: $!\n";
$expected_cksum = "4282390520\\s+17805\\s+ieu_rom.v";
chop($new_cksum = `cksum ieu_rom.v`);
die "Checksum failed for file ieu_rom.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ifu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/ifu.v > ifu.v") or die "Couldn't fork while building ifu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ifu.v: $!\n";
$expected_cksum = "3940217728\\s+34186\\s+ifu.v";
chop($new_cksum = `cksum ifu.v`);
die "Checksum failed for file ifu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### imdr.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/imdr/imdr.v > imdr.v") or die "Couldn't fork while building imdr.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building imdr.v: $!\n";
$expected_cksum = "2124469811\\s+8492\\s+imdr.v";
chop($new_cksum = `cksum imdr.v`);
die "Checksum failed for file imdr.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### imdr_ctrl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/imdr/imdr_ctrl.v > imdr_ctrl.v") or die "Couldn't fork while building imdr_ctrl.v: $!\n";
print WRITEME <<EOF;
347c
    case (st)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building imdr_ctrl.v: $!\n";
$expected_cksum = "1987641803\\s+17972\\s+imdr_ctrl.v";
chop($new_cksum = `cksum imdr_ctrl.v`);
die "Checksum failed for file imdr_ctrl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### imdr_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/imdr/imdr_dpath.v > imdr_dpath.v") or die "Couldn't fork while building imdr_dpath.v: $!\n";
print WRITEME <<EOF;
336c
  inv1_32 inv1_32_a (.inp(sum_dly), .out_(sum_) );
.
328c
                               .inp1(sum_dly),
.
326a
reg [31:0] sum_dly;
always @ (posedge clk) sum_dly <= sum;

.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building imdr_dpath.v: $!\n";
$expected_cksum = "2009780344\\s+17224\\s+imdr_dpath.v";
chop($new_cksum = `cksum imdr_dpath.v`);
die "Checksum failed for file imdr_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### incmod.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/incmod.v > incmod.v") or die "Couldn't fork while building incmod.v: $!\n";
print WRITEME <<EOF;
656c
     casex(nx_incfunc_rom)
.
633c
    casex(nx_incfunc_rom)
.
610c
    casex(nx_incfunc_rom)
.
584c
    casex(nx_incfunc_rom)
.
570c
    casex(nx_incfunc_rom)
.
543c
    casex(nx_incfunc_rom)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building incmod.v: $!\n";
$expected_cksum = "1994892239\\s+15349\\s+incmod.v";
chop($new_cksum = `cksum incmod.v`);
die "Checksum failed for file incmod.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### index_adders.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/index_adders.v > index_adders.v") or die "Couldn't fork while building index_adders.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building index_adders.v: $!\n";
$expected_cksum = "2023186955\\s+3433\\s+index_adders.v";
chop($new_cksum = `cksum index_adders.v`);
die "Checksum failed for file index_adders.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### itag_dummy.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/itag/rtl/itag_dummy.v > itag_dummy.v") or die "Couldn't fork while building itag_dummy.v: $!\n";
print WRITEME <<EOF;
71,76c
  itag_dout <= icu_tag_in_dly ^ icu_tag_addr_dly;
  itag_vld <= icu_tag_vld_dly;
  ic_hit <= ^{icu_tag_we_dly,enable_dly};
  itag_test_err_l <= ^{
		       test_mode_dly,
		       bist_mode_dly,
		       bist_reset_dly};
end
  
.
67,69c
always @ (posedge clk) begin
  icu_tag_in_dly <= icu_tag_in;
  icu_tag_vld_dly <= icu_tag_vld;
  icu_tag_we_dly <= icu_tag_we;
  icu_tag_addr_dly <= icu_tag_addr;
  enable_dly <= enable;
  test_mode_dly <= test_mode;
  bist_mode_dly <= bist_mode;
  bist_reset_dly <= bist_reset;
.
64,65c
reg     [`it_msb:0]     icu_tag_in_dly;
reg                     icu_tag_vld_dly;
reg                     icu_tag_we_dly;
reg     [`ic_msb:4]     icu_tag_addr_dly;
reg                     enable_dly;
reg                     test_mode_dly;
reg           [1:0]     bist_mode_dly;
reg                     bist_reset_dly;
reg     [`it_msb:0]     itag_dout;
reg                     itag_vld;
reg                     ic_hit;
reg                     itag_test_err_l;
.
24a
// this replaces itag_shell with random synthesizable logic
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building itag_dummy.v: $!\n";
$expected_cksum = "3631829389\\s+3627\\s+itag_dummy.v";
chop($new_cksum = `cksum itag_dummy.v`);
die "Checksum failed for file itag_dummy.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### iu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/rtl/iu.v > iu.v") or die "Couldn't fork while building iu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building iu.v: $!\n";
$expected_cksum = "3134781978\\s+32660\\s+iu.v";
chop($new_cksum = `cksum iu.v`);
die "Checksum failed for file iu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### length_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/length_dec.v > length_dec.v") or die "Couldn't fork while building length_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building length_dec.v: $!\n";
$expected_cksum = "921609057\\s+7714\\s+length_dec.v";
chop($new_cksum = `cksum length_dec.v`);
die "Checksum failed for file length_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### lib_imdr.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ex/rtl/imdr/lib_imdr.v > lib_imdr.v") or die "Couldn't fork while building lib_imdr.v: $!\n";
print WRITEME <<EOF;
510c
    case ({inp,inp_pre})
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building lib_imdr.v: $!\n";
$expected_cksum = "3403894208\\s+24434\\s+lib_imdr.v";
chop($new_cksum = `cksum lib_imdr.v`);
die "Checksum failed for file lib_imdr.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### main_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/main_dec.v > main_dec.v") or die "Couldn't fork while building main_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building main_dec.v: $!\n";
$expected_cksum = "3956360788\\s+5798\\s+main_dec.v";
chop($new_cksum = `cksum main_dec.v`);
die "Checksum failed for file main_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mantissa.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/mantissa.v > mantissa.v") or die "Couldn't fork while building mantissa.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mantissa.v: $!\n";
$expected_cksum = "3549476032\\s+4355\\s+mantissa.v";
chop($new_cksum = `cksum mantissa.v`);
die "Checksum failed for file mantissa.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mantissa_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/mantissa_cntl.v > mantissa_cntl.v") or die "Couldn't fork while building mantissa_cntl.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mantissa_cntl.v: $!\n";
$expected_cksum = "898487253\\s+3477\\s+mantissa_cntl.v";
chop($new_cksum = `cksum mantissa_cntl.v`);
die "Checksum failed for file mantissa_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mantissa_cntl_sub.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/mantissa_cntl_sub.v > mantissa_cntl_sub.v") or die "Couldn't fork while building mantissa_cntl_sub.v: $!\n";
print WRITEME <<EOF;
175c
      casex(a1func)
.
120c
      casex(a0func)
.
105c
	  case(1'b1)         // synopsys parallel_case
.
95c
        case(a2func)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mantissa_cntl_sub.v: $!\n";
$expected_cksum = "3344240399\\s+6722\\s+mantissa_cntl_sub.v";
chop($new_cksum = `cksum mantissa_cntl_sub.v`);
die "Checksum failed for file mantissa_cntl_sub.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mantissa_dp.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/mantissa_dp.v > mantissa_dp.v") or die "Couldn't fork while building mantissa_dp.v: $!\n";
print WRITEME <<EOF;
222c
      casex(nx_rsfunc_rom1)
.
209c
      casex(nx_rsfunc_rom0)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mantissa_dp.v: $!\n";
$expected_cksum = "3110276051\\s+7693\\s+mantissa_dp.v";
chop($new_cksum = `cksum mantissa_dp.v`);
die "Checksum failed for file mantissa_dp.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### miss_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/miss_cntl.v > miss_cntl.v") or die "Couldn't fork while building miss_cntl.v: $!\n";
print WRITEME <<EOF;
256c
case    (cur_state)
.
179c
case    (cur_state)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building miss_cntl.v: $!\n";
$expected_cksum = "1656988918\\s+8579\\s+miss_cntl.v";
chop($new_cksum = `cksum miss_cntl.v`);
die "Checksum failed for file miss_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mj_ffs_behv.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/rtl/mj_ffs_behv.v > mj_ffs_behv.v") or die "Couldn't fork while building mj_ffs_behv.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mj_ffs_behv.v: $!\n";
$expected_cksum = "3641722660\\s+291472\\s+mj_ffs_behv.v";
chop($new_cksum = `cksum mj_ffs_behv.v`);
die "Checksum failed for file mj_ffs_behv.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mj_muxes_behv.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/rtl/mj_muxes_behv.v > mj_muxes_behv.v") or die "Couldn't fork while building mj_muxes_behv.v: $!\n";
print WRITEME <<EOF;
6969c
   case (sel)
.
6901c
   case (sel)
.
6867c
   case(sel)
.
6848c
   case(sel)
.
6827c
   case(sel)
.
6806c
   case(sel)
.
6784c
   case(sel)
.
6763c
   case(sel)
.
6741c
   case(sel)
.
6719c
   case(sel)
.
6694c
   case(sel)
.
6669c
   case(sel)
.
6644c
   case(sel)
.
6619c
   case(sel)
.
6593c
   case(sel)
.
6568c
   case(sel)
.
6542c
   case(sel)
.
6516c
   case(sel)
.
3954c
   case(sel)
.
3797c
   case (sel)
.
3518c
   case (sel)
.
1872c
   case(sel)
.
1832c
   case(sel)
.
1798c
   case(sel)
.
1768c
   case(sel)
.
1701c
   case(sel)
.
1660c
   case(sel)
.
1625c
   case(sel)
.
1594c
   case(sel)
.
1529c
   case(sel)
.
1488c
   case(sel)
.
1454c
   case(sel)
.
1422c
   case(sel)
.
1355c
   case (sel)
.
1298c
   case(sel)
.
1246c
   case(sel)
.
1199c
   case(sel)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mj_muxes_behv.v: $!\n";
$expected_cksum = "4116145744\\s+299865\\s+mj_muxes_behv.v";
chop($new_cksum = `cksum mj_muxes_behv.v`);
die "Checksum failed for file mj_muxes_behv.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### mult_array.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/mult_array.v > mult_array.v") or die "Couldn't fork while building mult_array.v: $!\n";
print WRITEME <<EOF;
581c
      case(bits)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building mult_array.v: $!\n";
$expected_cksum = "2935905975\\s+34488\\s+mult_array.v";
chop($new_cksum = `cksum mult_array.v`);
die "Checksum failed for file mult_array.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### multmod.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/multmod.v > multmod.v") or die "Couldn't fork while building multmod.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building multmod.v: $!\n";
$expected_cksum = "3206411269\\s+2161\\s+multmod.v";
chop($new_cksum = `cksum multmod.v`);
die "Checksum failed for file multmod.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### multmod_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/multmod_cntl.v > multmod_cntl.v") or die "Couldn't fork while building multmod_cntl.v: $!\n";
print WRITEME <<EOF;
147c
     case(multfunc)
.
132c
     case(multfunc)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building multmod_cntl.v: $!\n";
$expected_cksum = "901748270\\s+5721\\s+multmod_cntl.v";
chop($new_cksum = `cksum multmod_cntl.v`);
die "Checksum failed for file multmod_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### multmod_dp.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/multmod_dp.v > multmod_dp.v") or die "Couldn't fork while building multmod_dp.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building multmod_dp.v: $!\n";
$expected_cksum = "3001662939\\s+14116\\s+multmod_dp.v";
chop($new_cksum = `cksum multmod_dp.v`);
die "Checksum failed for file multmod_dp.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### nxsign.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/nxsign.v > nxsign.v") or die "Couldn't fork while building nxsign.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building nxsign.v: $!\n";
$expected_cksum = "2438027214\\s+3221\\s+nxsign.v";
chop($new_cksum = `cksum nxsign.v`);
die "Checksum failed for file nxsign.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### pcsu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/pcsu/rtl/pcsu.v > pcsu.v") or die "Couldn't fork while building pcsu.v: $!\n";
print WRITEME <<EOF;
113c
assign  pj_clk_out     = clk_gate;
.
69a
input	clk_gate		;// 
.
52a
	clk_gate,
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building pcsu.v: $!\n";
$expected_cksum = "4110675684\\s+6954\\s+pcsu.v";
chop($new_cksum = `cksum pcsu.v`);
die "Checksum failed for file pcsu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### pipe.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/pipe/rtl/pipe.v > pipe.v") or die "Couldn't fork while building pipe.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building pipe.v: $!\n";
$expected_cksum = "1014068759\\s+8657\\s+pipe.v";
chop($new_cksum = `cksum pipe.v`);
die "Checksum failed for file pipe.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### pipe_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/pipe/rtl/pipe_cntl.v > pipe_cntl.v") or die "Couldn't fork while building pipe_cntl.v: $!\n";
print WRITEME <<EOF;
652c
case (cur_state)
.
456c
case    (cur_state)
.
325c
case	(cur_state)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building pipe_cntl.v: $!\n";
$expected_cksum = "4130977707\\s+22056\\s+pipe_cntl.v";
chop($new_cksum = `cksum pipe_cntl.v`);
die "Checksum failed for file pipe_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### pipe_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/pipe/rtl/pipe_dpath.v > pipe_dpath.v") or die "Couldn't fork while building pipe_dpath.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building pipe_dpath.v: $!\n";
$expected_cksum = "1037856329\\s+5669\\s+pipe_dpath.v";
chop($new_cksum = `cksum pipe_dpath.v`);
die "Checksum failed for file pipe_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### prils.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/prils.v > prils.v") or die "Couldn't fork while building prils.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building prils.v: $!\n";
$expected_cksum = "3642806178\\s+2607\\s+prils.v";
chop($new_cksum = `cksum prils.v`);
die "Checksum failed for file prils.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### prils_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/prils_cntl.v > prils_cntl.v") or die "Couldn't fork while building prils_cntl.v: $!\n";
print WRITEME <<EOF;
92c
    casex(nx_prifunc_rom1)
.
80c
    casex(nx_prifunc_rom0)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building prils_cntl.v: $!\n";
$expected_cksum = "1038301878\\s+3418\\s+prils_cntl.v";
chop($new_cksum = `cksum prils_cntl.v`);
die "Checksum failed for file prils_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### prils_dp.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/prils_dp.v > prils_dp.v") or die "Couldn't fork while building prils_dp.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building prils_dp.v: $!\n";
$expected_cksum = "2656413147\\s+3258\\s+prils_dp.v";
chop($new_cksum = `cksum prils_dp.v`);
die "Checksum failed for file prils_dp.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rcu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/rcu/rtl/rcu.v > rcu.v") or die "Couldn't fork while building rcu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rcu.v: $!\n";
$expected_cksum = "2115269363\\s+15913\\s+rcu.v";
chop($new_cksum = `cksum rcu.v`);
die "Checksum failed for file rcu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rcu_ctl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/rcu/rtl/rcu_ctl.v > rcu_ctl.v") or die "Couldn't fork while building rcu_ctl.v: $!\n";
print WRITEME <<EOF;
2143,2161d
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rcu_ctl.v: $!\n";
$expected_cksum = "1465119351\\s+83279\\s+rcu_ctl.v";
chop($new_cksum = `cksum rcu_ctl.v`);
die "Checksum failed for file rcu_ctl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rcu_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/rcu/rtl/rcu_dpath.v > rcu_dpath.v") or die "Couldn't fork while building rcu_dpath.v: $!\n";
print WRITEME <<EOF;
838,839d
834,836c
assign #1 do_a[31:0]= ram[add_a[5:0]];
assign #1 do_b[31:0]= ram[add_b[5:0]];
assign #1 do_c[31:0]= ram[add_c[5:0]];
.
829,831d
826,827c
always @ (posedge clk) begin
     if (we_d) ram[add_d[5:0]] <= di_d[31:0];
     if (we_e) ram[add_e[5:0]] <= di_e[31:0];
.
824a
reg [31:0] ram [63:0];

.
822,823c
// make a synthesizable register file
.
808a
input		clk;
.
794a
	clk,
.
585,586c
		.we_d(iu_data_we_w & !scache_wr_miss_w),
		.we_e(smu_we) );
.
575c
rf	scache(.clk(clk),
		.do_a(scache_dout_rs1),
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rcu_dpath.v: $!\n";
$expected_cksum = "1480829501\\s+28355\\s+rcu_dpath.v";
chop($new_cksum = `cksum rcu_dpath.v`);
die "Checksum failed for file rcu_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rs1_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/rs1_dec.v > rs1_dec.v") or die "Couldn't fork while building rs1_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rs1_dec.v: $!\n";
$expected_cksum = "783141423\\s+16933\\s+rs1_dec.v";
chop($new_cksum = `cksum rs1_dec.v`);
die "Checksum failed for file rs1_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rs2_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/rs2_dec.v > rs2_dec.v") or die "Couldn't fork while building rs2_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rs2_dec.v: $!\n";
$expected_cksum = "4160262263\\s+5758\\s+rs2_dec.v";
chop($new_cksum = `cksum rs2_dec.v`);
die "Checksum failed for file rs2_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rsadd.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/rsadd.v > rsadd.v") or die "Couldn't fork while building rsadd.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rsadd.v: $!\n";
$expected_cksum = "3747254399\\s+3234\\s+rsadd.v";
chop($new_cksum = `cksum rsadd.v`);
die "Checksum failed for file rsadd.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rsadd_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/rsadd_cntl.v > rsadd_cntl.v") or die "Couldn't fork while building rsadd_cntl.v: $!\n";
print WRITEME <<EOF;
243c
      case(rsfunc)
.
229c
      casex(rsfunc)
.
202c
      casex(nx_rsfunc_rom1)
.
189c
      casex(nx_rsfunc_rom0)
.
137c
    casex(incinfunc)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rsadd_cntl.v: $!\n";
$expected_cksum = "2127493508\\s+6453\\s+rsadd_cntl.v";
chop($new_cksum = `cksum rsadd_cntl.v`);
die "Checksum failed for file rsadd_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rsadd_dp.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/rsadd_dp.v > rsadd_dp.v") or die "Couldn't fork while building rsadd_dp.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rsadd_dp.v: $!\n";
$expected_cksum = "3655490803\\s+2431\\s+rsadd_dp.v";
chop($new_cksum = `cksum rsadd_dp.v`);
die "Checksum failed for file rsadd_dp.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### rsd_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/rsd_dec.v > rsd_dec.v") or die "Couldn't fork while building rsd_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building rsd_dec.v: $!\n";
$expected_cksum = "2318137679\\s+3312\\s+rsd_dec.v";
chop($new_cksum = `cksum rsd_dec.v`);
die "Checksum failed for file rsd_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### smu.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/smu/rtl/smu.v > smu.v") or die "Couldn't fork while building smu.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building smu.v: $!\n";
$expected_cksum = "695316757\\s+5592\\s+smu.v";
chop($new_cksum = `cksum smu.v`);
die "Checksum failed for file smu.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### smu_ctl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/smu/rtl/smu_ctl.v > smu_ctl.v") or die "Couldn't fork while building smu_ctl.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building smu_ctl.v: $!\n";
$expected_cksum = "1229749813\\s+23772\\s+smu_ctl.v";
chop($new_cksum = `cksum smu_ctl.v`);
die "Checksum failed for file smu_ctl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### smu_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/smu/rtl/smu_dpath.v > smu_dpath.v") or die "Couldn't fork while building smu_dpath.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building smu_dpath.v: $!\n";
$expected_cksum = "4217192775\\s+7392\\s+smu_dpath.v";
chop($new_cksum = `cksum smu_dpath.v`);
die "Checksum failed for file smu_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### spare.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/rtl/spare.v > spare.v") or die "Couldn't fork while building spare.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building spare.v: $!\n";
$expected_cksum = "1835727467\\s+1223\\s+spare.v";
chop($new_cksum = `cksum spare.v`);
die "Checksum failed for file spare.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### timescale.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/sim/env/timescale.v > timescale.v") or die "Couldn't fork while building timescale.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building timescale.v: $!\n";
$expected_cksum = "1117250881\\s+1159\\s+timescale.v";
chop($new_cksum = `cksum timescale.v`);
die "Checksum failed for file timescale.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### trap.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/pipe/rtl/trap.v > trap.v") or die "Couldn't fork while building trap.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building trap.v: $!\n";
$expected_cksum = "2922432824\\s+19847\\s+trap.v";
chop($new_cksum = `cksum trap.v`);
die "Checksum failed for file trap.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode.v > ucode.v") or die "Couldn't fork while building ucode.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode.v: $!\n";
$expected_cksum = "163632468\\s+13544\\s+ucode.v";
chop($new_cksum = `cksum ucode.v`);
die "Checksum failed for file ucode.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_ctrl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_ctrl.v > ucode_ctrl.v") or die "Couldn't fork while building ucode_ctrl.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_ctrl.v: $!\n";
$expected_cksum = "2440986344\\s+9572\\s+ucode_ctrl.v";
chop($new_cksum = `cksum ucode_ctrl.v`);
die "Checksum failed for file ucode_ctrl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_dat.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_dat.v > ucode_dat.v") or die "Couldn't fork while building ucode_dat.v: $!\n";
print WRITEME <<EOF;
658c
    case(u_f16)
.
526c
    case(u_f09)
.
494c
    case(u_f08)
.
472c
    case(u_f13)
.
449c
    case(u_f12)
.
423c
    case(u_f10)
.
373c
    case(u_f07)
.
358c
    case(u_f06)
.
320c
    case(u_f06)
.
301c
    case(u_f20)
.
261c
    case(u_f20)
.
226c
    case(u_f19)
.
98c
`include "ucode.h"
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_dat.v: $!\n";
$expected_cksum = "1891468349\\s+26206\\s+ucode_dat.v";
chop($new_cksum = `cksum ucode_dat.v`);
die "Checksum failed for file ucode_dat.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_dec.v > ucode_dec.v") or die "Couldn't fork while building ucode_dec.v: $!\n";
print WRITEME <<EOF;
229c
    case({bit1,bit0})
.
173c
`include  "ucode.h"
.
56c
    casex({valid_op_r,opcode_1_op_r,opcode_2_op_r})
.
35c
`include  "ucode.h"
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_dec.v: $!\n";
$expected_cksum = "819093662\\s+10761\\s+ucode_dec.v";
chop($new_cksum = `cksum ucode_dec.v`);
die "Checksum failed for file ucode_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_dpath.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_dpath.v > ucode_dpath.v") or die "Couldn't fork while building ucode_dpath.v: $!\n";
print WRITEME <<EOF;
72a
`include "ucode.h"

.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_dpath.v: $!\n";
$expected_cksum = "2234184702\\s+10680\\s+ucode_dpath.v";
chop($new_cksum = `cksum ucode_dpath.v`);
die "Checksum failed for file ucode_dpath.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_ind.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_ind.v > ucode_ind.v") or die "Couldn't fork while building ucode_ind.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_ind.v: $!\n";
$expected_cksum = "3977606067\\s+3127\\s+ucode_ind.v";
chop($new_cksum = `cksum ucode_ind.v`);
die "Checksum failed for file ucode_ind.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_lib.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_lib.v > ucode_lib.v") or die "Couldn't fork while building ucode_lib.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_lib.v: $!\n";
$expected_cksum = "2723842220\\s+5911\\s+ucode_lib.v";
chop($new_cksum = `cksum ucode_lib.v`);
die "Checksum failed for file ucode_lib.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_reg.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_reg.v > ucode_reg.v") or die "Couldn't fork while building ucode_reg.v: $!\n";
print WRITEME <<EOF;
57a
`include "ucode.h"

.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_reg.v: $!\n";
$expected_cksum = "2806422990\\s+9246\\s+ucode_reg.v";
chop($new_cksum = `cksum ucode_reg.v`);
die "Checksum failed for file ucode_reg.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode_seq.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode_seq.v > ucode_seq.v") or die "Couldn't fork while building ucode_seq.v: $!\n";
print WRITEME <<EOF;
175c
    case({bit1,bit0})
.
61a
`include "ucode.h"

.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode_seq.v: $!\n";
$expected_cksum = "3387925134\\s+15483\\s+ucode_seq.v";
chop($new_cksum = `cksum ucode_seq.v`);
die "Checksum failed for file ucode_seq.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### valid_dec.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ifu/rtl/valid_dec.v > valid_dec.v") or die "Couldn't fork while building valid_dec.v: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building valid_dec.v: $!\n";
$expected_cksum = "2441368702\\s+4811\\s+valid_dec.v";
chop($new_cksum = `cksum valid_dec.v`);
die "Checksum failed for file valid_dec.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### wrbuf_cntl.v

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/dcu/rtl/wrbuf_cntl.v > wrbuf_cntl.v") or die "Couldn't fork while building wrbuf_cntl.v: $!\n";
print WRITEME <<EOF;
196c
case (cur_state)
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building wrbuf_cntl.v: $!\n";
$expected_cksum = "2364233656\\s+8866\\s+wrbuf_cntl.v";
chop($new_cksum = `cksum wrbuf_cntl.v`);
die "Checksum failed for file wrbuf_cntl.v\n" unless ($new_cksum =~ /$expected_cksum/);

##### defines.h

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/rtl/defines.h > defines.h") or die "Couldn't fork while building defines.h: $!\n";
print WRITEME <<EOF;
187,188c
`define ITAG_MODULE itag_dummy
`define ICRAM_MODULE icram_dummy
.
175,176c
//`define ITAG_MODULE itag_shell
//`define ICRAM_MODULE icram_shell
.
113,114c
`define DTAG_MODULE dtag_dummy
`define DCRAM_MODULE dcram_dummy
.
101,102c
//`define DTAG_MODULE dtag_shell
//`define DCRAM_MODULE dcram_shell
.
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building defines.h: $!\n";
$expected_cksum = "2820033919\\s+7563\\s+defines.h";
chop($new_cksum = `cksum defines.h`);
die "Checksum failed for file defines.h\n" unless ($new_cksum =~ /$expected_cksum/);

##### fpu.h

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/fpu/rtl/fpu.h > fpu.h") or die "Couldn't fork while building fpu.h: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building fpu.h: $!\n";
$expected_cksum = "2833804004\\s+1590\\s+fpu.h";
chop($new_cksum = `cksum fpu.h`);
die "Checksum failed for file fpu.h\n" unless ($new_cksum =~ /$expected_cksum/);

##### ucode.h

$pid = open(WRITEME, "| ed -s ${sourcedir}/picoJava-II/design/iu/ucode/rtl/ucode.h > ucode.h") or die "Couldn't fork while building ucode.h: $!\n";
print WRITEME <<EOF;
1,\$p
EOF
close (WRITEME) or die "Couldn't close while building ucode.h: $!\n";
$expected_cksum = "781134570\\s+15631\\s+ucode.h";
chop($new_cksum = `cksum ucode.h`);
die "Checksum failed for file ucode.h\n" unless ($new_cksum =~ /$expected_cksum/);

############################################################################
