# 2D Winograd CNN Chip for COVID-19 and Pneumonia Detection
## 2 Materials and Methods
### Methods  
#### 2.2.1 Design Chip of CNN  
First of all, we completed the writing of the chip according to the general chip production process in Figure 2. The method written this time first wrote a basic convolution circuit chip and then made subsequent modifications based on this chip, applying the Winograd algorithm to it. In the basic convolution circuit chip architecture also shown in Figure 2, the CNN architecture was used as the calculation processing flow, and the order is Convolutional (Layer 0), Max-pooling (Layer 1), Flatten (Layer 2), a total of 3 layers [21; 28], and this experiment adopted the input of the grayscale image [26; 27].  
Figure 1: Basic CNN and Winograd CNN ICs design flow from RTL to Tape Out.  
Figure 2: Image convolution test bench with 20 signal circuits and 5 memories with CNN architecture diagram with 3 layers, and the architecture of the proposed stride 1 CNN for classification. The kernel of the architecture was set to 3 \(\times\) 3, the input set to 64 \(\times\) 64, and the output set to 4096 \(\times\) 1.  
First, at Layer 0, the input grayscale image (64 \(\times\) 64 pixels in size) needed to be padded with zeros to maintain the final output result with the same size as the original image. This is to keep the CNN stackable into CNNs [29] and then use 2 filters as kernel because the maximum pooling needs to be done later, which used the size of the kernel as 3 \(\times\) 3. Then, the result of Layer 0 will be presented by the calculation result of Rectified Linear Unit (ReLU) [30]. Then, the ReLU used here used a nonlinear-ReLU whose function is \(\mathrm{f}(\mathrm{x})=\mathrm{max}(0,\mathrm{x})\), and this method output result of this ReLU will only store positive numbers, and negative numbers will become 0. While using a simple activation function for fast prediction, the CNN architecture failed to produce convincing results when using single-layer convolutions. CNNs are large one-layer architectures, while a single layer is not as good as expected, but the results after stacking are satisfactory [30,31]. The ReLU activation function was used to maintain the gradient at a positive value so that the result does not disappear [32]. Finally, the result of the Layer 0 is currently two matrices with a size of 64 \(\times\) 64-pixel images.  
Next, we used the result of Layer 0 as the input of Layer 1 and performed max pooling. The max pooling method can capture part of the position information and feature strength of the frequency domain neurons and improve the classification performance of the convolutional neural network in the frequency domain [33]. Here we used a 2 \(\times\) 2 matrix to do the max pooling window with a stride of 1. The result of Layer 1 will be a 32 \(\times\) 32 matrix of pixels from 2 images. After that, in the last Layer, the output of Layer 1 was flattened.  
As mentioned earlier, flattening was done in the last Layer, and the output result is a one-dimensional state. As we mentioned earlier, to classify images, we needed a classifier, which is generated in the last Layer. Even though the results of flattening lack connectivity, it is simple and effective to filter out the actual and effective features to evaluate and distinguish [34,35].  
In the information processing part, it can also be seen from Figure 2 that under the CNN architecture, there will be a total of 8 outputs (green line) and 5 inputs (red lines) in the circuit. The output is a system busy indication signal, a grayscale image address signal and operation, an output memory read enable signal, an operation result memory read address signal, an operation output memory write enable signal, an operation result memory output signal, an operation result memory write address signal, and enable signal. As for the input part, they are the system clock signal, the system reset signal, the grayscale image ready indication signal, the input grayscale image pixel data signal, and the operation result memory read signal--a total of five input signals.