36 #include <boost/random.hpp>
37 #include <boost/nondet_random.hpp>
58 using std::ostringstream;
65 rfEntry_(rf), rfImpl_(NULL), rfArch_(NULL), machRf_(NULL), msm_(NULL),
66 inputPorts_(), inputLoadPorts_(), inputOpcodePorts_(), outputPorts_(),
67 outputLoadPorts_(), outputOpcodePorts_() {
157 assert(
false &&
"RF port implementation does not have direction");
171 <<
INDENT <<
"for tested_rf_0 : rf_under_test use entity work.";
175 <<
INDENT <<
"component rf_under_test" << std::endl;
177 <<
INDENT <<
"tested_rf_0\t:\trf_under_test " << std::endl;
181 if (!sizeGeneric.empty() || !widthGeneric.empty()) {
186 if (!sizeGeneric.empty()) {
193 if (!widthGeneric.empty()) {
199 if (!widthGeneric.empty()) {
208 <<
");" << std::endl;
224 <<
"in std_logic_vector(" << portWidth
225 <<
"-1 downto 0);" << std::endl;
229 <<
"in std_logic;" << std::endl;
233 <<
"in std_logic_vector(" << opcodeWidth
234 <<
"-1 downto 0);" << std::endl;
238 <<
"std_logic_vector(" << portWidth <<
"-1 downto 0);"
242 <<
"\t: std_logic_vector(1-1 downto 0);" << std::endl;
245 <<
"std_logic_vector(" << opcodeWidth <<
"-1 downto 0);"
262 <<
"out std_logic_vector(" << portWidth
263 <<
"-1 downto 0);" << std::endl;
267 <<
"in std_logic;" << std::endl;
271 <<
"in std_logic_vector(" << opcodeWidth
272 <<
"-1 downto 0);" << std::endl;
276 <<
"std_logic_vector(" << portWidth <<
"-1 downto 0);"
280 <<
"\t: std_logic_vector(1-1 downto 0);" << std::endl;
283 <<
"std_logic_vector(" << opcodeWidth <<
"-1 downto 0);"
314 <<
INDENT <<
"end component;"
353 boost::uniform_int<> distribution(INT_MIN, INT_MAX);
355 rng.seed(time(NULL));
356 boost::variate_generator<boost::mt19937&, boost::uniform_int<> >
357 randomNumber(rng, distribution);
364 fillCycles =
static_cast<int>(ceil(size/ports));
375 int outputWaitCycles = 0;
377 int pipelineFlushCycles = 0;
378 if (fillCycles > readCycles) {
381 outputWaitCycles = fillCycles + pipelineFlushCycles - readCycles;
383 pipelineFlushCycles =
rfArch_->
latency() + (readCycles - fillCycles);
394 int rdLoadPortIndex = 0;
395 int rdLoadRegIndex = 0;
398 for (
int i = 0; i < fillCycles; i++) {
400 if (i < outputWaitCycles) {
403 outputData[portName].push_back(0);
408 outputData[portName].push_back(
423 outputOpcode[opcodePort].push_back(0);
424 outputLoad[loadPort].push_back(0);
430 outputOpcode[opcodePort].push_back(rdLoadRegIndex);
431 outputLoad[loadPort].push_back(1);
443 int nopPortIndex = wrPortIndex;
446 if (j < rfArch_->maxWrites() && wrRegIndex <
rfArch_->
size()) {
447 uint32_t stimulus = (uint32_t)randomNumber();
450 stimulus = (stimulus << (32 - portWidth) >> (32 - portWidth));
455 inputData[portName].push_back(stimulus);
458 uint32_t opcode =
static_cast<uint32_t
>(wrRegIndex);
459 inputOpcode[opcodePort].push_back(opcode);
463 inputLoad[loadPort].push_back(load);
471 uint32_t stimulus = 0;
476 inputData[portName].push_back(stimulus);
479 inputOpcode[opcodePort].push_back(opcode);
481 inputLoad[loadPort].push_back(load);
491 for (
int i = 0; i < pipelineFlushCycles; i++) {
494 uint32_t stimulus = 0;
499 inputData[portName].push_back(stimulus);
502 inputOpcode[opcodePort].push_back(opcode);
504 inputLoad[loadPort].push_back(load);
510 outputOpcode[opcodePort].push_back(rdLoadRegIndex);
511 outputLoad[loadPort].push_back(1);
521 outputData[portName].push_back(
532 outputOpcode, outputLoad);
534 int totalCycleCount = fillCycles + pipelineFlushCycles;
551 <<
INDENT INDENT << portName <<
" <= " << portName <<
"_data("
552 <<
"current_cycle);" << std::endl
554 <<
"_data(current_cycle);" << std::endl
556 <<
"_data(current_cycle);" << std::endl;
565 <<
"_data(current_cycle);" << std::endl
567 <<
"_data(current_cycle);" << std::endl;
572 <<
"if current_cycle >= IGNORE_OUTPUT_COUNT then" << std::endl;
577 <<
"assert " << portName <<
" = " << portName <<
"_data"
578 <<
"(current_cycle)" << std::endl
580 <<
"report lf & \"TCE Assert: Verification failed at cycle \" "
581 <<
"& str(current_cycle, 10)" << std::endl
583 <<
"& str(conv_integer(signed(" << portName <<
")), 10)"
586 <<
"\" expected: \" & str(conv_integer(signed(" << portName
587 <<
"_data(current_cycle))), 10) severity error;"
588 << std::endl << std::endl;
649 std::ostringstream& stream,
653 for (PortDataArray::iterator i = array.begin(); i != array.end(); i++) {
654 string portName = i->first;
655 vector<uint32_t> data = i->second;