Introduce model interface class, make $root part or Syms (#3036)
This patch implements #3032. Verilator creates a module representing the
SystemVerilog $root scope (V3LinkLevel::wrapTop). Until now, this was
called the "TOP" module, which also acted as the user instantiated model
class. Syms used to hold a pointer to this root module, but hold
instances of any submodule. This patch renames this root scope module
from "TOP" to "$root", and introduces a separate model class which is
now an interface class. As the root module is no longer the user
interface class, it can now be made an instance of Syms, just like any
other submodule. This allows absolute references into the root module to
avoid an additional pointer indirection resulting in a potential speedup
(about 1.5% on OpenTitan). The model class now also contains all non
design specific generated code (e.g.: eval loops, trace config, etc),
which additionally simplifies Verilator internals.
Please see the updated documentation for the model interface changes.
2021-06-21 14:30:20 +00:00
|
|
|
module Vt_debug_emitv___024root;
|
2020-09-07 16:58:30 +00:00
|
|
|
input logic clk;
|
|
|
|
input logic in;
|
2020-12-08 23:29:45 +00:00
|
|
|
signed int [31:0] t.array[0:2];
|
|
|
|
logic [15:0] t.pubflat;
|
|
|
|
logic [15:0] t.pubflat_r;
|
|
|
|
signed int [31:0] t.fd;
|
|
|
|
signed int [31:0] t.i;
|
|
|
|
signed int [31:0] t.cyc;
|
|
|
|
signed int [31:0] t.fo;
|
|
|
|
signed int [31:0] t.sum;
|
2021-03-28 18:05:16 +00:00
|
|
|
signed real t.r;
|
2020-12-08 23:29:45 +00:00
|
|
|
string t.str;
|
|
|
|
signed int [31:0] t._Vpast_0_0;
|
|
|
|
signed int [31:0] t._Vpast_1_0;
|
|
|
|
signed int [31:0] t.unnamedblk3.i;
|
2020-09-07 16:58:30 +00:00
|
|
|
@(*)@([settle])@([initial])@(posedge clk)@(negedge
|
|
|
|
clk)always @(
|
|
|
|
*)@(
|
|
|
|
[settle])@(
|
|
|
|
[initial])@(
|
|
|
|
posedge
|
|
|
|
clk)@(
|
|
|
|
negedge
|
|
|
|
clk) begin
|
|
|
|
$display("stmt");
|
|
|
|
end
|
|
|
|
always @([settle])@([initial])@(posedge clk)@(negedge
|
|
|
|
clk) begin
|
|
|
|
$display("stmt");
|
|
|
|
end
|
|
|
|
initial begin
|
|
|
|
// Function: f
|
|
|
|
$write("stmt\nstmt 0 99\n");
|
|
|
|
// Function: t
|
|
|
|
$display("stmt");
|
|
|
|
// Function: f
|
|
|
|
$write("stmt\nstmt 1 -1\n");
|
|
|
|
// Function: t
|
|
|
|
$display("stmt");
|
|
|
|
// Function: f
|
|
|
|
$display("stmt");
|
|
|
|
$display("stmt 2 -2");
|
|
|
|
// Function: t
|
|
|
|
$display("stmt");
|
|
|
|
$display("stmt");
|
|
|
|
end
|
2021-06-04 14:00:13 +00:00
|
|
|
|
2020-09-07 16:58:30 +00:00
|
|
|
???? // CFUNC '_final_TOP'
|
|
|
|
$display("stmt");
|
|
|
|
always @(posedge clk)@(negedge clk) begin
|
|
|
|
$display("posedge clk");
|
|
|
|
end
|
|
|
|
always @(posedge clk)@(negedge clk) begin
|
|
|
|
__Vdly__t.pubflat_r <= t.pubflat;
|
|
|
|
end
|
|
|
|
always @(posedge clk)@(negedge clk) begin
|
|
|
|
__Vdly__t.cyc <= (32'sh1 + t.cyc);
|
2021-03-28 18:05:16 +00:00
|
|
|
__Vdly__t.r <= (0.01 + t.r);
|
2020-09-07 16:58:30 +00:00
|
|
|
t.fo = t.cyc;
|
|
|
|
// Function: inc
|
|
|
|
__Vtask_t.sub.inc__2__i = t.fo;
|
|
|
|
__Vtask_t.sub.inc__2__o = (32'h1 + __Vtask_t.sub.inc__2__i[31:1]);
|
|
|
|
t.sum = __Vtask_t.sub.inc__2__o;
|
|
|
|
// Function: f
|
|
|
|
__Vfunc_t.sub.f__3__v = t.sum;
|
|
|
|
begin : label0
|
|
|
|
begin : label0
|
|
|
|
if ((32'sh0 == __Vfunc_t.sub.f__3__v)) begin
|
|
|
|
__Vfunc_t.sub.f__3__Vfuncout = 32'sh21;
|
|
|
|
disable label0;
|
|
|
|
end
|
|
|
|
__Vfunc_t.sub.f__3__Vfuncout = (32'h1
|
|
|
|
+ __Vfunc_t.sub.f__3__v[2]);
|
|
|
|
disable label0;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
t.sum = __Vfunc_t.sub.f__3__Vfuncout;
|
2020-09-19 01:27:36 +00:00
|
|
|
$display("[%0t] sum = %~", $timet.sum, t.sum);
|
2020-12-08 04:15:29 +00:00
|
|
|
$display("a?= %d", ($c(32'sh1) ? $c(32'sh14)
|
|
|
|
: $c(32'sh1e)));
|
2020-09-07 16:58:30 +00:00
|
|
|
$c(;);
|
|
|
|
$display("%d", $c(0));
|
|
|
|
$fopen(72'h2f6465762f6e756c6c);
|
|
|
|
$fclose(t.fd);
|
|
|
|
$fopen(72'h2f6465762f6e756c6c, 8'h72);
|
|
|
|
$fgetc(t.fd);
|
|
|
|
$fflush(t.fd);
|
|
|
|
$fscanf(t.fd, "%d", t.sum);
|
|
|
|
;
|
2021-11-17 23:50:52 +00:00
|
|
|
$fdisplay(32'h69203d20, "%~", t.sum);
|
2020-09-07 16:58:30 +00:00
|
|
|
$fwrite(t.fd, "hello");
|
|
|
|
$readmemh(t.fd, t.array);
|
|
|
|
$readmemh(t.fd, t.array, 32'sh0);
|
|
|
|
$readmemh(t.fd, t.array, 32'sh0, 32'sh0);
|
|
|
|
t.sum = 32'sh0;
|
|
|
|
t.unnamedblk3.i = 32'sh0;
|
|
|
|
begin : label0
|
|
|
|
while ((t.unnamedblk3.i < t.cyc)) begin
|
|
|
|
t.sum = (t.sum + t.unnamedblk3.i);
|
|
|
|
if ((32'sha < t.sum)) begin
|
|
|
|
disable label0;
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
t.sum = (32'sh1 + t.sum);
|
|
|
|
end
|
|
|
|
t.unnamedblk3.i = (32'h1 + t.unnamedblk3.i);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if ((32'sh63 == t.cyc)) begin
|
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
if ((32'sh64 == t.cyc)) begin
|
|
|
|
$stop;
|
|
|
|
end
|
|
|
|
if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("default");
|
|
|
|
end
|
|
|
|
if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("default");
|
|
|
|
end
|
|
|
|
if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("default");
|
|
|
|
end
|
|
|
|
if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("default");
|
|
|
|
end
|
|
|
|
if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("0");
|
|
|
|
end
|
|
|
|
priority if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("0");
|
|
|
|
end
|
|
|
|
unique if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("0");
|
|
|
|
end
|
|
|
|
unique0 if (in) begin
|
|
|
|
$display("1");
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
$display("0");
|
|
|
|
end
|
2021-11-17 23:50:52 +00:00
|
|
|
$display("%~%~", t._Vpast_0_0t._Vpast_1_0,
|
2020-09-07 16:58:30 +00:00
|
|
|
t._Vpast_1_0);
|
|
|
|
t.str = $sformatf("cyc=%~", t.cyc);
|
|
|
|
;
|
|
|
|
$display("str = %@", t.str);
|
2020-10-14 01:13:52 +00:00
|
|
|
$display("%% [%t] [%^] to=%o td=%d", $time$realtime
|
|
|
|
$time$time, $realtime$time$time, $time
|
|
|
|
$time, $time);
|
2020-09-19 01:27:36 +00:00
|
|
|
$sscanf(40'h666f6f3d35, "foo=%d", t.i);
|
|
|
|
;
|
2020-12-08 04:15:29 +00:00
|
|
|
$printtimescale;
|
2020-09-19 01:27:36 +00:00
|
|
|
if ((32'sh5 != t.i)) begin
|
|
|
|
$stop;
|
|
|
|
end
|
2020-11-20 02:32:33 +00:00
|
|
|
t.sum =
|
|
|
|
???? // RAND
|
|
|
|
32'sha;
|
2021-03-28 18:05:16 +00:00
|
|
|
$display("%g", $log10(t.r));
|
|
|
|
$display("%g", $ln(t.r));
|
|
|
|
$display("%g", $exp(t.r));
|
|
|
|
$display("%g", $sqrt(t.r));
|
|
|
|
$display("%g", $floor(t.r));
|
|
|
|
$display("%g", $ceil(t.r));
|
|
|
|
$display("%g", $sin(t.r));
|
|
|
|
$display("%g", $cos(t.r));
|
|
|
|
$display("%g", $tan(t.r));
|
|
|
|
$display("%g", $asin(t.r));
|
|
|
|
$display("%g", $acos(t.r));
|
|
|
|
$display("%g", $atan(t.r));
|
|
|
|
$display("%g", $sinh(t.r));
|
|
|
|
$display("%g", $cosh(t.r));
|
|
|
|
$display("%g", $tanh(t.r));
|
|
|
|
$display("%g", $asinh(t.r));
|
|
|
|
$display("%g", $acosh(t.r));
|
|
|
|
$display("%g", $atanh(t.r));
|
2020-09-07 16:58:30 +00:00
|
|
|
end
|
|
|
|
/*verilator public_flat_rw @(posedge clk)@(negedge
|
|
|
|
clk) t.pubflat*/
|
|
|
|
always @(posedge clk)@(negedge clk) begin
|
|
|
|
__Vdly__t._Vpast_0_0 <= t.cyc;
|
|
|
|
end
|
|
|
|
always @(posedge clk)@(negedge clk) begin
|
|
|
|
__Vdly__t._Vpast_1_0 <= t.cyc;
|
|
|
|
end
|
|
|
|
__Vdly__t._Vpast_1_0 = t._Vpast_1_0;
|
|
|
|
t._Vpast_1_0 = __Vdly__t._Vpast_1_0;
|
|
|
|
__Vdly__t._Vpast_0_0 = t._Vpast_0_0;
|
|
|
|
t._Vpast_0_0 = __Vdly__t._Vpast_0_0;
|
2021-03-28 18:05:16 +00:00
|
|
|
__Vdly__t.r = t.r;
|
|
|
|
t.r = __Vdly__t.r;
|
2020-09-07 16:58:30 +00:00
|
|
|
__Vdly__t.cyc = t.cyc;
|
|
|
|
t.cyc = __Vdly__t.cyc;
|
|
|
|
__Vdly__t.pubflat_r = t.pubflat_r;
|
|
|
|
t.pubflat_r = __Vdly__t.pubflat_r;
|
|
|
|
always @(negedge clk) begin
|
|
|
|
$display("negedge clk, pfr = %x", t.pubflat_r);
|
|
|
|
end
|
2020-12-08 23:29:45 +00:00
|
|
|
signed int [31:0] __Vtask_t.sub.inc__2__i;
|
|
|
|
signed int [31:0] __Vtask_t.sub.inc__2__o;
|
|
|
|
signed int [31:0] __Vfunc_t.sub.f__3__Vfuncout;
|
|
|
|
signed int [31:0] __Vfunc_t.sub.f__3__v;
|
|
|
|
logic [15:0] __Vdly__t.pubflat_r;
|
|
|
|
signed int [31:0] __Vdly__t.cyc;
|
2021-03-28 18:05:16 +00:00
|
|
|
signed real __Vdly__t.r;
|
2020-12-08 23:29:45 +00:00
|
|
|
signed int [31:0] __Vdly__t._Vpast_0_0;
|
|
|
|
signed int [31:0] __Vdly__t._Vpast_1_0;
|
2020-09-07 16:58:30 +00:00
|
|
|
endmodule
|
2020-12-08 04:15:29 +00:00
|
|
|
package Vt_debug_emitv___024unit;
|
|
|
|
endpackage
|
|
|
|
package Vt_debug_emitv_Pkg;
|
|
|
|
endpackage
|
|
|
|
class Vt_debug_emitv___024unit__03a__03aCls;
|
2020-12-08 23:29:45 +00:00
|
|
|
signed int [31:0] member;
|
2020-12-08 04:15:29 +00:00
|
|
|
|
|
|
|
???? // CFUNC '__VnoInFunc_method'
|
|
|
|
|
|
|
|
???? // CFUNC 'new'
|
|
|
|
$_CSTMT(_ctor_var_reset(vlSymsp);
|
|
|
|
);
|
|
|
|
$unit::Cls.member = 32'sh1;
|
|
|
|
endclass
|
|
|
|
/*class*/package Vt_debug_emitv___024unit__03a__03aCls__Vclpkg;
|
|
|
|
end/*class*/package
|