syedshan
Advanced Member level 1
- Joined
- Feb 27, 2012
- Messages
- 463
- Helped
- 27
- Reputation
- 54
- Reaction score
- 26
- Trophy points
- 1,308
- Location
- Jeonju, South Korea
- Activity points
- 5,134
Dear all,
I have a synchronous system I am just placing the sample of my code, it is not the actual code since actual code includes
many complex naming signals. But please look into it.
What is the difference between following two codes for a synchronous signal in terms of function
I think both the system are functionality wise same. Can any one comment.
Code 1
Code 2:
PS: Ignore the Syntax error since I dont mean to check syntax
I have a synchronous system I am just placing the sample of my code, it is not the actual code since actual code includes
many complex naming signals. But please look into it.
What is the difference between following two codes for a synchronous signal in terms of function
I think both the system are functionality wise same. Can any one comment.
Code 1
Code:
always@(posedge clk)
begin
if(rst) a=0; b<=0; cnt<=0;
else
if(cnt==0) begin a<=10; cnt<=cnt+1; end
else if(cnt==1) begin a<=20; cnt<=cnt+1; end
else begin cnt<=0; a<=30; end
end
always@(posedge clk)
begin
if(rst) sum<=0;
else
case(cnt)
1: sum <= a;
2: sum <= sum+a;
3: sum <= sum +a;
default:
endcase
end
Code 2:
Code:
always@(posedge clk)
begin
if(rst) begin a=0; b<=0; cnt<=0; sum<=0; end
else
begin
if(cnt==0) begin a<=10; cnt<=cnt+1; end
else if(cnt==1) begin a<=20; cnt<=cnt+1; end
else begin cnt<=0; a<=30; end
case(cnt)
1: sum <= a;
2: sum <= sum+a;
3: sum <= sum +a;
default:
endcase
end
PS: Ignore the Syntax error since I dont mean to check syntax