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

Subversion Repositories pmodsf3driver

[/] [pmodsf3driver/] [trunk/] [hw/] [simulations/] [Testbench_PmodSF3SPIModes.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: 19/02/2025
4
-- Module Name: PmodSF3SPIModes
5
-- Description:
6
--      Pmod SF3 SPI Modes Handler for the 32 MB NOR Flash Memory MT25QL256ABA:
7
--      - When User Read/Write SPI Mode from/to memory (Non-Volatile / Enhanced Volatile register), the module updates its internal SPI Mode registers
8
--      - According to the Flash Memory specifications:
9
--                      - At Power-up, the SPI Mode from the Non-Volatile register is used
10
--                      - When RESET_NON_VOLATILE_COMMAND (0x99) command is executed, the SPI Mode from the Non-Volatile register is used
11
--                      - When WRITE_ENHANCED_VOLATILE_CONFIG_COMMAND (0x..) command is executed, the SPI Mode from the Enhanced Volatile register is used
12
--
13
--      SPI Single Mode: DQ0 as Input, DQ1 as Output, DQ[3:2] NOT USED
14
--      SPI Dual Mode: DQ[1:0] as InOut, DQ[3:2] NOT USED
15
--      SPI Quad Mode: DQ[3:0] as InOut
16
--
17
--              SPI Mode Bits ('0' = Enable Bit, '1' = Disable Bit)
18
--              | Quad | Dual | SPI Mode Output
19
--              |   0  |   0  | Quad
20
--              |   0  |   1  | Quad
21
--              |   1  |   0  | Dual
22
--              |   1  |   1  | Single (Default)
23
--
24
-- Ports
25
--              Input   -       i_sys_clock: System Input Clock
26
--              Input   -       i_reset: Module Reset ('0': No Reset, '1': Reset)
27
--              Input   -       i_end_of_tx: End of SPI Transmission ('0': In progress, '1': End of Transmission)
28
--              Input   -       i_command: Command Byte
29
--              Input   -       i_new_data_to_mem: New Data to Write on FLASH Ready (Write Mode) ('0': NOT Ready, '1': Ready)
30
--              Input   -       i_data_to_mem: Data Bytes to Write on FLASH
31
--              Input   -       i_data_from_mem_ready: Data Bytes Read from FLASH Ready (Read Mode) ('0': NOT Ready, '1': Ready)
32
--              Input   -       i_data_from_mem: Data Bytes Read from FLASH
33
--              Output  -       o_spi_single_enable: SPI Single Mode Enable ('0': Disable, '1': Enable)
34
--              Output  -       o_spi_dual_enable: SPI Dual Mode Enable ('0': Disable, '1': Enable)
35
--              Output  -       o_spi_quad_enable: SPI Quad Mode Enable ('0': Disable, '1': Enable)
36
------------------------------------------------------------------------
37
 
38
LIBRARY IEEE;
39
USE IEEE.STD_LOGIC_1164.ALL;
40
USE IEEE.NUMERIC_STD.ALL;
41
 
42
ENTITY Testbench_PmodSF3SPIModes is
43
END Testbench_PmodSF3SPIModes;
44
 
45
ARCHITECTURE Behavioral of Testbench_PmodSF3SPIModes is
46
 
47
COMPONENT PmodSF3SPIModes is
48
 
49
PORT(
50
        i_sys_clock: IN STD_LOGIC;
51
        i_reset: IN STD_LOGIC;
52
        i_end_of_tx: IN STD_LOGIC;
53
    i_command: IN UNSIGNED(7 downto 0);
54
        i_new_data_to_mem: IN STD_LOGIC;
55
    i_data_to_mem: IN UNSIGNED(7 downto 0);
56
        i_data_from_mem_ready: IN STD_LOGIC;
57
    i_data_from_mem: IN UNSIGNED(7 downto 0);
58
    o_spi_single_enable: OUT STD_LOGIC;
59
    o_spi_dual_enable: OUT STD_LOGIC;
60
    o_spi_quad_enable: OUT STD_LOGIC
61
);
62
 
63
END COMPONENT;
64
 
65
signal sys_clock: STD_LOGIC := '0';
66
signal sys_clock_2: STD_LOGIC := '0';
67
signal reset: STD_LOGIC := '0';
68
signal end_of_tx: STD_LOGIC := '0';
69
signal command: UNSIGNED(7 downto 0) := (others => '0');
70
signal new_data_to_mem: STD_LOGIC := '0';
71
signal data_to_mem: UNSIGNED(7 downto 0) := x"AB";
72
signal data_from_mem_ready: STD_LOGIC := '0';
73
signal data_from_mem: UNSIGNED(7 downto 0) := x"CD";
74
signal spi_single_enable: STD_LOGIC := '0';
75
signal spi_dual_enable: STD_LOGIC := '0';
76
signal spi_quad_enable: STD_LOGIC := '0';
77
 
78
begin
79
 
80
-- Clock 100 MHz
81
sys_clock <= not(sys_clock) after 5 ns;
82
 
83
-- Command Clock
84
process
85
begin
86
    sys_clock_2 <= not(sys_clock_2) after 5 ns;
87
    wait for 80 ns;
88
end process;
89
 
90
-- Reset
91
reset <= '1', '0' after 50 ns;
92
 
93
-- End of Transmission
94
end_of_tx <='1', '0' after 145 ns,
95
            -- End after Write Enhanced Volatile
96
            '1' after 15.685 us, '0' after 15.845 us,
97
            -- End after Write Non Volatile
98
            '1' after 28.485 us, '0' after 28.645 us;
99
 
100
-- Command
101
process(sys_clock_2)
102
begin
103
    if rising_edge(sys_clock_2) then
104
 
105
        -- Increment Command
106
        if (command < "11111111") then
107
            command <= command +1;
108
 
109
        -- Apply Non Volatile Dummy Cycle Register
110
        else
111
            command <= x"99";
112
        end if;
113
    end if;
114
end process;
115
 
116
-- New Data to Memory for Test
117
process(sys_clock)
118
begin
119
    if rising_edge(sys_clock) then
120
 
121
        -- No Data to Memory
122
        if (reset = '1') then
123
            new_data_to_mem <= '0';
124
 
125
        -- New Data to Memory
126
        else
127
            new_data_to_mem <= '1';
128
        end if;
129
    end if;
130
end process;
131
 
132
-- Data to Memory for Test
133
process(sys_clock)
134
begin
135
    if rising_edge(sys_clock) then
136
 
137
        -- Increment Data to Memory
138
        data_to_mem <= data_to_mem +2;
139
 
140
    end if;
141
end process;
142
 
143
-- Data from Memory Ready
144
data_from_mem_ready <=  '0',
145
                        '1' after 1.105 us, '0' after 1.175 us,
146
                        '1' after 16.005 us, '0' after 16.165 us,
147
                        '1' after 28.805 us, '0' after 28.965 us;
148
 
149
-- Data from Memory for Test
150
process(sys_clock)
151
begin
152
    if rising_edge(sys_clock) then
153
 
154
        -- Decrement Data to Memory
155
        data_from_mem <= data_from_mem -3;
156
 
157
    end if;
158
end process;
159
 
160
uut: PmodSF3SPIModes
161
    PORT map(
162
        i_sys_clock => sys_clock,
163
        i_reset => reset,
164
        i_end_of_tx => end_of_tx,
165
        i_command => command,
166
        i_new_data_to_mem => new_data_to_mem,
167
                i_data_to_mem => data_to_mem,
168
        i_data_from_mem_ready => data_from_mem_ready,
169
                i_data_from_mem => data_from_mem,
170
        o_spi_single_enable => spi_single_enable,
171
        o_spi_dual_enable => spi_dual_enable,
172
        o_spi_quad_enable => spi_quad_enable);
173
 
174
end Behavioral;

powered by: WebSVN 2.1.0

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