[lowrisc-dev] help: nexys4_ddr/src/boot.mem and scripts/cnvmem.v weirdness

Gabriel L. Somlo gsomlo at gmail.com
Wed Dec 5 19:43:11 GMT 2018


Help, I'm stuck trying to replicate building src/boot.mem in nexys4_ddr.

First off, I'm not sure which of the Makefile targets is responsible
for the version of boot.mem that's currently provided by v0.6 (I'm
assuming it's "make boot" but might be "jump" or "eth" as well)?

Secondly, the current iverilog shipping with my Fedora 28 distro
(version 10, iverilog-10-8.fc28.x86_64) is doing something weird
with scripts/cnvmem.v:

...
     begin
        $readmemh("cnvmem.mem", mem);
        i = 32'h40000000;
        while ((i < 32'h42000000) && (1'bx === ^mem[i]))
          i=i+16;
        first = i;
        i = 32'h42000000;
        while ((i >= 32'h40000000) && (1'bx === ^mem[i]))
          i=i-16;
        last = (i+16);
        if (last < first + 'H10000)
             last = first + 'H10000;
        for (i = i+1; i < last; i=i+1)
          mem[i] = 0;
        $display("First = %X, Last = %X", first, last-1);
        for (i = first; i < last; i=i+1)
28:       if (1'bx === ^mem[i]) mem[i] = 0;	// ##### HERE !!!  #####

        for (i = first; i < last; i=i+16)
          begin
             mem2[(i/16)&'hFFF] = {mem[i+15],mem[i+14],mem[i+13],mem[i+12],
                                   mem[i+11],mem[i+10],mem[i+9],mem[i+8],
                                   mem[i+7],mem[i+6],mem[i+5],mem[i+4],
                                   mem[i+3],mem[i+2],mem[i+1],mem[i+0]};
          end
        fd = $fopen("cnvmem.hex", "w");
        for (i = 0; i <= 'hfff; i=i+1)
          $fdisplay(fd, "%32x", mem2[i]);
        $fclose(fd);
        fd = $fopen("cnvmem.coe", "w");
        $fdisplay(fd, "memory_initialization_radix=16;");
        $fdisplay(fd, "memory_initialization_vector=");
        for (i = 0; i <= 'hfff; i=i+1)
          $fdisplay(fd, "%32x", mem2[i]);
        $fclose(fd);
     end
...

On line 28 of the program, the check for "undefined" (8'hxx) bytes
matches against ALL values, so the script will spit out a boot.mem
file consisting ENTIRELY of 0s!

For testing, I want to comment out that line and "post-process" instead
with:

  sed -i 's/x/0/g' src/boot.mem

... but I don't know which makefile target I want (see question #1).

Thanks much for any clue and/or hypotheses as to what might be going on.

Cheers,
--Gabriel



More information about the lowrisc-dev mailing list