tcfix.v
834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// tcfix.v v1 Frank Berndt
// cartrige GAL fix for toshiba flash protocol;
module tcfix (
D0, CLE, WE, RE, CEI, CEO
);
input D0; // data bit 0;
input CLE; // cmd latch enable;
input WE; // write enable;
input RE; // read enable;
input CEI; // CE from BB;
output CEO; // CE to flash;
// snoop on read commands;
// cmd 00 sets counter to 512+16=528;
// cmd 01 sets counter to 256+16=272;
// asynchronously set count;
// decrement on each rising edge of RE;
reg [9:0] cnt; // cycle counter;
wire [1:0]load; // load counter;
assign load[0] = CLE & ~WE & D0;
assign load[1] = CLE & ~WE & ~D0;
always @(posedge RE or posedge load[0] or posedge load[1])
begin
if(load[0])
cnt <= 10'd272;
else if(load[1])
cnt <= 10'd528;
else
cnt <= cnt - 1;
end
assign CEO = ~CLE & (CEI | (cnt == 0));
endmodule