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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [UartSC.h] - Diff between revs 462 and 500

Only display areas with differences | Details | Blame | View Log

Rev 462 Rev 500
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
 
 
// SystemC Uart: definition
// SystemC Uart: definition
 
 
// This file is part of the cycle accurate model of the OpenRISC 1000 based
// This file is part of the cycle accurate model of the OpenRISC 1000 based
// system-on-chip, ORPSoC, built using Verilator.
// system-on-chip, ORPSoC, built using Verilator.
 
 
// This program is free software: you can redistribute it and/or modify it
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or (at your
// the Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
// option) any later version.
 
 
// This program is distributed in the hope that it will be useful, but WITHOUT
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
// License for more details.
// License for more details.
 
 
// You should have received a copy of the GNU Lesser General Public License
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
 
 
// $Id: $
// $Id: $
 
 
#ifndef UART_SC__H
#ifndef UART_SC__H
#define UART_SC__H
#define UART_SC__H
 
 
#include "systemc.h"
#include "systemc.h"
#include <stdint.h>
#include <stdint.h>
 
 
//! Handle UART I/O
//! Handle UART I/O
 
 
class UartSC:public sc_core::sc_module {
class UartSC:public sc_core::sc_module {
public:
public:
 
 
        // Constructor
        // Constructor
        UartSC(sc_core::sc_module_name name);
        UartSC(sc_core::sc_module_name name);
 
 
        // The ports
        // The ports
        sc_in < bool > clk;
        sc_in < bool > clk;
        sc_in < bool > uarttx;
        sc_in < bool > uarttx;
        sc_out < bool > uartrx;
        sc_out < bool > uartrx;
 
 
        // Init function
        // Init function
        void initUart(int clk_freq_hz, int uart_baud);
        void initUart(int uart_baud);
        // Transmit (from ORPSoC) handling function
        // Transmit (from ORPSoC) handling function
        void checkTx();
        void checkTx();
 
        // Receieve (in ORPSoC) generation function
 
        void driveRx();
 
        // Check keyboard for entry
 
        int kbhit();
 
        // Enable canonical mode on console
 
        void nonblock(int state);
 
 
private:
private:
        int clocks_per_bit;
 
        uint8_t current_char;
        uint8_t current_char;
        int counter;
        int counter;
        int bits_received;
        int bits_received;
 
        int ns_per_bit;
 
 
 
        int rx_state;
 
        int rx_counter;
 
        int rx_bits_sent;
 
        char rx_char;
 
 
};                              // UartSC ()
};                              // UartSC ()
 
 
#endif // UART_SC__H
#endif // UART_SC__H
 
 

powered by: WebSVN 2.1.0

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