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 check if my code is working properly

Status
Not open for further replies.

martijn

Newbie level 4
Joined
Jun 16, 2004
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
87
copy partial variable

I've got this code:

input datain;
input clock;
output [0:5] data0;
output [0:5] data1;
output dir0;
output dir1;
// {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!
reg [0:7] shift;
reg [0:2] posi;
reg [0:5] data0;
reg [0:5] data1;
reg dir0;
reg dir1;

always @(negedge clock)
begin
shift[posi]= datain;
posi<=posi+1;
if (posi==3'd0)
begin
if (shift[0]==0)
begin
dir0<=shift[1];
data0<=shift[2:7];
end
else
begin
dir1<=shift[1];
data1<=shift[2:7];
end
end
end

is this part:

dir0<=shift[1];
data0<=shift[2:7];

good if I want to have dir0 the value of the 2nd bit of shift,
and data0 the value of the last 5 bits of shift?

thanks in advance.

Martijn
 

Re: copy partial variable

Yes, it's good, but dir0 will be the 2nd bit of shift and data0 will be last 5 bits of shift only when posi =0 and shift(0)=0... If this is your expected result, you're ok!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top