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.

[SOLVED] How to use bidirectional IO, need it for I2C?

Status
Not open for further replies.
Hm, you are right. Apparently, some compilers allow mixing...
The style may be actually accepted by the compiler. But sometimes syntax errors cause irregular error messages.
 
The style may be actually accepted by the compiler. But sometimes syntax errors cause irregular error messages.
Interesting conclusion, I didn't think about that.

---------- Post added at 19:11 ---------- Previous post was at 19:08 ----------

kenleigh, I advise you to find a nice book or online manual and refer to it when you have complications with syntax.
Personally, I sometimes use this
 
Interesting conclusion, I didn't think about that.

---------- Post added at 19:11 ---------- Previous post was at 19:08 ----------

kenleigh, I advise you to find a nice book or online manual and refer to it when you have complications with syntax.
Personally, I sometimes use this

Thanks for the link Alexium and for the expert tips FvM.
From the point of view of the bidirectional pin question, what should I do now? I mean is something like
"inout sda" the way to go?
and then how do I assign sda inside procedural blocks, since the compiler doesn't allow net data types to be assigned inside proc blocks.
 

is something like
"inout sda" the way to go?
Indeed it is.
You then declare a reg signal, say sda_out, in your module. You work with this reg in a procedural block. And somewhere in the module outside of the procedural block you write a statement:
Code:
assign sda = (write_enable == 1'b1)? sda_out : 1'bz

where sda is the bidirectional net port.
 
Indeed it is.
You then declare a reg signal, say sda_out, in your module. You work with this reg in a procedural block. And somewhere in the module outside of the procedural block you write a statement:
Code:
assign sda = (write_enable == 1'b1)? sda_out : 1'bz

where sda is the bidirectional net port.

Many thanks, will try this one out and keep you posted!!

---------- Post added at 19:20 ---------- Previous post was at 19:18 ----------

the write_enable is of datatype reg, right? and I have to manually set or reset this bit when I am doing reads or writes, right?
 
Last edited:

Many thanks, will try this one out and keep you posted!!
Your welcome, hoping I helped.

I have to manually set or reset this bit when I am doing reads or writes, right?
Exactly!

the write_enable is of datatype reg, right? and
That's your decision. It need not to be reg. I was thinking of making write_enable an input port of the receiver module, of type wire. But yes, eventually this port will receive it's value from a reg.
 

I was thinking of making write_enable an input port of the receiver module, of type wire. But yes, eventually this port will receive it's value from a reg.

In fact the 'sda' pin is acting as a transmit sometimes and a receive sometimes, at the moment I'm trying to implement an I2C master, not quite sure what you mean by "receiver module"?
 

If I had to make an I2C module, I would split it into two: receiver and transmitter. If you're not planning to do such a thing - never mind, It seems to me you get my point.
A year ago I've made a PS/2 controller module. PS/2 is also a serial port with one bidirectional data line, so I'm merely telling you how I made that controller. I'm not forcing you to adopt my design decisions, it would be better if you come your own way to understanding the problem :)
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top