245 lines
5.0 KiB
C++
245 lines
5.0 KiB
C++
/*
|
|
Copyright (c) 2020 - 2023 Wuhan University of Technology <295054118@whut.edu.cn>
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
|
|
#include <verilated.h>
|
|
#include "VBackPlaneChainTest.h"
|
|
#include <memory>
|
|
#include <iostream>
|
|
#include <getopt.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#if VM_TRACE
|
|
#include "verilated_fst_c.h"
|
|
#endif
|
|
|
|
|
|
char* img;
|
|
VBackPlaneChainTest *top;
|
|
#if VM_TRACE
|
|
VerilatedFstC* tfp;
|
|
#endif
|
|
vluint64_t main_time = 0;
|
|
|
|
double sc_time_stamp () {
|
|
return main_time;
|
|
}
|
|
|
|
|
|
|
|
static void sim_exit(){
|
|
#if VM_TRACE
|
|
tfp->close();
|
|
#endif
|
|
|
|
top->final();
|
|
|
|
delete top;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv, char **env) {
|
|
|
|
|
|
top = new VBackPlaneChainTest();
|
|
|
|
#if VM_TRACE
|
|
tfp = new VerilatedFstC;
|
|
Verilated::traceEverOn(true);
|
|
top->trace(tfp, 99); // Trace 99 levels of hierarchy
|
|
tfp->open("./tb/build/wave.fst");
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
top->reset = 1;
|
|
top->clock = 0;
|
|
top->io_clk400_0 = 0;
|
|
top->io_clk400_1 = 0;
|
|
top->io_clk400_2 = 0;
|
|
top->io_clk400_3 = 0;
|
|
top->io_clk400_4 = 0;
|
|
top->io_clk400_5 = 0;
|
|
|
|
while(!Verilated::gotFinish()) {
|
|
|
|
Verilated::timeInc(1);
|
|
|
|
if ( main_time != 1000 ){
|
|
} else {
|
|
top->reset = 0;
|
|
}
|
|
|
|
if ( main_time % 400 == 100 ) {
|
|
top->clock = 1;
|
|
} else if ( main_time % 400 == 300 ) {
|
|
top->clock = 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( main_time % 100 == 10 ) {
|
|
top->io_clk400_0 = 1;
|
|
} else if ( main_time % 100 == 60 ) {
|
|
top->io_clk400_0 = 0;
|
|
}
|
|
|
|
if ( main_time % 100 == 20 ) {
|
|
top->io_clk400_1 = 1;
|
|
} else if ( main_time % 100 == 70 ) {
|
|
top->io_clk400_1 = 0;
|
|
}
|
|
|
|
if ( main_time % 100 == 40 ) {
|
|
top->io_clk400_2 = 1;
|
|
} else if ( main_time % 100 == 90 ) {
|
|
top->io_clk400_2 = 0;
|
|
}
|
|
|
|
if ( main_time % 100 == 5 ) {
|
|
top->io_clk400_3 = 1;
|
|
} else if ( main_time % 100 == 55 ) {
|
|
top->io_clk400_3 = 0;
|
|
}
|
|
|
|
if ( main_time % 100 == 0 ) {
|
|
top->io_clk400_4 = 1;
|
|
} else if ( main_time % 100 == 50 ) {
|
|
top->io_clk400_4 = 0;
|
|
}
|
|
|
|
if ( main_time % 100 == 30 ) {
|
|
top->io_clk400_5 = 1;
|
|
} else if ( main_time % 100 == 80 ) {
|
|
top->io_clk400_5 = 0;
|
|
}
|
|
|
|
|
|
|
|
if( main_time == 50000 ){
|
|
top->io_spi_valid = 1;
|
|
top->io_spi_bits_address = 0x00 << 1 | 0x01;
|
|
top->io_spi_bits_register = 0x1;
|
|
top->io_spi_bits_data = 0xa5;
|
|
top->io_spi_bits_op = 0x01;
|
|
top->io_spi_bits_hash = 0x0;
|
|
|
|
} else if( main_time == 50100 ){
|
|
top->io_spi_valid = 0;
|
|
}
|
|
|
|
|
|
if( main_time == 250000 ){
|
|
top->io_spi_valid = 1;
|
|
top->io_spi_bits_address = 0x01 << 1 | 0x01;
|
|
top->io_spi_bits_register = 0x1;
|
|
top->io_spi_bits_data = 0x55;
|
|
top->io_spi_bits_op = 0x00;
|
|
top->io_spi_bits_hash = 0x0;
|
|
|
|
} else if( main_time == 250100 ){
|
|
top->io_spi_valid = 0;
|
|
}
|
|
|
|
if( main_time == 450000 ){
|
|
top->io_spi_valid = 1;
|
|
top->io_spi_bits_address = 0x02 << 1 | 0x01;
|
|
top->io_spi_bits_register = 0x1;
|
|
top->io_spi_bits_data = 0x55;
|
|
top->io_spi_bits_op = 0x00;
|
|
top->io_spi_bits_hash = 0x0;
|
|
|
|
} else if( main_time == 450100 ){
|
|
top->io_spi_valid = 0;
|
|
}
|
|
|
|
if( main_time == 650000 ){
|
|
top->io_spi_valid = 1;
|
|
top->io_spi_bits_address = 0x03 << 1 | 0x01;
|
|
top->io_spi_bits_register = 0x1;
|
|
top->io_spi_bits_data = 0x55;
|
|
top->io_spi_bits_op = 0x00;
|
|
top->io_spi_bits_hash = 0x0;
|
|
|
|
} else if( main_time == 650100 ){
|
|
top->io_spi_valid = 0;
|
|
}
|
|
|
|
if( main_time == 850000 ){
|
|
top->io_spi_valid = 1;
|
|
top->io_spi_bits_address = 0x04 << 1 | 0x01;
|
|
top->io_spi_bits_register = 0x1;
|
|
top->io_spi_bits_data = 0x55;
|
|
top->io_spi_bits_op = 0x00;
|
|
top->io_spi_bits_hash = 0x0;
|
|
|
|
} else if( main_time == 850100 ){
|
|
top->io_spi_valid = 0;
|
|
}
|
|
|
|
if( main_time == 1050000 ){
|
|
top->io_spi_valid = 1;
|
|
top->io_spi_bits_address = 0x05 << 1 | 0x01;
|
|
top->io_spi_bits_register = 0x1;
|
|
top->io_spi_bits_data = 0x55;
|
|
top->io_spi_bits_op = 0x00;
|
|
top->io_spi_bits_hash = 0x0;
|
|
|
|
} else if( main_time == 1050100 ){
|
|
top->io_spi_valid = 0;
|
|
}
|
|
|
|
|
|
|
|
top->eval();
|
|
#if VM_TRACE
|
|
tfp->dump(Verilated::time());
|
|
|
|
#endif
|
|
|
|
|
|
main_time ++;
|
|
|
|
if( main_time > 3050000 ){
|
|
break;
|
|
}
|
|
}
|
|
|
|
sim_exit();
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|