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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [wbutohex.v] - Blame information for rev 9

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

Line No. Rev Author Line
1 2 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbutohex.v
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     Supports a printable character conversion from a printable
8
//              ASCII character to six bits of valid data.  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
// Creator:     Dan Gisselquist, Ph.D.
20
//              Gisselquist Technology, LLC
21
//
22
///////////////////////////////////////////////////////////////////////////
23
//
24
// Copyright (C) 2015, Gisselquist Technology, LLC
25
//
26
// This program is free software (firmware): you can redistribute it and/or
27
// modify it under the terms of  the GNU General Public License as published
28
// by the Free Software Foundation, either version 3 of the License, or (at
29
// your option) any later version.
30
//
31
// This program is distributed in the hope that it will be useful, but WITHOUT
32
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
33
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
34
// for more details.
35
//
36
// License:     GPL, v3, as defined and found on www.gnu.org,
37
//              http://www.gnu.org/licenses/gpl.html
38
//
39
//
40
///////////////////////////////////////////////////////////////////////////
41
//
42
//
43
//
44
//
45
// Copyright:   2015
46
//
47
//
48
module  wbutohex(i_clk, i_stb, i_byte, o_stb, o_valid, o_hexbits);
49
        input                   i_clk, i_stb;
50
        input           [7:0]    i_byte;
51
        output  reg             o_stb, o_valid;
52
        output  reg     [5:0]    o_hexbits;
53
 
54
        always @(posedge i_clk)
55
                o_stb <= i_stb;
56
 
57
        always @(posedge i_clk)
58
        begin
59
                // These are the defaults, to be overwridden by the ifs below
60
                o_valid <= 1'b1;
61
                o_hexbits <= 6'h00;
62
 
63
                if ((i_byte >= 8'h30)&&(i_byte <= 8'h39)) // A digit
64
                        o_hexbits <= { 2'b0, i_byte[3:0] };
65
                else if ((i_byte >= 8'h41)&&(i_byte <= 8'h5a)) // Upper case
66
                        o_hexbits <= (i_byte[5:0] - 6'h01 + 6'h0a);// -'A'+10
67
                else if ((i_byte >= 8'h61)&&(i_byte <= 8'h7a))
68
                        o_hexbits <= (i_byte[5:0] +6'h03);       // -'a'+(10+26)
69
                else if (i_byte == 8'h40) // An '@' sign
70
                        o_hexbits <= 6'h3e;
71
                else if (i_byte == 8'h25) // A '%' sign
72
                        o_hexbits <= 6'h3f;
73
                else
74
                        o_valid <= 1'b0;
75
        end
76
endmodule
77
 

powered by: WebSVN 2.1.0

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