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

Subversion Repositories pmodsf3driver

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

powered by: WebSVN 2.1.0

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