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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [wbucompactlines.v] - Blame information for rev 112

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

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    wbucompactlines.v
4
//
5 102 dgisselq
// Project:     FPGA library
6 2 dgisselq
//
7
// Purpose:     Removes 'end of line' characters placed at the end of every
8
//              deworded word, unless we're idle or the line is too long.
9
//      This helps to format the output nicely to fit in an 80-character
10
//      display, should you need to do so for debugging.
11
//
12
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18 102 dgisselq
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
19 2 dgisselq
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// License:     GPL, v3, as defined and found on www.gnu.org,
31
//              http://www.gnu.org/licenses/gpl.html
32
//
33
//
34
////////////////////////////////////////////////////////////////////////////////
35
//
36
//
37
// When to apply a new line?
38
//      When no prior new line exists
39
//              or when prior line length exceeds (72)
40
//      Between codewords (need inserted newline)
41
//      When bus has become idle (~wb_cyc)&&(~busys)
42
//
43
// So, if every codeword ends in a newline, what we
44
// really need to do is to remove newlines.  Thus, if
45
// i_stb goes high while i_tx_busy, we skip the newline
46
// unless the line is empty.  ... But i_stb will always
47
// go high while i_tx_busy.  How about if the line
48
// length exceeds 72, we do nothing, but record the
49
// last word.  If the last word was a  <incomplete-thought>
50
//
51
//
52
module  wbucompactlines(i_clk, i_stb, i_nl_hexbits, o_stb, o_nl_hexbits,
53
                i_bus_busy, i_tx_busy, o_busy);
54
        input   i_clk, i_stb;
55
        input   [6:0]    i_nl_hexbits;
56
        output  reg     o_stb;
57
        output  reg     [6:0]    o_nl_hexbits;
58
        input                   i_bus_busy;
59
        input                   i_tx_busy;
60
        output  wire            o_busy;
61
 
62
        reg     last_out_nl, last_in_nl;
63
        initial last_out_nl = 1'b1;
64
        initial last_in_nl = 1'b1;
65
        always @(posedge i_clk)
66
                if ((~i_tx_busy)&&(o_stb))
67
                        last_out_nl <= (o_nl_hexbits[6]);
68
        always @(posedge i_clk)
69
                if ((i_stb)&&(~o_busy))
70
                        last_in_nl <= (i_nl_hexbits[6]);
71
 
72
        // Now, let's count how long our lines are
73
        reg     [6:0]    linelen;
74
        initial linelen = 7'h00;
75
        always @(posedge i_clk)
76
                if ((~i_tx_busy)&&(o_stb))
77
                begin
78
                        if (o_nl_hexbits[6])
79
                                linelen <= 0;
80
                        else
81
                                linelen <= linelen + 7'h1;
82
                end
83
 
84
        reg     full_line;
85
        initial full_line = 1'b0;
86
        always @(posedge i_clk)
87
                full_line <= (linelen > 7'd72);
88
 
89
 
90
        // Now that we know whether or not the last character was a newline,
91
        // and indeed how many characters we have in any given line, we can
92
        // selectively remove newlines from our output stream.
93
        initial o_stb = 1'b0;
94
        always @(posedge i_clk)
95
                if ((i_stb)&&(~o_busy))
96
                begin
97
                        o_stb <= (full_line)||(~i_nl_hexbits[6]);
98
                        o_nl_hexbits <= i_nl_hexbits;
99
                end else if (~o_busy)
100
                begin
101
                        o_stb <= (~i_tx_busy)&&(~i_bus_busy)&&(~last_out_nl)&&(last_in_nl);
102
                        o_nl_hexbits <= 7'h40;
103
                end else if (~i_tx_busy)
104
                        o_stb <= 1'b0;
105
 
106
        reg     r_busy;
107
        initial r_busy = 1'b0;
108
        always @(posedge i_clk)
109
                r_busy <= (o_stb);
110
        assign  o_busy = (r_busy)||(o_stb);
111
 
112
        /*
113
        output  wire    [27:0]  o_dbg;
114
        assign o_dbg = { o_stb, o_nl_hexbits, o_busy, r_busy, full_line,
115
                        i_bus_busy, linelen, i_tx_busy, i_stb, i_nl_hexbits };
116
        */
117
endmodule

powered by: WebSVN 2.1.0

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