Hardware Reference
In-Depth Information
65
i <= 0;
66
j <= 0;
67
elsif falling_edge(spi_clk) then
68
if pr_state /= nx_state then
69
i <= 0;
70
j <= 0;
71
elsif not (i=imax and j=jmax) then
72
if i/=imax then
73
i <= i + 1;
74
elsif j/=jmax then
75
i <= 0;
76
j <= j + 1;
77
end if;
78
end if;
79
end if;
80
end process;
81
82
--FSM state register:
83
process (spi_clk, rst)
84
begin
85
if (rst='1') THEN
86
pr_state <= idle;
87
elsif falling_edge(spi_clk) then
88
pr_state <= nx_state;
89
end if;
90
end process;
91
92
--FSM combinational logic:
93
process (all)
94
begin
95
--Default values:
96
SSn <= '0';
97
SCK <= spi_clk;
98
MOSI <= '-';
99
imax <= 0;
100
jmax <= 0;
101
--Other values:
102
case pr_state IS
103
when idle =>
104
SSn <= '1';
105
SCK <= '0';
106
if wr='1' then
107
nx_state <= WREN;
108
elsif rd='1' then
109
nx_state <= READx;
110
else
111
nx_state <= idle;
112
end if;
113
--Data-write sequence:
114
when WREN =>
115
MOSI <= WREN_opcode(7-i);
116
imax <= 7;
117
if i=imax then
118
nx_state <= deselect;
119
else
120
nx_state <= WREN;
121
end if;
Search WWH ::




Custom Search