1// This test is a distilled version of the bitcoin_8 benchmark. However 2// compared to pipeline_1.v, the stages perform non-trivial compute with a 3// submodule. 4 5module Compute(in, out1, out2); 6 input wire[7:0] in; 7 output wire[7:0] out1, out2; 8 9 assign out1 = in << 1; 10 assign out2 = in + 1; 11endmodule 12 13// Pipeline Stage: Adds 1 to input every clock 14module Stage(clk, in, out); 15 input wire clk; 16 input wire[7:0] in; 17 output reg[7:0] out; 18 19 wire[7:0] temp1, temp2; 20 Compute c1(in, temp1, temp2); 21 22 always @(posedge clk) begin 23 out <= temp1 + temp2; 24 end 25endmodule 26 27// Pipeline: DEPTH instances of Stage, chained together, plus a final delay 28module Pipeline #(parameter DEPTH = 8) (clk, in, out); 29 input wire clk; 30 input wire[7:0] in; 31 output reg[7:0] out; 32 33 genvar i; 34 for (i = 0; i < DEPTH; i=i+1) begin : STAGES 35 wire[7:0] temp; 36 if (i == 0) begin 37 Stage s(clk, in, temp); 38 end else begin 39 Stage s(clk, STAGES[i-1].temp, temp); 40 end 41 end 42 43 always @(posedge clk) begin 44 out <= STAGES[DEPTH-1].temp * 2; 45 end 46endmodule 47 48// Main: Stuff zeros in the pipe and wait until something comes out 49localparam[7:0] D = 8; 50reg[7:0] in = 8'b0; 51wire[7:0] out; 52 53Pipeline #(D) p(clock.val, in, out); 54 55reg[7:0] COUNT = 8'b0; 56always @(posedge clock.val) begin 57 $write("%d", COUNT); 58 COUNT <= COUNT + 1; 59 if (out == 160) begin 60 $finish; 61 end 62end 63