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

Subversion Repositories ssbcc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 sinclairrf
/*******************************************************************************
2
 *
3
 * Copyright 2013, Sinclair R.F., Inc.
4
 *
5
 * Test bench for the UART_Rx peripheral.
6
 *
7
 ******************************************************************************/
8
 
9
`timescale 1ns/1ps
10
 
11
module tb;
12
 
13
// 100 MHz clock
14
reg s_clk = 1'b1;
15
always @ (s_clk)
16
  s_clk <= #5 ~s_clk;
17
 
18
reg s_rst = 1'b1;
19
initial begin
20
  repeat (5) @ (posedge s_clk);
21
  s_rst = 1'b0;
22
end
23
 
24
// 115200 baud, 1 stop bit
25
reg [15*10:0] s_buf1 = {
26
                      // list last byte first
27
                      1'b1, 8'h00, 1'b0, // null character (also terminates program)
28
                      1'b1, 8'h0A, 1'b0, // LF
29
                      1'b1, 8'h0D, 1'b0, // CR
30
                      1'b1, 8'h12, 1'b0, // '!'
31
                      1'b1, 8'h63, 1'b0, // 'd'
32
                      1'b1, 8'h6C, 1'b0, // 'l'
33
                      1'b1, 8'h72, 1'b0, // 'r'
34
                      1'b1, 8'h6F, 1'b0, // 'o'
35
                      1'b1, 8'h57, 1'b0, // 'W'
36
                      1'b1, 8'h20, 1'b0, // ' '
37
                      1'b1, 8'h6F, 1'b0, // 'o'
38
                      1'b1, 8'h6C, 1'b0, // 'l'
39
                      1'b1, 8'h6C, 1'b0, // 'l'
40
                      1'b1, 8'h65, 1'b0, // 'e'
41
                      1'b1, 8'h48, 1'b0, // 'H'
42
                      1'b1
43
                    };
44
wire s_uart = s_buf1[0];
45
initial begin
46
  @ (negedge s_rst);
47
  #100;
48
  forever begin
49
    #8680.555;
50
    s_buf1 <= { 1'b1, s_buf1[1+:15*10] };
51
  end
52
end
53
 
54
wire [7:0] s_data;
55
wire       s_data_wr;
56
wire       s_done;
57
tb_UART_Rx uut(
58
  // synchronous reset and processor clock
59
  .i_rst        (s_rst),
60
  .i_clk        (s_clk),
61
  .i_uart_rx    (s_uart),
62
  .o_data       (s_data),
63
  .o_data_wr    (s_data_wr),
64
  .o_done       (s_done)
65
);
66
 
67
always @ (posedge s_clk)
68
  if (s_data_wr)
69
    $display("%h", s_data);
70
 
71
always @ (posedge s_clk)
72
  if (s_done)
73
    $finish;
74
 
75
endmodule

powered by: WebSVN 2.1.0

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