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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc/] [src/] [ser/] [ser.v] - Diff between revs 288 and 290

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 288 Rev 290
Line 1... Line 1...
//
//
// ser.v -- serial line interface
// ser.v -- serial line interface
//
//
 
 
 
 
module ser(clk, reset,
`timescale 1ns/10ps
           en, wr, addr,
`default_nettype none
 
 
 
 
 
module ser(clk, rst,
 
           stb, we, addr,
           data_in, data_out,
           data_in, data_out,
           wt, irq_r, irq_t,
           ack, irq_r, irq_t,
           rxd, txd);
           rxd, txd);
    // internal interface
    // internal interface
    input clk;
    input clk;
    input reset;
    input rst;
    input en;
    input stb;
    input wr;
    input we;
    input [3:2] addr;
    input [3:2] addr;
    input [7:0] data_in;
    input [7:0] data_in;
    output reg [7:0] data_out;
    output reg [7:0] data_out;
    output wt;
    output ack;
    output irq_r;
    output irq_r;
    output irq_t;
    output irq_t;
    // external interface
    // external interface
    input rxd;
    input rxd;
    output txd;
    output txd;
Line 26... Line 30...
  wire wr_rcv_ctrl;
  wire wr_rcv_ctrl;
  wire rd_rcv_data;
  wire rd_rcv_data;
  wire wr_xmt_ctrl;
  wire wr_xmt_ctrl;
  wire wr_xmt_data;
  wire wr_xmt_data;
 
 
  wire rcv_ready;
  wire rcv_rdy;
  reg rcv_ien;
  reg rcv_ien;
  wire [7:0] rcv_data;
  wire [7:0] rcv_data;
  wire xmt_ready;
  wire xmt_rdy;
  reg xmt_ien;
  reg xmt_ien;
 
 
  assign wr_rcv_ctrl = (en == 1 && wr == 1 && addr == 2'b00) ? 1 : 0;
  assign wr_rcv_ctrl = (stb == 1 && we == 1 && addr == 2'b00) ? 1 : 0;
  assign rd_rcv_data = (en == 1 && wr == 0 && addr == 2'b01) ? 1 : 0;
  assign rd_rcv_data = (stb == 1 && we == 0 && addr == 2'b01) ? 1 : 0;
  assign wr_xmt_ctrl = (en == 1 && wr == 1 && addr == 2'b10) ? 1 : 0;
  assign wr_xmt_ctrl = (stb == 1 && we == 1 && addr == 2'b10) ? 1 : 0;
  assign wr_xmt_data = (en == 1 && wr == 1 && addr == 2'b11) ? 1 : 0;
  assign wr_xmt_data = (stb == 1 && we == 1 && addr == 2'b11) ? 1 : 0;
 
 
  rcvbuf rcvbuf1(clk, reset, rd_rcv_data, rcv_ready, rcv_data, rxd);
  rcvbuf rcvbuf_1(clk, rst, rd_rcv_data, rcv_rdy, rcv_data, rxd);
  xmtbuf xmtbuf1(clk, reset, wr_xmt_data, xmt_ready, data_in, txd);
  xmtbuf xmtbuf_1(clk, rst, wr_xmt_data, xmt_rdy, data_in, txd);
 
 
  always @(posedge clk) begin
  always @(posedge clk) begin
    if (reset == 1) begin
    if (rst) begin
      rcv_ien <= 0;
      rcv_ien <= 0;
      xmt_ien <= 0;
      xmt_ien <= 0;
    end else begin
    end else begin
      if (wr_rcv_ctrl) begin
      if (wr_rcv_ctrl) begin
        rcv_ien <= data_in[1];
        rcv_ien <= data_in[1];
Line 58... Line 62...
 
 
  always @(*) begin
  always @(*) begin
    case (addr[3:2])
    case (addr[3:2])
      2'b00:
      2'b00:
        // rcv ctrl
        // rcv ctrl
        data_out = { 6'b000000, rcv_ien, rcv_ready };
        data_out = { 6'b000000, rcv_ien, rcv_rdy };
      2'b01:
      2'b01:
        // rcv data
        // rcv data
        data_out = rcv_data;
        data_out = rcv_data;
      2'b10:
      2'b10:
        // xmt ctrl
        // xmt ctrl
        data_out = { 6'b000000, xmt_ien, xmt_ready };
        data_out = { 6'b000000, xmt_ien, xmt_rdy };
      2'b11:
      2'b11:
        // xmt data (cannot be read)
        // xmt data (cannot be read)
        data_out = 8'hxx;
        data_out = 8'hxx;
      default:
      default:
        data_out = 8'hxx;
        data_out = 8'hxx;
    endcase
    endcase
  end
  end
 
 
  assign wt = 1'b0;
  assign ack = stb;
  assign irq_r = rcv_ien & rcv_ready;
  assign irq_r = rcv_ien & rcv_rdy;
  assign irq_t = xmt_ien & xmt_ready;
  assign irq_t = xmt_ien & xmt_rdy;
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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