Hi,
i m designing one concept in verilog and in that i need to compare the binary value with the integer value , how can i perform it , in verilog there is no type conversion function, how could i perform it,plz anyone clarify my doubt .
always @(posedge clk or negedge rst or rw)
begin
if(!rst) begin
data_out1=8'b0;
mem_status1='b0;
for (i=0;i<=7;i=i+1)
memory1=8'b0; end
else begin
for (i=0;i<=7;i=i+1)
if(rw=='b1 && t1=='b1 && t1==address ) begin
memory1[address]=data_in;
mem_status1='b1; end
else begin
if(rw=='b0 && t1=='b1 && t1==address)
data_out1=memory1[address]; end end
end
in the above code t1==adddres i need to do the write operation but in tat t1th bit is equal to address say if t1[5]==address(101base2=5 in integer) na, to check this condition,how can i write.plz give me an idia.
Here is the sample code i had tried...
hope this will be helpful for u..
module valcompare();
reg [15] a;
integer b;
initial
b = 15;
assign c = (a==b);
endmodule
Added after 11 minutes:
Dear Kanimozhi,
The value if t1 is a single bit,
say if i value is 3 , then ti[3] can be only '1' or '0',
but you are trying to compare a single bit value against a 3 bit value ...
saying tht t1 can be never greater than 1... and you are trying to compare with a 3-bit value, which may not be possible
input [7:0] t1;
input [2:0] address;
always @(posedge clk or negedge rst or rw)
begin
if(!rst) begin
data_out1=8'b0;
mem_status1='b0;
for (i=0;i<=7;i=i+1)
memory1=8'b0; end
else begin
for (i=0;i<=7;i=i+1) if(rw=='b1 && t1=='b1 && t1==address ) begin
memory1[address]=data_in;
mem_status1='b1; end
else begin if(rw=='b0 && t1=='b1 && t1==address)
data_out1=memory1[address]; end end
end
hi,
yes, thanks ya, now i understand my mistake in my program.
Added after 29 minutes:
Hi,
If i need to compare the t the position value with the address na, how will i do, say if the t th poition value is 5 na we will consider this as integer and address is binary and the crossponding binary value of address is 101base2 how to compare with the position value with the address value.