├── .gitignore
├── README.md
└── single-layer-perceptron
├── activation_function.v
├── ff_lib.v
├── fifo.v
├── perceptron_top.v
├── single-layer-perceptron.gise
├── single-layer-perceptron.xise
├── uart_rx6.v
├── uart_tx6.v
├── weighted_sum_top.v
└── weighted_sum_top_tb.v
/.gitignore:
--------------------------------------------------------------------------------
1 | # vim .gitignore
2 | [._]*.s[a-w][a-z]
3 | [._]s[a-w][a-z]
4 | *.un~
5 | Session.vim
6 | .netrwhist
7 | *~
8 |
9 | # OSX .gitignore
10 | .DS_Store
11 | .AppleDouble
12 | .LSOverride
13 |
14 | # Icon must ends with two \r.
15 | Icon
16 |
17 |
18 | # Thumbnails
19 | ._*
20 |
21 | # Files that might appear on external disk
22 | .Spotlight-V100
23 | .Trashes
24 | # ignore ModelSim generated files and directories (temp files and so on)
25 | [_@]*
26 |
27 | # Linux KDE directory preferences
28 | .directory
29 |
30 | # ModelSim .gitignore
31 | # ignore compilation output of ModelSim
32 | *.mti
33 | *.dat
34 | *.dbs
35 | *.psm
36 | *.bak
37 | *.cmp
38 | *.jpg
39 | *.html
40 | *.bsf
41 |
42 | # ignore simulation output of ModelSim
43 | wlf*
44 | *.wlf
45 | *.vstf
46 | *.ucdb
47 | cov*/
48 | transcript*
49 | sc_dpiheader.h
50 | vsim.dbg
51 |
52 | # XILINX ISE .gitignore
53 | # intermediate build files
54 | *.bgn
55 | *.bit
56 | *.bld
57 | *.cmd_log
58 | *.drc
59 | *.ll
60 | *.lso
61 | *.msd
62 | *.msk
63 | *.ncd
64 | *.ngc
65 | *.ngd
66 | *.ngr
67 | *.pad
68 | *.par
69 | *.pcf
70 | *.prj
71 | *.ptwx
72 | *.rbb
73 | *.rbd
74 | *.stx
75 | *.syr
76 | *.twr
77 | *.twx
78 | *.unroutes
79 | *.ut
80 | *.xpi
81 | *.xst
82 | *_bitgen.xwbt
83 | *_envsettings.html
84 | *_map.map
85 | *_map.mrp
86 | *_map.ngm
87 | *_map.xrpt
88 | *_ngdbuild.xrpt
89 | *_pad.csv
90 | *_pad.txt
91 | *_par.xrpt
92 | *_summary.html
93 | *_summary.xml
94 | *_usage.xml
95 | *_xst.xrpt
96 |
97 | # project-wide generated files
98 | par_usage_statistics.html
99 | usage_statistics_webtalk.html
100 | webtalk.log
101 | webtalk_pn.xml
102 | *.log
103 | *.cmd
104 | *.wdb
105 | *.exe
106 | *.xmsgs
107 | *.ini
108 | *.xsl
109 | *.xml
110 | *.xwbt
111 |
112 | # generated folders
113 | iseconfig/
114 | xlnx_auto_0_xdb/
115 | xst/
116 | _ngo/
117 | _xmsgs/
118 | ipcore_dir/
119 | isim/
120 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Project Description
2 | This is a Verilog library intended for fast, modular hardware implementation of neural networks.
3 |
4 | ## Current Status
5 | The project is currently under private development. The first release version will appear here at this repo.
6 |
--------------------------------------------------------------------------------
/single-layer-perceptron/activation_function.v:
--------------------------------------------------------------------------------
1 | `timescale 1ns / 1ps
2 | //////////////////////////////////////////////////////////////////////////////////
3 | // Company:
4 | // Engineer:
5 | //
6 | // Create Date: 00:54:37 04/03/2014
7 | // Design Name:
8 | // Module Name: activation_function
9 | // Project Name:
10 | // Target Devices:
11 | // Tool versions:
12 | // Description:
13 | //
14 | // Dependencies:
15 | //
16 | // Revision:
17 | // Revision 0.01 - File Created
18 | // Additional Comments:
19 | //
20 | //////////////////////////////////////////////////////////////////////////////////
21 | module activation_function(
22 | input signed [47 : 0] x,
23 | output reg signed [47 : 0] y
24 | );
25 | // [TODO] determine whether it is useful or necessary to use 48 bits for y, since
26 | // y will always be <= `ONE
27 |
28 | // [TODO] refine this representation
29 | `define ONE 48'h000001000000 /* 24.24 fixed point representation of 1.0 */
30 |
31 | // Approximates a sigmoid function
32 | // / 0, x < 0
33 | // f(x) = { x, 0 <= x <= 1
34 | // \ 1, x > 1
35 | always @(*) begin
36 | if (x[47]) // x < 0
37 | y = 47'b0;
38 | else if (x > `ONE)
39 | y = `ONE;
40 | else
41 | y = x;
42 | end
43 |
44 | endmodule
--------------------------------------------------------------------------------
/single-layer-perceptron/ff_lib.v:
--------------------------------------------------------------------------------
1 | `timescale 1ns / 1ps
2 | //////////////////////////////////////////////////////////////////////////////////
3 | // Company:
4 | // Engineer:
5 | //
6 | // Create Date: 20:23:12 04/02/2014
7 | // Design Name:
8 | // Module Name: ff_lib
9 | // Project Name:
10 | // Target Devices:
11 | // Tool versions:
12 | // Description:
13 | //
14 | // Dependencies:
15 | //
16 | // Revision:
17 | // Revision 0.01 - File Created
18 | // Additional Comments:
19 | //
20 | //////////////////////////////////////////////////////////////////////////////////
21 |
22 | // dff: D flip-flop
23 | // Parametrized width; default of 1
24 | module dff #(parameter WIDTH = 1) (
25 | input clk,
26 | input [WIDTH-1:0] d,
27 | output reg [WIDTH-1:0] q
28 | );
29 |
30 | always @(posedge clk)
31 | q <= d;
32 |
33 | endmodule
34 |
35 | // dffr: D flip-flop with active high synchronous reset
36 | // Parametrized width; default of 1
37 | module dffr #(parameter WIDTH = 1) (
38 | input clk,
39 | input r,
40 | input [WIDTH-1:0] d,
41 | output reg [WIDTH-1:0] q
42 | );
43 |
44 | always @(posedge clk)
45 | if (r)
46 | q <= {WIDTH{1'b0}};
47 | else
48 | q <= d;
49 | endmodule
50 |
51 |
52 | // dffre: D flip-flop with active high enable and reset
53 | // Parametrized width; default of 1
54 | module dffre #(parameter WIDTH = 1) (
55 | input clk,
56 | input r,
57 | input en,
58 | input [WIDTH-1:0] d,
59 | output reg [WIDTH-1:0] q
60 | );
61 |
62 | always @(posedge clk)
63 | if (r)
64 | q <= {WIDTH{1'b0}};
65 | else if (en)
66 | q <= d;
67 | else
68 | q <= q;
69 | endmodule
70 |
--------------------------------------------------------------------------------
/single-layer-perceptron/fifo.v:
--------------------------------------------------------------------------------
1 | `timescale 1ns / 1ps
2 | //////////////////////////////////////////////////////////////////////////////////
3 | // Company:
4 | // Engineer: Shane Leonard
5 | //
6 | // Create Date: 19:52:03 04/27/2014
7 | // Design Name:
8 | // Module Name: fifo
9 | // Project Name:
10 | // Target Devices:
11 | // Tool versions:
12 | // Description:
13 | //
14 | // Dependencies:
15 | //
16 | // Revision:
17 | // Revision 0.01 - File Created
18 | // Additional Comments:
19 | //
20 | //////////////////////////////////////////////////////////////////////////////////
21 | module fifo(
22 | input clk,
23 | input [WIDTH - 1:0] in,
24 | output [WIDTH - 1:0] out
25 | );
26 |
27 | parameter WIDTH = 18;
28 | parameter DEPTH = 2;
29 |
30 | wire [WIDTH - 1 : 0] pipe [DEPTH - 1 : 0];
31 |
32 | dff #(WIDTH) start(
33 | .d ( in ),
34 | .q ( pipe[0] ),
35 | .clk ( clk )
36 | );
37 |
38 | generate
39 | genvar i;
40 | for (i = 0; i < DEPTH - 1; i = i + 1)
41 | begin:pipeline_stage
42 |
43 | dff #(WIDTH) stage(
44 | .d ( pipe[i] ),
45 | .q ( pipe[i+1] ),
46 | .clk ( clk )
47 | );
48 |
49 | end
50 | endgenerate
51 |
52 | assign out = pipe[DEPTH - 1];
53 |
54 | endmodule
--------------------------------------------------------------------------------
/single-layer-perceptron/perceptron_top.v:
--------------------------------------------------------------------------------
1 | `timescale 1ns / 1ps
2 | `include "uart_tx6.v"
3 | //////////////////////////////////////////////////////////////////////////////////
4 | // Company:
5 | // Engineer:
6 | //
7 | // Create Date: 15:25:20 04/28/2014
8 | // Design Name:
9 | // Module Name: perceptron_top
10 | // Project Name:
11 | // Target Devices:
12 | // Tool versions:
13 | // Description:
14 | //
15 | // Dependencies:
16 | //
17 | // Revision:
18 | // Revision 0.01 - File Created
19 | // Additional Comments:
20 | //
21 | //////////////////////////////////////////////////////////////////////////////////
22 | module perceptron_top(
23 | input CLK,
24 | input RX,
25 | output TX
26 | );
27 |
28 | parameter N = 8; // number of input pairs to the weighted sum module
29 |
30 | ////////////////////////
31 | // Configure the UART //
32 | ////////////////////////
33 | wire [7:0] din, dout;
34 | reg en_16_x_baud = 0;
35 | wire rx_data_present, tx_data_present;
36 | wire baud_clk;
37 |
38 | dcm32to96mhz baud_clk_generator
39 | ( // Clock in ports
40 | .CLK_IN1(CLK), // IN
41 | // Clock out ports
42 | .CLK_OUT1(baud_clk)
43 | ); // OUT
44 |
45 | reg baud_count = 0;
46 |
47 | always @(posedge baud_clk) begin
48 | if (~baud_count) begin
49 | en_16_x_baud <= 1;
50 | end else begin
51 | en_16_x_baud <= 0;
52 | end
53 | baud_count <= baud_count + 1;
54 | end
55 |
56 | uart_rx6 uart_rx6 (
57 | .serial_in(RX),
58 | .en_16_x_baud(en_16_x_baud),
59 | .data_out(din),
60 | .buffer_read(1),
61 | .buffer_data_present(rx_data_present),
62 | //.buffer_half_full(),
63 | //.buffer_full(),
64 | .buffer_reset(0),
65 | .clk(baud_clk)
66 | );
67 |
68 | uart_tx6 uart_tx6 (
69 | .data_in(dout),
70 | .buffer_write(tx_data_present),
71 | .buffer_reset(0),
72 | .en_16_x_baud(en_16_x_baud),
73 | .serial_out(TX),
74 | //.buffer_data_present(),
75 | //.buffer_half_full(),
76 | //.buffer_full(),
77 | .clk(baud_clk)
78 | );
79 |
80 | parameter M = 8;
81 |
82 | wire [M-1:0] sum = {M{1'b1}};
83 |
84 | send_binary_as_ascii #(M) bin_to_char(
85 | .en_16_x_baud(en_16_x_baud),
86 | .send(rx_data_present),
87 | .binary_in(sum),
88 | .ascii_out(dout),
89 | .data_present(tx_data_present)
90 | );
91 |
92 | // wire [17:0] x_val = 18'd10;
93 | // wire [17:0] w_val = 18'd2;
94 |
95 | // wire [18*N-1:0] x = {N*{x_val}};
96 | // wire [18*N-1:0] w = {N*{w_val}};
97 |
98 | // weighted_sum_top #(N) weighted_sum(
99 | // .clk(baud_clk),
100 | // .x(x),
101 | // .w(w),
102 | // .sum(sum)
103 | // );
104 |
105 | endmodule
106 |
--------------------------------------------------------------------------------
/single-layer-perceptron/single-layer-perceptron.gise:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 11.1
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
--------------------------------------------------------------------------------
/single-layer-perceptron/single-layer-perceptron.xise:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
--------------------------------------------------------------------------------
/single-layer-perceptron/uart_rx6.v:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaneleonard/neural-hardware/a8d187db3504d263f885f7696ff15c074186e8ec/single-layer-perceptron/uart_rx6.v
--------------------------------------------------------------------------------
/single-layer-perceptron/uart_tx6.v:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shaneleonard/neural-hardware/a8d187db3504d263f885f7696ff15c074186e8ec/single-layer-perceptron/uart_tx6.v
--------------------------------------------------------------------------------
/single-layer-perceptron/weighted_sum_top.v:
--------------------------------------------------------------------------------
1 | `timescale 1ns / 1ps
2 | `define SPARTAN6_XC6SLX9_DSP_SLICES 16 // number of DSP48 slices on the SPARTAN 6 X9
3 | //////////////////////////////////////////////////////////////////////////////////
4 | // Company:
5 | // Engineer: Shane Leonard
6 | //
7 | // Create Date: 13:17:32 04/22/2014
8 | // Design Name:
9 | // Module Name: weighted_sum_top
10 | // Project Name:
11 | // Target Devices:
12 | // Tool versions:
13 | // Description:
14 | //
15 | // Dependencies:
16 | //
17 | // Revision:
18 | // Revision 0.01 - File Created
19 | // Additional Comments:
20 | //
21 | //////////////////////////////////////////////////////////////////////////////////
22 | module weighted_sum_top(
23 | input clk,
24 | input [ 18*N-1 : 0 ] x, w,
25 | output [ 47:0 ] sum
26 | );
27 |
28 | parameter N = 8; // number of 18-bit inputs
29 |
30 | // M = MIN(N, `SPARTAN6_XC6SLX9_DSP_SLICES)
31 | localparam M = `SPARTAN6_XC6SLX9_DSP_SLICES < N ? `SPARTAN6_XC6SLX9_DSP_SLICES : N;
32 |
33 | wire [47:0] carry [N - 1:0];
34 | wire [47:0] int_sum [N - 1:0];
35 |
36 | weighted_sum_slice start(
37 | .clk ( clk ),
38 | .a ( x[17:0] ),
39 | .b ( w[17:0] ),
40 | .pcin ( 48'b0 ),
41 | .pcout( carry[0] ),
42 | .p ( int_sum[0] )
43 | );
44 |
45 | generate
46 | genvar i;
47 | for (i = 1; i < M; i = i + 1)
48 | begin:dsp_slice
49 |
50 | wire [17:0] x_delayed, w_delayed;
51 |
52 | fifo #(.WIDTH(18), .DEPTH(i)) input_fifo(
53 | .clk( clk ),
54 | .in ( x[18*i-1:18*(i-1)] ),
55 | .out( x_delayed )
56 | );
57 |
58 | fifo #(.WIDTH(18), .DEPTH(i)) weight_fifo(
59 | .clk( clk ),
60 | .in ( w[18*i-1:18*(i-1)]),
61 | .out( w_delayed )
62 | );
63 |
64 | weighted_sum_slice slice(
65 | .clk ( clk ),
66 | .a ( x_delayed ),
67 | .b ( w_delayed ),
68 | .pcin ( carry[i-1] ),
69 | .pcout( carry[i] ),
70 | .p ( int_sum[i] )
71 | );
72 |
73 | end
74 | endgenerate
75 |
76 | assign sum = int_sum[N - 1];
77 |
78 | endmodule
--------------------------------------------------------------------------------
/single-layer-perceptron/weighted_sum_top_tb.v:
--------------------------------------------------------------------------------
1 | `timescale 1ns / 1ps
2 |
3 | ////////////////////////////////////////////////////////////////////////////////
4 | // Company:
5 | // Engineer:
6 | //
7 | // Create Date: 14:03:07 04/22/2014
8 | // Design Name: weighted_sum_top
9 | // Module Name: /home/shanel/research/neural-hardware/single-layer-perceptron/weighted_sum_top_tb.v
10 | // Project Name: single-layer-perceptron
11 | // Target Device:
12 | // Tool versions:
13 | // Description:
14 | //
15 | // Verilog Test Fixture created by ISE for module: weighted_sum_top
16 | //
17 | // Dependencies:
18 | //
19 | // Revision:
20 | // Revision 0.01 - File Created
21 | // Additional Comments:
22 | //
23 | ////////////////////////////////////////////////////////////////////////////////
24 |
25 | module weighted_sum_top_tb;
26 |
27 | parameter N = 16;
28 |
29 | // Inputs
30 | reg clk;
31 | reg [18*N-1:0] x, w;
32 |
33 | reg [17:0] x_val;
34 | reg [17:0] w_val;
35 |
36 | // Outputs
37 | wire [47:0] sum;
38 | wire [17:0] x_delayed, w_delayed;
39 |
40 | // Instantiate the Unit Under Test (UUT)
41 | weighted_sum_top #(N) uut (
42 | .clk(clk),
43 | .x(x),
44 | .w(w),
45 | .sum(sum)
46 | );
47 |
48 | fifo #(.WIDTH(18*N*2), .DEPTH(3 + N)) input_output_sync(
49 | .clk(clk),
50 | .in({x_val, w_val}),
51 | .out({x_delayed, w_delayed})
52 | );
53 |
54 | initial begin
55 | clk = 0;
56 | forever #5 clk = ~clk;
57 | end
58 |
59 | initial begin
60 | // Initialize Inputs
61 | x = 0;
62 | w = 0;
63 |
64 | // Wait 100 ns for global reset to finish
65 | #100;
66 |
67 | // Slight offset for clk
68 | #2;
69 |
70 | x_val = 18'd10;
71 | w_val = 18'd2;
72 |
73 | x = {N{x_val}};
74 | w = {N{w_val}};
75 | #10;
76 |
77 | ////////////////////////////
78 | // Add stimulus here //
79 | ////////////////////////////
80 | forever begin
81 | x_val = x_val + 1;
82 | w_val = w_val + 1;
83 |
84 | x = {N{x_val}};
85 | w = {N{w_val}};
86 | #10;
87 | end
88 | ////////////////////////////
89 | end
90 |
91 | always @(posedge clk) begin
92 | if (N * x_delayed * w_delayed != sum) begin
93 | $display("Expected %d... Got %d instead", N * x_delayed * w_delayed, sum);
94 | end
95 | end
96 |
97 |
98 | initial begin
99 |
100 | #1000;
101 | $finish;
102 |
103 | end
104 | endmodule
--------------------------------------------------------------------------------