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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [peripherals/] [inFIFO_async.v] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
//
2
// PERIPHERAL inFIFO_async:  @NAME@
3
//
4
generate
5
// FIFO memory
6
reg [7:0] s__fifo[@DEPTH-1@:0];
7
// write side of the FIFO
8
reg [@DEPTH_NBITS-1@:0] s__ix_in = @DEPTH_NBITS@'h0;
9
always @ (posedge i_rst or posedge @INCLK@)
10
  if (i_rst)
11
    s__ix_in <= @DEPTH_NBITS@'h0;
12
  else if (@DATA_WR@) begin
13
    s__ix_in <= s__ix_in + @DEPTH_NBITS@'d1;
14
    s__fifo[s__ix_in] <= @DATA@;
15
  end else
16
    s__ix_in <= s__ix_in;
17
// read side of the FIFO
18
reg [@DEPTH_NBITS-1@:0] s__ix_out = @DEPTH_NBITS@'h0;
19
always @ (posedge i_clk)
20
  if (i_rst)
21
    s__ix_out <= @DEPTH_NBITS@'h0;
22
  else if (s_inport && (s_T == 8'd@IX_DATA@))
23
    s__ix_out <= s__ix_out + @DEPTH_NBITS@'d1;
24
  else
25
    s__ix_out <= s__ix_out;
26
always @ (posedge i_clk)
27
  s__data <= s__fifo[s__ix_out];
28
// empty indication to the micro controller
29
// Note:  The lag in the "empty" indication is OK because of the minimum 2 clock
30
//        delay between reading the data and then reading the "empty"
31
//        indication.
32
reg [@DEPTH_NBITS-1@:0] s__ix_in_gray = @DEPTH_NBITS@'h0;
33
always @ (posedge @INCLK@)
34
  s__ix_in_gray <= { 1'b0, s__ix_in[@DEPTH_NBITS-1@:1] } ^ s__ix_in;
35
reg [@DEPTH_NBITS-1@:0] s__ix_in_gray_s[2:0];
36
always @ (posedge i_clk) begin
37
  s__ix_in_gray_s[0] <= s__ix_in_gray;
38
  s__ix_in_gray_s[1] <= s__ix_in_gray_s[0];
39
  s__ix_in_gray_s[2] <= s__ix_in_gray_s[1];
40
end
41
genvar ix__clk;
42
wire [@DEPTH_NBITS-1@:0] s__ix_in_clk;
43
assign s__ix_in_clk[@DEPTH_NBITS-1@] = s__ix_in_gray_s[2][@DEPTH_NBITS-1@];
44
for (ix__clk=@DEPTH_NBITS-1@; ix__clk>0; ix__clk=ix__clk-1) begin : gen__ix_in_clk
45
  assign s__ix_in_clk[ix__clk-1] = s__ix_in_clk[ix__clk] ^ s__ix_in_gray_s[2][ix__clk-1];
46
end
47
always @ (posedge i_clk)
48
  s__empty <= (s__ix_in_clk == s__ix_out);
49
// full indication to the fabric
50
reg [@DEPTH_NBITS-1@:0] s__ix_out_gray = @DEPTH_NBITS@'h0;
51
always @ (posedge i_clk)
52
  s__ix_out_gray <= { 1'b0, s__ix_out[@DEPTH_NBITS-1@:1] } ^ s__ix_out;
53
reg [@DEPTH_NBITS-1@:0] s__ix_out_gray_s[2:0];
54
always @ (posedge @INCLK@) begin
55
  s__ix_out_gray_s[0] <= s__ix_out_gray;
56
  s__ix_out_gray_s[1] <= s__ix_out_gray_s[0];
57
  s__ix_out_gray_s[2] <= s__ix_out_gray_s[1];
58
end
59
genvar ix__inclk;
60
wire [@DEPTH_NBITS-1@:0] s__ix_out_inclk;
61
assign s__ix_out_inclk[@DEPTH_NBITS-1@] = s__ix_out_gray_s[2][@DEPTH_NBITS-1@];
62
for (ix__inclk=@DEPTH_NBITS-1@; ix__inclk>0; ix__inclk=ix__inclk-1) begin : gen__ix_out_inclk
63
  assign s__ix_out_inclk[ix__inclk-1] = s__ix_out_inclk[ix__inclk] ^ s__ix_out_gray_s[2][ix__inclk-1];
64
end
65
reg [@DEPTH_NBITS-1@:0] s__delta_inclk = @DEPTH_NBITS@'h0;
66
always @ (posedge @INCLK@)
67
  s__delta_inclk <= s__ix_in - s__ix_out_inclk;
68
always @ (posedge @INCLK@)
69
  @DATA_FULL@ <= &s__delta_inclk[@DEPTH_NBITS-1@:3];
70
endgenerate

powered by: WebSVN 2.1.0

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