diff --git a/j1b/mem_dump.fs b/j1b/mem_dump.fs new file mode 100644 index 0000000..5dca2ef --- /dev/null +++ b/j1b/mem_dump.fs @@ -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 + + diff --git a/j1b/user.fs b/j1b/user.fs new file mode 100644 index 0000000..353d60e --- /dev/null +++ b/j1b/user.fs @@ -0,0 +1,4 @@ +\ Put your words here +: user_test + ." This is a simple user defined word " +; diff --git a/j1b/verilator/j1b.v b/j1b/verilator/j1b.v index d0e40af..507492a 100644 --- a/j1b/verilator/j1b.v +++ b/j1b/verilator/j1b.v @@ -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 @@ -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 + diff --git a/j1b/verilator/localtest_gen_hex b/j1b/verilator/localtest_gen_hex new file mode 100755 index 0000000..390d00b --- /dev/null +++ b/j1b/verilator/localtest_gen_hex @@ -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 diff --git a/j1b/verilator/localtest_interactive b/j1b/verilator/localtest_interactive new file mode 100755 index 0000000..2a83803 --- /dev/null +++ b/j1b/verilator/localtest_interactive @@ -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