项目作者: akaeba

项目描述 :
Bus functional model of an Enhanced Serial Peripheral Interface (eSPI) master
高级语言: VHDL
项目地址: git://github.com/akaeba/eSpiMasterBfm.git
创建时间: 2020-06-19T12:56:25Z
项目社区:https://github.com/akaeba/eSpiMasterBfm

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Unittest

eSpiMasterBfm

Enhanced SPI Master Bus Functional Model

Features

The eSpiMasterBfm provides VHDL procedures to interact with an eSPI endpoint.
Currently are procedures available for:

  • IO Read/Write
  • Memory Read/Write
  • Endpoint Configuration

Releases

Version Date Source Change log
latest latest.zip
v0.1.3 2021-10-01 v0.1.3.zip Bugfixes: IOWR/MEMWR checks for free queue before write;
Features: GHDL continuous unit test
v0.1.2 2021-04-12 v0.1.2.zip Bugfixes: Reset, alert mode, strlen, testbench;
Features: Server Specific Platform wire decoding
v0.1.1 2021-03-12 v0.1.1.zip Bugfixes: Supported to used IO mode; wait on virtual wire
v0.1.0 2020-12-30 v0.1.0.zip Configuration; IO read/write; Memory read/write

Example

The full provided function set demonstrates the eSpiMasterBfm_tb.vhd.
A tiny testbench example shows the snippet below:

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. library work;
  4. use work.eSpiMasterBfm.all;
  5. entity espi_tb is
  6. end entity espi_tb;
  7. architecture sim of espi_tb is
  8. -----------------------------
  9. -- ESPI ITF
  10. signal CSn : std_logic;
  11. signal SCK : std_logic;
  12. signal DIO : std_logic_vector(3 downto 0);
  13. signal ALERTn : std_logic;
  14. signal RESETn : std_logic;
  15. -----------------------------
  16. begin
  17. -----------------------------
  18. -- DUT
  19. -- add ESPI Slave here
  20. -----------------------------
  21. -----------------------------
  22. -- stimuli process
  23. p_stimuli : process
  24. variable eSpiBfm : tESpiBfm; -- eSPI Master bfm Handle
  25. variable good : boolean := true; -- test state
  26. variable slv08 : std_logic_vector(7 downto 0); -- help variable
  27. begin
  28. -- Initializes Endpoint according 'Exit G3' sequence
  29. -- init( this, RESETn, CSn, SCK, DIO, ALERTn, good, log );
  30. init( eSpiBfm, RESETn, CSn, SCK, DIO, ALERTn, good, INFO );
  31. -- write to io-mapped address
  32. -- IOWR( this, CSn, SCK, DIO, adr, data, good )
  33. IOWR( eSpiBfm, CSn, SCK, DIO, x"0080", x"47", good ); -- P80
  34. -- read from io-mapped address
  35. -- IORD( this, CSn, SCK, DIO, adr, data, good )
  36. IORD( eSpiBfm, CSn, SCK, DIO, x"0081", slv08, good ); -- P81
  37. -- write to memory-mapped address
  38. -- MEMWR32( this, CSn, SCK, DIO, adr, data, good );
  39. MEMWR32( eSpiBfm, CSn, SCK, DIO, x"00000080", x"47", good ); -- byte write
  40. -- read from memory-mapped address
  41. -- MEMRD32( this, CSn, SCK, DIO, adr, data, good );
  42. MEMRD32( eSpiBfm, CSn, SCK, DIO, x"00000080", slv08, good ); -- byte read
  43. -- done
  44. Report "That's it :-)";
  45. wait; -- stop continuous run
  46. end process p_stimuli;
  47. -----------------------------
  48. -----------------------------
  49. -- External Pull Resistors
  50. SCK <= 'L';
  51. DIO <= (others => 'H');
  52. ALERTn <= 'H';
  53. -----------------------------
  54. end architecture sim;

File Listing

The table below lists the major files in this project:

File Group Remark
eSpiMasterBfm.vhd BFM BFM itself, provides procedures to interact with an eSPI Slave
eSpiMasterBfm_tb.vhd TB eSpiMasterBfm testbench, example BFM procedure calls
eSpiMasterBfm_compile.tcl SIM compile script for Modelsim
eSpiMasterBfm_runsim.tcl SIM starts simulation

BFM procedures

Category Procedures Example
initialization INIT
RESET
INIT(bfm, RESETn, CSn, SCK, DIO, ALERTn, good)
slave configuration GET_CONFIGURATION
SET_CONFIGURATION
GET_STATUS
GET_CONFIGURATION(bfm, CSn, SCK, DIO, adr, cfg, sts, rsp)
virtual wire VWIREWR
VWIRERD
WAIT_VW_IS_EQ
VWIREWR(bfm, CSn, SCK, DIO, "PLTRST#", '1', good)
IO write IOWR_BYTE
IOWR_WORD
IOWR_DWORD
IOWR(bfm, CSn, SCK, DIO, adr16, dat08, good)
IO read IORD_BYTE
IORD_WORD
IORD_DWORD
IORD(bfm, CSn, SCK, DIO, adr16, dat08, good)
memory write MEMWR32 MEMWR32(bfm, CSn, SCK, DIO, adr32, dat08, good)
memory read MEMRD32 MEMRD32(bfm, CSn, SCK, DIO, adr32, dat08, good)
misc tespi tespi(bfm)

FAQ

INIT ends with WAIT_ALERT

ESPI slave initialization INIT(bfm, RESETn, CSn, SCK, DIO, ALERTn, good) stops with the log message ** Note: eSpiMasterBfm:WAIT_ALERT.
This is caused by non asserting the two virtual wire inputs SLAVE_BOOT_LOAD_DONE=1 and SLAVE_BOOT_LOAD_STATUS=1. According the
eSPI Specification
chapter Exit from G3 point 8 needs both virtual wires set to logical one for exit G3.

Contributors wanted

If you think useful project and also helpful, feel free to fork and contribute.
The license does not require this, but the project will love it :-). Contributors welcome.

eSPI Slaves

References