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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [wbusixchar.v] - Blame information for rev 2

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

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

powered by: WebSVN 2.1.0

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