SRCS=\
SPI_controler.nsl
+#SPI_controler.cpp
CPP_SRCS=\
-SPI_controler.cpp\
SPI_controler_test_case.cpp\
SPI_controler_top.cpp
LDFLAGS= -L/home/bols/systemc-2.2.0/lib-linux
--- /dev/null
+/*
+ Produced by NSL Core(version=20110614), IP ARCH, Inc. Wed Aug 10 21:05:17 2011
+ Licensed to :LIMITED EVALUATION USER:
+*/
+/*
+ EVALUATION COPY! DO NOT USE ANY PART OF THIS FILE FOR COMMERCIAL PRODUCTS.
+*/
+#include <systemc.h>
+template<typename T> int _nsl_readmem(T array[], const char *file, int start, int end, int sft) ;
+
+SC_MODULE( spi_controler ) {
+sc_in<bool> p_reset, m_clock;
+ sc_in <sc_uint<8> > send_data;
+sc_out <sc_uint<8> > resv_data;
+sc_in<bool> send;
+sc_in<bool> read_MOSI;
+sc_in<bool> write_MOSO;
+ sc_signal<sc_uint<8> > output_data;
+ sc_signal<sc_uint<8> > input_data;
+ sc_signal<sc_uint<1> > work_flg;
+
+void _sc_method_output_data() {
+
+}
+void _sc_method_input_data() {
+
+}
+void _sc_method_work_flg() {
+
+}
+ SC_CTOR( spi_controler )
+ :
+ output_data("output_data"),
+ input_data("input_data"),
+ work_flg("work_flg"),
+ send_data("send_data"),
+ resv_data("resv_data"),
+ p_reset("p_reset"),
+ m_clock("m_clock")
+ {
+};
+};
+/*
+ Produced by NSL Core(version=20110614), IP ARCH, Inc. Wed Aug 10 21:05:17 2011
+ Licensed to :LIMITED EVALUATION USER:
+*/
// 以下はSPIControlerTestクラスの宣言-----
class SPIControlerTest : public CPPUNIT_NS::TestFixture { //
- CPPUNIT_TEST_SUITE( SPIControlerTest ); //
- CPPUNIT_TEST( test_init ); //
- CPPUNIT_TEST( test_incr ); //
- CPPUNIT_TEST( test_clear ); //
- CPPUNIT_TEST_SUITE_END(); //
-
-protected:
- SPIControlerTop* c_;
-
-public:
- void setUp(); //
- void tearDown(); //
-
-protected:
- void test_init(); //
- void test_incr(); //
- void test_clear(); //
+ CPPUNIT_TEST_SUITE( SPIControlerTest ); //
+ CPPUNIT_TEST( test_init ); //
+ CPPUNIT_TEST( test_incr ); //
+ CPPUNIT_TEST( test_clear ); //
+ CPPUNIT_TEST_SUITE_END(); //
+
+ public:
+ SPIControlerTest();
+ ~SPIControlerTest();
+ void setUp(); //
+ void tearDown(); //
+
+ protected:
+ void test_init(); //
+ void test_incr(); //
+ void test_clear(); //
};
+ SPIControlerTop* c_ ;
// 以下はSPIControlerTestクラスの実装-----
-
CPPUNIT_TEST_SUITE_REGISTRATION( SPIControlerTest ); //
+SPIControlerTest::SPIControlerTest( )
+{
+ if(c_==NULL){
+ c_ = new SPIControlerTop();
+ }
+}
+SPIControlerTest::~SPIControlerTest( )
+{
+ if(c_!=NULL){
+ delete c_;
+ }
+}
// 各テスト・ケースの実行直前に呼ばれる
void SPIControlerTest::setUp() {
- c_ = new SPIControlerTop();
}
// 各テスト・ケースの実行直後に呼ばれる
void SPIControlerTest::tearDown() {
- delete c_;
}
// これ以降はテスト・ケースの実装内容
void SPIControlerTest::test_init() {
- CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
+ c_->nextStep(); //
+ c_->reset();
+ c_->nextStep(); //
+ CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
}
void SPIControlerTest::test_incr() {
- for ( int i = 1; i < 10; ++i ) {
- CPPUNIT_ASSERT_EQUAL(i,(int) c_->read_MOSI()); //
- }
+ for ( int i = 1; i < 10; ++i ) {
+ CPPUNIT_ASSERT_EQUAL(i,(int) c_->read_MOSI()); //
+ }
}
void SPIControlerTest::test_clear() {
- CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
+ c_->nextStep(); //
+ c_->reset();
+ c_->nextStep(); //
+ CPPUNIT_ASSERT_EQUAL(0,(int) c_->read_MOSI()); //
}
/*\r
EVALUATION COPY! DO NOT USE ANY PART OF THIS FILE FOR COMMERCIAL PRODUCTS. \r
*/\r
-#include "SPI_controler.h"\r
+#include "SPI_controler.sc"\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <stdint.h>\r
spi_controler.send(send);\r
spi_controler.read_MOSI(read_MOSI);\r
spi_controler.write_MOSO(write_MOSO);\r
+ sc_start(10, SC_NS);\r
}\r
\r
SPIControlerTop::~SPIControlerTop()\r
\r
void SPIControlerTop::nextStep()\r
{\r
+ sc_start(100, SC_NS);\r
+}\r
+\r
+void SPIControlerTop::reset()\r
+{\r
+ ctrl_clock = 0;\r
}\r
\r
void SPIControlerTop::send()\r
void nextStep();
void send();
char read_MOSI();
+ void reset();
void write_MOSO(char send_data);
};