Professional Documents
Culture Documents
Circular Buffer
oldest sample newest sample
x[k]
N-samples
Moving window of N samples
Two options: (1) Shift the register contents concurrently at every clock (2) Shift the address pointer
Sample n
Sample n-N+1 Sample n-N Sample n-1 Sample n-2 Sample n-3
N-cells
9/12/2010
Data Movement
Data samples: 0110, 1010, 1111, ... Method #1: Shift Register
0110 1010 0110 1111 1010 0110 ...
9/12/2010
Simulation result
0 reset clock Data_in[7:0] cell_0_1[7:0] cell_1_1[7:0] cell_2_1[7:0] cell_3_1[7:0] xx 02 00 00 00 00 03 03 04 04 03 05 05 04 03 06 06 05 04 03 07 07 06 05 04 08 08 07 06 05 09 09 08 07 06 0a 0a 09 08 07 0b 0b 0a 09 08 0c 40 80 120
00 00 00 00
03 04 05 06
07 08 09 0a
0b
write_ptr[1:0] x
9/12/2010
Cell 5
Cell 4 Cell 3 Cell 2 Cell 1 write_ptr Cell 0 Empty FIFO read_ptr
Cell 5
Cell 4 Cell 3 Cell 2 Cell 1 Cell 0 read_ptr
Cell 4
Cell 3 Cell 2 Cell 1 Cell 0 write_ptr
Full FIFO
9/12/2010
Module declaration
module FIFO_Buffer (Data_out, stack_full, stack_almost_full, stack_half_full, stack_almost_empty, stack_empty, Data_in, write_to_stack, read_from_stack, clk, rst);
parameter stack_width = 32; parameter stack_height = 8; parameter stack_ptr_width = 3; parameter AE_level = 2; parameter AF_level = 6; parameter HF_level = 4; output [stack_width -1: 0] output output input [stack_width -1: 0] input input
Circular Buffer & FIFO
// Width of stack and data paths // Height of stack (in # of words) // Width of pointer to address stack // almost empty level // Almost full level // Half full level Data_out; stack_full, stack_almost_full, stack_half_full; stack_almost_empty, stack_empty; Data_in; write_to_stack, read_from_stack; clk, rst;
9/12/2010 Pham Quoc Cuong 10
FIFO Signals
reg reg reg reg [ stack_ptr_width -1: 0] [ stack_ptr_width: 0] [stack_width -1: 0] [stack_width -1: 0] read_ptr, write_ptr; // Addresses for // reading and writing ptr_gap; // Gap between ptrs Data_out; stack [stack_height -1 : 0]; // memory array
// Stack status signals assign stack_full = (ptr_gap == stack_height); assign stack_almost_full = (ptr_gap == AF_level); assign stack_half_full = (ptr_gap == HF_level); assign stack_almost_empty = (ptr_gap == AE_level); assign stack_empty = (ptr_gap == 0);
9/12/2010
Simulation Result
9/12/2010
Synthesized Circuit
9/12/2010