OpenCores
URL https://opencores.org/ocsvn/smbus_controller/smbus_controller/trunk

Subversion Repositories smbus_controller

[/] [smbus_controller/] [trunk/] [hw/] [simulations/] [Testbench_SMBusAnalyzer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ldalmasso
------------------------------------------------------------------------
2
-- Engineer:    Dalmasso Loic
3
-- Create Date: 30/10/2024
4
-- Module Name: SMBusAnalyzer
5
-- Description:
6
--      SMBus Analyzer in charge to detect:
7
--          - Bus Busy Detection
8
--          - Bus Inactivity
9
--          - Bus Timeout
10
--          - Bus Arbitration
11
--          - Clock Stretching
12
--
13
-- WARNING: /!\ Require Pull-Up on SMBCLK and SMBDAT pins /!\
14
--
15
-- Ports
16
--              Input   -       i_clock: Module Input Clock
17
--              Input   -       i_clock_enable: Module Input Clock Enable
18
--              Input   -       i_smbclk_controller: SMBus Serial Clock from Controller
19
--              Input   -       i_smbcllk_line: SMBus Serial Clock bus line
20
--              Input   -       i_smbdat_controller: SMBus Serial Data from Controller
21
--              Input   -       i_smbdat_line: SMBus Serial Data bus line
22
--              Output  -       o_smbus_busy: SMBus Busy detection ('0': Not Busy, '1': Busy)
23
--              Output  -       o_smbus_timeout: SMBus Timeout detection ('0': No Timeout, '1': Timeout)
24
--              Output  -       o_smbus_arbitration: SMBus Arbitration detection ('0': Lost Arbitration, '1': Win Arbitration)
25
--              Output  -       o_smbclk_stretching: SMBus Clock Stretching detection ('0': Not Stretching, '1': Stretching)
26
------------------------------------------------------------------------
27
 
28
library IEEE;
29
use IEEE.STD_LOGIC_1164.ALL;
30
 
31
entity Testbench_SMBusAnalyzer is
32
end Testbench_SMBusAnalyzer;
33
 
34
architecture Behavioral of Testbench_SMBusAnalyzer is
35
 
36
COMPONENT SMBusAnalyzer is
37
 
38
GENERIC(
39
    INPUT_CLOCK_FREQ: INTEGER := 12_000_000;
40
        SMBUS_CLASS: INTEGER := 100_000
41
);
42
 
43
PORT(
44
        i_clock: IN STD_LOGIC;
45
        i_reset: IN STD_LOGIC;
46
    i_smbclk_controller: IN STD_LOGIC;
47
        i_smbclk_line: IN STD_LOGIC;
48
        i_smbdat_controller: IN STD_LOGIC;
49
    i_smbdat_line: IN STD_LOGIC;
50
    o_smbus_busy: OUT STD_LOGIC;
51
    o_smbus_timeout: OUT STD_LOGIC;
52
    o_smbus_arbitration: OUT STD_LOGIC;
53
        o_smbclk_stretching: OUT STD_LOGIC
54
);
55
 
56
END COMPONENT;
57
 
58
signal clock_12M: STD_LOGIC := '1';
59
signal reset: STD_LOGIC := '0';
60
signal smbclk_controller: STD_LOGIC := '0';
61
signal smbclk_line: STD_LOGIC := '0';
62
signal smbdat_controller: STD_LOGIC := '0';
63
signal smbdat_line: STD_LOGIC := '0';
64
signal smbus_busy: STD_LOGIC := '0';
65
signal smbus_timeout: STD_LOGIC := '0';
66
signal smbus_arbitration: STD_LOGIC := '0';
67
signal smbclk_stretching: STD_LOGIC := '0';
68
 
69
begin
70
 
71
-- Clock 12 MHz
72
clock_12M <= not(clock_12M) after 41.6667 ns;
73
 
74
-- Reset
75
reset <= '1', '0' after 3*83.3334 ns, '1' after 101.5 us, '0' after 103 us;
76
 
77
-- SMBus Clock
78
smbclk_controller <= '1', '0' after 625 ns, '1' after 725 ns, '0' after 1200 ns, '1' after 1500 ns, '0' after 7 us, '1' after 8 us;
79
smbclk_line <= '1','0' after 625 ns, '1' after 725 ns, '0' after 950 ns, '1' after 1050 ns, '0' after 1150 ns, '1' after 1200 ns, '0' after 1350 ns, '1' after 1500 ns, '0' after 7 us, '1' after 8 us,
80
                '0' after 200 us, '1' after 400 us, '0' after 500 us;
81
 
82
-- SMBus Data
83
smbdat_controller <= '1','0' after 500 ns, '1' after 800 ns, '0' after 950 ns, '1' after 1050 ns, '0' after 1150 ns, '1' after 1583.346 ns, '0' after 7 us, '1' after 8 us;
84
smbdat_line <= '1','0' after 500 ns, '1' after 800 ns, '1' after 950 ns, '0' after 1050 ns, '0' after 1150 ns, '1' after 1583.346 ns, '0' after 7 us, '1' after 8 us;
85
 
86
uut: SMBusAnalyzer
87
    GENERIC map(
88
     INPUT_CLOCK_FREQ => 12_000_000,
89
     SMBUS_CLASS => 100_000)
90
 
91
    PORT map(
92
           i_clock => clock_12M,
93
           i_reset => reset,
94
       i_smbclk_controller => smbclk_controller,
95
           i_smbclk_line => smbclk_line,
96
           i_smbdat_controller => smbdat_controller,
97
       i_smbdat_line => smbdat_line,
98
       o_smbus_busy => smbus_busy,
99
       o_smbus_timeout => smbus_timeout,
100
       o_smbus_arbitration => smbus_arbitration,
101
           o_smbclk_stretching => smbclk_stretching);
102
 
103
 
104
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.