fork download
  1. # your code goes here
  2.  
  3. import re
  4.  
  5. entBody = """entity pci_bfm is
  6. generic(
  7. G_INST_NAME : string := "PCI_BFM";
  8. G_HANDLE_NO : rpciBfmHandleNo := 0;
  9. G_IDSEL_POS_EXT_TARGET : idsel_pos := 30;
  10. G_IDSEL_POS_INT_TARGET : idsel_pos := 29
  11. );
  12. port(
  13. i_tb_stop : in boolean; -- Testbench global sto
  14. o_clk : out std_logic; -- PCI clock.
  15. o_rstn : out std_logic; -- PCI reset.
  16. o_idsel : out std_logic; -- Initialization devic
  17. i_reqn : in std_logic; -- Request. The reqn in
  18. o_gntn : out std_logic; -- Grant. The gntn onpu
  19. io_ad : inout std_logic_vector(31 downto 0); -- Address/data bus. Th
  20. io_cben : inout std_logic_vector(3 downto 0); -- Command/byte enable.
  21. io_par : inout std_logic; -- Parity. The par sign
  22. io_framen : inout std_logic; -- Frame. The framen si
  23. io_irdyn : inout std_logic; -- Initiator ready. The
  24. io_devseln : inout std_logic; -- Device select. Targe
  25. io_trdyn : inout std_logic; -- Target ready. The tr
  26. io_stopn : inout std_logic; -- Stop. The stopn sign
  27. io_perrn : inout std_logic; -- Parity error. The pe
  28. i_serrn : in std_logic; -- System error. The se
  29. i_intan : in std_logic; -- Interrupt A. The int
  30. o_lockn : out std_logic -- Locked operations. R
  31. );
  32. end entity pci_bfm;"""
  33.  
  34. entBody2 = """entity QSPI_FLASH_SPANSION_S25FL_BFM is
  35. generic
  36. (
  37. G_INST_NAME : string := "QSPI_FLASH_SPANSION_S25FL_BFM";
  38. G_HANDLE_NO : integer := 2
  39. );
  40. port (
  41. tb_stop : in boolean; -- Testbench global stop.
  42. sclk : in std_logic;
  43. csn : in std_logic;
  44. sdat : inout std_logic_vector(3 downto 0));
  45. end;"""
  46.  
  47. regex = re.compile(r'port\s*\((.+)\);', re.DOTALL)
  48.  
  49. m1 = regex.search(entBody)
  50. print(m1.group(1))
  51.  
  52. print('\n-------\n')
  53.  
  54. m2 = regex.search(entBody2)
  55. print(m2.group(1))
  56.  
  57.  
  58.  
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
                                                                      
    i_tb_stop  : in    boolean;                       -- Testbench global sto
    o_clk      : out   std_logic;                     -- PCI clock.          
    o_rstn     : out   std_logic;                     -- PCI reset.          
    o_idsel    : out   std_logic;                     -- Initialization devic
    i_reqn     : in    std_logic;                     -- Request. The reqn in
    o_gntn     : out   std_logic;                     -- Grant. The gntn onpu
    io_ad      : inout std_logic_vector(31 downto 0); -- Address/data bus. Th
    io_cben    : inout std_logic_vector(3 downto 0);  -- Command/byte enable.
    io_par     : inout std_logic;                     -- Parity. The par sign
    io_framen  : inout std_logic;                     -- Frame. The framen si
    io_irdyn   : inout std_logic;                     -- Initiator ready. The
    io_devseln : inout std_logic;                     -- Device select. Targe
    io_trdyn   : inout std_logic;                     -- Target ready. The tr
    io_stopn   : inout std_logic;                     -- Stop. The stopn sign
    io_perrn   : inout std_logic;                     -- Parity error. The pe
    i_serrn    : in    std_logic;                     -- System error. The se
    i_intan    : in    std_logic;                     -- Interrupt A. The int
    o_lockn    : out   std_logic                      -- Locked operations. R
    

-------


    tb_stop : in    boolean;                       -- Testbench global stop.
    sclk    : in    std_logic;
    csn     : in    std_logic;
    sdat    : inout std_logic_vector(3 downto 0)