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(1).patch

Alex Chadwick, 06/14/2019 01:39 PM

Download (4.86 KB)

View differences:

docs/CONTRIBUTORS
5 5
Please see the Verilator manual for additional contributors.
6 6

  
7 7
Jeremy Bennett
8
Alex Chadwick
8 9
John Coiner
9 10
Kanad Kanhere
10 11
Richard Myers
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
1959
                        for (AstUnpackArrayDType* arrayp
1960
                                 = VN_CAST(varp->dtypeSkipRefp(), UnpackArrayDType);
1958
                        AstNodeDType* elementp = varp->dtypeSkipRefp();
1959
                        for (AstUnpackArrayDType* arrayp = VN_CAST(elementp, UnpackArrayDType);
1961 1960
                             arrayp;
1962
                             arrayp = VN_CAST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) {
1961
                             arrayp = VN_CAST(elementp, UnpackArrayDType)) {
1963 1962
                            int vecnum = vects++;
1964 1963
                            if (arrayp->msb() < arrayp->lsb()) {
1965 1964
                                varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
......
1970 1969
                            puts("{ int __Vi"+cvtToStr(vecnum)+"="+cvtToStr(0)+";");
1971 1970
                            puts(" for (; "+ivar+"<"+cvtToStr(arrayp->elementsConst()));
1972 1971
                            puts("; ++"+ivar+") {\n");
1972
                            elementp = arrayp->subDTypep()->skipRefp();
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
                        // Want to detect types that are represented as arrays
1975
                        // (i.e. packed types of more than 64 bits).
1976
                        AstBasicDType* basicp = elementp->basicp();
1977
                        if (elementp->isWide() && !(basicp && basicp->keyword() == AstBasicDTypeKwd::STRING)) {
1978
                            int vecnum = vects++;
1979
                            string ivar = string("__Vi")+cvtToStr(vecnum);
1980
                            puts("{ int __Vi"+cvtToStr(vecnum)+"="+cvtToStr(0)+";");
1981
                            puts(" for (; "+ivar+"<"+cvtToStr(elementp->widthWords()));
1982
                            puts("; ++"+ivar+") {\n");
1985 1983
                        }
1984
                        puts("os"+op+varp->name());
1985
                        for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
1986
                        puts(";\n");
1986 1987
                        for (int v=0; v<vects; ++v) puts( "}}\n");
1987 1988
                    }
1988 1989
                }
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;
36
   string	sarr[2:1];
35 37

  
36 38
   string 	si;
37 39

  
......
53 55
	 vec[1][2] <= 32'h0102;
54 56
	 vec[2][1] <= 32'h0201;
55 57
	 vec[2][2] <= 32'h0202;
58
	 pvec[1][1] <= 32'h10101;
59
	 pvec[1][2] <= 32'h10102;
60
	 pvec[2][1] <= 32'h10201;
61
	 pvec[2][2] <= 32'h10202;
56 62
	 r <= 1.234;
57 63
	 s <= "hello";
64
	 sarr[1] <= "sarr[1]";
65
	 sarr[2] <= "sarr[2]";
58 66
      end
59 67
      if (cyc==1) begin
60 68
	 if ($test$plusargs("save_restore")!=0) begin
......
72 80
	 if (vec[1][2] !== 32'h0102) $stop;
73 81
	 if (vec[2][1] !== 32'h0201) $stop;
74 82
	 if (vec[2][2] !== 32'h0202) $stop;
83
	 if (pvec[1][1] !== 32'h10101) $stop;
84
	 if (pvec[1][2] !== 32'h10102) $stop;
85
	 if (pvec[2][1] !== 32'h10201) $stop;
86
	 if (pvec[2][2] !== 32'h10202) $stop;
75 87
	 if (r != 1.234) $stop;
76 88
	 $display("%s",s);
89
	 $display("%s",sarr[1]);
90
	 $display("%s",sarr[2]);
77 91
	 $write("*-* All Finished *-*\n");
78 92
	 $finish;
79 93
      end