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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [verilog/] [uart_decoder.v] - Blame information for rev 703

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

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ORPSoC Testbench UART Decoder                               ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  ORPSoC Testbench UART output decoder                        ////
7
////                                                              ////
8
////  To Do:                                                      ////
9
////                                                              ////
10
////                                                              ////
11
////  Author(s):                                                  ////
12
////      - jb, jb@orsoc.se                                       ////
13
////                                                              ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
18
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
 
42
// Receieves and decodes 8-bit,  1 stop bit, no parity UART signals.
43 354 julius
`timescale 1ns/1ns
44
module uart_decoder(clk, uart_tx);
45 6 julius
 
46 354 julius
   input clk;
47
   input uart_tx;
48 6 julius
 
49 354 julius
   // Default baud of 115200, period (ns)
50
   parameter uart_baudrate_period_ns = 8680;
51 6 julius
 
52
   // Something to trigger the task
53
   always @(posedge clk)
54
     uart_decoder;
55
 
56
   task uart_decoder;
57
      reg [7:0] tx_byte;
58
      begin
59 354 julius
         while (uart_tx !== 1'b1)
60
           @(uart_tx);
61 6 julius
         // Wait for start bit
62 354 julius
         while (uart_tx !== 1'b0)
63
           @(uart_tx);
64
         #(uart_baudrate_period_ns+(uart_baudrate_period_ns/2));
65
         tx_byte[0] = uart_tx;
66
         #uart_baudrate_period_ns;
67
         tx_byte[1] = uart_tx;
68
         #uart_baudrate_period_ns;
69
         tx_byte[2] = uart_tx;
70
         #uart_baudrate_period_ns;
71
         tx_byte[3] = uart_tx;
72
         #uart_baudrate_period_ns;
73
         tx_byte[4] = uart_tx;
74
         #uart_baudrate_period_ns;
75
         tx_byte[5] = uart_tx;
76
         #uart_baudrate_period_ns;
77
         tx_byte[6] = uart_tx;
78
         #uart_baudrate_period_ns;
79
         tx_byte[7] = uart_tx;
80
         #uart_baudrate_period_ns;
81 6 julius
         //Check for stop bit
82 354 julius
         if (uart_tx !== 1'b1)
83 6 julius
           begin
84
              // Wait for return to idle
85 354 julius
              while (uart_tx !== 1'b1)
86
                @(uart_tx);
87 6 julius
           end
88
         // display the char
89
         $write("%c", tx_byte);
90
      end
91
   endtask // user_uart_read_byte
92 354 julius
 
93
endmodule // uart_decoder

powered by: WebSVN 2.1.0

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