⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uart.h

📁 本程序用systemC仿真UART的功能
💻 H
字号:
#include "systemc.h"#include "uart_if.h"#include "uart_trx_if.h"#include "../pserial/send_module.h"#include "stdio.h"#include "../pserial/uart_gloabl_var.h"class uart: public uart_if, public uart_trx_if, public sc_module{  public:	sc_port< uart_trx_if >	uart_txport; //	sc_port< interrupt_if>  uart_interrrup;		//implementation of uart_if	void uart_action(unsigned int x_count);	void uartrw_rw(unsigned int address,unsigned int *data,int rw);	//implementation of uart_trx_if	unsigned int txbit(bool tb, int start);	//member functions	unsigned int evenparity(unsigned int txshifter);	unsigned int oddparity(unsigned int txshifter);	unsigned int force0(unsigned int txshifter);	unsigned int force1(unsigned int txshifter);	unsigned int stb(unsigned int txshifter);	unsigned int evenparity_rx(unsigned int b);	unsigned int oddparity_rx(unsigned int rxshifter);	unsigned int parity_error(unsigned int a);	//process	void receive_action();//	SC_HAS_PROCESS(Receive_module);	SC_HAS_PROCESS(uart);	uart(sc_module_name name_)		: sc_module(name_)	{  			SC_THREAD(receive_action);		int i;		rxshifter=0;		rx_count=1;		tx_count=0;		TxFifoCount=0;		RxFifoCount=0;		shifting=0;		count=0;		head=0;		rear=0;		front=0;		end=0;	//	uart_counter = 0;		ubrdiv =20;		ulcon=0x28;		ufcon= 0;//0x1;		ufstat=0x20;		for( i=0;i<16;i++)		{ 		t_buffer[i]=0;		r_buffer[i]=0;		}		//for (i=0;i<6;i++)		//	tmp[i]='a';	//	cout<<"construct u "<<ubrdiv<<endl;		init_uart();	}		private:		char sdata;	                unsigned int t_buffer[16];		unsigned int r_buffer[16];		unsigned int tx_count;		unsigned int rx_count;		unsigned int TxFifoCount;		unsigned int RxFifoCount;		unsigned int count;		unsigned int head;		unsigned int rear;		unsigned int front;		unsigned int end;		unsigned int stopbit;		unsigned int datalength;		unsigned int frame_length;    //length of frame		int odd,even;		int normal_mode,infra_red_mode;		int fifo;		int not_full,full,empty,not_empty;		int pclk,bps,uclk;	                   int receive_normal_mode;	        int trans_normal_mode;		bool shifting;		bool tb;		int  start;//	    unsigned int uart_counter;		unsigned int txshifter,rxshifter;				unsigned int uart_tx_bit;		unsigned int uart_rx_bit;		unsigned int rxbit;		unsigned int rxstart;	   		//unsigend int uartR[11]		unsigned int		ulcon;		//0x00		unsigned int		ucon;		//0x04		unsigned int		ufcon;		//0x08	        unsigned int		umcon;		//0x0c	        unsigned int		utrstat;	//0x10	        unsigned int		uerstat;	//0x14	        unsigned int		ufstat;		//0x18	        unsigned int		umstat;		//0x1c		 unsigned int		utxh;		//0x20	        unsigned int		urxh;		//0x24	        unsigned int		ubrdiv;		//0x28		//char tmp[6];	   };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -