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.

How to work out with "inout" port in verilog?

Status
Not open for further replies.

hcu

Advanced Member level 4
Joined
Feb 28, 2017
Messages
101
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
874
Hi,
I want to write into the memory through a port and sometimes after I have it read the memory content through the same port. How to do this? I am unfamiliar about inout port
 

Why people talk about i2c instantiation or tristate logic when it comes to inout port of verilog.
 

I2C uses inout to implement the open drain buffers. In standard I2C, the bus lines are either driven 0 or z, never 1.

In hardware terms, a tri-state buffer is the equivalent of an inout. Bidirectional data busses, e.g. memory data lines need to use tri-state buffers at all connected ports.
 

Module design 1(
Input clka,clkb,
Input we,re,
Input [3:0] addra,addrb,
Input [3:0] data,
Output reg [3:0]
);
Reg [3:0] ram [7:0];
Reg [3:0] temp;
always@(posedge clka)
If(we)
Ram[addra] <= data;

always@(posedge clkb)
If(re)
Temp<= ram[addrb];
Assign data = re ? Temp: 'dz;
Endmodule
This is both syntax free and synthesize able, but unable to write stimulus to "data" port. Tell me where it is wrong
 

you need to declare "data" as inout, not input
 

Re: How to work out with &quot;inout&quot; port in verilog?

it is a typo mistake while typing in phone.

- - - Updated - - -

memory data lines need to use tri-state buffers at all connected ports.

how should i use tri-state buffers in the code i posted here.
 
Last edited by a moderator:

Your code already describes a 4-bit wide three-state buffer
Code:
data = re ? Temp: 'dz;
 

Re: How to work out with &amp;quot;inout&amp;quot; port in verilog?

it is a typo mistake while typing in phone.

- - - Updated - - -

how should i use tri-state buffers in the code i posted here.

I'll assume that the mixed case keywords is also an artifact of using the phone.


Code Verilog - [expand]
1
2
3
4
Input [3:0] data,
//has to be a typo too, because this won't compile?
Output reg [3:0]
);



- - - Updated - - -

This piece of code doesn't make a whole lot of sense:

Code Verilog - [expand]
1
2
3
4
always@(posedge clkb)
If(re)
Temp<= ram[addrb];
Assign data = re ? Temp: 'dz;



when a re pulses high for one clock cycle and is caught on the rising_edge of clock it will have gone away in the next cycle when the temp is assigned to data (in reality it will likely stick around for a few hundered ps due to Tco and routing delays). Only if re is high for two clock cycles with this work correctly, i.e. 1st clock reads the ram 2nd clock outputs the data. To properly enable the output you would have to use a delayed version of the re.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top