NAND Flash Simulation Model设计总结:
重点是如何建立这样的模型:
通常做ASIC设计所可以使用的Verilog语言的成分比Verilog能提供的要小。它必须是可综合的。而用于仿真的Verilog程序,就可以使用整个Verilog所提供的语言全集。下面介绍一些设计仿真模型的相关技术:
1. task的使用
task便于封装一些通用的任务,这常常在Test bench中使用。
例如:
task memory_read;
input [BLCK_BITS-1:0] block;
input [PAGE_BITS-1:0] page;
input [COL_BITS-1:0] col;
output [DQ_BITS-1:0] data;
reg [(ROW_BITS + COL_BITS) -1:0] addr;
reg [(ROW_BITS) -1:0] page_addr;
begin
// chop off the lowest address bits
addr = {block, page, col};
page_addr = {block, page};
data = mem_array[addr];
end
endtask
使用Task便于提供一个接口,这个接口可以被用来调用。
2. 如何模拟电路中的一些Timing
比如建立,保持时间
每个Chip都有一些Timing之类的参数,一般在Chip的Datasheet中提供。为了模拟Chip的Timing特性。
Io_buf <= #tREA_max status_register;
#tWB_max;
第一句,是在延迟#tREA_max后,输出status_register的内容到Io_buf去。
第二句,是简单的延迟tWB_max。
3. 如何建立模型:
因为模型不必是可综合的,所以,可以采用Verilog中所有的语言成分。
我们的地址,命令和数据都是在We_n的上升沿进行的锁存。所以采用这样的结构来采样地址,命令和数据。
//
// address state enable.这下面是接收地址的允许条件
//
assign address_enable = (~Cle && Ale && ~Ce_n && Re_n);
// Address Latch, get the latched address on the rising edge of We_n
always @ (posedge We_n) begin // positive edge of We_n
if (address_enable) begin : latch_address
// Latch Column Address
if (addr_start <= COL_BYTES && addr_start <= addr_stop && ~col_valid) begin : latch_col_addr
case (addr_start)
1 : col_addr[7 : 0] = Io[7 : 0];
2 : col_addr[COL_BITS - 1 : 8] = Io[7 : 0];
endcase
if (addr_start >= 2) begin
col_valid = 1'b1;
end
end // latch_col_addr
// Latch Row Address
if (addr_start >= (COL_BYTES +1) && addr_start <= addr_stop) begin : latch_row_addr
case (addr_start)
3 : begin
row_addr_last[active_plane] = new_addr;
row_valid = 1'b0; ####
new_addr[7:0] = Io[7:0];
end
4 : begin
new_addr[15:8] = Io[7:0];
end
5 : begin
new_addr[(ROW_BITS -1):16] = Io[(ROW_BITS -1 -16):0];
end
endcase
// make sure interleaved ops don't allow the inactive die to continue when
// the address is out of it's range
if
重点是如何建立这样的模型:
通常做ASIC设计所可以使用的Verilog语言的成分比Verilog能提供的要小。它必须是可综合的。而用于仿真的Verilog程序,就可以使用整个Verilog所提供的语言全集。下面介绍一些设计仿真模型的相关技术:
1. task的使用
task便于封装一些通用的任务,这常常在Test bench中使用。
例如:
task memory_read;
input [BLCK_BITS-1:0] block;
input [PAGE_BITS-1:0] page;
input [COL_BITS-1:0] col;
output [DQ_BITS-1:0] data;
reg [(ROW_BITS + COL_BITS) -1:0] addr;
reg [(ROW_BITS) -1:0] page_addr;
begin
// chop off the lowest address bits
addr = {block, page, col};
page_addr = {block, page};
data = mem_array[addr];
end
endtask
使用Task便于提供一个接口,这个接口可以被用来调用。
2. 如何模拟电路中的一些Timing
比如建立,保持时间
每个Chip都有一些Timing之类的参数,一般在Chip的Datasheet中提供。为了模拟Chip的Timing特性。
Io_buf <= #tREA_max status_register;
#tWB_max;
第一句,是在延迟#tREA_max后,输出status_register的内容到Io_buf去。
第二句,是简单的延迟tWB_max。
3. 如何建立模型:
因为模型不必是可综合的,所以,可以采用Verilog中所有的语言成分。
我们的地址,命令和数据都是在We_n的上升沿进行的锁存。所以采用这样的结构来采样地址,命令和数据。
//
// address state enable.这下面是接收地址的允许条件
//
assign address_enable = (~Cle && Ale && ~Ce_n && Re_n);
// Address Latch, get the latched address on the rising edge of We_n
always @ (posedge We_n) begin // positive edge of We_n
if (address_enable) begin : latch_address
// Latch Column Address
if (addr_start <= COL_BYTES && addr_start <= addr_stop && ~col_valid) begin : latch_col_addr
case (addr_start)
1 : col_addr[7 : 0] = Io[7 : 0];
2 : col_addr[COL_BITS - 1 : 8] = Io[7 : 0];
endcase
if (addr_start >= 2) begin
col_valid = 1'b1;
end
end // latch_col_addr
// Latch Row Address
if (addr_start >= (COL_BYTES +1) && addr_start <= addr_stop) begin : latch_row_addr
case (addr_start)
3 : begin
row_addr_last[active_plane] = new_addr;
row_valid = 1'b0; ####
new_addr[7:0] = Io[7:0];
end
4 : begin
new_addr[15:8] = Io[7:0];
end
5 : begin
new_addr[(ROW_BITS -1):16] = Io[(ROW_BITS -1 -16):0];
end
endcase
// make sure interleaved ops don't allow the inactive die to continue when
// the address is out of it's range
if