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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [rtl/] [wbusixchar.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
3
//
4
// Filename:    wbusixchar.v
5
//
6
// Project:     FPGA library
7
//
8
// Purpose:     Supports a conversion from a six digit bus to a printable
9
//              ASCII character representing those six bits.  The encoding is
10
//              as follows:
11
//
12
//              0-9     ->      0-9
13
//              A-Z     ->      10-35
14
//              a-z     ->      36-61
15
//              @       ->      62
16
//              %       ->      63
17
//
18
//              Note that decoding is stateless, yet requires one clock.
19
//
20
//
21
// Creator:     Dan Gisselquist, Ph.D.
22
//              Gisselquist Technology, LLC
23
//
24
///////////////////////////////////////////////////////////////////////////
25
//
26
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
27
//
28
// This program is free software (firmware): you can redistribute it and/or
29
// modify it under the terms of  the GNU General Public License as published
30
// by the Free Software Foundation, either version 3 of the License, or (at
31
// your option) any later version.
32
//
33
// This program is distributed in the hope that it will be useful, but WITHOUT
34
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
35
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36
// for more details.
37
//
38
// License:     GPL, v3, as defined and found on www.gnu.org,
39
//              http://www.gnu.org/licenses/gpl.html
40
//
41
//
42
///////////////////////////////////////////////////////////////////////////
43
//
44
//
45
//
46
module  wbusixchar(i_clk, i_stb, i_bits, o_stb, o_char, o_busy, i_busy);
47
        input                   i_clk;
48
        input                   i_stb;
49
        input           [6:0]    i_bits;
50
        output  reg             o_stb;
51
        output  reg     [7:0]    o_char;
52
        output  wire            o_busy;
53
        input                   i_busy;
54
 
55
        initial o_char = 8'h00;
56
        always @(posedge i_clk)
57
                if ((i_stb)&&(~o_busy))
58
                begin
59
                        if (i_bits[6])
60
                                o_char <= 8'h0a;
61
                        else if (i_bits[5:0] <= 6'h09) // A digit, WORKS
62
                                o_char <= "0" + { 4'h0, i_bits[3:0] };
63
                        else if (i_bits[5:0] <= 6'd35) // Upper case
64
                                o_char <= "A" + { 2'h0, i_bits[5:0] } - 8'd10; // -'A'+10
65
                        else if (i_bits[5:0] <= 6'd61)
66
                                o_char <= "a" + { 2'h0, i_bits[5:0] } - 8'd36;// -'a'+(10+26)
67
                        else if (i_bits[5:0] == 6'd62) // An '@' sign
68
                                o_char <= 8'h40;
69
                        else // if (i_char == 6'h63) // A '%' sign
70
                                o_char <= 8'h25;
71
                end
72
 
73
        always @(posedge i_clk)
74
                if ((o_stb)&&(~i_busy))
75
                        o_stb <= 1'b0;
76
                else if ((i_stb)&&(~o_stb))
77
                        o_stb <= 1'b1;
78
 
79
        assign  o_busy = o_stb;
80
 
81
endmodule
82
 

powered by: WebSVN 2.1.0

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