data/full_repos/permissive/133043770/EnvelopeFollower.v
1: b'%Error: data/full_repos/permissive/133043770/EnvelopeFollower.v:2: Cannot find include file: AddOperation.v\n`include "AddOperation.v" \n         ^~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/133043770,data/full_repos/permissive/133043770/AddOperation.v\n             data/full_repos/permissive/133043770,data/full_repos/permissive/133043770/AddOperation.v.v\n             data/full_repos/permissive/133043770,data/full_repos/permissive/133043770/AddOperation.v.sv\n             AddOperation.v\n             AddOperation.v.v\n             AddOperation.v.sv\n             obj_dir/AddOperation.v\n             obj_dir/AddOperation.v.v\n             obj_dir/AddOperation.v.sv\n%Error: data/full_repos/permissive/133043770/EnvelopeFollower.v:3: Cannot find include file: SubtractOperation.v\n`include "SubtractOperation.v" \n         ^~~~~~~~~~~~~~~~~~~~~\n%Error: Exiting due to 2 error(s)\n'
module EnvelopeFollower(
	input [11:0] inSample,
	input inSampleReady,
	input inIsPlaying,
	input [11:0] inVelocity,
	output [11:0] outSample
);

	reg isStartSampling;
	

	reg [11:0] currentSample;
	reg [11:0] velocity = 5;
	

	wire [11:0] nextStartSample;

	wire nextStartOverflow;
	

	wire [11:0] nextEndSample;

	wire nextEndOverflow;
	
	initial begin
		currentSample <= 0;
		isStartSampling <= 1;
	end
	
	AddOperation calcNextStartSample (
		.lhs(currentSample), 
		.rhs(velocity), 
		.result(nextStartSample), 
		.overflow(nextStartOverflow)
	);
	
	SubtractOperation calcNextEndSample (
		.lhs(currentSample), 
		.rhs(velocity), 
		.result(nextEndSample), 
		.overflow(nextEndOverflow)
	);
	
	always @(posedge inSampleReady) begin
	    if (!inIsPlaying) begin
			if (nextEndSample > 0 && !nextEndOverflow) begin
				currentSample <= nextEndSample;
			end else begin
				currentSample <= 0;
				isStartSampling <= 1;
			end
		end 
		
		if (inIsPlaying) begin
			if (nextStartSample <= inSample && !nextStartOverflow && isStartSampling) begin
				currentSample <= nextStartSample;
			end else begin
				isStartSampling <= 0;
				currentSample <= inSample;
			end
		end 
	end
	
	assign outSample = currentSample;
endmodule
module EnvelopeFollower(
	input [11:0] inSample,
	input inSampleReady,
	input inIsPlaying,
	input [11:0] inVelocity,
	output [11:0] outSample
);


	reg isStartSampling;
	

	reg [11:0] currentSample;
	reg [11:0] velocity = 5;
	

	wire [11:0] nextStartSample;

	wire nextStartOverflow;
	

	wire [11:0] nextEndSample;

	wire nextEndOverflow;
	
	initial begin
		currentSample <= 0;
		isStartSampling <= 1;
	end
	
	AddOperation calcNextStartSample (
		.lhs(currentSample), 
		.rhs(velocity), 
		.result(nextStartSample), 
		.overflow(nextStartOverflow)
	);
	
	SubtractOperation calcNextEndSample (
		.lhs(currentSample), 
		.rhs(velocity), 
		.result(nextEndSample), 
		.overflow(nextEndOverflow)
	);
	
	always @(posedge inSampleReady) begin
	    if (!inIsPlaying) begin
			if (nextEndSample > 0 && !nextEndOverflow) begin
				currentSample <= nextEndSample;
			end else begin
				currentSample <= 0;
				isStartSampling <= 1;
			end
		end 
		
		if (inIsPlaying) begin
			if (nextStartSample <= inSample && !nextStartOverflow && isStartSampling) begin
				currentSample <= nextStartSample;
			end else begin
				isStartSampling <= 0;
				currentSample <= inSample;
			end
		end 
	end
	
	assign outSample = currentSample;
endmodule