Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

bidirectional inout of my signal

Altera_Forum
Honored Contributor II
1,642 Views

Hello all, 

 

I have this signal calls Sync that I need to be able write the signal when I want to drive the signal. I also need to read this signal too. 

 

So, I have 4 phases discriminator to phase them all out to 90 degree angle for solar panel charger up to 200V output to battery bank. 

 

The fpga need to read the Sync signal from charger and to generate phase discriminator, but sometime the charger didn't give the Sync during that period time, so I need to generate my own signal for that. I need to be able read/write the Sync signal for backup plan by not to depend on charger hardware. I look at couple of sample so me how to use inout 

 

module test( 

input clk, // The standard clock 

input direction, // Direction of io, 1 = set output, 0 = read input 

input data_in, // Data to send out when direction is 1 

output data_out, // Result of input pin when direction is 0 

inout io_port // The i/o port to send data through 

); 

 

 

reg a, b;  

 

 

assign io_port = direction ? a : 1'bz; 

assign data_out = b; 

 

 

always @(posedge clk) begin 

b <= io_port; 

a <= data_in; 

endendmodule 

 

 

How do I use this in testbench? 

 

Thanks, 

Sean
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
628 Views

What do you mean with  

--- Quote Start ---  

 

How do I use this in testbench? 

 

--- Quote End ---  

Bidirectional ports can be simulated, and you can read from/write to them at the testbenchlevel.
0 Kudos
Altera_Forum
Honored Contributor II
628 Views

 

--- Quote Start ---  

Hello all, 

 

I have this signal calls Sync that I need to be able write the signal when I want to drive the signal. I also need to read this signal too. 

 

So, I have 4 phases discriminator to phase them all out to 90 degree angle for solar panel charger up to 200V output to battery bank. 

 

The fpga need to read the Sync signal from charger and to generate phase discriminator, but sometime the charger didn't give the Sync during that period time, so I need to generate my own signal for that. I need to be able read/write the Sync signal for backup plan by not to depend on charger hardware. I look at couple of sample so me how to use inout 

 

module test( 

input clk, // The standard clock 

input direction, // Direction of io, 1 = set output, 0 = read input 

input data_in, // Data to send out when direction is 1 

output data_out, // Result of input pin when direction is 0 

inout io_port // The i/o port to send data through 

); 

 

 

reg a, b;  

 

 

assign io_port = direction ? a : 1'bz; 

assign data_out = b; 

 

 

always @(posedge clk) begin 

b <= io_port; 

a <= data_in; 

endendmodule 

 

 

How do I use this in testbench? 

 

Thanks, 

Sean 

--- Quote End ---  

 

Hello were you able to find the right code? Well I am working on bidireactional inout of the signal so can you help me out?
0 Kudos
Reply