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

Subversion Repositories ssbcc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
/*******************************************************************************
2
 *
3
 * Copyright 2013, Sinclair R.F., Inc.
4
 *
5
 * Test bench for inFIFO_async peripheral.
6
 *
7
 ******************************************************************************/
8
 
9
`timescale 1ns/1ps
10
 
11
module tb;
12
 
13
// 100 MHz processor clock
14
reg s_clk = 1'b1;
15
always @ (s_clk)
16
  s_clk <= #5 ~s_clk;
17
 
18
// synchronous processor reset
19
reg s_rst = 1'b1;
20
initial begin
21
  repeat (5) @ (posedge s_clk);
22
  s_rst = 1'b0;
23
end
24
 
25
// 250 MHz data source clock
26
reg s_fast_clk = 1'b1;
27
always @ (s_fast_clk)
28
  s_fast_clk <= #2 ~s_fast_clk;
29
 
30
// Write data to the micro controller at varying rates.
31
reg [7:0] s_v  = 8'd0;
32
reg       s_wr = 1'b0;
33
wire      s_full;
34
initial begin
35
  @ (negedge s_rst);
36
  repeat(20)
37
    @ (posedge s_fast_clk);
38
  // write 5 values in quick succession
39
  s_wr <= 1'b1;
40
  repeat(5) begin
41
    @ (posedge s_fast_clk);
42
    s_v <= s_v + 8'd1;
43
  end
44
  s_wr <= 1'b0;
45
  // write 5 values once every 13*2.5+? = 100 clock cycles (this is
46
  // substantially slower than the micro controller can read the data).
47
  repeat (5) begin
48
    repeat(99)
49
      @ (posedge s_fast_clk);
50
    s_wr <= 1'b1;
51
    @ (posedge s_fast_clk);
52
    s_v <= s_v + 8'd1;
53
    s_wr <= 1'b0;
54
  end
55
  // write to the FIFO whenever it isn't full
56
  forever begin
57
    s_wr <= ~s_full;
58
    @ (posedge s_fast_clk);
59
    if (s_wr)
60
      s_v <= s_v + 8'd1;
61
  end
62
end
63
 
64
wire      [7:0] s_diag;
65
wire            s_diag_wr;
66
wire            s_done;
67
tb_inFIFO_async uut(
68
  // synchronous reset and processor clock
69
  .i_rst        (s_rst),
70
  .i_clk        (s_clk),
71
  // asynchronous input FIFO
72
  .i_aclk       (s_fast_clk),
73
  .i_data       (s_v),
74
  .i_data_wr    (s_wr),
75
  .o_data_full  (s_full),
76
  // diagnostic echo of received value
77
  .o_diag       (s_diag),
78
  .o_diag_wr    (s_diag_wr),
79
  // termination signal
80
  .o_done       (s_done)
81
);
82
 
83
always @ (posedge s_clk)
84
  if (s_diag_wr)
85
    $display("%12d : %h", $time, s_diag);
86
 
87
always @ (posedge s_clk)
88
  if (s_done)
89
    $finish;
90
 
91
endmodule

powered by: WebSVN 2.1.0

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