diff --git a/verif/tb/verilog/nanosoc_tb.v b/verif/tb/verilog/nanosoc_tb.v index 9a99b2dc818d1232196ef67674ba8ad26dacd7f2..082a5914f62213832bc64ed6b15195a3b9cb54c3 100644 --- a/verif/tb/verilog/nanosoc_tb.v +++ b/verif/tb/verilog/nanosoc_tb.v @@ -363,15 +363,15 @@ nanosoc_ft1248x1_track `endif `ifndef COCOTB_SIM - nanosoc_uart_capture #(.LOGFILENAME("logs/ft1248_ip.log")) - u_nanosoc_uart_capture2( - .RESETn (NRST), - .CLK (ft_clk2uart), - .RXD (ft_txd2uart), - .DEBUG_TESTER_ENABLE ( ), - .SIMULATIONEND (), // This signal set to 1 at the end of simulation. - .AUXCTRL () - ); +// nanosoc_uart_capture #(.LOGFILENAME("logs/ft1248_ip.log")) +// u_nanosoc_uart_capture2( +// .RESETn (NRST), +// .CLK (ft_clk2uart), +// .RXD (ft_txd2uart), +// .DEBUG_TESTER_ENABLE ( ), +// .SIMULATIONEND (), // This signal set to 1 at the end of simulation. +// .AUXCTRL () +// ); `endif // -------------------------------------------------------------------------------- diff --git a/verif/trace/verilog/nanosoc_axi_stream_io_8_txd_from_file.v b/verif/trace/verilog/nanosoc_axi_stream_io_8_txd_from_file.v index 9b74cb571264ba8826b4e3db3acabf2bbdd6d4f5..084b2b16067e3000a4b0f441fa9c3692d998ed29 100644 --- a/verif/trace/verilog/nanosoc_axi_stream_io_8_txd_from_file.v +++ b/verif/trace/verilog/nanosoc_axi_stream_io_8_txd_from_file.v @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// customised example Cortex-M0 controller UART with file logging +// customised example ADP i/o stream controller (with code loader for netlist) // A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license. // // Contributors @@ -16,7 +16,8 @@ module nanosoc_axi_stream_io_8_txd_from_file - #(parameter TXDFILENAME = "txd.cmd", + #(parameter TXDFILENAME = "adp.cmd", + parameter CODEFILENAME = "image.hex", parameter VERBOSE = 0) ( input wire aclk, @@ -34,33 +35,100 @@ module nanosoc_axi_stream_io_8_txd_from_file integer fd; // channel descriptor for cmd file input integer ch; + + integer flen; + integer clen; + reg [31:0] codesize; + integer fp; + `define EOF -1 reg valid; reg [7:0] data8; - + +localparam BUFSIZE = (64 * 1024); + + reg [7:0] adpbuf [0:BUFSIZE-1]; + initial begin valid <= 0; -// $timeformat(-9, 0, " ns", 14); + flen = 0; + fd= $fopen(CODEFILENAME,"r"); + $write("** %m : input file : <%s> **\n", CODEFILENAME); + if (fd == 0) + $write("** %m : input file <%s> failed to open **\n", CODEFILENAME); + else begin + while (!$feof(fd)) begin + ch = $fgetc(fd); + flen = flen +1; + end + if (flen > 0) flen=flen-1; // correct for extra char count(???) + clen = (flen / 3); + codesize = clen[31:0]; + $write("** %m : flen: %d , codesize(flen/3): %d [0x%h]) **\n", flen, clen, codesize); + $fclose(fd); + end + // now build adp buffer + adpbuf[ 0] = 8'h1b; // <ESC> - enter ADP monitor + adpbuf[ 1] = "A"; // set address pointer + adpbuf[ 2] = " "; // to 0x20000000 + adpbuf[ 3] = "2"; // + adpbuf[ 4] = "0"; // + adpbuf[ 5] = "0"; // + adpbuf[ 6] = "0"; // + adpbuf[ 7] = "0"; // + adpbuf[ 8] = "0"; // + adpbuf[ 9] = "0"; // + adpbuf[10] = "0"; // + adpbuf[11] = 8'h0a; // newline + adpbuf[12] = "U"; // set upload filesize (N bytes) + adpbuf[13] = " "; // only up to 1Mbyte for now! + adpbuf[14] = "0" + codesize[19:16]; // + adpbuf[15] = "0" + codesize[15:12]; // + adpbuf[16] = "0" + codesize[11: 8]; // + adpbuf[17] = "0" + codesize[ 7: 4]; // + adpbuf[18] = "0" + codesize[ 3: 0]; // + adpbuf[19] = 8'h0a; // newline + $readmemh(CODEFILENAME, adpbuf, 20); + adpbuf[clen+20] = "C"; // control + adpbuf[clen+21] = " "; + adpbuf[clen+22] = "2"; // (gpio bit set) + adpbuf[clen+23] = "0"; + adpbuf[clen+24] = "1"; // assert reset to reboot + adpbuf[clen+25] = 8'h0a; // newline + // append any ADP command file to the code memory preload + flen =0; fd= $fopen(TXDFILENAME,"r"); + $write("** %m : input file : <%s> **\n", TXDFILENAME); if (fd == 0) - $write("** %m : input file failed to open **\n"); + $write("** %m : input file <%s> failed to open **\n", TXDFILENAME); else begin + while (!$feof(fd)) begin + adpbuf[clen+25 + flen] <= $fgetc(fd); + flen = flen +1; + end + $write("** %m : file closed after stream TX completed **\n"); + $fclose(fd); + end + if (flen > 0) flen=flen-1; // correct for extra char count(???) + // now output the entire adp buffer to the stream + flen = flen + clen+25+1; + fp = 0; + valid <= 0; + begin @(posedge aresetn); - ch = $fgetc(fd); - while (ch != `EOF) begin + while (fp < flen) begin @(posedge aclk); - data8 <= (ch & 8'hff); + data8 <= adpbuf[fp]; + fp = fp + 1; valid <= 1'b1; @(posedge aclk); while (txd8_ready == 1'b0) @(posedge aclk); valid <=0; - ch = $fgetc(fd); end - $write("** %m : file closed after stream TX completed **\n"); - $fclose(fd); + $write("** %m : adpbuf replay completed **\n"); valid <= 0; end end