I have modified the fifo example and wish to have char as ouput ...the program is as follows...
ca_fifo.h
#include <systemc.h> SC_MODULE (fifo) { sc_in<bool> read_write_n; sc_in<signed char> data_in; sc_in<bool> clock; sc_in<bool> reset; sc_out<signed char> output; void fifo_read(char &c); void fifo_write(char c); void fifo_reset(); void prc_fifo(); sc_event write_event,read_event; enum e{MAX=10}; char data[MAX]; int num_element,first; SC_CTOR (fifo) { SC_THREAD(prc_fifo); sensitive<<clock.pos(); sensitive <<read_write_n<<data_in; SC_THREAD(fifo_reset); sensitive<<reset; } }; void fifo::fifo_write(char c) { if(num_element==MAX) wait(read_event); wait(10,SC_NS); data[(first+num_element)% MAX]=c; ++num_element; write_event.notify(); } void fifo::fifo_read(char &c) { if(num_element==0) wait(write_event); wait(10,SC_NS); c=data[first]; -- num_element; first=(first+1)%MAX; read_event.notify(); }
ca_fifo.cpp
#include "ca_fifo.h" void fifo::prc_fifo() { if(read_write_n==1) { const char *str="HELLO !!! WELCOME \n"; while(*str){ fifo_write(*str++); } } else { char c; while(true){ fifo_read(c); cout<<c<<endl; } } } void fifo::fifo_reset() { num_element =first =0; }
the driver code driver_ca_fifo.cpp
SC_MODULE(driver_ca_fifo) { sc_out<bool> d_read_write_n,d_reset;//d_data_in; sc_out<signed char> d_data_in;//,d_data; void prc_driver_ca_fifo(); SC_CTOR (driver_ca_fifo) { SC_THREAD(prc_driver_ca_fifo); //sensitive<<pos.clock; } }; void driver_ca_fifo::prc_driver_ca_fifo() { while(1) { d_read_write_n = 1; d_reset = 0; wait (50 ,SC_NS); d_read_write_n = 0; //d_reset = 1'b0; wait (50 ,SC_NS); d_read_write_n = 1 ; } }
the monitor monitor_ca_fifo.cpp
SC_MODULE (monitor_ca_fifo) { sc_in<bool> m_read_write_n,m_reset; sc_in<signed char> m_data_in,m_out; void prc_monitor_ca_fifo(); SC_CTOR (monitor_ca_fifo) { SC_METHOD(prc_monitor_ca_fifo); sensitive<<m_read_write_n<<m_reset<<m_data_in<<m_out; } }; void monitor_ca_fifo::prc_monitor_ca_fifo() { cout<<"at time :"<<sc_time_stamp()<<"::"<<"(read_write_n,reset) \t"<<m_read_write_n<<m_reset<<"read data :\t"<<m_out<<endl; }
the main file fifo_main is
the running execution output is
(gdb) run Starting program: /home/mohit/Desktop/Untitled Folder/output [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1". SystemC 2.3.0-ASI --- Sep 18 2013 06:20:13 Copyright (c) 1996-2012 by all Contributors, ALL RIGHTS RESERVED at time :0 s::(read_write_n,reset) 00read data : at time :0 s::(read_write_n,reset) 10read data : at time :50 ns::(read_write_n,reset) 00read data : at time :100 ns::(read_write_n,reset) 10read data : at time :150 ns::(read_write_n,reset) 00read data : [Inferior 1 (process 3689) exited normally]
My ques is the code conceptually correct and how to display the char ....