Skip to content

Commit 181e4b9

Browse files
committed
update Verilator-related files to compile on version 4.228
- Starting from Verilator version 4.210, the model class is an interface object. For reaching Verilog variables internal to a module this means that we need to include an extra header in cpp files that reference them (#include "Vj1a___024root.h"). And they're now part of a rootp class which is a member of the model class; we need to add an extra level of indirection. So 'top->v__DOT__ram_prog[i] = v;' becomes 'top->rootp->v__DOT__ram_prog[i] = v;'. See https://verilator.org/guide/latest/connecting.html for more words. - I don't know when these were introduced, but Verilator has become more strict about allowing assignments to wires. So 'insn' has become a reg as we assign to it inside a procedural block. And the 'wire uart0_(wr|rd) = ..' wire declarations on line 60/61 were duplicates of the module port declarations.
1 parent 8dbff77 commit 181e4b9

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

j1a/verilator/j1a.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module j1a(input wire clk,
1919
/* verilator lint_off UNUSED */
2020
wire [12:0] code_addr;
2121
/* verilator lint_on UNUSED */
22-
wire [15:0] insn;
22+
reg [15:0] insn;
2323

2424
reg [15:0] ram_prog[0:4095] /* verilator public_flat */;
2525
always @(posedge clk) begin
@@ -57,8 +57,8 @@ module j1a(input wire clk,
5757

5858
// ###### UART ##########################################
5959

60-
wire uart0_wr = io_wr_ & io_addr_[12];
61-
wire uart0_rd = io_rd_ & io_addr_[12];
60+
assign uart0_wr = io_wr_ & io_addr_[12];
61+
assign uart0_rd = io_rd_ & io_addr_[12];
6262
assign uart_w = dout_[7:0];
6363

6464
// always @(posedge clk) begin

j1a/verilator/sim_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdio.h>
22
#include "Vj1a.h"
3+
#include "Vj1a___024root.h"
34
#include "verilated_vcd_c.h"
45

56
int main(int argc, char **argv)
@@ -20,7 +21,7 @@ int main(int argc, char **argv)
2021
fprintf(stderr, "invalid hex value at line %d\n", i + 1);
2122
exit(1);
2223
}
23-
top->v__DOT__ram_prog[i] = v;
24+
top->rootp->v__DOT__ram_prog[i] = v;
2425
}
2526

2627
top->resetq = 0;

j1a/verilator/vsim.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <assert.h>
22
#include "Vj1a.h"
3+
#include "Vj1a___024root.h"
34
#include "verilated.h"
45
#define VCD 0
56
#if VCD
@@ -60,7 +61,7 @@ Vj1a_init(v3 *self, PyObject *args, PyObject *kwds)
6061
fprintf(stderr, "invalid hex value at line %d\n", i + 1);
6162
exit(1);
6263
}
63-
self->dut->v__DOT__ram_prog[i] = v;
64+
self->dut->rootp->v__DOT__ram_prog[i] = v;
6465
}
6566
memset(self->rdepth, 0, sizeof(self->rdepth));
6667
memset(self->ddepth, 0, sizeof(self->ddepth));
@@ -126,11 +127,11 @@ static void cycle(v3* v)
126127
dut->clk = 1;
127128
dut->eval();
128129

129-
int pc = 4095 & dut->v__DOT___j1__DOT__pc;
130-
if (dut->v__DOT___j1__DOT__dstack__DOT__depth > v->ddepth[pc])
131-
v->ddepth[pc] = dut->v__DOT___j1__DOT__dstack__DOT__depth;
132-
if (dut->v__DOT___j1__DOT__rstack__DOT__depth > v->rdepth[pc])
133-
v->rdepth[pc] = dut->v__DOT___j1__DOT__rstack__DOT__depth;
130+
int pc = 4095 & dut->rootp->v__DOT___j1__DOT__pc;
131+
if (dut->rootp->v__DOT___j1__DOT__dstack__DOT__depth > v->ddepth[pc])
132+
v->ddepth[pc] = dut->rootp->v__DOT___j1__DOT__dstack__DOT__depth;
133+
if (dut->rootp->v__DOT___j1__DOT__rstack__DOT__depth > v->rdepth[pc])
134+
v->rdepth[pc] = dut->rootp->v__DOT___j1__DOT__rstack__DOT__depth;
134135
}
135136

136137
PyObject *v3_read(PyObject *_, PyObject *args)

j1b/verilator/sim_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <stdio.h>
22
#include "Vj1b.h"
3+
#include "Vj1b___024root.h"
34
#include "verilated_vcd_c.h"
45

56
int main(int argc, char **argv)
@@ -20,7 +21,7 @@ int main(int argc, char **argv)
2021
fprintf(stderr, "invalid hex value at line %d\n", i + 1);
2122
exit(1);
2223
}
23-
top->v__DOT__ram[i] = v;
24+
top->rootp->v__DOT__ram[i] = v;
2425
}
2526

2627
top->resetq = 0;

j1b/verilator/vsim.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <assert.h>
22
#include "Vj1b.h"
3+
#include "Vj1b___024root.h"
34
#include "verilated.h"
45
#define VCD 0
56
#if VCD
@@ -59,7 +60,7 @@ Vj1b_init(v3 *self, PyObject *args, PyObject *kwds)
5960
fprintf(stderr, "invalid hex value at line %d\n", i + 1);
6061
exit(1);
6162
}
62-
self->dut->v__DOT__ram[i] = v;
63+
self->dut->rootp->v__DOT__ram[i] = v;
6364
}
6465

6566
return 0;

0 commit comments

Comments
 (0)