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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_diligent_s3board/] [sim/] [rtl_sim/] [src/] [hw_uart.v] - Blame information for rev 211

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

Line No. Rev Author Line
1 136 olivier.gi
/*===========================================================================*/
2
/*                                 DIGITAL I/O                               */
3
/*---------------------------------------------------------------------------*/
4
/* Test the Digital I/O interface.                                           */
5
/*===========================================================================*/
6
 
7 153 olivier.gi
`define VERY_LONG_TIMEOUT
8 136 olivier.gi
 
9 153 olivier.gi
// Data rate
10
parameter UART_FREQ   = 115200;
11
integer   UART_PERIOD = 1000000000/UART_FREQ;
12 136 olivier.gi
 
13 153 olivier.gi
 
14 136 olivier.gi
reg [7:0] rxbuf;
15
integer   rxcnt;
16
 
17
task uart_rx;
18
      begin
19
         @(negedge UART_TXD);
20
         rxbuf = 0;
21 153 olivier.gi
         #(UART_PERIOD*3/2);
22 136 olivier.gi
         for (rxcnt = 0; rxcnt < 8; rxcnt = rxcnt + 1)
23
           begin
24
              rxbuf = {UART_TXD, rxbuf[7:1]};
25 153 olivier.gi
              #(UART_PERIOD);
26
           end
27
         $write("%s", rxbuf);
28
         $fflush();
29 136 olivier.gi
      end
30
endtask
31
 
32
task uart_tx;
33
      input [7:0] txbuf;
34
 
35
      reg [9:0] txbuf_full;
36
      integer   txcnt;
37
      begin
38
         UART_RXD = 1'b1;
39
         txbuf_full = {1'b1, txbuf, 1'b0};
40 153 olivier.gi
         #(UART_PERIOD);
41 136 olivier.gi
         for (txcnt = 0; txcnt < 10; txcnt = txcnt + 1)
42
           begin
43
              UART_RXD   =  txbuf_full[txcnt];
44 153 olivier.gi
              #(UART_PERIOD);
45 136 olivier.gi
           end
46
      end
47
endtask
48
 
49 153 olivier.gi
initial forever uart_rx;
50
 
51 136 olivier.gi
 
52
initial
53
   begin
54
      $display(" ===============================================");
55
      $display("|                 START SIMULATION              |");
56
      $display(" ===============================================");
57
      repeat(5) @(posedge CLK_50MHz);
58
      stimulus_done = 0;
59
 
60 153 olivier.gi
      UART_RXD = 1'b1;
61 136 olivier.gi
 
62 153 olivier.gi
      // Select hardware uart
63
      SW1 = 1'b1;
64
      SW0 = 1'b0;
65 136 olivier.gi
 
66 153 olivier.gi
      // Wait for welcome message to be received
67
      repeat(120000) @(posedge mclk);
68 136 olivier.gi
 
69 153 olivier.gi
      // Send something
70
      uart_tx("B");
71
      uart_tx("o");
72
      uart_tx("n");
73
      uart_tx("j");
74
      uart_tx("o");
75
      uart_tx("u");
76
      uart_tx("r");
77
      uart_tx(" ");
78
      uart_tx(":");
79
      uart_tx("-");
80
      uart_tx(")");
81
      uart_tx("\n");
82
      repeat(10000) @(posedge mclk);
83
 
84 136 olivier.gi
      stimulus_done = 1;
85 153 olivier.gi
      repeat(10) @(posedge mclk);
86
      $display("\n");
87
      $finish();
88 136 olivier.gi
 
89
   end
90
 

powered by: WebSVN 2.1.0

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