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.

Type conversion in verilog

Status
Not open for further replies.

Mkanimozhi

Full Member level 4
Full Member level 4
Joined
Aug 8, 2007
Messages
193
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
3,445
verilog binary

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 .

Regards
Kanimozhi.M
 

verilog type conversion

In verilog you can compare the integer value with the binary one...
please be more detailed in ur question
 

type conversion in verilog

hi,
This is my code

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




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.

Regards
kanimozhi.M
 

type conversion verilog

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
 

    Mkanimozhi

    Points: 2
    Helpful Answer Positive Rating
verilog integer to binary

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.

Regards
Kanimozhi.M
 

binary verilog

may be this will work ?

Code:
    if ( t1[address] == 1'b1 )
        if ( rw )  memory1[address] <= data_in; 
        else       data_out1  <= memory1[address];
---
 

    Mkanimozhi

    Points: 2
    Helpful Answer Positive Rating
verilog integer conversion

DEAR Mkanimozhi,

I too accept with j_andr, the solution suggested by him should work. please try, if u could not, let us know...
 

verilog binary to integer

Hi
kalyansumankv i have worked out it, it's working.thanks for ur help.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top