FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-02-2006, 08:55 PM
Guest
 
Posts: n/a
Default Problem in Serial Port Transmitter

Hi,

This code is not working for me (nothing is shown in hyperterm). Could
someone tell me any possible errors?

//-------------------------------------------------
// RS-232 TX module
// (c) fpga4fun.com KNJN LLC - 2003, 2004, 2005

//`define DEBUG // in DEBUG mode, we output one bit per clock cycle
(useful for faster simulations)
//`define RegisterInput // in RegisterInput mode, the input doesn't
have to stay valid while the character is been transmitted

module async_transmitter(clk, TxD_start, TxD_data, TxD, TxD_busy);
input clk, TxD_start;
input [7:0] TxD_data;
output TxD, TxD_busy;

parameter ClkFrequency = 25000000; // 25MHz
parameter Baud = 115200;

// Baud generator
parameter BaudGeneratorAccWidth = 16;
reg [BaudGeneratorAccWidth:0] BaudGeneratorAcc;
`ifdef DEBUG
wire [BaudGeneratorAccWidth:0] BaudGeneratorInc = 17'h10000;
`else
wire [BaudGeneratorAccWidth:0] BaudGeneratorInc =
((Baud<<(BaudGeneratorAccWidth-4))+(ClkFrequency>>5))/(ClkFrequency>>4);
`endif

wire BaudTick = BaudGeneratorAcc[BaudGeneratorAccWidth];
wire TxD_busy;
always @(posedge clk) if(TxD_busy) BaudGeneratorAcc <=
BaudGeneratorAcc[BaudGeneratorAccWidth-1:0] + BaudGeneratorInc;

// Transmitter state machine
reg [3:0] state;
wire TxD_ready = (state==0);
assign TxD_busy = ~TxD_ready;

always @(posedge clk)
case(state)
4'b0000: if(TxD_start) state <= 4'b0001;
4'b0001: if(BaudTick) state <= 4'b0100;
4'b0100: if(BaudTick) state <= 4'b1000; // start
4'b1000: if(BaudTick) state <= 4'b1001; // bit 0
4'b1001: if(BaudTick) state <= 4'b1010; // bit 1
4'b1010: if(BaudTick) state <= 4'b1011; // bit 2
4'b1011: if(BaudTick) state <= 4'b1100; // bit 3
4'b1100: if(BaudTick) state <= 4'b1101; // bit 4
4'b1101: if(BaudTick) state <= 4'b1110; // bit 5
4'b1110: if(BaudTick) state <= 4'b1111; // bit 6
4'b1111: if(BaudTick) state <= 4'b0010; // bit 7
4'b0010: if(BaudTick) state <= 4'b0011; // stop1
4'b0011: if(BaudTick) state <= 4'b0000; // stop2
default: if(BaudTick) state <= 4'b0000;
endcase

`ifdef RegisterInput
reg [7:0] TxD_dataD;
always @(posedge clk) if((state==0) & TxD_start) TxD_dataD <= TxD_data;
`else
wire [7:0] TxD_dataD =TxD_data;
`endif

// Output mux
reg muxbit;
always @(*)
case(state[2:0])
3'd0: muxbit <= TxD_dataD[0];
3'd1: muxbit <= TxD_dataD[1];
3'd2: muxbit <= TxD_dataD[2];
3'd3: muxbit <= TxD_dataD[3];
3'd4: muxbit <= TxD_dataD[4];
3'd5: muxbit <= TxD_dataD[5];
3'd6: muxbit <= TxD_dataD[6];
3'd7: muxbit <= TxD_dataD[7];
endcase

// Put together the start, data and stop bits
reg TxD;
always @(posedge clk) TxD <= (state<4) | (state[3] & muxbit); //
register the output to make it glitch free

endmodule
//------------------------------------------------------------------

Thanks.

Reply With Quote
  #2 (permalink)  
Old 01-02-2006, 08:56 PM
Guest
 
Posts: n/a
Default Re: Problem in Serial Port Transmitter

Could someone also list the proper procedure and a checklist for
connecting my FPGA to PC through serial ports and using
hyperterm?

Thanks in Advance.

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overheads of 4-port over 2-port SRAM John T. Goodman Verilog 0 01-25-2005 05:26 PM
making output port to bi-directional port! Vick Verilog 0 12-16-2004 07:14 AM
Making output-port to bi-directional-port! Vick Verilog 5 12-15-2004 07:03 AM
verilog model of serial presence-detect Nahum Barnea Verilog 0 06-08-2004 05:20 PM
port connection problem Rain Adelbert Verilog 3 04-02-2004 08:58 AM


All times are GMT +1. The time now is 06:44 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved