OpenASIP  2.0
RFTestbenchGenerator.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file RFTestbenchGenerator.cc
26  *
27  * Implementation of RFTestbenchGenerator class.
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include <sstream>
35 #include <vector>
36 #include <boost/random.hpp>
37 #include <boost/nondet_random.hpp>
38 #include <ctime>
39 #include <stdint.h>
40 #include "HDBManager.hh"
41 #include "RFEntry.hh"
42 #include "TestbenchGenerator.hh"
43 #include "RFTestbenchGenerator.hh"
44 #include "RFArchitecture.hh"
45 #include "Machine.hh"
46 #include "MachineState.hh"
47 #include "MachineStateBuilder.hh"
48 #include "MemorySystem.hh"
49 #include "RegisterFileState.hh"
50 #include "RFPortImplementation.hh"
51 #include "RFImplementation.hh"
52 #include "MathTools.hh"
53 
54 using std::string;
55 using std::vector;
56 using std::ifstream;
57 using std::ofstream;
58 using std::ostringstream;
59 
60 #define INDENT " "
61 
62 const std::string RFTestbenchGenerator::RF_NAME_ = "testRF";
63 
65  rfEntry_(rf), rfImpl_(NULL), rfArch_(NULL), machRf_(NULL), msm_(NULL),
66  inputPorts_(), inputLoadPorts_(), inputOpcodePorts_(), outputPorts_(),
67  outputLoadPorts_(), outputOpcodePorts_() {
68 
69 }
70 
72  if (msm_) {
73  delete(msm_);
74  }
75  if (machine_) {
76  delete(machine_);
77  }
78  if (memSystem_) {
79  delete(memSystem_);
80  }
81 }
82 
83 /**
84  * Creates the testbench and writes it to the given filestream
85  *
86  * @param file Filestream where the testbench is written
87  */
88 void
90 
93 
95  parseRfPorts();
98  createTbCode();
99  writeTestbench(file, rfImpl_);
100 }
101 
102 /**
103  * Creates machine state model with the RF under test in it
104  */
105 void
107 
109  int size = 0;
110  if (rfArch_->hasParameterizedSize()) {
111  // set reasonable default value
112  size = 16;
113  rfArch_->setSize(size);
114  } else {
115  size = rfArch_->size();
116  }
117  int width = 0;
119  width = 32;
120  rfArch_->setWidth(width);
121  } else {
122  width = rfArch_->width();
123  }
124 
125  string name = RF_NAME_;
126  // create simulation model of the RF
128  name, size, width, rfArch_->maxReads(), rfArch_->maxWrites(),
130  rfArch_->zeroRegister());
132 
133  MachineStateBuilder msmBuilder;
134 
136 
137  msm_ = msmBuilder.build(*machine_, *memSystem_);
138 }
139 
140 
141 void
143 
144  for (int i = 0; i < rfImpl_->portCount(); i++) {
145  string portName = rfImpl_->port(i).name();
146  string opcodePort = rfImpl_->port(i).opcodePort();
147  string loadPort = rfImpl_->port(i).loadPort();
148  if (rfImpl_->port(i).direction() == HDB::IN) {
149  inputPorts_.push_back(portName);
150  inputOpcodePorts_.push_back(opcodePort);
151  inputLoadPorts_.push_back(loadPort);
152  } else if (rfImpl_->port(i).direction() == HDB::OUT) {
153  outputPorts_.push_back(portName);
154  outputOpcodePorts_.push_back(opcodePort);
155  outputLoadPorts_.push_back(loadPort);
156  } else {
157  assert(false && "RF port implementation does not have direction");
158  }
159  }
160  }
161 
162 
163 /**
164  * Creates component declaration, connection signals and connects RF component
165  * to testbench
166  */
167 void
169 
170  bindingStream()
171  << INDENT << "for tested_rf_0 : rf_under_test use entity work.";
172  bindingStream() << rfImpl_->moduleName() << ";" << std::endl;
173 
175  << INDENT << "component rf_under_test" << std::endl;
177  << INDENT << "tested_rf_0\t:\trf_under_test " << std::endl;
178 
179  string sizeGeneric = rfImpl_->sizeParameter();
180  string widthGeneric = rfImpl_->widthParameter();
181  if (!sizeGeneric.empty() || !widthGeneric.empty()) {
183  << INDENT INDENT << "generic(" << std::endl;
185  << INDENT INDENT << "generic map (" << std::endl;
186  if (!sizeGeneric.empty()) {
188  << INDENT INDENT INDENT << sizeGeneric
189  << "\t: integer := " << rfArch_->size();
191  << INDENT INDENT INDENT << sizeGeneric << " => "
192  << rfArch_->size();
193  if (!widthGeneric.empty()) {
194  declarationStream() << ";" << std::endl;
195  instantiationStream() << "," << std::endl;
196  }
197  }
198 
199  if (!widthGeneric.empty()) {
201  << INDENT INDENT INDENT << widthGeneric
202  << "\t: integer := " << rfArch_->width();
204  << INDENT INDENT INDENT << widthGeneric << " => "
205  << rfArch_->width();
206  }
208  << ");" << std::endl;
210  << ")" << std::endl;
211  }
212 
214  << INDENT INDENT << "port(" << std::endl;
216  << INDENT INDENT << "port map (" << std::endl;
217 
218  const int portWidth = rfArch_->width();
219  int opcodeWidth = opcodePortWidth();
220  for (int i = 0; i < rfArch_->writePortCount(); i++) {
221  // data port
223  << INDENT INDENT << inputPorts_.at(i) << "\t: "
224  << "in std_logic_vector(" << portWidth
225  << "-1 downto 0);" << std::endl;
226  // load port
228  << INDENT INDENT << inputLoadPorts_.at(i) << "\t: "
229  << "in std_logic;" << std::endl;
230  // opcode port
232  << INDENT INDENT << inputOpcodePorts_.at(i) << "\t: "
233  << "in std_logic_vector(" << opcodeWidth
234  << "-1 downto 0);" << std::endl;
235 
236  signalStream()
237  << INDENT << "signal " << inputPorts_.at(i) << "\t: "
238  << "std_logic_vector(" << portWidth << "-1 downto 0);"
239  << std::endl;
240  signalStream()
241  << INDENT << "signal " << inputLoadPorts_.at(i)
242  << "\t: std_logic_vector(1-1 downto 0);" << std::endl;
243  signalStream()
244  << INDENT << "signal " << inputOpcodePorts_.at(i) << "\t: "
245  << "std_logic_vector(" << opcodeWidth << "-1 downto 0);"
246  << std::endl;
247 
249  << INDENT INDENT INDENT << inputPorts_.at(i) << " => "
250  << inputPorts_.at(i) << "," << std::endl;
252  << INDENT INDENT INDENT << inputLoadPorts_.at(i) << " => "
253  << inputLoadPorts_.at(i) << "(0)," << std::endl;
255  << INDENT INDENT INDENT << inputOpcodePorts_.at(i) << " => "
256  << inputOpcodePorts_.at(i) << "," << std::endl;
257  }
258 
259  for (int i = 0; i < rfArch_->readPortCount(); i++) {
261  << INDENT INDENT << outputPorts_.at(i) << "\t: "
262  << "out std_logic_vector(" << portWidth
263  << "-1 downto 0);" << std::endl;
264  // load port
266  << INDENT INDENT << outputLoadPorts_.at(i) << "\t: "
267  << "in std_logic;" << std::endl;
268  // opcode port
270  << INDENT INDENT << outputOpcodePorts_.at(i) << "\t: "
271  << "in std_logic_vector(" << opcodeWidth
272  << "-1 downto 0);" << std::endl;
273 
274  signalStream()
275  << INDENT << "signal " << outputPorts_.at(i) << "\t: "
276  << "std_logic_vector(" << portWidth << "-1 downto 0);"
277  << std::endl;
278  signalStream()
279  << INDENT << "signal " << outputLoadPorts_.at(i)
280  << "\t: std_logic_vector(1-1 downto 0);" << std::endl;
281  signalStream()
282  << INDENT << "signal " << outputOpcodePorts_.at(i) << "\t: "
283  << "std_logic_vector(" << opcodeWidth << "-1 downto 0);"
284  << std::endl;
285 
287  << INDENT INDENT INDENT << outputPorts_.at(i) << " => "
288  << outputPorts_.at(i) << "," << std::endl;
290  << INDENT INDENT INDENT << outputLoadPorts_.at(i) << " => "
291  << outputLoadPorts_.at(i) << "(0)," << std::endl;
293  << INDENT INDENT INDENT << outputOpcodePorts_.at(i) << " => "
294  << outputOpcodePorts_.at(i) << "," << std::endl;
295  }
297  << INDENT INDENT INDENT
298  << rfImpl_->clkPort() << " => " << rfImpl_->clkPort()
299  << "," << std::endl
300  << INDENT INDENT INDENT
301  << rfImpl_->rstPort() << " => " << rfImpl_->rstPort()
302  << "," << std::endl
303  << INDENT INDENT INDENT
304  << rfImpl_->glockPort() << " => " << rfImpl_->glockPort()
305  << ");";
306 
308  << INDENT INDENT << rfImpl_->glockPort() << "\t: in std_logic;"
309  << std::endl
310  << INDENT INDENT << rfImpl_->rstPort() << "\t: in std_logic;"
311  << std::endl
312  << INDENT INDENT << rfImpl_->clkPort() << "\t: in std_logic);"
313  << std::endl
314  << INDENT << "end component;"
315  << std::endl;
316 
317  signalStream()
318  << INDENT << "signal " << rfImpl_->glockPort() << "\t: std_logic;"
319  << std::endl
320  << INDENT << "signal " << rfImpl_->rstPort() << "\t: std_logic;"
321  << std::endl
322  << INDENT << "signal " << rfImpl_->clkPort() << "\t: std_logic;"
323  << std::endl;
324 
325 }
326 
327 
328 /**
329  * Creates input and output data tables
330  *
331  * Creates input and output data and control signals as well for the
332  * testbench. Testbench writes to and reads from every register. If RF has
333  * multiple write or read ports maximum number of ports is used on every
334  * cycle. Ports are written and read in round robin order.
335  * Test is pipelined in such way that writing starts on the first cycle and
336  * reading starts when all the registers can be read without stall cycles.
337  */
338 void
340 
343 
344  PortDataArray inputData;
345  PortDataArray inputOpcode;
346  PortDataArray inputLoad;
347 
348  PortDataArray outputData;
349  PortDataArray outputOpcode;
350  PortDataArray outputLoad;
351 
352  // initialize a random number generator for the stimuli
353  boost::uniform_int<> distribution(INT_MIN, INT_MAX);
354  boost::mt19937 rng;
355  rng.seed(time(NULL));
356  boost::variate_generator<boost::mt19937&, boost::uniform_int<> >
357  randomNumber(rng, distribution);
358 
359  // Number of cycles needed to write to all registers
360  int fillCycles = 0;
361  if (rfArch_->size() >= rfArch_->writePortCount()) {
362  double size = rfArch_->size();
363  double ports = rfArch_->writePortCount();
364  fillCycles = static_cast<int>(ceil(size/ports));
365  } else {
366  // RF has more write ports than registers
367  fillCycles = rfArch_->size();
368  }
369  // Number of cycles needed to read all registers (this includes flush
370  // cycles)
371  int readCycles =
372  static_cast<int>(ceil(rfArch_->size() / rfArch_->readPortCount()));
373 
374  // Number of cycles needed to wait before we can start reading from RF
375  int outputWaitCycles = 0;
376  // Number of cycles needed to read rest of the register after fill cycles
377  int pipelineFlushCycles = 0;
378  if (fillCycles > readCycles) {
379  pipelineFlushCycles = rfArch_->latency();
380  // total cycles - read cycles
381  outputWaitCycles = fillCycles + pipelineFlushCycles - readCycles;
382  } else {
383  pipelineFlushCycles = rfArch_->latency() + (readCycles - fillCycles);
384  outputWaitCycles = rfArch_->latency();
385  }
386 
387  // port index and register where next input should be written to
388  int wrPortIndex = 0;
389  int wrRegIndex = 0;
390  // port index and register where next output should be read from
391  int rdPortIndex = 0;
392  int rdRegIndex = 0;
393  // port index and register where next output load is written to
394  int rdLoadPortIndex = 0;
395  int rdLoadRegIndex = 0;
396 
397  // Write data to registers and also start reading them when possible
398  for (int i = 0; i < fillCycles; i++) {
399  // Handle output first because register state is updated immediately
400  if (i < outputWaitCycles) {
401  for (int j = 0; j < rfArch_->readPortCount(); j++) {
402  string portName = outputPorts_.at(j);
403  outputData[portName].push_back(0);
404  }
405  } else {
406  for (int j = 0; j < rfArch_->readPortCount(); j++) {
407  string portName = outputPorts_.at(rdPortIndex);
408  outputData[portName].push_back(
409  simRF.registerState(rdRegIndex).value().unsignedValue());
410  // round robin regs and ports
411  rdRegIndex++;
412  rdRegIndex = rdRegIndex % rfArch_->size();
413  rdPortIndex++;
414  rdPortIndex = rdPortIndex % rfArch_->readPortCount();
415  }
416  }
417 
418  // write output load and opcode signals
419  if ( i < (outputWaitCycles - rfArch_->latency())) {
420  for (int j = 0; j < rfArch_->readPortCount(); j++) {
421  string opcodePort = outputOpcodePorts_.at(j);
422  string loadPort = outputLoadPorts_.at(j);
423  outputOpcode[opcodePort].push_back(0);
424  outputLoad[loadPort].push_back(0);
425  }
426  } else {
427  for (int j = 0; j < rfArch_->readPortCount(); j++) {
428  string opcodePort = outputOpcodePorts_.at(rdLoadPortIndex);
429  string loadPort = outputLoadPorts_.at(rdLoadPortIndex);
430  outputOpcode[opcodePort].push_back(rdLoadRegIndex);
431  outputLoad[loadPort].push_back(1);
432  // round robin regs and ports
433  rdLoadRegIndex++;
434  rdLoadRegIndex = rdLoadRegIndex % rfArch_->size();
435  rdLoadPortIndex++;
436  rdLoadPortIndex = rdLoadPortIndex % rfArch_->readPortCount();
437  }
438  }
439 
440 
441  // write inputs
442  for (int j = 0; j < rfArch_->writePortCount(); j++) {
443  int nopPortIndex = wrPortIndex;
444  // write only to as many ports per cycle as possible
445  // and write only once to every register
446  if (j < rfArch_->maxWrites() && wrRegIndex < rfArch_->size()) {
447  uint32_t stimulus = (uint32_t)randomNumber();
448  const int portWidth = rfArch_->width();
449  SimValue simStim(portWidth);
450  stimulus = (stimulus << (32 - portWidth) >> (32 - portWidth));
451  simStim = stimulus;
452  simRF.registerState(wrRegIndex).setValue(simStim);
453 
454  string portName = inputPorts_.at(wrPortIndex);
455  inputData[portName].push_back(stimulus);
456 
457  string opcodePort = inputOpcodePorts_.at(wrPortIndex);
458  uint32_t opcode = static_cast<uint32_t>(wrRegIndex);
459  inputOpcode[opcodePort].push_back(opcode);
460 
461  string loadPort = inputLoadPorts_.at(wrPortIndex);
462  uint32_t load = 1;
463  inputLoad[loadPort].push_back(load);
464 
465  wrRegIndex++;
466  // use round robin for write ports
467  wrPortIndex++;
468  wrPortIndex = wrPortIndex % rfArch_->writePortCount();
469  } else {
470  // write nop to other ports
471  uint32_t stimulus = 0;
472  uint32_t opcode = 0;
473  uint32_t load = 0;
474 
475  string portName = inputPorts_.at(nopPortIndex);
476  inputData[portName].push_back(stimulus);
477 
478  string opcodePort = inputOpcodePorts_.at(nopPortIndex);
479  inputOpcode[opcodePort].push_back(opcode);
480  string loadPort = inputLoadPorts_.at(nopPortIndex);
481  inputLoad[loadPort].push_back(load);
482 
483  // round robin
484  wrPortIndex++;
485  wrPortIndex = wrPortIndex % rfArch_->writePortCount();
486  }
487  }
488  }
489 
490  // No more data to be written, read rest of the registers
491  for (int i = 0; i < pipelineFlushCycles; i++) {
492  for (int j = 0; j < rfArch_->writePortCount(); j++) {
493  // write nop to write ports
494  uint32_t stimulus = 0;
495  uint32_t opcode = 0;
496  uint32_t load = 0;
497 
498  string portName = inputPorts_.at(j);
499  inputData[portName].push_back(stimulus);
500 
501  string opcodePort = inputOpcodePorts_.at(j);
502  inputOpcode[opcodePort].push_back(opcode);
503  string loadPort = inputLoadPorts_.at(j);
504  inputLoad[loadPort].push_back(load);
505  }
506  // write output load signals
507  for (int j = 0; j < rfArch_->readPortCount(); j++) {
508  string opcodePort = outputOpcodePorts_.at(rdLoadPortIndex);
509  string loadPort = outputLoadPorts_.at(rdLoadPortIndex);
510  outputOpcode[opcodePort].push_back(rdLoadRegIndex);
511  outputLoad[loadPort].push_back(1);
512  // round robin regs and ports
513  rdLoadRegIndex++;
514  rdLoadRegIndex = rdLoadRegIndex % rfArch_->size();
515  rdLoadPortIndex++;
516  rdLoadPortIndex = rdLoadPortIndex % rfArch_->readPortCount();
517  }
518  // write output data, opcodes and loads
519  for (int j = 0; j < rfArch_->readPortCount(); j++) {
520  string portName = outputPorts_.at(rdPortIndex);
521  outputData[portName].push_back(
522  simRF.registerState(rdRegIndex).value().unsignedValue());
523  // round robin regs and ports
524  rdRegIndex++;
525  rdRegIndex = rdRegIndex % rfArch_->size();
526  rdPortIndex++;
527  rdPortIndex = rdPortIndex % rfArch_->readPortCount();
528  }
529  }
530 
531  createStimulusArrays(inputData, inputOpcode, inputLoad, outputData,
532  outputOpcode, outputLoad);
533 
534  int totalCycleCount = fillCycles + pipelineFlushCycles;
535  writeTbConstants(totalCycleCount, outputWaitCycles);
536 }
537 
538 /**
539  * Writes the testbench main process code
540  */
541 void
543 
544  // input ports
545  for (int i = 0; i < rfArch_->writePortCount(); i++) {
546  string portName = inputPorts_.at(i);
547  string loadPort = inputLoadPorts_.at(i);
548  string opcodePort = inputOpcodePorts_.at(i);
549 
550  tbCodeStream()
551  << INDENT INDENT << portName << " <= " << portName << "_data("
552  << "current_cycle);" << std::endl
553  << INDENT INDENT << loadPort << " <= " << loadPort
554  <<"_data(current_cycle);" << std::endl
555  << INDENT INDENT << opcodePort << " <= " << opcodePort
556  << "_data(current_cycle);" << std::endl;
557  }
558  // output port load and opcode signals
559  for (int i = 0; i < rfArch_->readPortCount(); i++) {
560  string loadPort = outputLoadPorts_.at(i);
561  string opcodePort = outputOpcodePorts_.at(i);
562 
563  tbCodeStream()
564  << INDENT INDENT << loadPort << " <= " << loadPort
565  <<"_data(current_cycle);" << std::endl
566  << INDENT INDENT << opcodePort << " <= " << opcodePort
567  << "_data(current_cycle);" << std::endl;
568  }
569  // output ports
570  tbCodeStream()
571  << std::endl << std::endl << INDENT INDENT
572  << "if current_cycle >= IGNORE_OUTPUT_COUNT then" << std::endl;
573  for (int i = 0; i < rfArch_->readPortCount(); i++) {
574  string portName = outputPorts_.at(i);
575  tbCodeStream()
576  << INDENT INDENT INDENT
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
582  << INDENT INDENT INDENT INDENT <<"& \" output: \" "
583  << "& str(conv_integer(signed(" << portName << ")), 10)"
584  << std::endl
585  << INDENT INDENT INDENT INDENT << "& "
586  << "\" expected: \" & str(conv_integer(signed(" << portName
587  << "_data(current_cycle))), 10) severity error;"
588  << std::endl << std::endl;
589  }
590  tbCodeStream() << INDENT INDENT << "end if;" << std::endl;
591 }
592 
593 /**
594  * Writes input, output and control signal data to output streams
595  *
596  * @param inputData Array containing input ports and their values
597  * @param inputOpcode Array containing input port opcode ports and their
598  * values
599  * @param inputLoad Array containing input port load ports and their values
600  * @param outputData Array containing output ports and their values
601  * @param outputOpcode Array containing output port opcode ports and their
602  * values
603  * @param outputLoad Array containing output port load ports and their values
604  */
605 void
607  PortDataArray& inputData,
608  PortDataArray& inputOpcode,
609  PortDataArray& inputLoad,
610  PortDataArray& outputData,
611  PortDataArray& outputOpcode,
612  PortDataArray& outputLoad) {
613 
614  int portWidth = rfArch_->width();
615  writeDataArrays(inputArrayStream(), inputData, portWidth);
616  writeDataArrays(outputArrayStream(), outputData, portWidth);
617 
618  int loadWidth = 1;
619  writeDataArrays(loadArrayStream(), inputLoad, loadWidth);
620  writeDataArrays(loadArrayStream(), outputLoad, loadWidth);
621 
622  int opcodeWidth = opcodePortWidth();
623  writeDataArrays(opcodeArrayStream(), inputOpcode, opcodeWidth);
624  writeDataArrays(opcodeArrayStream(), outputOpcode, opcodeWidth);
625 }
626 
627 int
629 
630  int width = 0;
631  if (rfArch_->size() > 1) {
632  unsigned int biggestIndex = rfArch_->size()-1;
633  width = MathTools::requiredBits(biggestIndex);
634  } else {
635  width = 1;
636  }
637  return width;
638 }
639 
640 /**
641  * Write one PortDataArray to output stream
642  *
643  * @param stream Output stream
644  * @param array Array to be written
645  * @param portWidth Width of the output port
646  */
647 void
649  std::ostringstream& stream,
650  PortDataArray& array,
651  int portWidth) {
652 
653  for (PortDataArray::iterator i = array.begin(); i != array.end(); i++) {
654  string portName = i->first;
655  vector<uint32_t> data = i->second;
656  writeStimulusArray(stream, data, portName, portWidth);
657  }
658 }
TestbenchGenerator::bindingStream
std::ostringstream & bindingStream()
Definition: TestbenchGenerator.cc:188
RFTestbenchGenerator::createMachineState
void createMachineState()
Definition: RFTestbenchGenerator.cc:106
HDB::HWBlockImplementation::clkPort
std::string clkPort() const
Definition: HWBlockImplementation.cc:175
TestbenchGenerator::tbCodeStream
std::ostringstream & tbCodeStream()
Definition: TestbenchGenerator.cc:223
HDB::RFArchitecture::maxReads
int maxReads() const
Definition: RFArchitecture.cc:447
TestbenchGenerator::writeTestbench
void writeTestbench(std::ofstream &file, HDB::HWBlockImplementation *impl)
Definition: TestbenchGenerator.cc:116
TestbenchGenerator::opcodeArrayStream
std::ostringstream & opcodeArrayStream()
Definition: TestbenchGenerator.cc:208
RFTestbenchGenerator::outputOpcodePorts_
std::vector< std::string > outputOpcodePorts_
Definition: RFTestbenchGenerator.hh:101
INDENT
#define INDENT
Definition: RFTestbenchGenerator.cc:60
MachineStateBuilder.hh
TestbenchGenerator::instantiationStream
std::ostringstream & instantiationStream()
Definition: TestbenchGenerator.cc:198
HDB::RFArchitecture::latency
int latency() const
Definition: RFArchitecture.cc:497
RegisterFileState.hh
TestbenchGenerator::writeTbConstants
void writeTbConstants(int totalCycles, int outputIgnoreCycles)
Definition: TestbenchGenerator.cc:104
HDB::RFArchitecture::zeroRegister
bool zeroRegister() const
Definition: RFArchitecture.cc:541
HDB::RFEntry
Definition: RFEntry.hh:47
RFTestbenchGenerator::machine_
TTAMachine::Machine * machine_
Definition: RFTestbenchGenerator.hh:93
HDB::RFPortImplementation::direction
Direction direction() const
Definition: RFPortImplementation.cc:88
TestbenchGenerator::inputArrayStream
std::ostringstream & inputArrayStream()
Definition: TestbenchGenerator.cc:203
RFTestbenchGenerator::inputPorts_
std::vector< std::string > inputPorts_
Definition: RFTestbenchGenerator.hh:96
HDB::RFArchitecture::hasParameterizedSize
bool hasParameterizedSize() const
Definition: RFArchitecture.cc:282
RFTestbenchGenerator::outputPorts_
std::vector< std::string > outputPorts_
Definition: RFTestbenchGenerator.hh:99
TestbenchGenerator::writeStimulusArray
virtual void writeStimulusArray(std::ostringstream &stream, std::vector< uint32_t > &dataArray, std::string portName, int portWidth)
Definition: TestbenchGenerator.cc:68
MemorySystem.hh
HDB::RFImplementation::widthParameter
std::string widthParameter() const
Definition: RFImplementation.cc:154
RFTestbenchGenerator::rfImpl_
HDB::RFImplementation * rfImpl_
Definition: RFTestbenchGenerator.hh:88
RFTestbenchGenerator::outputLoadPorts_
std::vector< std::string > outputLoadPorts_
Definition: RFTestbenchGenerator.hh:100
HDB::RFArchitecture::width
int width() const
Definition: RFArchitecture.cc:343
SimValue
Definition: SimValue.hh:96
RFTestbenchGenerator::rfArch_
HDB::RFArchitecture * rfArch_
Definition: RFTestbenchGenerator.hh:89
HDB::RFEntry::architecture
RFArchitecture & architecture() const
Definition: RFEntry.cc:145
RFTestbenchGenerator::parseRfPorts
void parseRfPorts()
Definition: RFTestbenchGenerator.cc:142
HDB::HWBlockImplementation::rstPort
std::string rstPort() const
Definition: HWBlockImplementation.cc:197
assert
#define assert(condition)
Definition: Application.hh:86
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
TestbenchGenerator::declarationStream
std::ostringstream & declarationStream()
Definition: TestbenchGenerator.cc:183
TTAMachine::Machine::addRegisterFile
virtual void addRegisterFile(RegisterFile &unit)
Definition: Machine.cc:236
HDB::RFImplementation::sizeParameter
std::string sizeParameter() const
Definition: RFImplementation.cc:132
RFTestbenchGenerator::RFTestbenchGenerator
RFTestbenchGenerator(HDB::RFEntry *rf)
Definition: RFTestbenchGenerator.cc:64
RFImplementation.hh
HDB::RFArchitecture::maxWrites
int maxWrites() const
Definition: RFArchitecture.cc:472
RFTestbenchGenerator::memSystem_
MemorySystem * memSystem_
Definition: RFTestbenchGenerator.hh:94
RFPortImplementation.hh
TestbenchGenerator::signalStream
std::ostringstream & signalStream()
Definition: TestbenchGenerator.cc:193
RFArchitecture.hh
HDB::RFArchitecture::hasParameterizedWidth
bool hasParameterizedWidth() const
Definition: RFArchitecture.cc:271
MathTools::requiredBits
static int requiredBits(unsigned long int number)
MachineStateBuilder
Definition: MachineStateBuilder.hh:62
RFTestbenchGenerator::createStimulusArrays
void createStimulusArrays(PortDataArray &inputData, PortDataArray &inputOpcode, PortDataArray &inputLoad, PortDataArray &outputData, PortDataArray &outputOpcode, PortDataArray &outputLoad)
Definition: RFTestbenchGenerator.cc:606
NullRegisterFileState::instance
static NullRegisterFileState & instance()
Definition: RegisterFileState.cc:111
HDB::RFEntry::implementation
RFImplementation & implementation() const
Definition: RFEntry.cc:102
RFTestbenchGenerator::RF_NAME_
static const std::string RF_NAME_
Definition: RFTestbenchGenerator.hh:103
TestbenchGenerator.hh
Machine.hh
HDB::PortImplementation::loadPort
std::string loadPort() const
Definition: PortImplementation.cc:96
HDB::RFArchitecture::setWidth
void setWidth(int width)
Definition: RFArchitecture.cc:294
HDB::RFArchitecture::guardLatency
int guardLatency() const
Definition: RFArchitecture.cc:551
RFTestbenchGenerator::inputOpcodePorts_
std::vector< std::string > inputOpcodePorts_
Definition: RFTestbenchGenerator.hh:98
MemorySystem
Definition: MemorySystem.hh:55
RFTestbenchGenerator::createStimulus
void createStimulus()
Definition: RFTestbenchGenerator.cc:339
HDB::RFImplementation::port
RFPortImplementation & port(int index) const
Definition: RFImplementation.cc:281
SimValue::unsignedValue
unsigned int unsignedValue() const
Definition: SimValue.cc:919
RFTestbenchGenerator::machRf_
TTAMachine::RegisterFile * machRf_
Definition: RFTestbenchGenerator.hh:90
RFTestbenchGenerator::~RFTestbenchGenerator
virtual ~RFTestbenchGenerator()
Definition: RFTestbenchGenerator.cc:71
HDB::PortImplementation::name
std::string name() const
Definition: PortImplementation.cc:74
RegisterFileState::registerState
virtual RegisterState & registerState(int index)
Definition: RegisterFileState.cc:81
RFTestbenchGenerator::generateTestbench
virtual void generateTestbench(std::ofstream &file)
Definition: RFTestbenchGenerator.cc:89
RFTestbenchGenerator::opcodePortWidth
int opcodePortWidth() const
Definition: RFTestbenchGenerator.cc:628
HDB::RFPortImplementation::opcodePort
std::string opcodePort() const
Definition: RFPortImplementation.cc:110
RFTestbenchGenerator::writeDataArrays
void writeDataArrays(std::ostringstream &stream, PortDataArray &array, int portWidth)
Definition: RFTestbenchGenerator.cc:648
MachineStateBuilder::build
MachineState * build(const TTAMachine::Machine &machine, MemorySystem &memSys)
Definition: MachineStateBuilder.cc:104
TestbenchGenerator::PortDataArray
std::map< std::string, std::vector< uint32_t > > PortDataArray
Definition: TestbenchGenerator.hh:56
HDB::RFArchitecture::readPortCount
int readPortCount() const
Definition: RFArchitecture.cc:372
MachineState.hh
RFTestbenchGenerator::rfEntry_
HDB::RFEntry * rfEntry_
Definition: RFTestbenchGenerator.hh:87
RegisterFileState
Definition: RegisterFileState.hh:49
HDB::IN
@ IN
Input port.
Definition: HDBTypes.hh:41
RFTestbenchGenerator.hh
TTAMachine::RegisterFile::NORMAL
@ NORMAL
Used for general register allocation.
Definition: RegisterFile.hh:51
HDB::RFImplementation::portCount
int portCount() const
Definition: RFImplementation.cc:255
TestbenchGenerator::loadArrayStream
std::ostringstream & loadArrayStream()
Definition: TestbenchGenerator.cc:213
HDB::RFArchitecture::size
int size() const
Definition: RFArchitecture.cc:326
RFEntry.hh
HDB::HWBlockImplementation::moduleName
std::string moduleName() const
Definition: HWBlockImplementation.cc:153
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
MathTools.hh
HDB::HWBlockImplementation::glockPort
std::string glockPort() const
Definition: HWBlockImplementation.cc:219
HDBManager.hh
TestbenchGenerator::outputArrayStream
std::ostringstream & outputArrayStream()
Definition: TestbenchGenerator.cc:218
RFTestbenchGenerator::createTbInstantiation
void createTbInstantiation()
Definition: RFTestbenchGenerator.cc:168
HDB::RFArchitecture::setSize
void setSize(int size)
Definition: RFArchitecture.cc:310
HDB::OUT
@ OUT
Output port.
Definition: HDBTypes.hh:42
RFTestbenchGenerator::createTbCode
void createTbCode()
Definition: RFTestbenchGenerator.cc:542
HDB::RFArchitecture::writePortCount
int writePortCount() const
Definition: RFArchitecture.cc:397
RFTestbenchGenerator::inputLoadPorts_
std::vector< std::string > inputLoadPorts_
Definition: RFTestbenchGenerator.hh:97
TTAMachine::Machine
Definition: Machine.hh:73
RegisterState::setValue
virtual void setValue(const SimValue &value)
Definition: RegisterState.cc:80
MachineState::registerFileState
RegisterFileState & registerFileState(const std::string &name)
Definition: MachineState.cc:213
RFTestbenchGenerator::msm_
MachineState * msm_
Definition: RFTestbenchGenerator.hh:92