- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 06:04 PM
Hi,
I'm about as newbie as you can get, so my appologies. I wrote a simple module which takes a nibble and displays it as a hexadecimal on a seven digit display. I then wanted to use this module in a more "complex" hierarchy. And so I wrote the following:
module top (nibble, load, display);
input [3:0] nibble;
input load;
output [7:0] display;
reg [7:0] display;
always @(load)
begin
if(load) begin
DisplayHex dh1(nibble, display);
end
end
endmodule
I get the following from the xilinx compiler:
ompiling verilog file "top.v" in library work
ERROR:HDLCompilers:26 - "top.v" line 35 unexpected token: 'DisplayHex'
Module <top> compiled
Analysis of file <"top.prj"> failed.
The DisplayHex.v module looks like this:
module DisplayHex(nibble, display);
input [3:0] nibble;
output [7:0] display;
reg [7:0] display;
always @(nibble)
begin
case(nibble)
4'b0000:display= ~8'b11111100;
4'b0001:display= ~8'b01100000;
4'b0010:display= ~8'b11011010;
4'b0011:display= ~8'b11110010;
4'b0100:display= ~8'b01100110;
4'b0101:display= ~8'b10110110;
4'b0110:display= ~8'b10111110;
4'b0111:display= ~8'b11100000;
4'b1000:display= ~8'b11111110;
4'b1001:display= ~8'b11110110;
4'b1010:display= ~8'b11101110;
4'b1011:display= ~8'b00111110;
4'b1100:display= ~8'b10011100;
4'b1101:display= ~8'b01111010;
4'b1110:display= ~8'b10011110;
4'b1111:display= ~8'b10001110;
endcase
end
endmodule
If someone can help me out, I would certainly appreciate it.
DavidBear
Solved! Go to Solution.
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 07:28 PM
"DisplayHex dh1(nibble, display);" is an instance. It should not be inside an "always" block.
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 07:47 PM
Thanks, evgenis1
However, I am still confused. If my code looks like this:
module top (nibble, load, display); input [3:0] nibble; input load; output [7:0] display; wire [7:0] display; DisplayHex dh1(nibble,display); endmodule
it does compile, but it does not depend on the load wire.
If I surround the DisplayHex with an "if(load) begin" block, I get the very disconcerting error message:
Module <top> compiled
ERROR:HDLCompilers:26 - "top.v" line 28 expecting 'endmodule', found 'if'
Analysis of file <"top.prj"> failed.
Functionally what I want to do is display the current nibble when load is set to '1' and not change the display when load is set to '0'. I must be thinking about this all wrong. If you have any insights into my confusion, please feel free to respond.
DavidBear
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 07:59 PM
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 08:14 PM
Again, thank you!
This is the sollution with which I came up:
module top (nibble, load, display);
input [3:0] nibble;
input load;
output [7:0] display;
wire [7:0] display;
reg [3:0] bits;
wire [3:0] w;
always @(load) begin
if(load) begin
bits = nibble;
end
end
assign w = bits;
DisplayHex dh1(w,display);
endmodule
Is there a more effecient route to this result (current "design" uses 12 macrocells), while manipulating events in the "top" module?
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 08:28 PM
By the way, what do the following warnings mean?
WARNING:Xst:905 - "top.v" line 31: One or more signals are missing in the sensitivity list of always block. To enable synthesis of FPGA/CPLD hardware, XST will assume that all necessary signals are present in the sensitivity list. Please note that the result of the synthesis may differ from the initial design specification. The missing signals are:
<nibble>
WARNING:Xst:737 - Found 4-bit latch for signal <bits>. Latches may be generated from incomplete case or if statements. We do not recommend the use of latches in FPGA/CPLD designs, as they may lead to timing problems.
WARNING:NgdBuild:1012 - The constraint <INST "/" KEEP_HIERARCHY = TRUE> is
overridden on the design object top by the constraint <INST "/"
KEEP_HIERARCHY = TRUE>.
WARNING:Cpld:310 - Cannot apply TIMESPEC TS1000 = PERIOD:PERIOD_bits<0>.CLKF:0.000 nS because of one of the following: (a) a signal name was not found; (b) a signal was removed or renamed due to optimization; (c) there is no path between the FROM node and TO node in the TIMESPEC.
WARNING:Cpld:310 - Cannot apply TIMESPEC TS1001 = PERIOD:PERIOD_bits<1>.CLKF:0.000 nS because of one of the following: (a) a signal name was not found; (b) a signal was removed or renamed due to optimization; (c) there is no path between the FROM node and TO node in the TIMESPEC.
WARNING:Cpld:310 - Cannot apply TIMESPEC TS1002 = PERIOD:PERIOD_bits<2>.CLKF:0.000 nS because of one of the following: (a) a signal name was not found; (b) a signal was removed or renamed due to optimization; (c) there is no path between the FROM node and TO node in the TIMESPEC.
WARNING:Cpld:310 - Cannot apply TIMESPEC TS1003 = PERIOD:PERIOD_bits<3>.CLKF:0.000 nS because of one of the following: (a) a signal name was not found; (b) a signal was removed or renamed due to optimization; (c) there is no path between the FROM node and TO node in the TIMESPEC.
WARNING:Cpld:310 - Cannot apply TIMESPEC AUTO_TS_F2F = MAXDELAY:FROM:FFS(*):TO:FFS(*):0.000 nS because of one of the following: (a) a signal name was not found; (b) a signal was removed or renamed due to optimization; (c) there is no path between the FROM node and TO node in the TIMESPEC.
WARNING:Cpld:310 - Cannot apply TIMESPEC AUTO_TS_P2P = MAXDELAY:FROM:PADS(*):TO:PADS(*):0.000 nS because of one of the following: (a) a signal name was not found; (b) a signal was removed or renamed due to optimization; (c) there is no path between the FROM node and TO node in the TIMESPEC.
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-20-2009 08:40 PM
Those warnings mean that "always" block has "load" and "nibble" that can change the "bits" result, but the sensitivity list only contains "load". It's a nasty kind of warning that can break the circuit.
Writing "always @(load or nibble)" should fix that warning. Or "always @(*)" if you have Verilog 2001 enabled.
OutputLogic
Re: Verilog question
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-21-2009 11:29 AM
The warning about missing elements in the sensitivity list means that
your simulation will not match the synthesized logic. This is because
a gated latch needs to update its outputs continuously when the
gate is "open" or active. So in simulation you would need to "trigger"
the always block when nibble changes.
In this case you should ignore the latch warning. Under normal
circumstances you do not want to unintentionally create latches by
leaving out "else" conditions. In your case you intended to create
the latch. For larger designs, where you may have to pore through
pages of warnings, it is a good idea to name your latch signals
in a way that makes it easy to see you intended to create a latch,
for example:
reg [3:0] latched_bits;
always @(load) begin
if(load) begin
latched_bits = nibble;
end
end
Then you will see the warning that a latch was created for "latched_bits" and you
can easily ignore it.
You also asked why this takes 12 macrocells and if there is a more efficient way
to generate your logic. If you were using an FPGA, I would say you found the most
efficient way. However for macrocell-based CPLD's you should think of the
architecture of the part, which has combinatorial logic feeding a register. In this
case latching the input bits uses four macrocells, then you need seven more
to convert the latched bits to 7-segment. If you instead latched the decoded
output (seven latches instead of four), you actually use only 7 macrocells
because the latch is added to the same macrocell doing the decoding.
Finally there is a way in Verilog to do what you attempted in the beginning.
If instead of a module, you defined a task for DisplayHex, you could place
the conversion "in line" in your always block. I would suggest finding a
good reference book for Verilog. I learned using Thomas & Moorby's
book, then used the Doulos Golden Reference Guide once I got the
basics and just needed a quick reference with examples. I also have
the official Verilog Language Reference Manual, but find it less useful
for those using the language than for those attempting to write a
simulator or synthesis engine for it.
Regards,
Gabor











