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

Subversion Repositories eco32

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

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

Line No. Rev Author Line
1 117 hellwig
//
2
// xmt.v -- serial line transmitter
3
//
4
 
5
 
6 290 hellwig
`timescale 1ns/10ps
7
`default_nettype none
8
 
9
 
10 27 hellwig
module xmt(clk, reset, load, empty, parallel_in, serial_out);
11
    input clk;
12
    input reset;
13
    input load;
14
    output reg empty;
15
    input [7:0] parallel_in;
16
    output serial_out;
17
 
18
  reg [3:0] state;
19
  reg [8:0] shift;
20
  reg [10:0] count;
21
 
22
  assign serial_out = shift[0];
23
 
24
  always @(posedge clk) begin
25
    if (reset == 1) begin
26
      state <= 4'h0;
27
      shift <= 9'b111111111;
28
      empty <= 1;
29
    end else begin
30
      if (state == 4'h0) begin
31
        if (load == 1) begin
32
          state <= 4'h1;
33
          shift <= { parallel_in, 1'b0 };
34
          count <= 1302;
35
          empty <= 0;
36
        end
37
      end else
38
      if (state == 4'hb) begin
39
        state <= 4'h0;
40
        empty <= 1;
41
      end else begin
42
        if (count == 0) begin
43
          state <= state + 1;
44
          shift[8:0] <= { 1'b1, shift[8:1] };
45
          count <= 1302;
46
        end else begin
47
          count <= count - 1;
48
        end
49
      end
50
    end
51
  end
52
 
53
endmodule

powered by: WebSVN 2.1.0

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