Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  Voneline
  WFH
General Info
  Papers

verilator-savable.patch

Alex Chadwick, 06/14/2019 08:58 AM

Download (4.12 KB)

View differences:

src/V3EmitC.cpp
1955 1955
                    else if (varp->isStatic() && varp->isConst()) {}
1956 1956
                    else {
1957 1957
                        int vects = 0;
1958
                        // This isn't very robust and may need cleanup for other data types
1958
                        AstNodeDType* basicp = NULL;
1959 1959
                        for (AstUnpackArrayDType* arrayp
1960
                                 = VN_CAST(varp->dtypeSkipRefp(), UnpackArrayDType);
1960
                                 = VN_CAST(basicp = varp->dtypeSkipRefp(), UnpackArrayDType);
1961 1961
                             arrayp;
1962
                             arrayp = VN_CAST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) {
1962
                             arrayp = VN_CAST(basicp = arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) {
1963 1963
                            int vecnum = vects++;
1964 1964
                            if (arrayp->msb() < arrayp->lsb()) {
1965 1965
                                varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
......
1971 1971
                            puts(" for (; "+ivar+"<"+cvtToStr(arrayp->elementsConst()));
1972 1972
                            puts("; ++"+ivar+") {\n");
1973 1973
                        }
1974
                        if (varp->basicp() && (varp->basicp()->keyword() == AstBasicDTypeKwd::STRING
1975
                                               || !varp->basicp()->isWide())) {
1976
                            puts("os"+op+varp->name());
1977
                            for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
1978
                            puts(";\n");
1979
                        } else {
1980
                            puts("os."+writeread+"(&"+varp->name());
1981
                            for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
1982
                            puts(",sizeof("+varp->name());
1983
                            for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
1984
                            puts("));\n");
1974
                        if (!(basicp->widthMin() <= 16 || basicp->isQuad() || !basicp->isWide())) {
1975
                            int vecnum = vects++;
1976
                            string ivar = string("__Vi")+cvtToStr(vecnum);
1977
                            puts("{ int __Vi"+cvtToStr(vecnum)+"="+cvtToStr(0)+";");
1978
                            puts(" for (; "+ivar+"<"+cvtToStr(basicp->widthWords()));
1979
                            puts("; ++"+ivar+") {\n");
1985 1980
                        }
1981
                        puts("os"+op+varp->name());
1982
                        for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
1983
                        puts(";\n");
1986 1984
                        for (int v=0; v<vects; ++v) puts( "}}\n");
1987 1985
                    }
1988 1986
                }
test_regress/t/t_savable.v
30 30
   reg [1:0] 	save2;
31 31
   reg [255:0] 	cycdone;  // Make sure each cycle executes exactly once
32 32
   reg [31:0]	vec[2:1][2:1];
33
   reg [2:1][2:1][31:0]	pvec;
33 34
   real		r;
34 35
   string	s,s2;
35 36

  
......
53 54
	 vec[1][2] <= 32'h0102;
54 55
	 vec[2][1] <= 32'h0201;
55 56
	 vec[2][2] <= 32'h0202;
57
	 pvec[1][1] <= 32'h10101;
58
	 pvec[1][2] <= 32'h10102;
59
	 pvec[2][1] <= 32'h10201;
60
	 pvec[2][2] <= 32'h10202;
56 61
	 r <= 1.234;
57 62
	 s <= "hello";
58 63
      end
......
72 77
	 if (vec[1][2] !== 32'h0102) $stop;
73 78
	 if (vec[2][1] !== 32'h0201) $stop;
74 79
	 if (vec[2][2] !== 32'h0202) $stop;
80
	 if (pvec[1][1] !== 32'h10101) $stop;
81
	 if (pvec[1][2] !== 32'h10102) $stop;
82
	 if (pvec[2][1] !== 32'h10201) $stop;
83
	 if (pvec[2][2] !== 32'h10202) $stop;
75 84
	 if (r != 1.234) $stop;
76 85
	 $display("%s",s);
77 86
	 $write("*-* All Finished *-*\n");