In what follows when we say “1D signal”, we mean a 1-dimensional array of type logic[31:0].
By “2D signal” we mean a 2D-dimensional array of type logic[31:0] (i.e. each entry in the array is of this
When we only say “signal” we mean a 1D signal.
We define a simplified version of convolution, in which the signal does not get inverted. Specifically,
given signal x of length N, and a shorter signal y of length 2*L+1 (for some integer L), the convolution of
the two is a third signal z given by
(Eq. 1) z[n] = x[n-L]*y + x[n-(L-1)]*y + … + x[n]*y[L] + x[n+1]*y[L+1] + … + x[n+L]*y[2L]
where 0 <= n <= N-1
To calculate z[n], you can imagine that you take the y signal, center it on x[n], take the product of over-
lapping elements, and add the products.
Border cases: if Eq.1 refers to out-of-bound elements, you can consider them to be 0. E.g. if n<L, then
consider that x[n-L] = 0 and if n+L>N-1 then consider that x[n+L]=0.
Say x = (1,1,1,1,1,1) and y = (2,3,4). So N=4 and L = 1. Then
z = x[0-1]*y + x*y + x*y = 0*2 + 1*3 + 1*4 = 7. (border case)
z = x[1-1]* y + x*y + x*y = 9.
z = x[2-1]* y + x*y + x*y = 9.
z = x[5-1]*y + x*y + x*y = 1*2 + 1*3 + 0*4 = 5. (border case)
A 2D convolution is similar, but this time the signals are 2D arrays. 2D convolutions are used for image
processing, in which case x is called the image and y is called the kernel.
Given a 2D signal x which is N-by-N and a smaller signal y which is (2L+1)-by-L(2L+1), their convolution is
a third 2D signal z. The signal y is often called the “kernel” in machine learning.
(Here we are indexing from the top-left, so z is the top-left (first row, first column), z is first
row, 2nd column, and z is 2nd row, first column).
To calculate z[n,m], center y (often called the kernel) on x[n,m]; take the product of overlapping terms.
Then add the products. Same as before, entries outside the matrix bounds are considered to be 0.
x = [1 1 1 1
2 2 2 2
3 3 3 3] (semi-colons separate the rows)
y = [0.5 0.5 0.5
0.5 0.5 0.5
0.5 0.5 0.5]
z = [3 4.5 4.5 3
(z[0,0] = 0.5*(1+1+2+2), etc)
Work to do:
Your design will implement the 1-dimensional (1D) convolution.
Your design will implement the 2-D convolution, and write the code that collects coverage.
1) Module interface
Your module’s interface must conform to the following. Three dots indicate something you need to fill
in, like the data type, size, etc.
module convolution … (
input …. signal_x … ,
input … signal_y …,
input logic start,
input logic clk,
output … signal_z …,
output logic done);
The start and done signals are as usual: the module starts computing when start is asserted by the
testbench (for one clock cycle), and any further assertions of start while the module is computing are
ignored. When done computing, the module asserts done for one clock cycle.
Your module must be parametrized with parameter N: this is the size of image signal x. (recall x is length
N in 1D and N-by-N in 2D). The kernel signal y will always be of length 3 (in 1D) or 3-by-3 (in 2D). Default
value of N = 9.
Put your module in a file called convolution.sv
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: email@example.com 微信:itcsdx