Electronics > FPGA

Help with Verilog vectors

(1/2) > >>

rea5245:
I don't understand why a piece of Verilog code doesn't work, and I don't know how to fix it.

Here's the code. It's accessing a ROM:


--- Code: ---module U16(input A12, input A7, input A6, input A5, input A4,
    input A3, input A2, input A1, input A0,
    inout I_O0, inout I_O1, inout I_O2, inout I_O3, inout I_O4, inout I_O5, inout I_O6, inout I_O7,
    input nCE, input A10, input nOE, input A11, input A9, input A8, input nWE);

   wire [12:0] A = {A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1, A0};
   wire [7:0] I_O = {I_O7, I_O6, I_O5, I_O4, I_O3, I_O2, I_O1, I_O0};

   rom romimpl(A, nCE, nOE, I_O);

endmodule

--- End code ---

When this is run in Modelsim, the data lines (I_O<n>) are all HiZ.

If I change the invocation of romimpl to:


--- Code: ---   rom romimpl(A, nCE, nOE, {I_O7, I_O6, I_O5, I_O4, I_O3, I_O2, I_O1, I_O0});

--- End code ---

it works: the data lines have data on them.

So obviously, the way I'm collecting I_O<n> into a vector is wrong.

What's the right way to do it?

Thank you.

Foxxz:
You need to


--- Code: ---   wire [12:0] A;
   wire [7:0] I_O;

   assign A = {A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1, A0};
   assign I_O = {I_O7, I_O6, I_O5, I_O4, I_O3, I_O2, I_O1, I_O0};

--- End code ---

rea5245:

--- Quote from: Foxxz on December 02, 2022, 10:11:02 pm ---
--- Code: ---   wire [12:0] A;
   wire [7:0] I_O;

   assign A = {A12, A11, A10, A9, A8, A7, A6, A5, A4, A3, A2, A1, A0};
   assign I_O = {I_O7, I_O6, I_O5, I_O4, I_O3, I_O2, I_O1, I_O0};

--- End code ---

--- End quote ---

Thank you, but that did not fix it.

Another thing that puzzles me is that the A vector works OK. Could this have something to do with A being input and I_O being inout?

BrianHG:
For this to work, you need all the address inputs tied or set to something especially the nCE and nOE.
If you do not, Modelsim will most likely show you blue Hi-Z output waveform for the data.

If the data in the 'rom romimpl()' implementation contents is not set or cleared, any missing address inputs, then output waveform will most likely be Red unknown X, assuming you tied the nCE and nOE to GND.

rea5245:

--- Quote from: BrianHG on December 02, 2022, 11:38:41 pm ---For this to work, you need all the address inputs tied or set to something especially the nCE and nOE.
If you do not, Modelsim will most likely show you blue Hi-Z output waveform for the data.

--- End quote ---

Yeah, but all I need to do, to change it from non-working to working is to change:
   rom romimpl(A, nCE, nOE, I_O);
to:
   rom romimpl(A, nCE, nOE, {I_O7, I_O6, I_O5, I_O4, I_O3, I_O2, I_O1, I_O0});

So the address lines, nCE, and nOE are OK. And if I put a breakpoint in the 'rom' module, I can verify that they're OK.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod