Forum Discussion
Altera_Forum
Honored Contributor
16 years agohey Daixiwen sorry to trouble you again i seem to be having problems with reading / writing... more than one value i have no clue why i have tried everything possible the code works well as long as its only one value being written or read as soon as i change that to more than one i start getting garbage values. i implemented the address logic like u said.. i have pasted the test code here again please let me know if what i am doing is right or wrong ...
////////////////////////////////// here is the C code in Nios 2 /////////////// int main(void) { printf("enter the values to be passed\n"); for(i=0;i<1;i++) { scanf("%d",&k);iowr(scalar_write_inst_base,i,k); yy= iord_32direct(scalar_write_inst_base,i) ;
printf("\n output data is %#x \n",yy); } //////////////////////////// verilog test code/////////////////////////////// input [1:0] addr_off; ---- for address decoding logic reg [31:0] qx,qy; reg[31:0] temp; input[31:0] write_data; output[31:0] read_data; always @ (posedge CLOCK_50) begin if(addr_off==0) begin qx = write_data; read_data = qx; end else if (addr_off==1) begin qy= write_data; read_data=qy; end end // always /////////////////////////////// end ////////////////////////////////////////// the same code works if i just have one value to read or write but fails if more than 1 which makes me think there is some problem in the address decoding or in the S/w access side.. Please do let me know what am i doing wrong.. Or is there something else i should be taking into account and i havent ?? Thanks again..