2020
2121
2222class ProcessorNode :
23+ """
24+ Base class to implement test of the processor
25+ nodes of the systolic array architecture.
26+ """
27+
2328 def __init__ (self , dut ):
2429 self .dut = dut
2530 self .rng = np .random .default_rng ()
2631
2732 def data_in_ports (self ):
33+ """
34+ Returns a list of handlers. Must be specialized in child classes.
35+ """
2836 logger .error (
2937 "The method is not overloaded by child class, test cannot work."
3038 )
3139 return [self .dut .noinput ,]
3240
3341 def data_in_int_bits (self ):
42+ """
43+ Returns a list of integers. Must be specialized in child classes.
44+ """
3445 logger .error (
3546 "The method is not overloaded by child class, test cannot work."
3647 )
3748 return [None ,]
3849
3950 def data_in_frac_bits (self ):
51+ """
52+ Returns a list of integers. Must be specialized in child classes.
53+ """
4054 logger .error (
4155 "The method is not overloaded by child class, test cannot work."
4256 )
4357 return [None ,]
4458
4559 def data_out_ports (self ):
60+ """
61+ Returns a list of handlers. Must be specialized in child classes.
62+ """
4663 logger .error (
4764 "The method is not overloaded by child class, test cannot work."
4865 )
4966 return [self .dut .nooutput ,]
5067
5168 def data_out_int_bits (self ):
69+ """
70+ Returns a list of integers. Must be specialized in child classes.
71+ """
5272 logger .error (
5373 "The method is not overloaded by child class, test cannot work."
5474 )
5575 return [None ,]
5676
5777 def data_out_frac_bits (self ):
78+ """
79+ Returns a list of integers. Must be specialized in child classes.
80+ """
5881 logger .error (
5982 "The method is not overloaded by child class, test cannot work."
6083 )
6184 return [None ,]
6285
6386 def random_fixed_array (self , length , int_bits , frac_bits ):
87+ """
88+ Generate a random fixed point number.
89+ """
6490 bits = int_bits + frac_bits
6591 MAX_VALUE = (2 ** (bits - 1 ) - 1 ) / 2 ** frac_bits
6692 MIN_VALUE = - (2 ** (bits - 1 )) / 2 ** frac_bits
@@ -77,6 +103,9 @@ def random_fixed_array(self, length, int_bits, frac_bits):
77103 return ap_data
78104
79105 def random_data_in_arrays (self , length ):
106+ """
107+ Generate a list of array of data for each in port.
108+ """
80109 int_bits = self .data_in_int_bits ()
81110 frac_bits = self .data_in_frac_bits ()
82111
@@ -85,12 +114,19 @@ def random_data_in_arrays(self, length):
85114 return data_in
86115
87116 def expected_output_uncasted (self , data_in ):
117+ """
118+ The expected out value with full precision.
119+ Must be specialized in child class.
120+ """
88121 logger .error (
89122 "The method is not overloaded by child class, test cannot work."
90123 )
91124 return [APyFixed (data_in , 1 , 1 ), ]
92125
93126 def expected_output (self , data_in ):
127+ """
128+ The expected output with the given out precision.
129+ """
94130 int_bits = self .data_out_int_bits ()
95131 frac_bits = self .data_out_frac_bits ()
96132
@@ -122,6 +158,9 @@ def expected_output(self, data_in):
122158 return data_out
123159
124160 async def test_processor_node (self , N ):
161+ """
162+ Test loop.
163+ """
125164 # generate random input data
126165 data_in = self .random_data_in_arrays (N + 3 )
127166
0 commit comments