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

Gabriel L. Somlo gsomlo at gmail.com
Wed Dec 5 21:06:28 GMT 2018


Looks like I just accidentally landed on a buggy iverilog version.
It appears to be fixed in 10.2, which ships with newer Fedora
releases (29 and up).

I think "data2mem" would object to Xs in boot.mem (and yes, sed did
provide an adequate workaround, while I was waiting for the newer
iverilog to compile :)

Thanks again,
--Gabriel

On Wed, Dec 05, 2018 at 08:11:43PM +0000, Dr Jonathan Kimmitt wrote:
> That script was introduced to try to make the conversion process more portable and robust to address changes. There is undoubtedly an older version of iverilog that behaves as per the Ubuntu 16.04 version. There is an alternative method used in older releases of LowRISC that works in a similar way but also has some portability issues. I can’t remember when this change was made but definitely after the v0.3 release. As you suspected ‘make boot’ is the correct command. It may not even matter about X’s in the ROM image, since these areas are not meant to be used. However the first and last addresses would have to be fixed in this case (not a problem) if the X === detect does not work.
> 
> Obviously it would be rather trivial to write your own C, Python or Perl version of this converter.
> 
> Sent from my iPhone
> 
> > On 5 Dec 2018, at 19:43, Gabriel L. Somlo <gsomlo at gmail.com> wrote:
> > 
> > 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