URL
https://opencores.org/ocsvn/uart8systemc/uart8systemc/trunk
Subversion Repositories uart8systemc
Compare Revisions
- This comparison shows the changes necessary to convert path
/uart8systemc/trunk/vpi
- from Rev 6 to Rev 7
- ↔ Reverse comparison
Rev 6 → Rev 7
/reset_uart.h
4,16 → 4,17
vpiHandle RESET = vpi_handle_by_name("module_tb.RESET", NULL); |
vpiHandle RX = vpi_handle_by_name("module_tb.RX", NULL); |
vpiHandle TX = vpi_handle_by_name("module_tb.TX", NULL); |
vpiHandle WORK_FR = vpi_handle_by_name("module_tb.WORK_FR", NULL); |
|
reset.format=vpiIntVal; |
rx_value.format = vpiIntVal; |
tx_value.format = vpiIntVal; |
|
if(counter_reset < 5) |
if(SC_UART->reset_set()) |
{ |
|
reset.value.integer = 1; |
vpi_put_value(RESET, &reset, NULL, vpiNoDelay); |
counter_reset = counter_reset + 1; |
|
tx_value.value.integer = SC_UART->read_tx(); |
vpi_put_value(RX, &tx_value, NULL, vpiNoDelay); |
20,12 → 21,18
|
vpi_get_value(TX, &rx_value); |
SC_UART->write_rx(rx_value.value.integer); |
|
reset.value.integer = SC_UART->get_baud_rate(); |
vpi_put_value(WORK_FR, &reset, NULL, vpiNoDelay); |
|
//data.clear(); |
//parity.clear(); |
//SC_UART->clear_validation(); |
} |
else |
{ |
reset.value.integer = 0; |
vpi_put_value(RESET, &reset, NULL, vpiNoDelay); |
SC_UART->reset_set_low(); |
} |
|
return 0; |
/env_uart.cpp
1,4 → 1,4
#include "../iverilog/vpi_user.h" |
#include <iverilog/vpi_user.h> |
|
#include "../systemC/link_sc.h" |
|
5,16 → 5,28
int counter; |
int counter_reset; |
|
unsigned int new_clock; |
|
#include <stdio.h> |
#include <iostream> |
#include <dlfcn.h> |
#include <random> |
#include <vector> |
#include<string.h> |
|
unsigned int data_cnt=0; |
|
using namespace std; |
|
vector<unsigned int> data; |
vector<unsigned int> parity; |
|
|
void* lib_handle; |
|
//typedef void (*ThreadSCRun_dl)(); |
//ThreadSCRun_dl ThreadSC; |
|
Control_SC* (*create)(); |
void (*destroy)(Control_SC*); |
|
30,19 → 42,18
s_vpi_value start_tx; |
s_vpi_value ready_tx; |
|
#include "execute_uart.h" |
#include "run_sim.h" |
#include "reset_uart.h" |
#include "global_init.h" |
#include "counter_global.h" |
|
void Leitura_register() |
void uart_test_suit_register() |
{ |
s_vpi_systf_data tf_data; |
|
tf_data.type = vpiSysTask; |
tf_data.sysfunctype = 0; |
tf_data.tfname = "$execute_uart"; |
tf_data.calltf = execute_uart_calltf; |
tf_data.tfname = "$run_sim"; |
tf_data.calltf = run_sim_calltf; |
tf_data.compiletf = 0; |
tf_data.sizetf = 0; |
tf_data.user_data = 0; |
57,14 → 68,6
tf_data.user_data = 0; |
vpi_register_systf(&tf_data); |
|
tf_data.type = vpiSysTask; |
tf_data.sysfunctype = 0; |
tf_data.tfname = "$global_counter"; |
tf_data.calltf = global_counter_calltf; |
tf_data.compiletf = 0; |
tf_data.sizetf = 0; |
tf_data.user_data = 0; |
vpi_register_systf(&tf_data); |
|
tf_data.type = vpiSysTask; |
tf_data.sysfunctype = 0; |
77,7 → 80,7
} |
|
void (*vlog_startup_routines[])() = { |
Leitura_register, |
uart_test_suit_register, |
0 |
}; |
|
/global_init.h
11,10 → 11,9
rx_value.format = vpiIntVal; |
tx_value.format = vpiIntVal; |
|
reset.value.integer = 1; |
vpi_put_value(RESET, &reset, NULL, vpiNoDelay); |
reset.value.integer = 0; |
vpi_put_value(START, &reset, NULL, vpiNoDelay); |
vpi_put_value(RESET, &reset, NULL, vpiNoDelay); |
|
counter = 0; |
counter_reset = 0; |
28,24 → 27,21
|
create = (Control_SC* (*)())dlsym(lib_handle, "create_object"); |
destroy = (void (*)(Control_SC*))dlsym(lib_handle, "destroy_object"); |
//ThreadSC = (ThreadSCRun_dl) dlsym(lib_handle, "ThreadSCRun"); |
|
SC_UART = (Control_SC*)create(); |
SC_UART->set_baud_rate(115200,50); |
SC_UART->init(); |
SC_UART->set_period_clock_sc(20); |
//SC_UART->set_baud_rate(115200,50); |
//SC_UART->init(); |
//SC_UART->set_period_clock_sc(20); |
|
reset.value.integer = SC_UART->get_baud_rate(); |
vpi_put_value(WORK_FR, &reset, NULL, vpiNoDelay); |
|
SC_UART->reset_set_high(); |
|
tx_value.value.integer = SC_UART->read_tx(); |
vpi_put_value(RX, &tx_value, NULL, vpiNoDelay); |
|
vpi_get_value(TX, &rx_value); |
SC_UART->write_rx(rx_value.value.integer); |
|
SC_UART->run_sim(); |
|
return 0; |
} |