../src/lowrisc_dv_dpi_jtagdpi_0.1/jtagdpi.sv Cov: 71.4%

   1: // Copyright lowRISC contributors.
   2: // Licensed under the Apache License, Version 2.0, see LICENSE for details.
   3: // SPDX-License-Identifier: Apache-2.0
   4: 
   5: module jtagdpi #(
   6:   parameter string Name = "jtag0", // name of the JTAG interface (display only)
   7:   parameter int ListenPort = 44853 // TCP port to listen on
   8: )(
   9:   input  logic clk_i,
  10:   input  logic rst_ni,
  11: 
  12:   output logic jtag_tck,
  13:   output logic jtag_tms,
  14:   output logic jtag_tdi,
  15:   input  logic jtag_tdo,
  16:   output logic jtag_trst_n,
  17:   output logic jtag_srst_n
  18: );
  19: 
  20:   import "DPI-C"
  21:   function chandle jtagdpi_create(input string name, input int listen_port);
  22: 
  23:   import "DPI-C"
  24:   function void jtagdpi_tick(input chandle ctx, output bit tck, output bit tms,
  25:                              output bit tdi, output bit trst_n,
  26:                              output bit srst_n, input bit tdo);
  27: 
  28:   import "DPI-C"
  29:   function void jtagdpi_close(input chandle ctx);
  30: 
  31:   chandle ctx;
  32: 
  33:   initial begin
  34:     ctx = jtagdpi_create(Name, ListenPort);
  35:   end
  36: 
  37:   final begin
  38:     jtagdpi_close(ctx);
  39:     ctx = 0;
  40:   end
  41: 
  42:   always_ff @(posedge clk_i, negedge rst_ni) begin
  43:     jtagdpi_tick(ctx, jtag_tck, jtag_tms, jtag_tdi, jtag_trst_n, jtag_srst_n,
  44:                  jtag_tdo);
  45:   end
  46: 
  47: endmodule
  48: