Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Please have look at this code and tell me

Status
Not open for further replies.

appu1985

Member level 2
Joined
Jun 10, 2007
Messages
52
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,627
How to put the clock in this code. and is this a simple correct way to write code.
Code:
module pe(clk,lrate,i,x,p,psw,psy,mode,io,xo,po,pswo);

parameter size = 65535;
input lrate;
wire lrate;
//Input ports of the PROCESSING ELEMENT
input clk;
input [7:0]i;//Index of the input pixel
input [7:0]x;//Value of the pixel input
input [3:0]p;//The Index of the person whose image is being sent
input [4:0]psw;//Partial Sum for weight updating
input [12:0]psy;//Partial Sum for output calculation
input [1:0]mode;//To select the operation as Recognition Phase or Training Phase 00,01- Recognition
					//10 - Trainging and Weight Updating 11 - Projection Calculation

//Output ports of the PROCESSING ELEMENT

output [7:0]io;//The index of the pixel which is evaluated at this PE and going to next PE
output [7:0]xo;//The value of pixel going to next PE
output [3:0]po;//The index value of the person whose image is under processing
output [4:0]pswo;//The calculated the Partial Sum of Weight update sent to next PE as well as stored here
//output [12:0]psyo;//The calculated the Partial Sum of output sent to next PE as well as stored here

//Register Declarations inside the PROCESSING ELEMENT

reg [4:0]w [65535:0];//A register in the processig element to store the weights of the Image
reg [12:0]ylearn [15:0];//A register to store the projection "Y" of each image max 16 images 
reg [4:0]psw1;//A register to store the partial sum evaluated 
reg [12:0]pso1;//A register to store the Partial Sum for evaluating the output projection " Y ".

//Wire Declaration as used inside the processing element
wire [4:0]g;
wire [4:0]w1;
wire [12:0]t;
wire [12:0]psj;
wire [3:0]sel;
//Instantiation of the ckt for the 2nd Step of Weight Update
//Here  'g' is the Partial sum and 'w1' is the Updated weight


//decoder dec(mode,sel);// Adecoder is used just to evaluate the mode of operation

//Initially the logic is selected depending upon the mode of operation
//The below case logic coverts into a Multiplexer
case(mode)
00:out2 s2(i,lrate,w,ylearn,x,psw,g,w1);//Combinational Logic to implement .. STEP 2 - Update the weight vectors
01:out2 s2(i,lrate,w,ylearn,x,psw,g,w1);//Combinational Logic to implement .. STEP 2 - Update the weight vectors
10:out1 s1(x,w,psy,t,psj);//Combinational Logic to Implement ... STEP 1- Calculate the projections
11:out1 s1(x,w,psy,t,psj);//Combinational Logic to Implement ... STEP 1- Calculate the projections
default
endcase

//First Mode of Operation when the projections are to be evaluated.
if(mode == 2'b10 || mode == 2'b11)//It checks if the mode of operation is for Output evaluation
	begin
		pso1 <= pso1 + psj; //Keeps on accumulating the Partial Sum for Output evaluation
			if(i%size)//If one image has passed then it starts assigning the outputs . size is a parmameter holding the image size.
				begin
					ylearn[p] <= psj;//The Output is assigned
				end
	end 

//Once all the outputs are evaluated the mode is changed to 00 or 01 to Update the weights.

if(mode == 2'b00 || mode == 2'b01)//Checks for the mode of operation
	begin
		psw1 <= psw1 + g;//PSW1 accumulates the partial sum of the weight updation formula 
								//Now for the jth PE if the PS has been evaluated
			if()//The condition to check if the complete Partial Sum has been evaluated or not.
			 begin
			  psw <= psw1;//Then we pass the accumulated partial sum to evaluate the updated weight
			  w[i] = w1;
			 end
	end

endmodule
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top