Skip to content

The verilator testbench extended with possibility to dump the memory with all defined words to the hex file. #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions j1b/mem_dump.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\ Written by Wojciech M. Zabolotny for the testbench with memory dump
\ feature
$2345 io@ \ Dump the memory to mem_dump.hex


4 changes: 4 additions & 0 deletions j1b/user.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\ Put your words here
: user_test
." This is a simple user defined word "
;
21 changes: 17 additions & 4 deletions j1b/verilator/j1b.v
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ module j1b(input wire clk,

// ###### UART ##########################################

wire uart0_wr = io_wr_ & io_addr_[12];
wire uart0_rd = io_rd_ & io_addr_[12];
wire uart0_wr = io_wr_ & ( io_addr_ == 16'h1000 );
wire uart0_rd = io_rd_ & ( io_addr_ == 16'h1000 );
assign uart_w = dout_[7:0];

// always @(posedge clk) begin
Expand All @@ -79,7 +79,20 @@ module j1b(input wire clk,
*/

assign io_din =
(io_addr_[12] ? {24'd0, uart0_data} : 32'd0) |
(io_addr_[13] ? {28'd0, 1'b0, 1'b0, uart0_valid, 1'b1} : 32'd0);
(io_addr_ == 16'h1000 ? {24'd0, uart0_data} : 32'd0) |
(io_addr_ == 16'h2000 ? {28'd0, 1'b0, 1'b0, uart0_valid, 1'b1} : 32'd0);

// ###### DUMP MEMORY FUNCTION #############################
int fout;
int i;
always @(posedge clk) begin
if ( io_rd_ & ( io_addr_== 16'h2345 )) begin
fout = $fopen("mem_dump.hex","w");
for(i=0;i<=8191;i++)
$fdisplay(fout,"%8.8h",ram[i]);
$fclose(fout);
end
end

endmodule

15 changes: 15 additions & 0 deletions j1b/verilator/localtest_gen_hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set -e
make

# ( echo
# python expand.py ../swapforth.fs ../../demos/factorials.fs
# echo 42 FAC .FAC
# ) |
# obj_dir/Vj1a ../build/nuc.hex
# # grep 1,405,006,117,752,879,898,543,142,606,244,511,569,936,384,000,000,000

echo |
python shell.py -p ../ -p ../../common -p ../../anstests/ -p ../../../forth \
-e '#noverbose' swapforth.fs \
user.fs mem_dump.fs
#../runtests.fs # ../../demos/factorials.fs
14 changes: 14 additions & 0 deletions j1b/verilator/localtest_interactive
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set -e
make

# ( echo
# python expand.py ../swapforth.fs ../../demos/factorials.fs
# echo 42 FAC .FAC
# ) |
# obj_dir/Vj1a ../build/nuc.hex
# # grep 1,405,006,117,752,879,898,543,142,606,244,511,569,936,384,000,000,000

#echo |
python shell.py -p ../ -p ../../common -p ../../anstests/ -e '#noverbose' swapforth.fs \
user.fs
#../runtests.fs # ../../demos/factorials.fs