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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [example/] [interrupt/] [tb.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 12 sinclairrf
/*******************************************************************************
2
 *
3
 * Copyright 2015, Sinclair R.F., Inc.
4
 *
5
 * Test bench for two-interrupt peripheral.
6
 *
7
 ******************************************************************************/
8
 
9
`timescale 1ns/1ps
10
 
11
module tb;
12
 
13
// 10 MHz clock
14
reg s_clk = 1'b1;
15
always @ (s_clk) s_clk <= #50 ~s_clk;
16
 
17
reg s_rst = 1'b1;
18
initial begin
19
  repeat (5) @ (posedge s_clk);
20
  s_rst <= 1'b0;
21
end
22
 
23
reg s_interrupt = 1'b0;
24
initial begin
25
  repeat (50) @ (posedge s_clk);
26
  s_interrupt = 1'b1;
27
  @ (posedge s_clk)
28
  s_interrupt = 1'b0;
29
end
30
 
31
wire s_UART_Tx;
32
dual_interrupt uut(
33
  // synchronous reset and processor clock
34
  .i_rst        (s_rst),
35
  .i_clk        (s_clk),
36
  // transmit-only UART
37
  .o_uart_tx    (s_UART_Tx),
38
  // interrupts
39
  .i_interrupt  (s_interrupt)
40
);
41
 
42
localparam baud = 115200;
43
localparam dt_baud = 1.0e9/baud;
44
reg [8:0] deser = 9'h1FF;
45
initial forever begin
46
  @ (negedge s_UART_Tx);
47
  #(dt_baud/2.0);
48
  repeat (9) begin
49
    #dt_baud;
50
    deser = { s_UART_Tx, deser[1+:8] };
51
  end
52
  if (deser[8] != 1'b1)
53
    $display("%13d : Malformed UART transmition", $time);
54
  else if ((8'h20 <= deser[0+:8]) && (deser[0+:8]<=8'h80))
55
    $display("%13d : Sent 0x%02H : %c", $time, deser[0+:8], deser[0+:8]);
56
  else
57
    $display("%13d : Sent 0x%02H", $time, deser[0+:8]);
58
  if (deser[0+:8] == 8'h0A) begin
59
    @ (negedge s_clk)
60
    $finish;
61
  end
62
end
63
 
64
initial begin
65
  $dumpfile("tb.vcd");
66
  $dumpvars();
67
end
68
 
69
endmodule

powered by: WebSVN 2.1.0

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