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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc/] [src/] [ser/] [xmtbuf.v] - Blame information for rev 288

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

Line No. Rev Author Line
1 117 hellwig
//
2
// xmtbuf.v -- serial line transmitter buffer
3
//
4
 
5
 
6 27 hellwig
module xmtbuf(clk, reset, write, ready, data_in, serial_out);
7
    input clk;
8
    input reset;
9
    input write;
10
    output reg ready;
11
    input [7:0] data_in;
12
    output serial_out;
13
 
14
  reg [1:0] state;
15
  reg [7:0] data_hold;
16
  reg load;
17
  wire empty;
18
 
19
  xmt xmt1(clk, reset, load, empty, data_hold, serial_out);
20
 
21
  always @(posedge clk) begin
22
    if (reset == 1) begin
23
      state <= 2'b00;
24
      ready <= 1;
25
      load <= 0;
26
    end else begin
27
      case (state)
28
        2'b00:
29
          begin
30
            if (write == 1) begin
31
              state <= 2'b01;
32
              data_hold <= data_in;
33
              ready <= 0;
34
              load <= 1;
35
            end
36
          end
37
        2'b01:
38
          begin
39
            state <= 2'b10;
40
            ready <= 1;
41
            load <= 0;
42
          end
43
        2'b10:
44
          begin
45
            if (empty == 1 && write == 0) begin
46
              state <= 2'b00;
47
              ready <= 1;
48
              load <= 0;
49
            end else
50
            if (empty == 1 && write == 1) begin
51
              state <= 2'b01;
52
              data_hold <= data_in;
53
              ready <= 0;
54
              load <= 1;
55
            end else
56
            if (empty == 0 && write == 1) begin
57
              state <= 2'b11;
58
              data_hold <= data_in;
59
              ready <= 0;
60
              load <= 0;
61
            end
62
          end
63
        2'b11:
64
          begin
65
            if (empty == 1) begin
66
              state <= 2'b01;
67
              ready <= 0;
68
              load <= 1;
69
            end
70
          end
71
      endcase
72
    end
73
  end
74
 
75
endmodule

powered by: WebSVN 2.1.0

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